diff options
author | archie <archie@FreeBSD.org> | 2000-07-13 22:54:34 +0000 |
---|---|---|
committer | archie <archie@FreeBSD.org> | 2000-07-13 22:54:34 +0000 |
commit | 7357df6b4854f9914c605ad7c7cf3c01ea7700fd (patch) | |
tree | f79218274bf72874f2d01c6213ea088c3a3e768d /sys/net/if_ethersubr.c | |
parent | ef18034ac19957f4a94d28dd906d02cf32260a83 (diff) | |
download | FreeBSD-src-7357df6b4854f9914c605ad7c7cf3c01ea7700fd.zip FreeBSD-src-7357df6b4854f9914c605ad7c7cf3c01ea7700fd.tar.gz |
Make all Ethernet drivers attach using ether_ifattach() and detach using
ether_ifdetach().
The former consolidates the operations of if_attach(), ng_ether_attach(),
and bpfattach(). The latter consolidates the corresponding detach operations.
Reviewed by: julian, freebsd-net
Diffstat (limited to 'sys/net/if_ethersubr.c')
-rw-r--r-- | sys/net/if_ethersubr.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 7ae976e..d7c410b 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -646,12 +646,14 @@ ether_demux(ifp, eh, m) * Perform common duties while attaching to interface list */ void -ether_ifattach(ifp) +ether_ifattach(ifp, bpf) register struct ifnet *ifp; + int bpf; { register struct ifaddr *ifa; register struct sockaddr_dl *sdl; + if_attach(ifp); ifp->if_type = IFT_ETHER; ifp->if_addrlen = 6; ifp->if_hdrlen = 14; @@ -660,18 +662,32 @@ ether_ifattach(ifp) if (ifp->if_baudrate == 0) ifp->if_baudrate = 10000000; ifa = ifnet_addrs[ifp->if_index - 1]; - if (ifa == 0) { - printf("ether_ifattach: no lladdr!\n"); - return; - } + KASSERT(ifa != NULL, ("%s: no lladdr!\n", __FUNCTION__)); sdl = (struct sockaddr_dl *)ifa->ifa_addr; sdl->sdl_type = IFT_ETHER; sdl->sdl_alen = ifp->if_addrlen; bcopy((IFP2AC(ifp))->ac_enaddr, LLADDR(sdl), ifp->if_addrlen); + if (bpf) + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); if (ng_ether_attach_p != NULL) (*ng_ether_attach_p)(ifp); } +/* + * Perform common duties while detaching an Ethernet interface + */ +void +ether_ifdetach(ifp, bpf) + struct ifnet *ifp; + int bpf; +{ + if (ng_ether_detach_p != NULL) + (*ng_ether_detach_p)(ifp); + if (bpf) + bpfdetach(ifp); + if_detach(ifp); +} + SYSCTL_DECL(_net_link); SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet"); |