Core networking libraries including LwIP implementation

Dependencies:   DebugLib Socket lwip lwip-sys

Dependents:   EthernetInterface

Fork of NetworkingCoreLib by Donatien Garnier

Committer:
donatien
Date:
Fri Jun 22 16:18:09 2012 +0000
Revision:
15:cf5f669a30bc
Parent:
13:f7d8c8088289
DebugLib up

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 1:240e3322b87a 1 /* IPInterface.h */
donatien 13:f7d8c8088289 2 /* Copyright (C) 2012 mbed.org, MIT License
donatien 13:f7d8c8088289 3 *
donatien 13:f7d8c8088289 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien 13:f7d8c8088289 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
donatien 13:f7d8c8088289 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
donatien 13:f7d8c8088289 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
donatien 13:f7d8c8088289 8 * furnished to do so, subject to the following conditions:
donatien 13:f7d8c8088289 9 *
donatien 13:f7d8c8088289 10 * The above copyright notice and this permission notice shall be included in all copies or
donatien 13:f7d8c8088289 11 * substantial portions of the Software.
donatien 13:f7d8c8088289 12 *
donatien 13:f7d8c8088289 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien 13:f7d8c8088289 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien 13:f7d8c8088289 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien 13:f7d8c8088289 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 13:f7d8c8088289 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien 13:f7d8c8088289 18 */
donatien 1:240e3322b87a 19
donatien 1:240e3322b87a 20 #ifndef IPINTERFACE_H_
donatien 1:240e3322b87a 21 #define IPINTERFACE_H_
donatien 1:240e3322b87a 22
donatien 1:240e3322b87a 23 #include "core/fwk.h"
donatien 1:240e3322b87a 24
donatien 1:240e3322b87a 25 /** Generic IP-based network interface
donatien 1:240e3322b87a 26 *
donatien 1:240e3322b87a 27 */
donatien 1:240e3322b87a 28 class IPInterface
donatien 1:240e3322b87a 29 {
donatien 1:240e3322b87a 30 public:
donatien 8:387f573a6813 31 IPInterface();
donatien 8:387f573a6813 32 virtual ~IPInterface();
donatien 1:240e3322b87a 33
donatien 8:387f573a6813 34 //int init(); //Initialize interface; no connection should be performed at this stage
donatien 10:14ef6ceb4e75 35 virtual int connect() = 0; //Do connect the interface
donatien 10:14ef6ceb4e75 36 virtual int disconnect() = 0;
donatien 8:387f573a6813 37 //It is encouraged that the derived class implement a "setup(...)" function to configure the interface before the connection
donatien 10:14ef6ceb4e75 38
donatien 10:14ef6ceb4e75 39 char* getIPAddress(); //Get IP Address as a string ('a.b.c.d')
donatien 10:14ef6ceb4e75 40 bool isConnected(); //Is the interface connected?
donatien 1:240e3322b87a 41
donatien 8:387f573a6813 42 static IPInterface* getDefaultInterface(); //For use by TCP, UDP sockets library
donatien 1:240e3322b87a 43
donatien 8:387f573a6813 44 //WARN: Implementation will have to be more careful in case of multiple interfaces (or implement a routing protocol based on local IP addresses differentiation)
donatien 8:387f573a6813 45 void registerAsDefaultInterface(); //First come, first served
donatien 8:387f573a6813 46 void unregisterAsDefaultInterface(); //Must be called before inst is destroyed to avoid invalid ptr fault
donatien 1:240e3322b87a 47
donatien 10:14ef6ceb4e75 48 protected:
donatien 10:14ef6ceb4e75 49 //Must be called by subclasses
donatien 10:14ef6ceb4e75 50 void setIPAddress(char* ipAddr);
donatien 10:14ef6ceb4e75 51 void setConnected(bool connected);
donatien 10:14ef6ceb4e75 52
donatien 1:240e3322b87a 53 private:
donatien 10:14ef6ceb4e75 54 char m_ipAddr[16];
donatien 10:14ef6ceb4e75 55 bool m_connected;
donatien 10:14ef6ceb4e75 56
donatien 8:387f573a6813 57 static IPInterface* s_pDefaultInterface;
donatien 1:240e3322b87a 58 };
donatien 1:240e3322b87a 59
donatien 1:240e3322b87a 60 #endif /* IPINTERFACE_H_ */