Ethernet Interface Library
Dependencies: Socket lwip-eth lwip-sys lwip
Fork of EthernetInterface by
EthernetInterface.h@3:f5776537f27f, 2012-06-26 (annotated)
- Committer:
- donatien
- Date:
- Tue Jun 26 14:30:34 2012 +0000
- Revision:
- 3:f5776537f27f
- Child:
- 4:9a52c802be61
Update underlying libraries
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 3:f5776537f27f | 1 | /* EthernetInterface.h */ |
donatien | 3:f5776537f27f | 2 | /* Copyright (C) 2012 mbed.org, MIT License |
donatien | 3:f5776537f27f | 3 | * |
donatien | 3:f5776537f27f | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
donatien | 3:f5776537f27f | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
donatien | 3:f5776537f27f | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
donatien | 3:f5776537f27f | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
donatien | 3:f5776537f27f | 8 | * furnished to do so, subject to the following conditions: |
donatien | 3:f5776537f27f | 9 | * |
donatien | 3:f5776537f27f | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
donatien | 3:f5776537f27f | 11 | * substantial portions of the Software. |
donatien | 3:f5776537f27f | 12 | * |
donatien | 3:f5776537f27f | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
donatien | 3:f5776537f27f | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
donatien | 3:f5776537f27f | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
donatien | 3:f5776537f27f | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
donatien | 3:f5776537f27f | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
donatien | 3:f5776537f27f | 18 | */ |
donatien | 3:f5776537f27f | 19 | |
donatien | 3:f5776537f27f | 20 | #ifndef ETHERNETINTERFACE_H_ |
donatien | 3:f5776537f27f | 21 | #define ETHERNETINTERFACE_H_ |
donatien | 3:f5776537f27f | 22 | |
donatien | 3:f5776537f27f | 23 | #include "core/fwk.h" |
donatien | 3:f5776537f27f | 24 | |
donatien | 3:f5776537f27f | 25 | #include "rtos.h" |
donatien | 3:f5776537f27f | 26 | |
donatien | 3:f5776537f27f | 27 | #include "LwIPInterface.h" |
donatien | 3:f5776537f27f | 28 | |
donatien | 3:f5776537f27f | 29 | #include "lwip/netif.h" |
donatien | 3:f5776537f27f | 30 | |
donatien | 3:f5776537f27f | 31 | /** Interface using Ethernet to connect to an IP-based network |
donatien | 3:f5776537f27f | 32 | * |
donatien | 3:f5776537f27f | 33 | */ |
donatien | 3:f5776537f27f | 34 | class EthernetInterface : public LwIPInterface |
donatien | 3:f5776537f27f | 35 | { |
donatien | 3:f5776537f27f | 36 | public: |
donatien | 3:f5776537f27f | 37 | EthernetInterface(); |
donatien | 3:f5776537f27f | 38 | |
donatien | 3:f5776537f27f | 39 | int init(); //With DHCP |
donatien | 3:f5776537f27f | 40 | |
donatien | 3:f5776537f27f | 41 | int init(const char* ip, const char* mask, const char* gateway, const char* dns1, const char* dns2); //No DHCP |
donatien | 3:f5776537f27f | 42 | |
donatien | 3:f5776537f27f | 43 | virtual int connect(); |
donatien | 3:f5776537f27f | 44 | virtual int disconnect(); |
donatien | 3:f5776537f27f | 45 | |
donatien | 3:f5776537f27f | 46 | private: |
donatien | 3:f5776537f27f | 47 | static void netifStatusCb(struct netif *netif); |
donatien | 3:f5776537f27f | 48 | |
donatien | 3:f5776537f27f | 49 | static int32_t s_lpcNetifOff; //Offset between m_lpcNetif and this ... this might be quite kludgy but should work! |
donatien | 3:f5776537f27f | 50 | |
donatien | 3:f5776537f27f | 51 | struct netif m_lpcNetif; |
donatien | 3:f5776537f27f | 52 | Semaphore m_netifStatusSphre; |
donatien | 3:f5776537f27f | 53 | bool m_useDHCP; |
donatien | 3:f5776537f27f | 54 | }; |
donatien | 3:f5776537f27f | 55 | |
donatien | 3:f5776537f27f | 56 | //As a helper, include TCPSocket.h & UDPSocket.h here |
donatien | 3:f5776537f27f | 57 | #include "TCPSocket.h" |
donatien | 3:f5776537f27f | 58 | #include "UDPSocket.h" |
donatien | 3:f5776537f27f | 59 | |
donatien | 3:f5776537f27f | 60 | #endif /* ETHERNETINTERFACE_H_ */ |