lwIP Wiki
Advertisement

DHCP initialisation and usage[]

I've found very little documentation here or on the web about how to migrate from a Static IP design to a DHCP design. I suggest we insert a code clipping something like this:

	netif_add(&netif_eth0, NULL, NULL, NULL, NULL, ethernetif_init, ip_input);
 	netif_set_default(&netif_eth0);
 
 #if 0
 	// Static address
 	struct ip_addr my_ipaddr;
 	struct ip_addr my_netmask;
 	struct ip_addr my_gw;
 
 	IP4_ADDR(&my_ipaddr,  192, 168, 0, 2);
 	IP4_ADDR(&my_netmask, 255, 255, 0, 0);
 	IP4_ADDR(&my_gw,      192, 168, 0, 1);
 	
 	netif_set_addr(&netif_eth0, &my_ipaddr, &my_netmask, &my_gw);
 	netif_set_up(&netif_eth0);
 #else
 	// Dynamic address
 	dhcp_start(&netif_eth0);
 #endif
 
 

PS: Is the example above Best Practice? --Mischief 11:02, 3 January 2008 (CST)

Defining LWIP_DHCP[]

Under "DHCP from an application perspective" it says that LWIP_DHCP should be defined as '1' in lwipopts.h. LWIP_DHCP is, defined as '0' in lwip/opt.h (which holds plain defaults; user selections are to be placed in lwipopts.h).

Advertisement