Subject: Re: ifwatcher written! [was Re: Getting laptop to auto-dhclient]
To: Brian Grayson (home) <bgrayson@austin.rr.com>
From: Todd Vierling <tv@duh.org>
List: netbsd-users
Date: 10/12/2003 10:00:31
On Sun, 12 Oct 2003, Brian Grayson (home) wrote:
: It looks like link up/down are (both) type RTM_IFINFO. Where would I
: find documentation about what to do with the rtm_* fields on a
: link up/down message? It appears that on link down, the rtm_seq is 1,
: and on link up, the rtm_seq is 2,
No, that's not what you want; that's simply a sequence number. You likely
want the data part of the routing socket message, which gives you what you
really want, link state from if_data.
If I'm reading the code correctly (which isn't guaranteed after how late I
was up last night 8-), in ifwatchd.c:dispatch(), the arg "msg" should be
castable to "struct if_msghdr". From that, you can traverse to ifm_data, a
"struct if_data", and look at ifi_link_state. If it's changed from whatever
value was last seen (LINK_STATE_{UNKNOWN,DOWN,UP}), you can do the
appropriate action.
--
-- Todd Vierling <tv@duh.org> <tv@pobox.com>