diff options
author | sam <sam@FreeBSD.org> | 2004-12-08 05:45:59 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2004-12-08 05:45:59 +0000 |
commit | 2c929f635e2ee240aed007e68c7125eeb4f0426f (patch) | |
tree | ae5e1de46e56e4d1d92c6e394de8f5b9ec0353cc /sys/net | |
parent | bc6df700aa4860ce07ae94d1afda16fa44002a88 (diff) | |
download | FreeBSD-src-2c929f635e2ee240aed007e68c7125eeb4f0426f.zip FreeBSD-src-2c929f635e2ee240aed007e68c7125eeb4f0426f.tar.gz |
Cleanup link state change notification:
o add new if_link_state_change routine that deals with link state changes
o change mii to use if_link_state_change
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 26 | ||||
-rw-r--r-- | sys/net/if_var.h | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index b21701d..3968345 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -955,6 +955,32 @@ if_route(struct ifnet *ifp, int flag, int fam) #endif } +void (*vlan_link_state_p)(struct ifnet *, int); /* XXX: private from if_vlan */ + +/* + * Handle a change in the interface link state. + */ +void +if_link_state_change(struct ifnet *ifp, int link_state) +{ + int link; + + /* Notify that the link state has changed. */ + if (ifp->if_link_state != link_state) { + ifp->if_link_state = link_state; + rt_ifmsg(ifp); + if (link_state == LINK_STATE_UP) + link = NOTE_LINKUP; + else if (link_state == LINK_STATE_DOWN) + link = NOTE_LINKDOWN; + else + link = NOTE_LINKINV; + KNOTE_UNLOCKED(&ifp->if_klist, link); + if (ifp->if_nvlans != 0) + (*vlan_link_state_p)(ifp, link); + } +} + /* * Mark an interface down and notify protocols of * the transition. diff --git a/sys/net/if_var.h b/sys/net/if_var.h index f3517c6..ebbaa25 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -629,6 +629,7 @@ int if_delmulti(struct ifnet *, struct sockaddr *); void if_detach(struct ifnet *); void if_down(struct ifnet *); void if_initname(struct ifnet *, const char *, int); +void if_link_state_change(struct ifnet *, int); int if_printf(struct ifnet *, const char *, ...) __printflike(2, 3); int if_setlladdr(struct ifnet *, const u_char *, int); void if_up(struct ifnet *); |