Maybe someone else could also comment on this and let me know if I am wrong but 
as far as I know you don’t have to do anything once the IP address is obtained 
from DHCP. I don’t think you should ever be calling dhcp_stop() unless maybe 
you really don’t want to use dhcp anymore. Maybe they are incorrectly doing 
that in the example to free up the udp pcb being used by dhcp. But I don’t 
think dhcp_stop() should be called because the dhcp client should continue to 
run to renew IP leases when they expire and stay registered with the dhcp 
server.

As far as I know all you have to do is call dhcp_start() (which also ends up 
calling autoip_start() if AUTOIP is enabled) then just call 
dhcp_fine_tmr(),dhcp_coarse_tmr(), and autioip_tmr() at their respective 
intervals. Once the address is obtained, your netif will be updated with that 
address – you don’t have to do anything.

From: [email protected] 
[mailto:[email protected]] On Behalf Of 
Robert Deschambault
Sent: Thursday, June 18, 2015 8:29 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Strategy Question for DHCP

Hi,

Ok, did another little experiment and I notice that if I don't call dhcp_stop() 
in the DHCP state machine when the IP address gets assigned I can ping my 
target when I use AUTOIP.  Autoip is in state 3 (bound) and everything is fine. 
 When I call dhcp_stop() at any time, autoip goes to state 0 (stop) and I lose 
comms with the target.

My question is this:  What should I be doing once the IP address is assigned by 
either DHCP or AUTOIP in coop mode?  Any call to dhcp_stop() seems to be the 
wrong answer.  But all the examples I have seen for an STM32F4xx call that 
function once the IP address has been assigned.  Any comments?


On Wed, Jun 17, 2015 at 8:28 PM, Robert Deschambault 
<[email protected]<mailto:[email protected]>> wrote:
Hi,

I did a quick test to see when the autoip state is set to stop.  It looks like 
that when the IP address becomes non-zero, the DHCP code recognizes the 
assignment and makes a call to dhcp_stop() which I believe is calling 
autoip_stop() function coop mode.  Here is what the printf debug looks like at 
assignment (my code is also printing stuff too and please remember I have 
modified the default IP address pool for my application):

...
dhcp_discover()
transaction id xid(abcd0001)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
dhcp_discover: deleting()ing
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 16000 msecs
autoip_tmr() AutoIP-State: 2, ttw=6
autoip_tmr() AutoIP-State: 2, ttw=5
autoip_tmr() AutoIP-State: 2, ttw=4
autoip_tmr() AutoIP-State: 2, ttw=3
autoip_tmr() AutoIP-State: 2, ttw=2
autoip_tmr() AutoIP-State: 2, ttw=1
autoip_tmr() AutoIP-State: 2, ttw=0
autoip_bind(netif=20000778) cd0 192.168.252.11
autoip_tmr() AutoIP-State: 2, ttw=20
autoip_tmr() AutoIP-State: 2, ttw=19
MAIN: Network assigned by DHCP server:
dhcp_stop()
MAIN:    IP:    192.168.252.11
MAIN:    SN:    255.255.255.0
MAIN:    GW:    192.168.252.1
autoip_tmr() AutoIP-State: 0, ttw=18
autoip_tmr() AutoIP-State: 0, ttw=18
autoip_tmr() AutoIP-State: 0, ttw=18
...

after this the last line is repeated over and over again.  ttw always stays at 
18 and the state is always 0 (stop).  I don't know if this the expected 
behavior?

--
Bob Deschambault



--
Bob Deschambault
6614 Astro Court, Mississauga
Ontario, Canada L5N 7J2
home: 905 824 7159
cell: 416 457 7163
twitter: @rdeschambault
1Fm3QkinyqiMbpnvSZMLM1AyjBvbuYeTBE
________________________________
Confidentiality Notice: This e-mail may contain confidential and privileged 
material for the sole use of the intended recipient(s). Any review, use, 
distribution or disclosure by others is strictly prohibited. If you are not the 
intended recipient (or authorized to receive from the recipient), please 
contact the sender by reply e-mail and delete all copies of the message.
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to