|
From: | address@hidden |
Subject: | Re: [lwip-users] Noob DHCP question |
Date: | Tue, 20 Mar 2012 21:20:15 +0100 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20120313 Thunderbird/11.0 |
Kieran Mansley wrote:
On 15 Mar 2012, at 15:37, Chris Ponder wrote:At the application level I want to know when I have an address, if there is an error getting an address, if the network lead is disconnected / re-connected so that I can restart the Ethernet or set a static address as I see fit.I'm not sure what the supported way of doing this is, but I'm sure that other people do similar things to this. Can anyone help Chris with some suggestions here please?
- "when I have an address": you can register a callback with netif_set_status_callback() that gets called when the netif is set up or down. Since DHCP sets it to 'up' after getting an address, is this what you want? - "the network lead is disconnected": you can register a callback with netif_set_link_callback(), but for this callback to work, your netif driver needs to notify lwIP of link state changes by calling netif_set_link_up() / netif_set_link_down(). - "if there is an error getting an address": I'm not sure how to do that: DHCP just keeps on trying. Maybe you can just use a timeout and do something if you didn't get an address X seconds after the link went from 'down' to 'up'?
Simon
[Prev in Thread] | Current Thread | [Next in Thread] |