]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to...
authorfbernon <fbernon>
Wed, 28 Mar 2007 09:23:35 +0000 (09:23 +0000)
committerfbernon <fbernon>
Wed, 28 Mar 2007 09:23:35 +0000 (09:23 +0000)
CHANGELOG
src/core/netif.c
src/include/lwip/netif.h

index ef4a6b9ca5a248f7990e599b5e219d2ea74f47d4..edac6dbf23c65f68e6a63a153bb32a1cf278bef5 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -23,6 +23,12 @@ HISTORY
 
   ++ New features:
 
+  2007-03-28 Frédéric Bernon
+  * netif.h, netif.c: A new NETIF_FLAG_ETHARP flag is defined in netif.h, to allow to 
+    initialize a network interface's flag with. It tell this interface is an ethernet
+    device, and we can use ARP with it to do a "gratuitous ARP" (RFC 3220 "IP Mobility
+    Support for IPv4" section 4.6) when interface is "up" with netif_set_up().
+
   2007-03-26 Frédéric Bernon, Jonathan Larmour  
   * opt.h, tcpip.c: New configuration option LWIP_ARP allow to disable ARP init at build
     time if you only use PPP or SLIP. The default is enable. Note we don't have to call 
index b599497c04818c07da5024527770923793a293c7..a994b580e6bf07da3f1ca059d523470e1e66cc76 100644 (file)
 #include "lwip/tcp.h"
 #include "lwip/snmp.h"
 
+#if LWIP_ARP
+#include "netif/etharp.h"
+#endif /* LWIP_ARP */
+
+
 struct netif *netif_list = NULL;
 struct netif *netif_default = NULL;
 
@@ -219,14 +224,6 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
   snmp_insert_ipaddridx_tree(netif);
   snmp_insert_iprteidx_tree(0,netif);
 
-#if 0 /* only allowed for Ethernet interfaces TODO: how can we check? */
-  /** For Ethernet network interfaces, we would like to send a
-   *  "gratuitous ARP"; this is an ARP packet sent by a node in order
-   *  to spontaneously cause other nodes to update an entry in their
-   *  ARP cache. From RFC 3220 "IP Mobility Support for IPv4" section 4.6.
-   */ 
-  etharp_query(netif, ipaddr, NULL);
-#endif
   LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
     netif->name[0], netif->name[1],
     ip4_addr1(&netif->ip_addr),
@@ -296,11 +293,24 @@ void netif_set_up(struct netif *netif)
     
 #if LWIP_SNMP
     snmp_get_sysuptime(&netif->ts);
-#endif
+#endif /* LWIP_SNMP */
+
 #if LWIP_NETIF_CALLBACK
     if ( netif->status_callback )
       (netif->status_callback)( netif );
 #endif /* LWIP_NETIF_CALLBACK */
+
+#if LWIP_ARP
+    /** For Ethernet network interfaces, we would like to send a
+     *  "gratuitous ARP"; this is an ARP packet sent by a node in order
+     *  to spontaneously cause other nodes to update an entry in their
+     *  ARP cache. From RFC 3220 "IP Mobility Support for IPv4" section 4.6.
+     */ 
+    if ((netif->flags & NETIF_FLAG_ETHARP) == 0) {
+      etharp_query(netif, &(netif->ip_addr), NULL);
+    }
+#endif /* LWIP_ARP */
+    
   }
 }
 
index 9c86f8e58ce8d737424201bb81fa15d960201cae..776e534585ae2e8a75d1baa8453a5d342cbdb2b3 100644 (file)
@@ -64,6 +64,8 @@
 /** if set, the interface has an active link
  *  (set by the network interface driver) */
 #define NETIF_FLAG_LINK_UP 0x10U
+/** if set, the netif is an device using ARP */
+#define NETIF_FLAG_ETHARP 0x20U
 
 /** Generic data structure used for all lwIP network interfaces.
  *  The following fields should be filled in by the initialization
@@ -101,7 +103,7 @@ struct netif {
 #if LWIP_DHCP
   /** the DHCP client state information for this netif */
   struct dhcp *dhcp;
-#endif
+#endif /* LWIP_DHCP */
   /** number of bytes used in hwaddr */
   u8_t hwaddr_len;
   /** link level hardware address of this interface */
@@ -130,11 +132,11 @@ struct netif {
   u32_t ifoutucastpkts;
   u32_t ifoutnucastpkts;
   u32_t ifoutdiscards;
-#endif
+#endif /* LWIP_SNMP */
 #if LWIP_IGMP
   /* This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/
   err_t (*igmp_mac_filter)( struct netif *netif, struct ip_addr *group, u8_t action);
-#endif
+#endif /* LWIP_IGMP */
 };
 
 /** The list of network interfaces. */