lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] dhcp_release_and_stop() clears the assigned IP address


From: R. Diez
Subject: [lwip-users] dhcp_release_and_stop() clears the assigned IP address
Date: Wed, 13 Feb 2019 16:36:15 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Hi all:

I have been hit by this change of behaviour:

dhcp_release_and_stop() clears the assigned IP address

https://savannah.nongnu.org/bugs/?55380

This was a nasty surprise, for it was not documented in the CHANGELOG file.

My application tries to obtain an IP address over DHCP, and if it fails, it 
sets a fall-back IP address.

However, my application keeps forever trying with DHCP. As soon as a DHCP server answers, it starts using the IP addressed obtained with DHCP, and stops using the fall-back IP address.

I could not find much documentation about lwIP's DHCP timeouts, so I implemented my own timeout. When the timeout occurs, my application calls dhcp_stop(), just in case, and then calls dhcp_start() again.

This logic no longer works now because the newest version of dhcp_stop() clears the IP address on the interface, even if the IP address was not set with DHCP, but manually.

Can someone help me solve this problem? I could use some clarification on the 
following points:

Point 1) dhcp_release_and_stop() should perhaps not unconditionally clear an IP 
address that DHCP has not set. I mean that this line:

netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4);

should probably be within the if (dhcp_supplied_address(netif)) { ... }, and 
not afterwards.

Point 2) Maybe I could properly control lwIP's DHCP timeout, so that I do not need to implement my own. Or at least know how long it takes. I couldn't figure it out yet.

Point 3) What happens when DHCP does time out in lwIP?

Question 3a) How do I find out that a time out occurred, so that I can set the fall-back IP address. I only want to set the fall-back IP address after DHCP has timed out at least once.

Question 3b) Does lwIP automatically clear the IP address on timeout, even if 
it did not come from DHCP?

Question 3c) Do I need to call dhcp_release_and_stop() after the timeout, 
before starting DHCP again?

Many thanks in advance,
  rdiez



reply via email to

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