NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Revision:
5:dd63a1e02b1b
Parent:
4:fd826cad83c0
--- a/if/eth/EthernetNetIf.cpp	Fri Jul 09 14:46:47 2010 +0000
+++ b/if/eth/EthernetNetIf.cpp	Tue Jul 27 15:59:42 2010 +0000
@@ -22,9 +22,12 @@
 */
 
 #include "EthernetNetIf.h"
+
 #include "netif/etharp.h"
 #include "lwip/dhcp.h"
 #include "lwip/dns.h"
+#include "lwip/igmp.h"
+
 #include "drv/eth/eth_drv.h"
 #include "mbed.h"
 
@@ -34,7 +37,7 @@
 #include "netCfg.h"
 #if NET_ETH
 
-EthernetNetIf::EthernetNetIf() : LwipNetIf(), m_ethArpTimer(), m_dhcpCoarseTimer(), m_dhcpFineTimer(), m_pNetIf(NULL),
+EthernetNetIf::EthernetNetIf() : LwipNetIf(), m_ethArpTimer(), m_dhcpCoarseTimer(), m_dhcpFineTimer(), m_igmpTimer(), m_pNetIf(NULL),
 m_netmask(255,255,255,255), m_gateway(), m_hostname(NULL)
 {
   m_hostname = NULL;
@@ -42,7 +45,7 @@
   m_useDhcp = true;
 }
 
-EthernetNetIf::EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns) : LwipNetIf(), m_ethArpTimer(), m_dhcpCoarseTimer(), m_dhcpFineTimer(), m_pNetIf(NULL), m_hostname(NULL) //W/o DHCP
+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
 {
   m_hostname = NULL;
   m_netmask = netmask;
@@ -57,6 +60,7 @@
 {
   if(m_pNetIf)
   {
+    igmp_stop(m_pNetIf); //Stop IGMP processing
     netif_set_down(m_pNetIf);
     netif_remove(m_pNetIf);
     delete m_pNetIf;
@@ -129,6 +133,10 @@
     }
   }
   
+  #if LWIP_IGMP
+  igmp_start(m_pNetIf); //Start IGMP processing
+  #endif
+  
   m_ip = IpAddr(&(m_pNetIf->ip_addr));
    
   DBG("Connected, IP : %d.%d.%d.%d\n", m_ip[0], m_ip[1], m_ip[2], m_ip[3]);
@@ -143,6 +151,13 @@
     m_ethArpTimer.reset();
     etharp_tmr();
   }
+  #if LWIP_IGMP
+  if(m_igmpTimer.read_ms()>=IGMP_TMR_INTERVAL)
+  {
+    m_igmpTimer.reset();
+    igmp_tmr();
+  }
+  #endif
   LwipNetIf::poll();
   eth_poll();
 }