Dependents: TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more
Revision 3:5a6792c147c0, committed 2010-11-19
- Comitter:
- segundo
- Date:
- Fri Nov 19 21:01:51 2010 +0000
- Parent:
- 2:a622b444296b
- Child:
- 4:966a0265edfc
- Commit message:
Changed in this revision
--- a/if/eth/EthernetNetIf.cpp Wed Nov 17 18:55:32 2010 +0000 +++ b/if/eth/EthernetNetIf.cpp Fri Nov 19 21:01:51 2010 +0000 @@ -43,6 +43,7 @@ //m_hostname = NULL; m_pNetIf = new netif; m_useDhcp = true; + m_setup = false; } EthernetNetIf::EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns) : LwipNetIf(), m_ethArpTimer(), m_dhcpCoarseTimer(), m_dhcpFineTimer(), m_igmpTimer(), m_pNetIf(NULL), m_hostname(NULL) //W/o DHCP @@ -54,6 +55,7 @@ m_pNetIf = new netif; dns_setserver(0, &dns.getStruct()); m_useDhcp = false; + m_setup = false; } EthernetNetIf::~EthernetNetIf() @@ -70,6 +72,16 @@ EthernetErr EthernetNetIf::setup(int timeout_ms /*= 15000*/) { + if (m_setup) + { + igmp_stop(m_pNetIf); + netif_set_down(m_pNetIf); + netif_remove(m_pNetIf); + delete m_pNetIf; + eth_free(); + m_pNetIf = new netif; + } + LwipNetIf::init(); //m_ethArpTicker.attach_us(ðarp_tmr, ARP_TMR_INTERVAL * 1000); // = 5s in etharp.h m_ethArpTimer.start(); @@ -129,6 +141,7 @@ else netif_set_down(m_pNetIf); DBG("\r\nTimeout.\r\n"); + m_setup = true; return ETH_TIMEOUT; } } @@ -141,6 +154,7 @@ DBG("Connected, IP : %d.%d.%d.%d\n", m_ip[0], m_ip[1], m_ip[2], m_ip[3]); + m_setup = true; return ETH_OK; } @@ -162,4 +176,8 @@ eth_poll(); } +const char* EthernetNetIf::getHwAddr() const { + return (char*)m_pNetIf->hwaddr; +} + #endif
--- a/if/eth/EthernetNetIf.h Wed Nov 17 18:55:32 2010 +0000 +++ b/if/eth/EthernetNetIf.h Fri Nov 19 21:01:51 2010 +0000 @@ -79,7 +79,10 @@ EthernetErr setup(int timeout_ms = 15000); virtual void poll(); - + + ///Returns an array containing the hardware address + const char* getHwAddr() const; + private: Timer m_ethArpTimer; Timer m_dhcpCoarseTimer; @@ -94,7 +97,7 @@ IpAddr m_gateway; const char* m_hostname; - + bool m_setup; }; #endif
--- a/lwip/core/timers.c Wed Nov 17 18:55:32 2010 +0000 +++ b/lwip/core/timers.c Fri Nov 19 21:01:51 2010 +0000 @@ -220,6 +220,7 @@ /** Initialize this module */ void sys_timeouts_init(void) { + next_timeout = NULL; #if IP_REASSEMBLY sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); #endif /* IP_REASSEMBLY */