Dependents:   SNMPAgent HTTPServer think_speak_a cyassl-client ... more

Committer:
mamezu
Date:
Thu Dec 09 01:33:56 2010 +0000
Revision:
0:0f6c82fcde82

        

Who changed what in which revision?

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