Hello everyone, (I'm working with lwip 1.4.0.)
I have a question regarding netif_add. netif_add( ) has the following prototype. struct netif *netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input) My network interface is supposed to be configured by DHCP, so I have no appropriate value for addr, gw, mask. I'd like to provide these 3 parameters as NULL, and have netif_add do whatever is appropriate for the 3 corresponding fields (probably set them to all-bits 0). netif_add calls netif_set_addr netif_set_addr calls netif_set_ipaddr, netif_set_netmask, netif_set_gw. netif_set_gw can handle NULL thanks to ip_addr_set Same for netif_set_netmask. However, netif_set_ipaddr crashes because it calls ip_addr_cmp which doesn't expect one of its parameters to be NULL. Would the following patch be acceptable? $ diff -u netif.c.orig netif.c --- netif.c.orig 2011-05-06 10:51:25.000000000 +0200 +++ netif.c 2011-08-03 18:11:23.052107100 +0200 @@ -325,7 +325,7 @@ struct tcp_pcb_listen *lpcb; /* address is actually being changed? */ - if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) { + if ((ipaddr != NULL) && ip_addr_cmp(ipaddr, &(netif->ip_addr)) == 0) { /* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */ LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n")); pcb = tcp_active_pcbs; or the equivalent if (ipaddr && ip_addr_cmp(ipaddr, &(netif->ip_addr)) == 0) { -- Regards. _______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users