lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Best practice for DHCP/Static IP config


From: address@hidden
Subject: Re: [lwip-users] Best practice for DHCP/Static IP config
Date: Tue, 22 Jan 2019 20:01:47 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Am 22.01.2019 um 09:58 schrieb address@hidden:
Could I get a recommendation for run-time configurable DHCP/Static IP address. Sorry if this has been asked 100 times before. Just wondering what the people who actually use lwip do…

From monitoring the mailing list, I understand no graceful shutdown… So I am ok with a startup variable and reset the hardware to make the setting take effect. #define is not really what I am looking for.

Is this the right way?

 1. Start the stack
 2. Check my config for desired static IP, or DHCP requested (dip
    switch, config bit, etc)

netif_set_default()

if (dhcp)

         dhcp_start();

else

         netif_set_up();

No, that was old usage. It has been changed with 2.0.0: you now *always* need to set the netif up. Then call dhcp_start() or net_set_addr().

A pointer to an example that does this, or 5 lines of pseudo code would be great!

There is 'contrib\examples\example_app\test.c', but this file is somewhat of a bad example since it tries to include all possible code with ifdefs...

So:
netif_add() // either with satic IP address or call netif_set_addr() later
netif_set_default()
netif_set_up()
if (dhcp)
        dhcp_start();
else
        netif_set_addr(); // if not set with netif_add()

And remember that the netif has to set the link flag up ('netif_set_link_up()') for things to work.

(SAME54, lwip 2.0.3, free RTOS 10.0.0)

Thanks Simon, Sylvain,  Steve, Patrick, and others who are providing such great help to this list! Most of my questions are answered by just watching the emails on this list.

Good to know!

Regards,
Simon



reply via email to

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