> Please, could give me more details?
> I'm using netconn API.

No difference. The Netif-API is for handling network interfaces. As far as 
I can see, it works no matter what API you use for data-transfer (Raw, 
netconn, sockets).

In your current project you probably have some global handle for your 
network interface (netif*).
You do a netif_add(netif, ip, mask, gateway, state, init, input).

The new part would be an optional netif_set_status_callback(netif, 
callback) where "callback" is a void functiond with a netif* parameter.
This will be called on a status change of the networkinterface (going up, 
down, etc).
Then a simple netifapi_dhcp_start(netif) is enough to start the DHCP 
process in the stack/a new task.
When this returns, the DHCP process is not yet finished but simply started 
successfully. So I create a Task that waits for DHCP to finish using an 
Event/sempahore: if(EventWait(dhcpEvent, timeout) == FALSE).
When this times out, I stop the DHCP processing with netifapi_dhcp_stop
(netif) and use a fixed IP for the interface.
My callback function looks like this:

if(netif->flags & NETIF_FLAG_UP){
  if(netif->flags & NETIF_FLAG_DHCP){
    if(dhcpEvent){
      if(netif->dhcp){
        if((ip_addr *) &(netif->ip_addr) != IP_ADDR_ANY){
          EventSet(dhcpEvent);

meaning, when the status callback hits, I check if the DHCP process was 
successful and if so I set my semaphore/Event to stop the timeout in the 
other Task.

Not much more to it. You need to have DHCP active in your lwipopts.h of 
course. Other than that... should be straight forward.

kind regards,
Fabian
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to