bruno LARNAUDIE
/
HTTPServer
EthernetNetIf/LPC2368/if/eth/EthernetNetIf.h@0:58c3d014a4e7, 2011-09-06 (annotated)
- Committer:
- slowness
- Date:
- Tue Sep 06 18:05:46 2011 +0000
- Revision:
- 0:58c3d014a4e7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
slowness | 0:58c3d014a4e7 | 1 | |
slowness | 0:58c3d014a4e7 | 2 | /* |
slowness | 0:58c3d014a4e7 | 3 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
slowness | 0:58c3d014a4e7 | 4 | |
slowness | 0:58c3d014a4e7 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
slowness | 0:58c3d014a4e7 | 6 | of this software and associated documentation files (the "Software"), to deal |
slowness | 0:58c3d014a4e7 | 7 | in the Software without restriction, including without limitation the rights |
slowness | 0:58c3d014a4e7 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
slowness | 0:58c3d014a4e7 | 9 | copies of the Software, and to permit persons to whom the Software is |
slowness | 0:58c3d014a4e7 | 10 | furnished to do so, subject to the following conditions: |
slowness | 0:58c3d014a4e7 | 11 | |
slowness | 0:58c3d014a4e7 | 12 | The above copyright notice and this permission notice shall be included in |
slowness | 0:58c3d014a4e7 | 13 | all copies or substantial portions of the Software. |
slowness | 0:58c3d014a4e7 | 14 | |
slowness | 0:58c3d014a4e7 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
slowness | 0:58c3d014a4e7 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
slowness | 0:58c3d014a4e7 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
slowness | 0:58c3d014a4e7 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
slowness | 0:58c3d014a4e7 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
slowness | 0:58c3d014a4e7 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
slowness | 0:58c3d014a4e7 | 21 | THE SOFTWARE. |
slowness | 0:58c3d014a4e7 | 22 | */ |
slowness | 0:58c3d014a4e7 | 23 | |
slowness | 0:58c3d014a4e7 | 24 | /** \file |
slowness | 0:58c3d014a4e7 | 25 | Ethernet network interface header file |
slowness | 0:58c3d014a4e7 | 26 | */ |
slowness | 0:58c3d014a4e7 | 27 | |
slowness | 0:58c3d014a4e7 | 28 | #ifndef ETHERNETNETIF_H |
slowness | 0:58c3d014a4e7 | 29 | #define ETHERNETNETIF_H |
slowness | 0:58c3d014a4e7 | 30 | |
slowness | 0:58c3d014a4e7 | 31 | struct netif; |
slowness | 0:58c3d014a4e7 | 32 | |
slowness | 0:58c3d014a4e7 | 33 | #include "mbed.h" |
slowness | 0:58c3d014a4e7 | 34 | |
slowness | 0:58c3d014a4e7 | 35 | #include "if/lwip/LwipNetIf.h" |
slowness | 0:58c3d014a4e7 | 36 | |
slowness | 0:58c3d014a4e7 | 37 | ///Ethernet network interface return codes |
slowness | 0:58c3d014a4e7 | 38 | enum EthernetErr |
slowness | 0:58c3d014a4e7 | 39 | { |
slowness | 0:58c3d014a4e7 | 40 | __ETH_MIN = -0xFFFF, |
slowness | 0:58c3d014a4e7 | 41 | ETH_TIMEOUT, ///<Timeout during setup |
slowness | 0:58c3d014a4e7 | 42 | ETH_OK = 0 ///<Success |
slowness | 0:58c3d014a4e7 | 43 | }; |
slowness | 0:58c3d014a4e7 | 44 | |
slowness | 0:58c3d014a4e7 | 45 | ///Ethernet network interface |
slowness | 0:58c3d014a4e7 | 46 | /** |
slowness | 0:58c3d014a4e7 | 47 | This class provides Ethernet connectivity to the stack |
slowness | 0:58c3d014a4e7 | 48 | */ |
slowness | 0:58c3d014a4e7 | 49 | class EthernetNetIf : public LwipNetIf |
slowness | 0:58c3d014a4e7 | 50 | { |
slowness | 0:58c3d014a4e7 | 51 | public: |
slowness | 0:58c3d014a4e7 | 52 | ///Instantiates the Interface and register it against the stack, DHCP will be used |
slowness | 0:58c3d014a4e7 | 53 | EthernetNetIf(); //W/ DHCP |
slowness | 0:58c3d014a4e7 | 54 | |
slowness | 0:58c3d014a4e7 | 55 | ///Instantiates the Interface and register it against the stack, DHCP will not be used |
slowness | 0:58c3d014a4e7 | 56 | /** |
slowness | 0:58c3d014a4e7 | 57 | IpAddr is a container class that can be constructed with either 4 bytes or no parameters for a null IP address. |
slowness | 0:58c3d014a4e7 | 58 | */ |
slowness | 0:58c3d014a4e7 | 59 | EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns); //W/o DHCP |
slowness | 0:58c3d014a4e7 | 60 | virtual ~EthernetNetIf(); |
slowness | 0:58c3d014a4e7 | 61 | |
slowness | 0:58c3d014a4e7 | 62 | ///Brings the interface up |
slowness | 0:58c3d014a4e7 | 63 | /** |
slowness | 0:58c3d014a4e7 | 64 | Uses DHCP if necessary |
slowness | 0:58c3d014a4e7 | 65 | @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s |
slowness | 0:58c3d014a4e7 | 66 | @return : ETH_OK on success or ETH_TIMEOUT on timeout |
slowness | 0:58c3d014a4e7 | 67 | */ |
slowness | 0:58c3d014a4e7 | 68 | EthernetErr setup(int timeout_ms = 15000); |
slowness | 0:58c3d014a4e7 | 69 | |
slowness | 0:58c3d014a4e7 | 70 | virtual void poll(); |
slowness | 0:58c3d014a4e7 | 71 | |
slowness | 0:58c3d014a4e7 | 72 | private: |
slowness | 0:58c3d014a4e7 | 73 | Timer m_ethArpTimer; |
slowness | 0:58c3d014a4e7 | 74 | Timer m_dhcpCoarseTimer; |
slowness | 0:58c3d014a4e7 | 75 | Timer m_dhcpFineTimer; |
slowness | 0:58c3d014a4e7 | 76 | Timer m_igmpTimer; |
slowness | 0:58c3d014a4e7 | 77 | |
slowness | 0:58c3d014a4e7 | 78 | bool m_useDhcp; |
slowness | 0:58c3d014a4e7 | 79 | |
slowness | 0:58c3d014a4e7 | 80 | netif* m_pNetIf; |
slowness | 0:58c3d014a4e7 | 81 | |
slowness | 0:58c3d014a4e7 | 82 | IpAddr m_netmask; |
slowness | 0:58c3d014a4e7 | 83 | IpAddr m_gateway; |
slowness | 0:58c3d014a4e7 | 84 | |
slowness | 0:58c3d014a4e7 | 85 | const char* m_hostname; |
slowness | 0:58c3d014a4e7 | 86 | |
slowness | 0:58c3d014a4e7 | 87 | }; |
slowness | 0:58c3d014a4e7 | 88 | |
slowness | 0:58c3d014a4e7 | 89 | #endif |
slowness | 0:58c3d014a4e7 | 90 |