Fork of NetServicesMin with some warnings removed

Dependencies:   lwip-sys lwip

Fork of NetServicesMin by Hendrik Lipka

Committer:
hlipka
Date:
Mon Jan 10 21:03:11 2011 +0000
Revision:
0:8b387bed54c2
initial version

Who changed what in which revision?

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