|
From: | Muhamad Ikhwan Ismail |
Subject: | RE: [lwip-users] dhcp and bsd socket library for lwIP |
Date: | Wed, 21 May 2008 08:50:16 +0000 |
Hi, 1.To initialize the stack you should call the function tcpip_init(). You might have to change some stuffs depending on your implementation e.g. in my case i neeeded to call the memp_init earlier due to the fact my driver needs the pbuf pool for it's initialization. 2.This is an example how i initialized my DHCP (version 1.2) but i dont think it differed that much my_ethernet = (struct netif*)mallocx(sizeof(struct netif)); netif_init(); netif_add(my_ethernet,NULL,NULL,NULL,NULL,ethernetif_init,tcpip_input); /*bring the netif up if using static IP, otherwise dhcp will do it*/ #if LWIP_DHCP #include "..\..\lwip\src\include\lwip\dhcp.h dhcp_start(my_ethernet); //ready the timeout in case dhcp fails, which handles by assigning dummy address sys_timeout(DHCP_FAILURE_INTERVAL, (sys_timeout_handler)dhcp_failure_handler, NULL); //use sys_timeout for dhcp timers instead of calling on interval in tcpip_thread sys_timeout(DHCP_FINE_TIMER_MSECS,(sys_timeout_handler)dhcp_fine_tmrhandler,NULL); sys_timeout((1000*DHCP_COARSE_TIMER_SECS),(sys_timeout_handler)dhcp_coarse_tmrhandler,NULL); #else /*no LWIP_DHCP*/ ip_addr_set(&(my_ethernet->ip_addr),&dummyadd); ip_addr_set(&(my_ethernet->netmask),&dummymsk); ip_addr_set(&(my_ethernet->gw),&dummygtw); netif_set_up(my_ethernet); netif_set_default(my_ethernet); # endif//#if LWIP_DHCP You might wanna take note, that you should sleep all your applications a few seconds to allow the DHCP process to complete. This function for me is called during initialization (by a thread that does all the initialization). The TCP IP thread also is created there for me though that is very much imo up to your implementation. To check your ip address just view the variable of your netif during debugging.
Change the world with e-mail. Join the i’m Initiative from Microsoft. |
[Prev in Thread] | Current Thread | [Next in Thread] |