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.



Date: Wed, 21 May 2008 00:11:59 -0700
From: [EMAIL PROTECTED]
To: [email protected]
Subject: [lwip-users] dhcp and bsd socket library for lwIP

Hi, 
I am new in using lwIP. I need some help. 
1. I am trying to use BSD soket library that is supported in lwIP, means I am 
trying to use socket, sendto etc functions instead of netconn_** functions. I 
have seen some examples in contrib folder but I still have following doubts:  
1. How should I do the initializations? which functions should I call to 
initialize the stack?
I want to use dhcp. Do you have any source code (of any server/client program) 
as an example where I can find how to use the DHCP calls? I would be interested 
to know when DHCP is up, how do I find out the IP address(and subnet mask) that 
I have got?  So kindly share any source code/project where I can findout the 
initialization sequence of the stack for using dhcp with BSD socket library 
functions.  Thanking you in advance,
Ted. 

      
_________________________________________________________________
Change the world with e-mail. Join the i’m Initiative from Microsoft.
http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_ChangeWorld
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to