lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] DHCP usage with latest git code version


From: Bram Peeters
Subject: Re: [lwip-users] DHCP usage with latest git code version
Date: Fri, 11 Sep 2015 09:10:28 +0000

Thanks for the clarification!

I had to add 
#define LWIP_DHCP_CHECK_LINK_UP 1
as well to make 


>netif_set_up(&gnetif);
>dhcp_start(&gnetif);
>Then DHCP will start if netif is already "link up" or at the next "link  up" 
>event.


work with the netif initially in link down 
Otherwise the DCHP state was in DHCP_STATE_OFF mode, and stayed in that mode 
when dhcp_network_changed(struct netif *netif) was called when link up occurred.

 

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Sylvain Rochet
Sent: donderdag 10 september 2015 14:53
To: Mailing list for lwIP users
Subject: Re: [lwip-users] DHCP usage with latest git code version

Hi Bram,


On Thu, Sep 10, 2015 at 11:01:37AM +0000, Bram Peeters wrote:
> Hi,
> 
> What is the recommended sequence to start DHCP with the latest git 
> sources (anno 20150910) ? In the past dhcp_start() would automatically 
> bring up the interface, and there is still a lot of references 
> floating around to that way of working.

The behavior changed, an interface must be administratively up before starting 
DHCP, which makes more sense than the previous behavior.


> So that note is wrong now because dhcp_start has an error  on a down 
> interface:


>   if (netif_is_link_up(&gnetif))
>   {
>     /* When the netif is fully configured this function must be called */
>     netif_set_up(&gnetif);

"netif link up" and "netif up" events are orthogonal properties, 
coupling these events are wrong.

netif link up = hardware state, whether cable is plugged or unplugged

netif up = software administrative state, whether interface should be 
           used for routing or not


So, a interface must be administratively up before starting DHCP, so:

netif_set_up(&gnetif);
dhcp_start(&gnetif);

Then DHCP will start if netif is already "link up" or at the next "link 
up" event.

If your port does not support link down/up events, you also need to call 
netif_set_linkup() on your netif, but you'll lose the link status 
signaling which makes DHCP fast.

Sylvain

reply via email to

[Prev in Thread] Current Thread [Next in Thread]