Dependents: TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more
Diff: if/eth/EthernetNetIf.cpp
- Revision:
- 3:5a6792c147c0
- Parent:
- 0:ac1725ba162c
- Child:
- 4:966a0265edfc
--- 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