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