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