gavin beardall
/
EthernetNetIf
if/net/netif.h@0:715023d993d6, 2011-10-17 (annotated)
- Committer:
- gbeardall
- Date:
- Mon Oct 17 10:39:17 2011 +0000
- Revision:
- 0:715023d993d6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gbeardall | 0:715023d993d6 | 1 | |
gbeardall | 0:715023d993d6 | 2 | /* |
gbeardall | 0:715023d993d6 | 3 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
gbeardall | 0:715023d993d6 | 4 | |
gbeardall | 0:715023d993d6 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
gbeardall | 0:715023d993d6 | 6 | of this software and associated documentation files (the "Software"), to deal |
gbeardall | 0:715023d993d6 | 7 | in the Software without restriction, including without limitation the rights |
gbeardall | 0:715023d993d6 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
gbeardall | 0:715023d993d6 | 9 | copies of the Software, and to permit persons to whom the Software is |
gbeardall | 0:715023d993d6 | 10 | furnished to do so, subject to the following conditions: |
gbeardall | 0:715023d993d6 | 11 | |
gbeardall | 0:715023d993d6 | 12 | The above copyright notice and this permission notice shall be included in |
gbeardall | 0:715023d993d6 | 13 | all copies or substantial portions of the Software. |
gbeardall | 0:715023d993d6 | 14 | |
gbeardall | 0:715023d993d6 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
gbeardall | 0:715023d993d6 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
gbeardall | 0:715023d993d6 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
gbeardall | 0:715023d993d6 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
gbeardall | 0:715023d993d6 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
gbeardall | 0:715023d993d6 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
gbeardall | 0:715023d993d6 | 21 | THE SOFTWARE. |
gbeardall | 0:715023d993d6 | 22 | */ |
gbeardall | 0:715023d993d6 | 23 | |
gbeardall | 0:715023d993d6 | 24 | #ifndef NETIF_H |
gbeardall | 0:715023d993d6 | 25 | #define NETIF_H |
gbeardall | 0:715023d993d6 | 26 | |
gbeardall | 0:715023d993d6 | 27 | #include "core/ipaddr.h" |
gbeardall | 0:715023d993d6 | 28 | /* |
gbeardall | 0:715023d993d6 | 29 | #include "nettcpsocket.h" |
gbeardall | 0:715023d993d6 | 30 | #include "netudpsocket.h" |
gbeardall | 0:715023d993d6 | 31 | #include "netdnsrequest.h" |
gbeardall | 0:715023d993d6 | 32 | */ |
gbeardall | 0:715023d993d6 | 33 | class NetTcpSocket; |
gbeardall | 0:715023d993d6 | 34 | class NetUdpSocket; |
gbeardall | 0:715023d993d6 | 35 | class NetDnsRequest; |
gbeardall | 0:715023d993d6 | 36 | |
gbeardall | 0:715023d993d6 | 37 | #if 0 |
gbeardall | 0:715023d993d6 | 38 | enum NetifEvent |
gbeardall | 0:715023d993d6 | 39 | { |
gbeardall | 0:715023d993d6 | 40 | NETIF_CONNECTED, //Connected, can create & use sockets now |
gbeardall | 0:715023d993d6 | 41 | NETIF_DNSREPLY, |
gbeardall | 0:715023d993d6 | 42 | NETIF_DISCONNECTED |
gbeardall | 0:715023d993d6 | 43 | }; |
gbeardall | 0:715023d993d6 | 44 | #endif |
gbeardall | 0:715023d993d6 | 45 | |
gbeardall | 0:715023d993d6 | 46 | class NetIf |
gbeardall | 0:715023d993d6 | 47 | { |
gbeardall | 0:715023d993d6 | 48 | public: |
gbeardall | 0:715023d993d6 | 49 | NetIf(); |
gbeardall | 0:715023d993d6 | 50 | virtual ~NetIf(); |
gbeardall | 0:715023d993d6 | 51 | virtual NetTcpSocket* tcpSocket() = 0; //Create a new tcp socket |
gbeardall | 0:715023d993d6 | 52 | virtual NetUdpSocket* udpSocket() = 0; //Create a new udp socket |
gbeardall | 0:715023d993d6 | 53 | virtual void poll() = 0; |
gbeardall | 0:715023d993d6 | 54 | virtual NetDnsRequest* dnsRequest(const char* hostname) = 0; //Create a new NetDnsRequest object |
gbeardall | 0:715023d993d6 | 55 | virtual NetDnsRequest* dnsRequest(Host* pHost) = 0; //Create a new NetDnsRequest object |
gbeardall | 0:715023d993d6 | 56 | |
gbeardall | 0:715023d993d6 | 57 | //!Returns the IP of the interface once it's connected |
gbeardall | 0:715023d993d6 | 58 | IpAddr getIp() const; |
gbeardall | 0:715023d993d6 | 59 | |
gbeardall | 0:715023d993d6 | 60 | protected: |
gbeardall | 0:715023d993d6 | 61 | IpAddr m_ip; |
gbeardall | 0:715023d993d6 | 62 | }; |
gbeardall | 0:715023d993d6 | 63 | |
gbeardall | 0:715023d993d6 | 64 | #endif |