A modified version of http://mbed.org/users/segundo/libraries/NetServices/ljhqix to add HTTP proxy feature (based on http://mbed.org/users/igorsk/programs/NetServicesSource/ltjpag)

Dependents:   SenseClient

Committer:
mimil
Date:
Tue Sep 06 13:26:45 2011 +0000
Revision:
0:308f83189a3f

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mimil 0:308f83189a3f 1
mimil 0:308f83189a3f 2 /*
mimil 0:308f83189a3f 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
mimil 0:308f83189a3f 4
mimil 0:308f83189a3f 5 Permission is hereby granted, free of charge, to any person obtaining a copy
mimil 0:308f83189a3f 6 of this software and associated documentation files (the "Software"), to deal
mimil 0:308f83189a3f 7 in the Software without restriction, including without limitation the rights
mimil 0:308f83189a3f 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mimil 0:308f83189a3f 9 copies of the Software, and to permit persons to whom the Software is
mimil 0:308f83189a3f 10 furnished to do so, subject to the following conditions:
mimil 0:308f83189a3f 11
mimil 0:308f83189a3f 12 The above copyright notice and this permission notice shall be included in
mimil 0:308f83189a3f 13 all copies or substantial portions of the Software.
mimil 0:308f83189a3f 14
mimil 0:308f83189a3f 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mimil 0:308f83189a3f 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mimil 0:308f83189a3f 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mimil 0:308f83189a3f 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mimil 0:308f83189a3f 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mimil 0:308f83189a3f 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mimil 0:308f83189a3f 21 THE SOFTWARE.
mimil 0:308f83189a3f 22 */
mimil 0:308f83189a3f 23
mimil 0:308f83189a3f 24 #ifndef NET_H
mimil 0:308f83189a3f 25 #define NET_H
mimil 0:308f83189a3f 26
mimil 0:308f83189a3f 27 class NetIf;
mimil 0:308f83189a3f 28 class NetTcpSocket;
mimil 0:308f83189a3f 29 class NetUdpSocket;
mimil 0:308f83189a3f 30 class NetDnsRequest;
mimil 0:308f83189a3f 31
mimil 0:308f83189a3f 32 #include <list>
mimil 0:308f83189a3f 33 using std::list;
mimil 0:308f83189a3f 34
mimil 0:308f83189a3f 35 /*
mimil 0:308f83189a3f 36 #include "host.h"
mimil 0:308f83189a3f 37 #include "ipaddr.h"
mimil 0:308f83189a3f 38 #include "netservice.h"
mimil 0:308f83189a3f 39 #include "if/net/netif.h"
mimil 0:308f83189a3f 40 #include "if/net/nettcpsocket.h"
mimil 0:308f83189a3f 41 #include "if/net/netudpsocket.h"
mimil 0:308f83189a3f 42 #include "if/net/netdnsrequest.h"
mimil 0:308f83189a3f 43 */
mimil 0:308f83189a3f 44
mimil 0:308f83189a3f 45 class Host;
mimil 0:308f83189a3f 46 class NetIf;
mimil 0:308f83189a3f 47 class NetTcpSocket;
mimil 0:308f83189a3f 48 class NetUdpSocket;
mimil 0:308f83189a3f 49 class NetDnsRequest;
mimil 0:308f83189a3f 50
mimil 0:308f83189a3f 51 class Net
mimil 0:308f83189a3f 52 {
mimil 0:308f83189a3f 53 private:
mimil 0:308f83189a3f 54 Net();
mimil 0:308f83189a3f 55 ~Net();
mimil 0:308f83189a3f 56 public:
mimil 0:308f83189a3f 57 static void poll(); //Poll every if & socket
mimil 0:308f83189a3f 58
mimil 0:308f83189a3f 59 static NetTcpSocket* tcpSocket(NetIf& netif);
mimil 0:308f83189a3f 60 static NetTcpSocket* tcpSocket(); //Socket on default if
mimil 0:308f83189a3f 61 static void releaseTcpSocket(NetTcpSocket* pNetTcpSocket);
mimil 0:308f83189a3f 62
mimil 0:308f83189a3f 63 static NetUdpSocket* udpSocket(NetIf& netif);
mimil 0:308f83189a3f 64 static NetUdpSocket* udpSocket(); //Socket on default if
mimil 0:308f83189a3f 65 static void releaseUdpSocket(NetUdpSocket* pNetUdpSocket);
mimil 0:308f83189a3f 66
mimil 0:308f83189a3f 67 static NetDnsRequest* dnsRequest(const char* hostname, NetIf& netif);
mimil 0:308f83189a3f 68 static NetDnsRequest* dnsRequest(const char* hostname); //Create a new NetDnsRequest object from default if
mimil 0:308f83189a3f 69
mimil 0:308f83189a3f 70 static NetDnsRequest* dnsRequest(Host* pHost, NetIf& netif);
mimil 0:308f83189a3f 71 static NetDnsRequest* dnsRequest(Host* pHost); //Create a new NetDnsRequest object from default if
mimil 0:308f83189a3f 72
mimil 0:308f83189a3f 73 static void setDefaultIf(NetIf& netif); //Deprecated
mimil 0:308f83189a3f 74 static void setDefaultIf(NetIf* pIf);
mimil 0:308f83189a3f 75 static NetIf* getDefaultIf();
mimil 0:308f83189a3f 76
mimil 0:308f83189a3f 77 protected:
mimil 0:308f83189a3f 78 friend class NetIf;
mimil 0:308f83189a3f 79 friend class NetTcpSocket;
mimil 0:308f83189a3f 80 friend class NetUdpSocket;
mimil 0:308f83189a3f 81
mimil 0:308f83189a3f 82 static void registerIf(NetIf* pIf);
mimil 0:308f83189a3f 83 static void unregisterIf(NetIf* pIf);
mimil 0:308f83189a3f 84
mimil 0:308f83189a3f 85 static void registerNetTcpSocket(NetTcpSocket* pNetTcpSocket);
mimil 0:308f83189a3f 86 static void unregisterNetTcpSocket(NetTcpSocket* pNetTcpSocket);
mimil 0:308f83189a3f 87
mimil 0:308f83189a3f 88 static void registerNetUdpSocket(NetUdpSocket* pNetUdpSocket);
mimil 0:308f83189a3f 89 static void unregisterNetUdpSocket(NetUdpSocket* pNetUdpSocket);
mimil 0:308f83189a3f 90
mimil 0:308f83189a3f 91 private:
mimil 0:308f83189a3f 92 static Net& net(); //Return inst of singleton
mimil 0:308f83189a3f 93
mimil 0:308f83189a3f 94 NetIf* m_defaultIf;
mimil 0:308f83189a3f 95
mimil 0:308f83189a3f 96 list<NetIf*> m_lpIf;
mimil 0:308f83189a3f 97 list<NetTcpSocket*> m_lpNetTcpSocket;
mimil 0:308f83189a3f 98 list<NetUdpSocket*> m_lpNetUdpSocket;
mimil 0:308f83189a3f 99 };
mimil 0:308f83189a3f 100
mimil 0:308f83189a3f 101 #endif