lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] DHCP


From: Bill Auerbach
Subject: RE: [lwip-users] DHCP
Date: Tue, 27 May 2008 09:14:30 -0400

> With this, you are relying on lwIP-internal data structures! While this
> surely works, it is strongly discouraged by the lwIP developers: The
> internals data structures are never guaranteed to be portable accross
> versions so you risk your code being valid for a specific version of
> lwIP only!
> 
> I'm aware this is a problem here, though: there is no function (or
> macro) netif_get_addr corresponding to your code, which is why Jonathan
> suggested using nectonn_addr, which leads to the same result if you
> have one netif only.

This assumes the use of the netconn API.  I (and some others) use raw APIs.
So there could be some more simple netif apis:

netif_get_default
netif_get_addr
netif_get_ipaddr
netif_get_netmask
netif_get_gw
netif_set_hostname
netif_get_hostname

This would remove more requirements for direct access of lwIP internals.

I've added for myself netif_get_hostname and netif_set_hostname because I
need to get and set these dynamically.

> > If( ( netif->flags & (NETIF_FLAG_UP | NETIF_FLAG_LINK_UP) ) !=
> > (NETIF_FLAG_UP | NETIF_FLAG_LINK_UP) )
> >     Check_timer - if expired do something.
> >
> Same as above: please don't use the internal structs and its flag
> definitions when the same can be done differently since you risk using
> portablilty over lwIP versions:

Apologies, my (very) bad - for those following this thread and have only
seen the wrong way, it's:

if(! netif_is_up( netif ) ) { ..... }

> Since 1.3.0 (which was when NETIF_FALG_LINK_UP was introduced), you can
> set callback functions to be called when the netif status changes,
> which
> event eliminates the use of a timer suggested by bill:
> netif_set_status_callback.

Don't I need a timer still to know that the callback *wasn't* called?  I'm
waiting on DHCP *not* providing an IP address (in 5 seconds in my case).

Would it make sense for an autoip mode that uses a fixed address?  Though
one reason I didn't use autoip is it appears to include a good bit of code.

Bill






reply via email to

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