lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #20409] Add netif callback function for link change ev


From: Jared Grubb
Subject: [lwip-devel] [bug #20409] Add netif callback function for link change event
Date: Wed, 11 Jul 2007 16:42:24 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4

Follow-up Comment #17, bug #20409 (project lwip):

> The problem with not making it mandatory would be the decision of when to
send the gratuitous ARP. 

I personally like the idea of making it mandatory, because having lwIP
respond to changes in link is a desirable thing. Saying "users upgrading to
lwIP 1.3 need to be aware of the following changes" is not a bad thing, and I
believe this could be a reasonable thing to require users to address.

> the network driver [...set link up flag]

A driver should most certainly do that anyway. The problem is how do we
notify the stack of this event.

I got an idea. The same events need to happen for *all* interfaces, therefore
it's not necessary to set a field *per* netif. The behavior could be done this
way:
* Create global variable void (*netif_state_change)(*netif) in netif.c.
Drivers call this function when link changes.
* Create netif_set_state_change(*fcn) {netif_link_change=fcn;}
* Create netif_do_state_change(netif) that does all the stuff (see below for
pseudo-code)
* netif_init() {... netif_set_state_change(netif_do_link_change);} (default
behavior, try to make this emulate how it's already being done in lwIP)
* tcpip_init() {... netif_set_state_change(tcpip_link_change);} (overridable
if the user uses API)
* Create tcpip_state_change() { return
tcpip_callback(netif_do_state_change,netif); }
This can all be marked off by #if..#endif if this is not mandatory. (I use
"state" instead of "link" since we are handling UP<->DOWN and LINK<->NOLINK.
Therefore netif_set_up/down calls it for UP/DOWN and driver calls it for
LINK/NOLINK)

> So we would have to set the netif state to down when the link is down?

Yes, I think so. Here is what I picture:
netif_do_state_change {
  if (DOWN & NOLINK) { nothing? }
  if (DOWN & LINK) {
     if (DHCP) {
        dhcp_bind (which will set up)
     }
  }
  if (UP & LINK) { ARP }
  if (UP & NOLINK) {
     if (DHCP) {
        dhcp_release (which sets down)
     } else {
        set down??
     }
  }
}

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?20409>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

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