ID the MBED processor on the network if you have more than one. View MBED name on DHCP of your Router - Example \"MBED PE\" Change your ID in Core / host.h

Committer:
JeffM
Date:
Sat Nov 06 14:11:02 2010 +0000
Revision:
0:fd3b85615428
MBED ID 1A

Who changed what in which revision?

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