diff options
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 *); |