Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

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