Dependencies:   mbed

Dependents:   TCP

Committer:
slowness
Date:
Tue Sep 06 18:05:46 2011 +0000
Revision:
0:58c3d014a4e7

        

Who changed what in which revision?

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