Dependencies:   mbed

Committer:
robertcook
Date:
Wed Jun 13 18:39:46 2012 +0000
Revision:
0:32a0996dff0f

        

Who changed what in which revision?

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