Committer:
donatien
Date:
Fri Aug 06 10:42:05 2010 +0000
Revision:
3:e02ec42cf9c8

        

Who changed what in which revision?

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