testing of combination of LCS and LAN

Dependencies:   mbed

Committer:
damir
Date:
Wed Jan 14 13:29:55 2015 +0000
Revision:
0:a7a6a692162f
Test of LAN

Who changed what in which revision?

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