Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed

Dependencies:   mbed

HTTPServer/HTTPLog.h

Committer:
pehrhovey
Date:
2010-03-14
Revision:
0:a548a085de55

File content as of revision 0:a548a085de55:

#ifndef HTTPLOG_H
#define HTTPLOG_H

#include "HTTPServer.h"

class HTTPLog : public HTTPHandler {
  public:
    HTTPLog(const char *prefix) : HTTPHandler(prefix) {}
    HTTPLog(HTTPServer *server, const char *prefix) : HTTPHandler(prefix) { server->addHandler(this); }

  private:
    virtual HTTPHandle action(HTTPConnection *con) const {
      struct ip_addr ip = con->pcb()->remote_ip;
      printf("%hhu.%hhu.%hhu.%hhu %s %s", (ip.addr)&0xFF, (ip.addr>>8)&0xFF, (ip.addr>>16)&0xFF, (ip.addr>>24)&0xFF, (con->getType() == POST? "POST" : "GET"), con->getURL());
      return HTTP_AddFields;
    }
};

#endif