EthernetNetIf

Dependents:   XBee_WiFi_EA_LPC4088

Committer:
hmike
Date:
Wed Nov 19 12:00:42 2014 +0000
Revision:
0:62580107d20c
EthernetNetIf

Who changed what in which revision?

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