diff options
author | wollman <wollman@FreeBSD.org> | 1996-02-06 18:51:28 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1996-02-06 18:51:28 +0000 |
commit | 25ee6cca2a6483ef8d489b2eb60f0fbe475a32f2 (patch) | |
tree | e789decafa3124e34fc14cb210cda149ccb87570 /sys | |
parent | 2dfb2421458a36326af35171e59f21fbf98ab24f (diff) | |
download | FreeBSD-src-25ee6cca2a6483ef8d489b2eb60f0fbe475a32f2.zip FreeBSD-src-25ee6cca2a6483ef8d489b2eb60f0fbe475a32f2.tar.gz |
Clean up Ethernet drivers:
- fill in and use ifp->if_softc
- use if_bpf rather than private cookie variables
- change bpf interface to take advantage of this
- call ether_ifattach() directly from Ethernet drivers
- delete kludge in if_attach() that did this indirectly
Diffstat (limited to 'sys')
44 files changed, 322 insertions, 627 deletions
diff --git a/sys/dev/ar/if_ar.c b/sys/dev/ar/if_ar.c index 27ae67b..adf0ed1 100644 --- a/sys/dev/ar/if_ar.c +++ b/sys/dev/ar/if_ar.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ar.c,v 1.3 1995/12/10 13:38:34 phk Exp $ + * $Id: if_ar.c,v 1.4 1995/12/15 00:54:03 bde Exp $ */ /* @@ -95,8 +95,6 @@ AR_ENA_SCA | (ch ? AR_SEL_SCA_1:AR_SEL_SCA_0)) #define ARC_SET_OFF(iobase) outb(iobase+AR_MSCA_EN, 0) -#define ARUNIT2SC(unit) ar_sc_ind[unit] - static struct ar_hardc { int cunit; struct ar_softc *sc; @@ -125,7 +123,6 @@ struct ar_softc { int unit; /* With regards to all ar devices */ int subunit; /* With regards to this card */ struct ar_hardc *hc; - caddr_t bpf; u_int txdesc; /* On card address */ u_int txstart; /* On card address */ @@ -145,8 +142,6 @@ struct ar_softc { struct kern_devconf kdc; }; -static struct ar_softc *ar_sc_ind[NAR*NPORT]; - static int arprobe(struct isa_device *id); static int arattach(struct isa_device *id); @@ -395,6 +390,7 @@ arattach(struct isa_device *id) ifp = &sc->ifsppp.pp_if; + ifp->if_softc = sc; ifp->if_unit = hc->startunit + unit; ifp->if_name = "ar"; ifp->if_mtu = PP_MTU; @@ -416,7 +412,7 @@ arattach(struct isa_device *id) if_attach(ifp); #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_PPP, PPP_HEADER_LEN); + bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN); #endif } @@ -505,7 +501,7 @@ void arintr(int unit) static void arstart(struct ifnet *ifp) { - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; int i, len, tlen; struct mbuf *mtx; u_char *txdata; @@ -562,8 +558,8 @@ arstart(struct ifnet *ifp) i++; #if NBPFILTER > 0 - if(sc->bpf) - bpf_mtap(sc->bpf, mtx); + if(ifp->if_bpf) + bpf_mtap(ifp, mtx); #endif m_freem(mtx); ++sc->ifsppp.pp_if.if_opackets; @@ -624,7 +620,7 @@ arioctl(struct ifnet *ifp, int cmd, caddr_t data) int s, error; int was_up, should_be_up; struct sppp *sp = (struct sppp *)ifp; - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; TRC(printf("ar%d: arioctl.\n", ifp->if_unit);) @@ -674,7 +670,7 @@ arioctl(struct ifnet *ifp, int cmd, caddr_t data) static void arwatchdog(struct ifnet *ifp) { - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; if(!(ifp->if_flags & IFF_RUNNING)) return; @@ -860,11 +856,6 @@ void arc_init(struct isa_device *id) sc->rxend = next + bufmem; sc->rxmax = (sc->rxend - sc->rxstart) / AR_BUF_SIZ; next += bufmem; - - /* - * This is by ARUNIT2SC(). - */ - ar_sc_ind[x] = sc; } } @@ -1233,8 +1224,8 @@ ar_get_packets(struct ar_softc *sc) m->m_pkthdr.len = m->m_len = len; ar_copy_rxbuf(m, sc, len); #if NBPFILTER > 0 - if(sc->bpf) - bpf_mtap(sc->bpf, m); + if(sc->ifsppp.pp_if.if_bpf) + bpf_mtap(&sc->ifsppp.pp_if, m); #endif sppp_input(&sc->ifsppp.pp_if, m); sc->ifsppp.pp_if.if_ipackets++; diff --git a/sys/dev/ar/if_ar_isa.c b/sys/dev/ar/if_ar_isa.c index 27ae67b..adf0ed1 100644 --- a/sys/dev/ar/if_ar_isa.c +++ b/sys/dev/ar/if_ar_isa.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ar.c,v 1.3 1995/12/10 13:38:34 phk Exp $ + * $Id: if_ar.c,v 1.4 1995/12/15 00:54:03 bde Exp $ */ /* @@ -95,8 +95,6 @@ AR_ENA_SCA | (ch ? AR_SEL_SCA_1:AR_SEL_SCA_0)) #define ARC_SET_OFF(iobase) outb(iobase+AR_MSCA_EN, 0) -#define ARUNIT2SC(unit) ar_sc_ind[unit] - static struct ar_hardc { int cunit; struct ar_softc *sc; @@ -125,7 +123,6 @@ struct ar_softc { int unit; /* With regards to all ar devices */ int subunit; /* With regards to this card */ struct ar_hardc *hc; - caddr_t bpf; u_int txdesc; /* On card address */ u_int txstart; /* On card address */ @@ -145,8 +142,6 @@ struct ar_softc { struct kern_devconf kdc; }; -static struct ar_softc *ar_sc_ind[NAR*NPORT]; - static int arprobe(struct isa_device *id); static int arattach(struct isa_device *id); @@ -395,6 +390,7 @@ arattach(struct isa_device *id) ifp = &sc->ifsppp.pp_if; + ifp->if_softc = sc; ifp->if_unit = hc->startunit + unit; ifp->if_name = "ar"; ifp->if_mtu = PP_MTU; @@ -416,7 +412,7 @@ arattach(struct isa_device *id) if_attach(ifp); #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_PPP, PPP_HEADER_LEN); + bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN); #endif } @@ -505,7 +501,7 @@ void arintr(int unit) static void arstart(struct ifnet *ifp) { - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; int i, len, tlen; struct mbuf *mtx; u_char *txdata; @@ -562,8 +558,8 @@ arstart(struct ifnet *ifp) i++; #if NBPFILTER > 0 - if(sc->bpf) - bpf_mtap(sc->bpf, mtx); + if(ifp->if_bpf) + bpf_mtap(ifp, mtx); #endif m_freem(mtx); ++sc->ifsppp.pp_if.if_opackets; @@ -624,7 +620,7 @@ arioctl(struct ifnet *ifp, int cmd, caddr_t data) int s, error; int was_up, should_be_up; struct sppp *sp = (struct sppp *)ifp; - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; TRC(printf("ar%d: arioctl.\n", ifp->if_unit);) @@ -674,7 +670,7 @@ arioctl(struct ifnet *ifp, int cmd, caddr_t data) static void arwatchdog(struct ifnet *ifp) { - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; if(!(ifp->if_flags & IFF_RUNNING)) return; @@ -860,11 +856,6 @@ void arc_init(struct isa_device *id) sc->rxend = next + bufmem; sc->rxmax = (sc->rxend - sc->rxstart) / AR_BUF_SIZ; next += bufmem; - - /* - * This is by ARUNIT2SC(). - */ - ar_sc_ind[x] = sc; } } @@ -1233,8 +1224,8 @@ ar_get_packets(struct ar_softc *sc) m->m_pkthdr.len = m->m_len = len; ar_copy_rxbuf(m, sc, len); #if NBPFILTER > 0 - if(sc->bpf) - bpf_mtap(sc->bpf, m); + if(sc->ifsppp.pp_if.if_bpf) + bpf_mtap(&sc->ifsppp.pp_if, m); #endif sppp_input(&sc->ifsppp.pp_if, m); sc->ifsppp.pp_if.if_ipackets++; diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c index bf63619..b9516e8 100644 --- a/sys/dev/de/if_de.c +++ b/sys/dev/de/if_de.c @@ -21,7 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_de.c,v 1.41 1996/01/23 21:47:00 se Exp $ + * $Id: if_de.c,v 1.42 1996/01/26 09:29:26 phk Exp $ * */ @@ -1083,7 +1083,7 @@ tulip_rx_intr( eh = *mtod(m, struct ether_header *); #if NBPFILTER > 0 if (sc->tulip_bpf != NULL) - bpf_tap(sc->tulip_bpf, mtod(m, caddr_t), total_len); + bpf_tap(ifp, mtod(m, caddr_t), total_len); #endif if ((sc->tulip_if.if_flags & IFF_PROMISC) && (eh.ether_dhost[0] & 1) == 0 @@ -1223,7 +1223,7 @@ static ifnet_ret_t tulip_start( struct ifnet * const ifp) { - tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(ifp->if_unit); + tulip_softc_t * const sc = ifp->if_softc; struct ifqueue * const ifq = &ifp->if_snd; tulip_ringinfo_t * const ri = &sc->tulip_txinfo; struct mbuf *m, *m0, *next_m0; @@ -1374,7 +1374,7 @@ tulip_start( */ #if NBPFILTER > 0 if (sc->tulip_bpf != NULL) - bpf_mtap(sc->tulip_bpf, m); + bpf_mtap(ifp, m); #endif IF_ENQUEUE(&sc->tulip_txq, m); @@ -1869,7 +1869,7 @@ tulip_ioctl( ioctl_cmd_t cmd, caddr_t data) { - tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(ifp->if_unit); + tulip_softc_t * const sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; @@ -1994,6 +1994,7 @@ tulip_attach( { struct ifnet * const ifp = &sc->tulip_if; + ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST; ifp->if_ioctl = tulip_ioctl; ifp->if_output = ether_output; @@ -2018,12 +2019,10 @@ tulip_attach( tulip_reset(sc); if_attach(ifp); -#if defined(__NetBSD__) ether_ifattach(ifp); -#endif #if NBPFILTER > 0 - bpfattach(&sc->tulip_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif } diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index 35f8740..a68341f 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ed.c,v 1.92 1995/12/15 07:31:40 davidg Exp $ + * $Id: if_ed.c,v 1.93 1996/01/24 21:06:02 phk Exp $ */ /* @@ -113,7 +113,6 @@ struct ed_softc { int is790; /* set by the probe code if the card is 790 * based */ - caddr_t bpf; /* BPF "magic cookie" */ caddr_t mem_start; /* NIC memory start address */ caddr_t mem_end; /* NIC memory end address */ u_long mem_size; /* total NIC memory size */ @@ -1434,6 +1433,7 @@ ed_attach(isa_dev) /* * Initialize ifnet structure */ + ifp->if_softc = sc; ifp->if_unit = isa_dev->id_unit; ifp->if_name = "ed"; ifp->if_output = ether_output; @@ -1458,6 +1458,7 @@ ed_attach(isa_dev) * Attach the interface */ if_attach(ifp); + ether_ifattach(ifp); } /* device attach does transition from UNCONFIGURED to IDLE state */ sc->kdc.kdc_state = DC_IDLE; @@ -1482,7 +1483,7 @@ ed_attach(isa_dev) * If BPF is in the kernel, call the attach for it */ #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif return 1; } @@ -1494,7 +1495,7 @@ static void ed_reset(ifp) struct ifnet *ifp; { - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; int s; if (sc->gone) @@ -1542,7 +1543,7 @@ static void ed_watchdog(ifp) struct ifnet *ifp; { - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; if (sc->gone) return; @@ -1559,7 +1560,7 @@ static void ed_init(ifp) struct ifnet *ifp; { - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; int i, s; if (sc->gone) @@ -1769,7 +1770,7 @@ static void ed_start(ifp) struct ifnet *ifp; { - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; struct mbuf *m0, *m; caddr_t buffer; int len; @@ -1904,8 +1905,8 @@ outloop: * Tap off here if there is a bpf listener. */ #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, m0); + if (ifp->if_bpf) { + bpf_mtap(ifp, m0); } #endif @@ -1924,7 +1925,7 @@ static inline void ed_rint(sc) struct ed_softc *sc; { - struct ifnet *ifp = (struct ifnet *)sc; + struct ifnet *ifp = &sc->arpcom.ac_if; u_char boundry; u_short len; struct ed_ring packet_hdr; @@ -2264,7 +2265,7 @@ ed_ioctl(ifp, command, data) caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *) data; - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; @@ -2524,8 +2525,8 @@ ed_get_packet(sc, buf, len, multicast) * Check if there's a BPF listener on this interface. If so, hand off * the raw packet to bpf. */ - if (sc->bpf) { - bpf_mtap(sc->bpf, m); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, m); /* * Note that the interface cannot be in promiscuous mode if diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c index c072171..66e305c 100644 --- a/sys/dev/ep/if_ep.c +++ b/sys/dev/ep/if_ep.c @@ -38,7 +38,7 @@ */ /* - * $Id: if_ep.c,v 1.38 1996/01/26 09:27:22 phk Exp $ + * $Id: if_ep.c,v 1.39 1996/01/29 03:16:12 gibbs Exp $ * * Promiscuous mode added and interrupt logic slightly changed * to reduce the number of adapter failures. Transceiver select @@ -449,6 +449,7 @@ epattach(is) GO_WINDOW(0); outw(BASE + EP_W0_RESOURCE_CFG, SET_IRQ(irq)); + ifp->if_softc = sc; ifp->if_unit = is->id_unit; ifp->if_name = "ep"; ifp->if_mtu = ETHERMTU; @@ -459,6 +460,7 @@ epattach(is) ifp->if_watchdog = epwatchdog; if_attach(ifp); + ether_ifattach(ifp); /* device attach does transition from UNCONFIGURED to IDLE state */ kdc_ep[is->id_unit].kdc_state=DC_IDLE; @@ -506,7 +508,7 @@ epattach(is) sc->top = sc->mcur = 0; #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif return 1; } @@ -680,7 +682,7 @@ static void epstart(ifp) struct ifnet *ifp; { - register struct ep_softc *sc = &ep_softc[ifp->if_unit]; + register struct ep_softc *sc = ifp->if_softc; register u_int len; register struct mbuf *m; struct mbuf *top; @@ -759,8 +761,8 @@ startagain: outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */ #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, top); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, top); } #endif @@ -1083,8 +1085,8 @@ all_pkt: top->m_pkthdr.len = sc->cur_len; #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, top); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, top); /* * Note that the interface cannot be in promiscuous mode if there are @@ -1153,7 +1155,7 @@ epioctl(ifp, cmd, data) caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *) data; - struct ep_softc *sc = &ep_softc[ifp->if_unit]; + struct ep_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/dev/ep/if_epreg.h b/sys/dev/ep/if_epreg.h index a9b3593..2dc6b59 100644 --- a/sys/dev/ep/if_epreg.h +++ b/sys/dev/ep/if_epreg.h @@ -31,7 +31,7 @@ */ /* - * $Id: if_epreg.h,v 1.9 1996/01/29 03:16:14 gibbs Exp $ + * $Id: if_epreg.h,v 1.10 1996/01/30 22:55:43 mpp Exp $ * * Promiscuous mode added and interrupt logic slightly changed * to reduce the number of adapter failures. Transceiver select @@ -61,7 +61,6 @@ struct ep_softc { short rx_latency; short rx_avg_pkt; short cur_len; - caddr_t bpf; /* BPF "magic cookie" */ u_short ep_connectors; /* Connectors on this card. */ int stat; /* some flags */ #define F_RX_FIRST 0x1 diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c index 5e141c5..e07970a 100644 --- a/sys/dev/fe/if_fe.c +++ b/sys/dev/fe/if_fe.c @@ -214,9 +214,6 @@ static struct fe_softc { void ( * init )( struct fe_softc * ); /* Just before fe_init(). */ void ( * stop )( struct fe_softc * ); /* Just after fe_stop(). */ - /* For BPF. */ - caddr_t bpf; /* BPF "magic cookie" */ - /* Transmission buffer management. */ u_short txb_free; /* free bytes in TX buffer */ u_char txb_count; /* number of packets in TX buffer */ @@ -236,15 +233,7 @@ static struct fe_softc { #define sc_dcstate kdc.kdc_state #define sc_description kdc.kdc_description -/* - * Some entry functions receive a "struct ifnet *" typed pointer as an - * argument. It points to arpcom.ac_if of our softc. Remember arpcom.ac_if - * is located at very first of the fe_softc struct. So, there is no - * difference between "struct fe_softc *" and "struct ifnet *" at the machine - * language level. We just cast to turn a "struct ifnet *" value into "struct - * fe_softc * value". If this were C++, we would need no such cast at all. - */ -#define IFNET2SOFTC(P) ( ( struct fe_softc * )(P) ) +#define IFNET2SOFTC(P) (P)->if_softc /* Standard driver entry points. These can be static. */ static int fe_probe ( struct isa_device * ); @@ -271,7 +260,6 @@ static struct fe_filter static int fe_hash ( u_char * ); static void fe_setmode ( struct fe_softc * ); static void fe_loadmar ( struct fe_softc * ); -static void fe_setlinkaddr ( struct fe_softc * ); #if FE_DEBUG >= 1 static void fe_dump ( int, struct fe_softc *, char * ); #endif @@ -1061,6 +1049,7 @@ fe_attach ( struct isa_device *isa_dev ) /* * Initialize ifnet structure */ + sc->sc_if.if_softc = sc; sc->sc_if.if_unit = sc->sc_unit; sc->sc_if.if_name = "fe"; sc->sc_if.if_output = ether_output; @@ -1122,7 +1111,7 @@ fe_attach ( struct isa_device *isa_dev ) /* Attach and stop the interface. */ if_attach( &sc->sc_if ); fe_stop( sc->sc_unit ); /* This changes the state to IDLE. */ - fe_setlinkaddr( sc ); + ether_ifattach(&sc->sc_if); /* Print additional info when attached. */ printf( "fe%d: address %6D, type %s\n", sc->sc_unit, @@ -1162,8 +1151,7 @@ fe_attach ( struct isa_device *isa_dev ) #if NBPFILTER > 0 /* If BPF is in the kernel, call the attach for it. */ - bpfattach(&sc->bpf, &sc->sc_if, DLT_EN10MB, - sizeof(struct ether_header)); + bpfattach(&sc->sc_if, DLT_EN10MB, sizeof(struct ether_header)); #endif return 1; } @@ -2100,6 +2088,7 @@ fe_ioctl ( struct ifnet *ifp, int command, caddr_t data ) } #endif +#ifdef notdef #ifdef SIOCSIFPHYSADDR case SIOCSIFPHYSADDR: { @@ -2115,6 +2104,7 @@ fe_ioctl ( struct ifnet *ifp, int command, caddr_t data ) break; } #endif +#endif /* notdef */ #ifdef SIOCSIFFLAGS case SIOCSIFFLAGS: @@ -2278,8 +2268,8 @@ fe_get_packet ( struct fe_softc * sc, u_short len ) * Check if there's a BPF listener on this interface. * If it is, hand off the raw packet to bpf. */ - if ( sc->bpf ) { - bpf_mtap( sc->bpf, m ); + if ( sc->sc_if.if_bpf ) { + bpf_mtap( &sc->sc_if, m ); } #endif @@ -2680,47 +2670,6 @@ fe_loadmar ( struct fe_softc * sc ) #endif } -/* - * Copy the physical (Ethernet) address into the "data link" address - * entry of the address list for an interface. - * This is (said to be) useful for netstat(1) to keep track of which - * interface is which. - * - * What I'm not sure on this function is, why this is a driver's function. - * Probably this should be moved to somewhere independent to a specific - * hardware, such as if_ehtersubr.c. FIXME. - */ -static void -fe_setlinkaddr ( struct fe_softc * sc ) -{ - struct ifaddr *ifa; - struct sockaddr_dl * sdl; - - /* - * Search down the ifa address list looking for the AF_LINK type entry. - */ - for ( ifa = sc->sc_if.if_addrlist; ifa != NULL; ifa = ifa->ifa_next ) { - if ( ifa->ifa_addr != NULL - && ifa->ifa_addr->sa_family == AF_LINK ) { - - /* - * We have found an AF_LINK type entry. - * Fill in the link-level address for this interface - */ - sdl = (struct sockaddr_dl *) ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(sc->sc_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); -#if FE_DEBUG >= 3 - log( LOG_INFO, "fe%d: link address set\n", - sc->sc_unit ); -#endif - return; - } - } -} - #if FE_DEBUG >= 1 static void fe_dump ( int level, struct fe_softc * sc, char * message ) diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 1fdf77d..fe68fa8 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_fxp.c,v 1.9 1996/01/23 21:47:03 se Exp $ + * $Id: if_fxp.c,v 1.10 1996/01/26 09:29:28 phk Exp $ */ /* @@ -84,7 +84,6 @@ struct fxp_softc { struct arpcom arpcom; /* per-interface network data */ - caddr_t bpf; /* BPF token */ struct fxp_csr *csr; /* control/status registers */ struct fxp_cb_tx *cbl_base; /* base of TxCB list */ struct fxp_cb_tx *cbl_first; /* first active TxCB in list */ @@ -281,6 +280,7 @@ fxp_attach(config_id, unit) fxp_sc[unit] = sc; ifp = &sc->arpcom.ac_if; + ifp->if_softc = sc; ifp->if_unit = unit; ifp->if_name = "fxp"; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; @@ -297,8 +297,10 @@ fxp_attach(config_id, unit) * Attach the interface. */ if_attach(ifp); + ether_ifattach(ifp); + #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif splx(s); return; @@ -413,7 +415,7 @@ static void fxp_start(ifp) struct ifnet *ifp; { - struct fxp_softc *sc = (struct fxp_softc *)ifp; + struct fxp_softc *sc = ifp->if_softc; struct fxp_csr *csr = sc->csr; struct fxp_cb_tx *txp; struct mbuf *m, *mb_head; @@ -529,8 +531,8 @@ tbdinit: /* * Pass packet to bpf if there is a listener. */ - if (sc->bpf != NULL) - bpf_mtap(sc->bpf, mb_head); + if (ifp->if_bpf != NULL) + bpf_mtap(ifp, mb_head); #endif /* * Set a 5 second timer just in case we don't hear from the @@ -624,8 +626,8 @@ rcvloop: sizeof(struct ether_header); eh = mtod(m, struct ether_header *); #if NBPFILTER > 0 - if (sc->bpf != NULL) { - bpf_tap(sc->bpf, mtod(m, caddr_t), total_len); + if (ifp->if_bpf != NULL) { + bpf_tap(ifp, mtod(m, caddr_t), total_len); /* * Only pass this packet up if it is for us. */ @@ -790,7 +792,7 @@ static void fxp_init(ifp) struct ifnet *ifp; { - struct fxp_softc *sc = (struct fxp_softc *)ifp; + struct fxp_softc *sc = ifp->if_softc; struct fxp_cb_config *cbp; struct fxp_cb_ias *cb_ias; struct fxp_cb_tx *txp; @@ -1006,7 +1008,7 @@ fxp_ioctl(ifp, command, data) caddr_t data; { struct ifaddr *ifa = (struct ifaddr *) data; - struct fxp_softc *sc = (struct fxp_softc *)ifp; + struct fxp_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c index 4094ef2..903b1e2 100644 --- a/sys/dev/ie/if_ie.c +++ b/sys/dev/ie/if_ie.c @@ -43,7 +43,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ie.c,v 1.31 1995/12/10 13:38:45 phk Exp $ + * $Id: if_ie.c,v 1.32 1996/01/26 09:27:26 phk Exp $ */ /* @@ -303,11 +303,6 @@ static struct ie_softc { struct ie_en_addr mcast_addrs[MAXMCAST + 1]; int mcast_count; - -#if NBPFILTER > 0 - caddr_t ie_bpf; -#endif - } ie_softc[NIE]; #define MK_24(base, ptr) ((caddr_t)((u_long)ptr - (u_long)base)) @@ -579,12 +574,13 @@ ieattach(dvp) struct ie_softc *ie = &ie_softc[unit]; struct ifnet *ifp = &ie->arpcom.ac_if; + ifp->if_softc = ie; ifp->if_unit = unit; ifp->if_name = iedriver.name; ifp->if_mtu = ETHERMTU; printf(" <%s R%d> ethernet address %6D\n", - ie_hardware_names[ie_softc[unit].hard_type], - ie_softc[unit].hard_vers + 1, + ie_hardware_names[ie->hard_type], + ie->hard_vers + 1, ie->arpcom.ac_enaddr, ":"); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; @@ -596,29 +592,13 @@ ieattach(dvp) ifp->if_hdrlen = 14; #if NBPFILTER > 0 - bpfattach(&ie_softc[unit].ie_bpf, ifp, DLT_EN10MB, - sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif if_attach(ifp); + ether_ifattach(ifp); kdc_ie[unit].kdc_description = ie_hardware_names[ie_softc[unit].hard_type]; - - { - struct ifaddr *ifa = ifp->if_addrlist; - struct sockaddr_dl *sdl; - while(ifa && ifa->ifa_addr && ifa->ifa_addr->sa_family != AF_LINK) - ifa = ifa->ifa_next; - - if(!ifa || !ifa->ifa_addr) return 1; - - /* Provide our ether address to the higher layers */ - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = 6; - sdl->sdl_slen = 0; - bcopy(ie->arpcom.ac_enaddr, LLADDR(sdl), 6); - return 1; - } + return 1; } /* @@ -857,7 +837,7 @@ static inline int check_eh(struct ie_softc *ie, * Receiving all multicasts, but no unicasts except those destined for us. */ #if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); /* BPF gets this packet if anybody cares */ + *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); /* BPF gets this packet if anybody cares */ #endif if(eh->ether_dhost[0] & 1) { return 1; @@ -870,7 +850,7 @@ static inline int check_eh(struct ie_softc *ie, * Receiving all packets. These need to be passed on to BPF. */ #if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); + *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); #endif /* If for us, accept and hand up to BPF */ if(ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) return 1; @@ -904,7 +884,7 @@ static inline int check_eh(struct ie_softc *ie, * Whew! (Hope this is a fast machine...) */ #if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); + *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); #endif /* We want to see multicasts. */ if(eh->ether_dhost[0] & 1) return 1; @@ -928,7 +908,7 @@ static inline int check_eh(struct ie_softc *ie, * as quickly as possible. */ #if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); + *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); #endif return 1; } @@ -1221,7 +1201,7 @@ static void ie_readframe(unit, ie, num) m0.m_next = m; /* Pass it up */ - bpf_mtap(ie->ie_bpf, &m0); + bpf_mtap(&ie->arpcom.ac_if, &m0); } /* * A signal passed up from the filtering code indicating that the @@ -1283,7 +1263,7 @@ static void iestart(ifp) struct ifnet *ifp; { - struct ie_softc *ie = &ie_softc[ifp->if_unit]; + struct ie_softc *ie = ifp->if_softc; struct mbuf *m0, *m; unsigned char *buffer; u_short len; @@ -1317,8 +1297,8 @@ iestart(ifp) * See if bpf is listening on this interface, let it see the packet * before we commit it to the wire. */ - if(ie->ie_bpf) - bpf_tap(ie->ie_bpf, ie->xmit_cbuffs[ie->xmit_count], len); + if(ie->arpcom.ac_if.if_bpf) + bpf_tap(&ie->arpcom.ac_if, ie->xmit_cbuffs[ie->xmit_count], len); #endif ie->xmit_buffs[ie->xmit_count]->ie_xmit_flags = IE_XMIT_LAST | len; @@ -1883,7 +1863,7 @@ ieioctl(ifp, command, data) caddr_t data; { struct ifaddr *ifa = (struct ifaddr *)data; - struct ie_softc *ie = &ie_softc[ifp->if_unit]; + struct ie_softc *ie = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c index 2f8198c..3e060a4 100644 --- a/sys/dev/lnc/if_lnc.c +++ b/sys/dev/lnc/if_lnc.c @@ -123,9 +123,6 @@ static struct lnc_softc { #ifdef DEBUG int lnc_debug; #endif -#if NBPFILTER > 0 - caddr_t bpf; /* XXX bpf magic cookie - move to arpcom */ -#endif LNCSTATS_STRUCT } lnc_softc[NLNC]; @@ -631,8 +628,8 @@ lnc_rint(int unit) eh = (struct ether_header *) head->m_data; #if NBPFILTER > 0 - if (sc->bpf) - bpf_mtap(sc->bpf, head); + if (sc->arpcom.ac_if.if_bpf) + bpf_mtap(&sc->arpcom.ac_if, head); /* Check this packet is really for us */ @@ -1162,6 +1159,7 @@ lnc_attach(struct isa_device * isa_dev) /* Fill in arpcom structure entries */ + sc->arpcom.ac_if.if_softc = sc; sc->arpcom.ac_if.if_name = lncdriver.name; sc->arpcom.ac_if.if_unit = isa_dev->id_unit; sc->arpcom.ac_if.if_mtu = ETHERMTU; @@ -1180,6 +1178,7 @@ lnc_attach(struct isa_device * isa_dev) */ if_attach(&sc->arpcom.ac_if); + ether_ifattach(&sc->arpcom.ac_if); sc->kdc.kdc_state = DC_IDLE; printf("lnc%d: %s, address %6D\n", @@ -1188,7 +1187,7 @@ lnc_attach(struct isa_device * isa_dev) sc->arpcom.ac_enaddr, ":"); #if NBPFILTER > 0 - bpfattach(&sc->bpf, &sc->arpcom.ac_if, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(&sc->arpcom.ac_if, DLT_EN10MB, sizeof(struct ether_header)); #endif return (1); @@ -1500,7 +1499,7 @@ static void lnc_start(struct ifnet *ifp) { - struct lnc_softc *sc = &lnc_softc[ifp->if_unit]; + struct lnc_softc *sc = ifp->if_softc; struct host_ring_entry *desc; int tmp; int end_of_packet; @@ -1636,8 +1635,8 @@ lnc_start(struct ifnet *ifp) ifp->if_timer = 2; #if NBPFILTER > 0 - if (sc->bpf) - bpf_mtap(sc->bpf, head); + if (sc->arpcom.ac_if.if_bpf) + bpf_mtap(&sc->arpcom.ac_if, head); #endif if (sc->nic.mem_mode != DMA_MBUF) @@ -1658,7 +1657,7 @@ static int lnc_ioctl(struct ifnet * ifp, int command, caddr_t data) { - struct lnc_softc *sc = &lnc_softc[ifp->if_unit]; + struct lnc_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *) data; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/i386/include/cronyx.h b/sys/i386/include/cronyx.h index 5b2160d..4386773 100644 --- a/sys/i386/include/cronyx.h +++ b/sys/i386/include/cronyx.h @@ -414,7 +414,6 @@ typedef struct _chan_t { struct ifnet *ifp; /* network interface data */ struct ifnet *master; /* master interface, or ==ifp */ struct _chan_t *slaveq; /* slave queue pointer, or NULL */ - caddr_t bpf; /* packet filter data */ cx_soft_opt_t sopt; /* software options and state flags */ cx_break_t brk; /* line break mode */ #ifdef __bsdi__ diff --git a/sys/i386/isa/if_ar.c b/sys/i386/isa/if_ar.c index 27ae67b..adf0ed1 100644 --- a/sys/i386/isa/if_ar.c +++ b/sys/i386/isa/if_ar.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ar.c,v 1.3 1995/12/10 13:38:34 phk Exp $ + * $Id: if_ar.c,v 1.4 1995/12/15 00:54:03 bde Exp $ */ /* @@ -95,8 +95,6 @@ AR_ENA_SCA | (ch ? AR_SEL_SCA_1:AR_SEL_SCA_0)) #define ARC_SET_OFF(iobase) outb(iobase+AR_MSCA_EN, 0) -#define ARUNIT2SC(unit) ar_sc_ind[unit] - static struct ar_hardc { int cunit; struct ar_softc *sc; @@ -125,7 +123,6 @@ struct ar_softc { int unit; /* With regards to all ar devices */ int subunit; /* With regards to this card */ struct ar_hardc *hc; - caddr_t bpf; u_int txdesc; /* On card address */ u_int txstart; /* On card address */ @@ -145,8 +142,6 @@ struct ar_softc { struct kern_devconf kdc; }; -static struct ar_softc *ar_sc_ind[NAR*NPORT]; - static int arprobe(struct isa_device *id); static int arattach(struct isa_device *id); @@ -395,6 +390,7 @@ arattach(struct isa_device *id) ifp = &sc->ifsppp.pp_if; + ifp->if_softc = sc; ifp->if_unit = hc->startunit + unit; ifp->if_name = "ar"; ifp->if_mtu = PP_MTU; @@ -416,7 +412,7 @@ arattach(struct isa_device *id) if_attach(ifp); #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_PPP, PPP_HEADER_LEN); + bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN); #endif } @@ -505,7 +501,7 @@ void arintr(int unit) static void arstart(struct ifnet *ifp) { - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; int i, len, tlen; struct mbuf *mtx; u_char *txdata; @@ -562,8 +558,8 @@ arstart(struct ifnet *ifp) i++; #if NBPFILTER > 0 - if(sc->bpf) - bpf_mtap(sc->bpf, mtx); + if(ifp->if_bpf) + bpf_mtap(ifp, mtx); #endif m_freem(mtx); ++sc->ifsppp.pp_if.if_opackets; @@ -624,7 +620,7 @@ arioctl(struct ifnet *ifp, int cmd, caddr_t data) int s, error; int was_up, should_be_up; struct sppp *sp = (struct sppp *)ifp; - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; TRC(printf("ar%d: arioctl.\n", ifp->if_unit);) @@ -674,7 +670,7 @@ arioctl(struct ifnet *ifp, int cmd, caddr_t data) static void arwatchdog(struct ifnet *ifp) { - struct ar_softc *sc = ARUNIT2SC(ifp->if_unit); + struct ar_softc *sc = ifp->if_softc; if(!(ifp->if_flags & IFF_RUNNING)) return; @@ -860,11 +856,6 @@ void arc_init(struct isa_device *id) sc->rxend = next + bufmem; sc->rxmax = (sc->rxend - sc->rxstart) / AR_BUF_SIZ; next += bufmem; - - /* - * This is by ARUNIT2SC(). - */ - ar_sc_ind[x] = sc; } } @@ -1233,8 +1224,8 @@ ar_get_packets(struct ar_softc *sc) m->m_pkthdr.len = m->m_len = len; ar_copy_rxbuf(m, sc, len); #if NBPFILTER > 0 - if(sc->bpf) - bpf_mtap(sc->bpf, m); + if(sc->ifsppp.pp_if.if_bpf) + bpf_mtap(&sc->ifsppp.pp_if, m); #endif sppp_input(&sc->ifsppp.pp_if, m); sc->ifsppp.pp_if.if_ipackets++; diff --git a/sys/i386/isa/if_cx.c b/sys/i386/isa/if_cx.c index cd7c193..bdbdef1 100644 --- a/sys/i386/isa/if_cx.c +++ b/sys/i386/isa/if_cx.c @@ -268,6 +268,7 @@ cxattach (struct isa_device *id) } bzero (c->ifp, IFSTRUCTSZ); c->master = c->ifp; + c->ifp->if_softc = c; c->ifp->if_unit = u; c->ifp->if_name = "cx"; c->ifp->if_mtu = PP_MTU; @@ -280,7 +281,7 @@ cxattach (struct isa_device *id) if_attach (c->ifp); #if NBPFILTER > 0 /* If BPF is in the kernel, call the attach for it. */ - bpfattach (&c->bpf, c->ifp, DLT_PPP, PPP_HEADER_LEN); + bpfattach (c->ifp, DLT_PPP, PPP_HEADER_LEN); #endif } } @@ -319,7 +320,7 @@ struct isa_driver cxdriver = { cxprobe, cxattach, "cx" }; static int cxsioctl (struct ifnet *ifp, int cmd, caddr_t data) { - cx_chan_t *q, *c = cxchan[ifp->if_unit]; + cx_chan_t *q, *c = ifp->if_softc; int error, s, was_up, should_be_up; /* @@ -488,8 +489,8 @@ cxput (cx_chan_t *c, char b) } m_copydata (m, 0, len, buf); #if NBPFILTER > 0 - if (c->bpf) - bpf_mtap (c->bpf, m); + if (c->ifp->if_bpf) + bpf_mtap (c->ifp, m); #endif m_freem (m); @@ -555,7 +556,7 @@ cxsend (cx_chan_t *c) static void cxstart (struct ifnet *ifp) { - cx_chan_t *q, *c = cxchan[ifp->if_unit]; + cx_chan_t *q, *c = ifp->if_softc; if (c->ifp->if_flags & IFF_DEBUG) print (("cx%d.%d: cxstart\n", c->board->num, c->num)); @@ -579,7 +580,7 @@ cxstart (struct ifnet *ifp) static void cxwatchdog (struct ifnet *ifp) { - cx_chan_t *q, *c = cxchan[ifp->if_unit]; + cx_chan_t *q, *c = ifp->if_softc; if (! (ifp->if_flags & IFF_RUNNING)) return; @@ -816,8 +817,8 @@ cxinput (cx_chan_t *c, void *buf, unsigned len) * Check if there's a BPF listener on this interface. * If so, hand off the raw packet to bpf. */ - if (c->bpf) - bpf_tap (c->bpf, buf, len); + if (c->ifp->if_bpf) + bpf_tap (c->ifp, buf, len); #endif /* Count the received bytes to the subchannel, not the master. */ diff --git a/sys/i386/isa/if_ed.c b/sys/i386/isa/if_ed.c index 35f8740..a68341f 100644 --- a/sys/i386/isa/if_ed.c +++ b/sys/i386/isa/if_ed.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ed.c,v 1.92 1995/12/15 07:31:40 davidg Exp $ + * $Id: if_ed.c,v 1.93 1996/01/24 21:06:02 phk Exp $ */ /* @@ -113,7 +113,6 @@ struct ed_softc { int is790; /* set by the probe code if the card is 790 * based */ - caddr_t bpf; /* BPF "magic cookie" */ caddr_t mem_start; /* NIC memory start address */ caddr_t mem_end; /* NIC memory end address */ u_long mem_size; /* total NIC memory size */ @@ -1434,6 +1433,7 @@ ed_attach(isa_dev) /* * Initialize ifnet structure */ + ifp->if_softc = sc; ifp->if_unit = isa_dev->id_unit; ifp->if_name = "ed"; ifp->if_output = ether_output; @@ -1458,6 +1458,7 @@ ed_attach(isa_dev) * Attach the interface */ if_attach(ifp); + ether_ifattach(ifp); } /* device attach does transition from UNCONFIGURED to IDLE state */ sc->kdc.kdc_state = DC_IDLE; @@ -1482,7 +1483,7 @@ ed_attach(isa_dev) * If BPF is in the kernel, call the attach for it */ #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif return 1; } @@ -1494,7 +1495,7 @@ static void ed_reset(ifp) struct ifnet *ifp; { - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; int s; if (sc->gone) @@ -1542,7 +1543,7 @@ static void ed_watchdog(ifp) struct ifnet *ifp; { - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; if (sc->gone) return; @@ -1559,7 +1560,7 @@ static void ed_init(ifp) struct ifnet *ifp; { - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; int i, s; if (sc->gone) @@ -1769,7 +1770,7 @@ static void ed_start(ifp) struct ifnet *ifp; { - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; struct mbuf *m0, *m; caddr_t buffer; int len; @@ -1904,8 +1905,8 @@ outloop: * Tap off here if there is a bpf listener. */ #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, m0); + if (ifp->if_bpf) { + bpf_mtap(ifp, m0); } #endif @@ -1924,7 +1925,7 @@ static inline void ed_rint(sc) struct ed_softc *sc; { - struct ifnet *ifp = (struct ifnet *)sc; + struct ifnet *ifp = &sc->arpcom.ac_if; u_char boundry; u_short len; struct ed_ring packet_hdr; @@ -2264,7 +2265,7 @@ ed_ioctl(ifp, command, data) caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *) data; - struct ed_softc *sc = (struct ed_softc *)ifp; + struct ed_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; @@ -2524,8 +2525,8 @@ ed_get_packet(sc, buf, len, multicast) * Check if there's a BPF listener on this interface. If so, hand off * the raw packet to bpf. */ - if (sc->bpf) { - bpf_mtap(sc->bpf, m); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, m); /* * Note that the interface cannot be in promiscuous mode if diff --git a/sys/i386/isa/if_eg.c b/sys/i386/isa/if_eg.c index 0f03f54..9d2f3bf 100644 --- a/sys/i386/isa/if_eg.c +++ b/sys/i386/isa/if_eg.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_eg.c,v 1.10 1995/12/15 00:54:09 bde Exp $ + * $Id: if_eg.c,v 1.11 1996/01/26 09:27:17 phk Exp $ */ /* To do: @@ -423,6 +423,7 @@ egattach (struct isa_device *id) } /* Initialize ifnet structure. */ + ifp->if_softc = sc; ifp->if_unit = id->id_unit; ifp->if_name = "eg"; ifp->if_output = ether_output; @@ -432,13 +433,14 @@ egattach (struct isa_device *id) /* Now we can attach the interface. */ if_attach(ifp); + ether_ifattach(ifp); /* device attach does transition from UNCONFIGURED to IDLE state */ sc->kdc.kdc_state = DC_IDLE; #if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif return 1; @@ -519,7 +521,7 @@ static void egstart(ifp) struct ifnet *ifp; { - register struct eg_softc *sc = &eg_softc[ifp->if_unit]; + register struct eg_softc *sc = ifp->if_softc; struct mbuf *m0, *m; int len; short *ptr; @@ -552,7 +554,7 @@ egstart(ifp) } #if NBPFILTER > 0 if (sc->sc_arpcom.ac_if.if_bpf) - bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0); + bpf_mtap(&sc->sc_arpcom.ac_if, m0); #endif m_freem(m0); @@ -684,7 +686,7 @@ egread(sc, buf, len) * If so, hand off the raw packet to BPF. */ if (ifp->if_bpf) { - bpf_mtap(ifp->if_bpf, m); + bpf_mtap(ifp, m); /* * Note that the interface cannot be in promiscuous mode if @@ -716,7 +718,7 @@ egioctl(ifp, command, data) int command; caddr_t data; { - struct eg_softc *sc = &eg_softc[ifp->if_unit]; + struct eg_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; diff --git a/sys/i386/isa/if_el.c b/sys/i386/isa/if_el.c index c7b4aba..a72fc7c 100644 --- a/sys/i386/isa/if_el.c +++ b/sys/i386/isa/if_el.c @@ -6,7 +6,7 @@ * * Questions, comments, bug reports and fixes to kimmel@cs.umass.edu. * - * $Id: if_el.c,v 1.21 1995/12/15 00:54:10 bde Exp $ + * $Id: if_el.c,v 1.22 1996/01/26 09:27:19 phk Exp $ */ /* Except of course for the portions of code lifted from other FreeBSD * drivers (mainly elread, elget and el_ioctl) @@ -80,7 +80,6 @@ static struct el_softc { struct arpcom arpcom; /* Ethernet common */ u_short el_base; /* Base I/O addr */ - caddr_t bpf; /* BPF magic cookie */ char el_pktbuf[EL_BUFSIZ]; /* Frame buffer */ } el_softc[NEL]; @@ -208,6 +207,7 @@ el_attach(struct isa_device *idev) el_hardreset(idev->id_unit); /* Initialize ifnet structure */ + ifp->if_softc = sc; ifp->if_unit = idev->id_unit; ifp->if_name = "el"; ifp->if_mtu = ETHERMTU; @@ -220,6 +220,7 @@ el_attach(struct isa_device *idev) /* Now we can attach the interface */ dprintf(("Attaching interface...\n")); if_attach(ifp); + ether_ifattach(ifp); kdc_el[idev->id_unit].kdc_state = DC_BUSY; /* Put the station address in the ifa address list's AF_LINK @@ -244,7 +245,7 @@ el_attach(struct isa_device *idev) /* Finally, attach to bpf filter if it is present. */ #if NBPFILTER > 0 dprintf(("Attaching to BPF...\n")); - bpfattach(&sc->bpf,ifp,DLT_EN10MB,sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif dprintf(("el_attach() finished.\n")); @@ -357,7 +358,7 @@ el_start(struct ifnet *ifp) int s, i, len, retries, done; /* Get things pointing in the right directions */ - sc = &el_softc[ifp->if_unit]; + sc = ifp->if_softc; base = sc->el_base; dprintf(("el_start()...\n")); @@ -400,8 +401,8 @@ el_start(struct ifnet *ifp) /* Give the packet to the bpf, if any */ #if NBPFILTER > 0 - if(sc->bpf) - bpf_tap(sc->bpf,sc->el_pktbuf,len); + if(sc->arpcom.ac_if.if_bpf) + bpf_tap(&sc->arpcom.ac_if, sc->el_pktbuf, len); #endif /* Transfer datagram to board */ @@ -588,8 +589,9 @@ static inline void elread(struct el_softc *sc,caddr_t buf,int len) * Check if there's a bpf filter listening on this interface. * If so, hand off the raw packet to bpf. */ - if(sc->bpf) { - bpf_tap(sc->bpf,buf,len+sizeof(struct ether_header)); + if(sc->arpcom.ac_if.if_bpf) { + bpf_tap(&sc->arpcom.ac_if, buf, + len + sizeof(struct ether_header)); /* * Note that the interface cannot be in promiscuous mode if @@ -699,7 +701,7 @@ el_ioctl(ifp, command, data) caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *)data; - struct el_softc *sc = &el_softc[ifp->if_unit]; + struct el_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; @@ -825,7 +827,7 @@ el_ioctl(ifp, command, data) static void el_watchdog(struct ifnet *ifp) { - log(LOG_ERR,"el%d: device timeout\n",ifp->if_unit); + log(LOG_ERR,"el%d: device timeout\n", ifp->if_unit); ifp->if_oerrors++; el_reset(ifp->if_unit); } diff --git a/sys/i386/isa/if_ep.c b/sys/i386/isa/if_ep.c index c072171..66e305c 100644 --- a/sys/i386/isa/if_ep.c +++ b/sys/i386/isa/if_ep.c @@ -38,7 +38,7 @@ */ /* - * $Id: if_ep.c,v 1.38 1996/01/26 09:27:22 phk Exp $ + * $Id: if_ep.c,v 1.39 1996/01/29 03:16:12 gibbs Exp $ * * Promiscuous mode added and interrupt logic slightly changed * to reduce the number of adapter failures. Transceiver select @@ -449,6 +449,7 @@ epattach(is) GO_WINDOW(0); outw(BASE + EP_W0_RESOURCE_CFG, SET_IRQ(irq)); + ifp->if_softc = sc; ifp->if_unit = is->id_unit; ifp->if_name = "ep"; ifp->if_mtu = ETHERMTU; @@ -459,6 +460,7 @@ epattach(is) ifp->if_watchdog = epwatchdog; if_attach(ifp); + ether_ifattach(ifp); /* device attach does transition from UNCONFIGURED to IDLE state */ kdc_ep[is->id_unit].kdc_state=DC_IDLE; @@ -506,7 +508,7 @@ epattach(is) sc->top = sc->mcur = 0; #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif return 1; } @@ -680,7 +682,7 @@ static void epstart(ifp) struct ifnet *ifp; { - register struct ep_softc *sc = &ep_softc[ifp->if_unit]; + register struct ep_softc *sc = ifp->if_softc; register u_int len; register struct mbuf *m; struct mbuf *top; @@ -759,8 +761,8 @@ startagain: outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */ #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, top); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, top); } #endif @@ -1083,8 +1085,8 @@ all_pkt: top->m_pkthdr.len = sc->cur_len; #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, top); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, top); /* * Note that the interface cannot be in promiscuous mode if there are @@ -1153,7 +1155,7 @@ epioctl(ifp, cmd, data) caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *) data; - struct ep_softc *sc = &ep_softc[ifp->if_unit]; + struct ep_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/i386/isa/if_epreg.h b/sys/i386/isa/if_epreg.h index a9b3593..2dc6b59 100644 --- a/sys/i386/isa/if_epreg.h +++ b/sys/i386/isa/if_epreg.h @@ -31,7 +31,7 @@ */ /* - * $Id: if_epreg.h,v 1.9 1996/01/29 03:16:14 gibbs Exp $ + * $Id: if_epreg.h,v 1.10 1996/01/30 22:55:43 mpp Exp $ * * Promiscuous mode added and interrupt logic slightly changed * to reduce the number of adapter failures. Transceiver select @@ -61,7 +61,6 @@ struct ep_softc { short rx_latency; short rx_avg_pkt; short cur_len; - caddr_t bpf; /* BPF "magic cookie" */ u_short ep_connectors; /* Connectors on this card. */ int stat; /* some flags */ #define F_RX_FIRST 0x1 diff --git a/sys/i386/isa/if_fe.c b/sys/i386/isa/if_fe.c index 5e141c5..e07970a 100644 --- a/sys/i386/isa/if_fe.c +++ b/sys/i386/isa/if_fe.c @@ -214,9 +214,6 @@ static struct fe_softc { void ( * init )( struct fe_softc * ); /* Just before fe_init(). */ void ( * stop )( struct fe_softc * ); /* Just after fe_stop(). */ - /* For BPF. */ - caddr_t bpf; /* BPF "magic cookie" */ - /* Transmission buffer management. */ u_short txb_free; /* free bytes in TX buffer */ u_char txb_count; /* number of packets in TX buffer */ @@ -236,15 +233,7 @@ static struct fe_softc { #define sc_dcstate kdc.kdc_state #define sc_description kdc.kdc_description -/* - * Some entry functions receive a "struct ifnet *" typed pointer as an - * argument. It points to arpcom.ac_if of our softc. Remember arpcom.ac_if - * is located at very first of the fe_softc struct. So, there is no - * difference between "struct fe_softc *" and "struct ifnet *" at the machine - * language level. We just cast to turn a "struct ifnet *" value into "struct - * fe_softc * value". If this were C++, we would need no such cast at all. - */ -#define IFNET2SOFTC(P) ( ( struct fe_softc * )(P) ) +#define IFNET2SOFTC(P) (P)->if_softc /* Standard driver entry points. These can be static. */ static int fe_probe ( struct isa_device * ); @@ -271,7 +260,6 @@ static struct fe_filter static int fe_hash ( u_char * ); static void fe_setmode ( struct fe_softc * ); static void fe_loadmar ( struct fe_softc * ); -static void fe_setlinkaddr ( struct fe_softc * ); #if FE_DEBUG >= 1 static void fe_dump ( int, struct fe_softc *, char * ); #endif @@ -1061,6 +1049,7 @@ fe_attach ( struct isa_device *isa_dev ) /* * Initialize ifnet structure */ + sc->sc_if.if_softc = sc; sc->sc_if.if_unit = sc->sc_unit; sc->sc_if.if_name = "fe"; sc->sc_if.if_output = ether_output; @@ -1122,7 +1111,7 @@ fe_attach ( struct isa_device *isa_dev ) /* Attach and stop the interface. */ if_attach( &sc->sc_if ); fe_stop( sc->sc_unit ); /* This changes the state to IDLE. */ - fe_setlinkaddr( sc ); + ether_ifattach(&sc->sc_if); /* Print additional info when attached. */ printf( "fe%d: address %6D, type %s\n", sc->sc_unit, @@ -1162,8 +1151,7 @@ fe_attach ( struct isa_device *isa_dev ) #if NBPFILTER > 0 /* If BPF is in the kernel, call the attach for it. */ - bpfattach(&sc->bpf, &sc->sc_if, DLT_EN10MB, - sizeof(struct ether_header)); + bpfattach(&sc->sc_if, DLT_EN10MB, sizeof(struct ether_header)); #endif return 1; } @@ -2100,6 +2088,7 @@ fe_ioctl ( struct ifnet *ifp, int command, caddr_t data ) } #endif +#ifdef notdef #ifdef SIOCSIFPHYSADDR case SIOCSIFPHYSADDR: { @@ -2115,6 +2104,7 @@ fe_ioctl ( struct ifnet *ifp, int command, caddr_t data ) break; } #endif +#endif /* notdef */ #ifdef SIOCSIFFLAGS case SIOCSIFFLAGS: @@ -2278,8 +2268,8 @@ fe_get_packet ( struct fe_softc * sc, u_short len ) * Check if there's a BPF listener on this interface. * If it is, hand off the raw packet to bpf. */ - if ( sc->bpf ) { - bpf_mtap( sc->bpf, m ); + if ( sc->sc_if.if_bpf ) { + bpf_mtap( &sc->sc_if, m ); } #endif @@ -2680,47 +2670,6 @@ fe_loadmar ( struct fe_softc * sc ) #endif } -/* - * Copy the physical (Ethernet) address into the "data link" address - * entry of the address list for an interface. - * This is (said to be) useful for netstat(1) to keep track of which - * interface is which. - * - * What I'm not sure on this function is, why this is a driver's function. - * Probably this should be moved to somewhere independent to a specific - * hardware, such as if_ehtersubr.c. FIXME. - */ -static void -fe_setlinkaddr ( struct fe_softc * sc ) -{ - struct ifaddr *ifa; - struct sockaddr_dl * sdl; - - /* - * Search down the ifa address list looking for the AF_LINK type entry. - */ - for ( ifa = sc->sc_if.if_addrlist; ifa != NULL; ifa = ifa->ifa_next ) { - if ( ifa->ifa_addr != NULL - && ifa->ifa_addr->sa_family == AF_LINK ) { - - /* - * We have found an AF_LINK type entry. - * Fill in the link-level address for this interface - */ - sdl = (struct sockaddr_dl *) ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(sc->sc_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); -#if FE_DEBUG >= 3 - log( LOG_INFO, "fe%d: link address set\n", - sc->sc_unit ); -#endif - return; - } - } -} - #if FE_DEBUG >= 1 static void fe_dump ( int level, struct fe_softc * sc, char * message ) diff --git a/sys/i386/isa/if_ie.c b/sys/i386/isa/if_ie.c index 4094ef2..903b1e2 100644 --- a/sys/i386/isa/if_ie.c +++ b/sys/i386/isa/if_ie.c @@ -43,7 +43,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ie.c,v 1.31 1995/12/10 13:38:45 phk Exp $ + * $Id: if_ie.c,v 1.32 1996/01/26 09:27:26 phk Exp $ */ /* @@ -303,11 +303,6 @@ static struct ie_softc { struct ie_en_addr mcast_addrs[MAXMCAST + 1]; int mcast_count; - -#if NBPFILTER > 0 - caddr_t ie_bpf; -#endif - } ie_softc[NIE]; #define MK_24(base, ptr) ((caddr_t)((u_long)ptr - (u_long)base)) @@ -579,12 +574,13 @@ ieattach(dvp) struct ie_softc *ie = &ie_softc[unit]; struct ifnet *ifp = &ie->arpcom.ac_if; + ifp->if_softc = ie; ifp->if_unit = unit; ifp->if_name = iedriver.name; ifp->if_mtu = ETHERMTU; printf(" <%s R%d> ethernet address %6D\n", - ie_hardware_names[ie_softc[unit].hard_type], - ie_softc[unit].hard_vers + 1, + ie_hardware_names[ie->hard_type], + ie->hard_vers + 1, ie->arpcom.ac_enaddr, ":"); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; @@ -596,29 +592,13 @@ ieattach(dvp) ifp->if_hdrlen = 14; #if NBPFILTER > 0 - bpfattach(&ie_softc[unit].ie_bpf, ifp, DLT_EN10MB, - sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif if_attach(ifp); + ether_ifattach(ifp); kdc_ie[unit].kdc_description = ie_hardware_names[ie_softc[unit].hard_type]; - - { - struct ifaddr *ifa = ifp->if_addrlist; - struct sockaddr_dl *sdl; - while(ifa && ifa->ifa_addr && ifa->ifa_addr->sa_family != AF_LINK) - ifa = ifa->ifa_next; - - if(!ifa || !ifa->ifa_addr) return 1; - - /* Provide our ether address to the higher layers */ - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = 6; - sdl->sdl_slen = 0; - bcopy(ie->arpcom.ac_enaddr, LLADDR(sdl), 6); - return 1; - } + return 1; } /* @@ -857,7 +837,7 @@ static inline int check_eh(struct ie_softc *ie, * Receiving all multicasts, but no unicasts except those destined for us. */ #if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); /* BPF gets this packet if anybody cares */ + *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); /* BPF gets this packet if anybody cares */ #endif if(eh->ether_dhost[0] & 1) { return 1; @@ -870,7 +850,7 @@ static inline int check_eh(struct ie_softc *ie, * Receiving all packets. These need to be passed on to BPF. */ #if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); + *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); #endif /* If for us, accept and hand up to BPF */ if(ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) return 1; @@ -904,7 +884,7 @@ static inline int check_eh(struct ie_softc *ie, * Whew! (Hope this is a fast machine...) */ #if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); + *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); #endif /* We want to see multicasts. */ if(eh->ether_dhost[0] & 1) return 1; @@ -928,7 +908,7 @@ static inline int check_eh(struct ie_softc *ie, * as quickly as possible. */ #if NBPFILTER > 0 - *to_bpf = (ie->ie_bpf != 0); + *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); #endif return 1; } @@ -1221,7 +1201,7 @@ static void ie_readframe(unit, ie, num) m0.m_next = m; /* Pass it up */ - bpf_mtap(ie->ie_bpf, &m0); + bpf_mtap(&ie->arpcom.ac_if, &m0); } /* * A signal passed up from the filtering code indicating that the @@ -1283,7 +1263,7 @@ static void iestart(ifp) struct ifnet *ifp; { - struct ie_softc *ie = &ie_softc[ifp->if_unit]; + struct ie_softc *ie = ifp->if_softc; struct mbuf *m0, *m; unsigned char *buffer; u_short len; @@ -1317,8 +1297,8 @@ iestart(ifp) * See if bpf is listening on this interface, let it see the packet * before we commit it to the wire. */ - if(ie->ie_bpf) - bpf_tap(ie->ie_bpf, ie->xmit_cbuffs[ie->xmit_count], len); + if(ie->arpcom.ac_if.if_bpf) + bpf_tap(&ie->arpcom.ac_if, ie->xmit_cbuffs[ie->xmit_count], len); #endif ie->xmit_buffs[ie->xmit_count]->ie_xmit_flags = IE_XMIT_LAST | len; @@ -1883,7 +1863,7 @@ ieioctl(ifp, command, data) caddr_t data; { struct ifaddr *ifa = (struct ifaddr *)data; - struct ie_softc *ie = &ie_softc[ifp->if_unit]; + struct ie_softc *ie = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/i386/isa/if_ix.c b/sys/i386/isa/if_ix.c index b883491..9f081cc 100644 --- a/sys/i386/isa/if_ix.c +++ b/sys/i386/isa/if_ix.c @@ -28,7 +28,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_ix.c,v 1.17 1995/12/15 00:54:17 bde Exp $ + * $Id: if_ix.c,v 1.18 1996/01/26 09:27:27 phk Exp $ */ #include "ix.h" @@ -588,6 +588,7 @@ ixattach(struct isa_device *dvp) { * allocation, this will have to get revisited. */ bzero(ifp, sizeof(ifp)); + ifp->if_softc = sc; ifp->if_name = ixdriver.name; ifp->if_unit = unit; ifp->if_mtu = ETHERMTU; @@ -607,24 +608,9 @@ ixattach(struct isa_device *dvp) { #endif /* IXCOUNTERS */ if_attach(ifp); + ether_ifattach(ifp); sc->kdc.kdc_state = DC_IDLE; - /* Search down the ifa address list looking for the AF_LINK type entry */ - ifa = ifp->if_addrlist; - while ((ifa != 0) && - (ifa->ifa_addr != 0) && - (ifa->ifa_addr->sa_family != AF_LINK)) { - ifa = ifa->ifa_next; - } - /* If we find an AF_LINK type entry, we well fill in the hardware addr */ - if ((ifa != 0) && (ifa->ifa_addr != 0)) { - /* Fill in the link level address for this interface */ - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDRESS_LENGTH; - sdl->sdl_slen = 0; - bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDRESS_LENGTH); - } printf("ix%d: address %6D\n", unit, sc->arpcom.ac_enaddr, ":"); return(0); } @@ -1326,7 +1312,7 @@ ixintr_fr_free(int unit, rfd_t *rfd) { void ixstart(struct ifnet *ifp) { int unit = ifp->if_unit; - ix_softc_t *sc = &ix_softc[unit]; + ix_softc_t *sc = ifp->if_softc; scb_t *scb = (scb_t *)BOARDTOKV(SCB_ADDR); cb_t *cb = sc->cb_head; tbd_t *tbd; @@ -1456,7 +1442,7 @@ ixstart_exit: int ixstop(struct ifnet *ifp) { int unit = ifp->if_unit; - ix_softc_t *sc = &ix_softc[unit]; + ix_softc_t *sc = ifp->if_softc; DEBUGBEGIN(DEBUGSTOP) DEBUGDO(printf("ixstop:");) diff --git a/sys/i386/isa/if_le.c b/sys/i386/isa/if_le.c index 73dff3b..0bb4eba 100644 --- a/sys/i386/isa/if_le.c +++ b/sys/i386/isa/if_le.c @@ -21,7 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_le.c,v 1.28 1996/01/25 23:00:42 joerg Exp $ + * $Id: if_le.c,v 1.29 1996/01/26 09:27:29 phk Exp $ */ /* @@ -233,9 +233,6 @@ struct le_softc { u_int le_mcmask; /* bit mask for CRC-32 for multicast hash */ le_mcbits_t *le_mctbl; /* pointer to multicast table */ const char *le_prodname; /* product name DE20x-xx */ -#if NBPFILTER > 0 - caddr_t le_bpf; /* BPF context */ -#endif u_char le_hwaddr[6]; /* local copy of hwaddr */ unsigned le_scast_drops; /* singlecast drops */ unsigned le_mcast_drops; /* multicast drops */ @@ -395,6 +392,7 @@ le_attach( struct ifnet *ifp = &sc->le_if; struct ifaddr *ifa = ifp->if_addrlist; + ifp->if_softc = sc; ifp->if_mtu = ETHERMTU; printf("%s%d: %s ethernet address %6D\n", ifp->if_name, ifp->if_unit, @@ -409,26 +407,13 @@ le_attach( ifp->if_hdrlen = 14; #if NBPFILTER > 0 - bpfattach(&sc->le_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif if_attach(ifp); + ether_ifattach(ifp); kdc_le[dvp->id_unit].kdc_state = DC_IDLE; - while (ifa && ifa->ifa_addr && ifa->ifa_addr->sa_family != AF_LINK) - ifa = ifa->ifa_next; - - if (ifa != NULL && ifa->ifa_addr != NULL) { - struct sockaddr_dl *sdl; - /* - * Provide our ether address to the higher layers - */ - sdl = (struct sockaddr_dl *) ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = 6; - sdl->sdl_slen = 0; - MEMCPY(LLADDR(sdl), sc->le_ac.ac_enaddr, 6); - } return 1; } @@ -465,8 +450,8 @@ le_input( MEMCPY(&eh, seg1, sizeof(eh)); #if NBPFILTER > 0 - if (sc->le_bpf != NULL && seg2 == NULL) { - bpf_tap(sc->le_bpf, seg1, total_len); + if (sc->le_if.if_bpf != NULL && seg2 == NULL) { + bpf_tap(&sc->le_if, seg1, total_len); /* * If this is single cast but not to us * drop it! @@ -522,8 +507,8 @@ le_input( if (seg2 != NULL) MEMCPY(mtod(m, caddr_t) + len1, seg2, total_len - len1); #if NBPFILTER > 0 - if (sc->le_bpf != NULL && seg2 != NULL) { - bpf_mtap(sc->le_bpf, m); + if (sc->le_if.if_bpf != NULL && seg2 != NULL) { + bpf_mtap(&sc->le_if, m); /* * If this is single cast but not to us * drop it! @@ -556,7 +541,7 @@ le_ioctl( int cmd, caddr_t data) { - le_softc_t *sc = &le_softc[ifp->if_unit]; + le_softc_t *sc = ifp->if_softc; int s, error = 0; if ((sc->le_flags & IFF_UP) == 0) @@ -1216,8 +1201,8 @@ lemac_start( LE_OUTB(sc, LEMAC_REG_TQ, tx_pg); /* tell chip to transmit this packet */ #if NBPFILTER > 0 - if (sc->le_bpf) - bpf_mtap(sc->le_bpf, m); + if (sc->le_if.if_bpf) + bpf_mtap(&sc->le_if, m); #endif m_freem(m); /* free the mbuf */ diff --git a/sys/i386/isa/if_lnc.c b/sys/i386/isa/if_lnc.c index 2f8198c..3e060a4 100644 --- a/sys/i386/isa/if_lnc.c +++ b/sys/i386/isa/if_lnc.c @@ -123,9 +123,6 @@ static struct lnc_softc { #ifdef DEBUG int lnc_debug; #endif -#if NBPFILTER > 0 - caddr_t bpf; /* XXX bpf magic cookie - move to arpcom */ -#endif LNCSTATS_STRUCT } lnc_softc[NLNC]; @@ -631,8 +628,8 @@ lnc_rint(int unit) eh = (struct ether_header *) head->m_data; #if NBPFILTER > 0 - if (sc->bpf) - bpf_mtap(sc->bpf, head); + if (sc->arpcom.ac_if.if_bpf) + bpf_mtap(&sc->arpcom.ac_if, head); /* Check this packet is really for us */ @@ -1162,6 +1159,7 @@ lnc_attach(struct isa_device * isa_dev) /* Fill in arpcom structure entries */ + sc->arpcom.ac_if.if_softc = sc; sc->arpcom.ac_if.if_name = lncdriver.name; sc->arpcom.ac_if.if_unit = isa_dev->id_unit; sc->arpcom.ac_if.if_mtu = ETHERMTU; @@ -1180,6 +1178,7 @@ lnc_attach(struct isa_device * isa_dev) */ if_attach(&sc->arpcom.ac_if); + ether_ifattach(&sc->arpcom.ac_if); sc->kdc.kdc_state = DC_IDLE; printf("lnc%d: %s, address %6D\n", @@ -1188,7 +1187,7 @@ lnc_attach(struct isa_device * isa_dev) sc->arpcom.ac_enaddr, ":"); #if NBPFILTER > 0 - bpfattach(&sc->bpf, &sc->arpcom.ac_if, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(&sc->arpcom.ac_if, DLT_EN10MB, sizeof(struct ether_header)); #endif return (1); @@ -1500,7 +1499,7 @@ static void lnc_start(struct ifnet *ifp) { - struct lnc_softc *sc = &lnc_softc[ifp->if_unit]; + struct lnc_softc *sc = ifp->if_softc; struct host_ring_entry *desc; int tmp; int end_of_packet; @@ -1636,8 +1635,8 @@ lnc_start(struct ifnet *ifp) ifp->if_timer = 2; #if NBPFILTER > 0 - if (sc->bpf) - bpf_mtap(sc->bpf, head); + if (sc->arpcom.ac_if.if_bpf) + bpf_mtap(&sc->arpcom.ac_if, head); #endif if (sc->nic.mem_mode != DMA_MBUF) @@ -1658,7 +1657,7 @@ static int lnc_ioctl(struct ifnet * ifp, int command, caddr_t data) { - struct lnc_softc *sc = &lnc_softc[ifp->if_unit]; + struct lnc_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *) data; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/i386/isa/if_ze.c b/sys/i386/isa/if_ze.c index 797cdaa..53330a0 100644 --- a/sys/i386/isa/if_ze.c +++ b/sys/i386/isa/if_ze.c @@ -47,7 +47,7 @@ */ /* - * $Id: if_ze.c,v 1.27 1995/12/17 21:22:57 phk Exp $ + * $Id: if_ze.c,v 1.28 1996/01/26 09:27:33 phk Exp $ */ #include "ze.h" @@ -127,8 +127,6 @@ static struct ze_softc { u_long smem_size; /* total shared memory size */ caddr_t smem_ring; /* start of RX ring-buffer (in smem) */ - caddr_t bpf; /* BPF "magic cookie" */ - u_char memwidth; /* width of access to card mem 8 or 16 */ u_char xmit_busy; /* transmitter is busy */ u_char txb_cnt; /* Number of transmit buffers */ @@ -619,6 +617,7 @@ ze_attach(isa_dev) /* * Initialize ifnet structure */ + ifp->if_softc = sc; ifp->if_unit = isa_dev->id_unit; ifp->if_name = "ze" ; ifp->if_mtu = ETHERMTU; @@ -633,29 +632,7 @@ ze_attach(isa_dev) * Attach the interface */ if_attach(ifp); - - /* - * Search down the ifa address list looking for the AF_LINK type entry - */ - ifa = ifp->if_addrlist; - while ((ifa != 0) && (ifa->ifa_addr != 0) && - (ifa->ifa_addr->sa_family != AF_LINK)) - ifa = ifa->ifa_next; - /* - * If we find an AF_LINK type entry we fill in the hardware address. - * This is useful for netstat(1) to keep track of which interface - * is which. - */ - if ((ifa != 0) && (ifa->ifa_addr != 0)) { - /* - * Fill in the link-level address for this interface - */ - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); - } + ether_ifattach(ifp); /* * Print additional info when attached @@ -670,7 +647,7 @@ ze_attach(isa_dev) * If BPF is in the kernel, call the attach for it */ #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif #if NAPM > 0 @@ -929,7 +906,7 @@ static inline void ze_xmit(ifp) struct ifnet *ifp; { - struct ze_softc *sc = &ze_softc[ifp->if_unit]; + struct ze_softc *sc = ifp->if_softc; u_short len = sc->txb_next_len; /* @@ -984,7 +961,7 @@ static void ze_start(ifp) struct ifnet *ifp; { - struct ze_softc *sc = &ze_softc[ifp->if_unit]; + struct ze_softc *sc = ifp->if_softc; struct mbuf *m0, *m; caddr_t buffer; int len; @@ -1055,8 +1032,8 @@ outloop: * If there is BPF support in the configuration, tap off here. */ #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, m0); + if (ifp->if_bpf) { + bpf_mtap(ifp, m0); } #endif @@ -1344,7 +1321,7 @@ ze_ioctl(ifp, command, data) caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *)data; - struct ze_softc *sc = &ze_softc[ifp->if_unit]; + struct ze_softc *sc = ifp->if_softc; int s, error = 0; s = splnet(); @@ -1535,8 +1512,8 @@ ze_get_packet(sc, buf, len) * Check if there's a BPF listener on this interface. * If so, hand off the raw packet to bpf. */ - if (sc->bpf) { - bpf_mtap(sc->bpf, head); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, head); /* * Note that the interface cannot be in promiscuous mode if diff --git a/sys/i386/isa/if_zp.c b/sys/i386/isa/if_zp.c index 36e03f1..2e09ee6 100644 --- a/sys/i386/isa/if_zp.c +++ b/sys/i386/isa/if_zp.c @@ -34,7 +34,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * From: if_ep.c,v 1.9 1994/01/25 10:46:29 deraadt Exp $ - * $Id: if_zp.c,v 1.14 1995/12/13 10:35:36 phk Exp $ + * $Id: if_zp.c,v 1.15 1996/01/26 09:27:34 phk Exp $ */ /*- * TODO: @@ -174,7 +174,6 @@ static struct zp_softc { struct mbuf *mb[MAX_MBS]; /* spare mbuf storage. */ int next_mb; /* Which mbuf to use next. */ int last_mb; /* Last mbuf. */ - caddr_t bpf; /* BPF "magic cookie" */ short ep_io_addr; /* i/o bus address */ char ep_connectors; /* Connectors on this card. */ int tx_start_thresh;/* Current TX_start_thresh. */ @@ -542,6 +541,7 @@ zpattach(isa_dev) printf(" address %6D\n", sc->arpcom.ac_enaddr, ":"); + ifp->if_softc = sc; ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; ifp->if_unit = isa_dev->id_unit; @@ -554,24 +554,10 @@ zpattach(isa_dev) ifp->if_flags |= IFF_LINK0; if_attach(ifp); + ether_ifattach(ifp); - /* Fill the hardware address into ifa_addr if we find an AF_LINK - * entry. We need to do this so bpf's can get the hardware addr of - * this card. netstat likes this too! */ - ifa = ifp->if_addrlist; - while ((ifa != 0) && (ifa->ifa_addr != 0) && - (ifa->ifa_addr->sa_family != AF_LINK)) - ifa = ifa->ifa_next; - - if ((ifa != 0) && (ifa->ifa_addr != 0)) { - sdl = (struct sockaddr_dl *) ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); - } #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif #if NAPM > 0 sc->s_hook.ah_fun = zp_suspend; @@ -687,7 +673,7 @@ static void zpstart(ifp) struct ifnet *ifp; { - register struct zp_softc *sc = &zp_softc[ifp->if_unit]; + register struct zp_softc *sc = ifp->if_softc; struct mbuf *m, *top; int s, len, pad; @@ -760,8 +746,8 @@ startagain: outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */ #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, top); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, top); } #endif @@ -973,8 +959,8 @@ zpread(sc) while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); ++sc->arpcom.ac_if.if_ipackets; #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, top); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, top); /* Note that the interface cannot be in promiscuous mode if * there are no BPF listeners. And if we are in promiscuous @@ -1012,7 +998,7 @@ zpioctl(ifp, cmd, data) caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *) data; - struct zp_softc *sc = &zp_softc[ifp->if_unit]; + struct zp_softc *sc = ifp->if_softc; int error = 0; diff --git a/sys/i386/isa/lpt.c b/sys/i386/isa/lpt.c index a3b1287..7b37dfa 100644 --- a/sys/i386/isa/lpt.c +++ b/sys/i386/isa/lpt.c @@ -46,7 +46,7 @@ * SUCH DAMAGE. * * from: unknown origin, 386BSD 0.1 - * $Id: lpt.c,v 1.47 1995/12/08 23:20:32 phk Exp $ + * $Id: lpt.c,v 1.48 1995/12/10 13:38:56 phk Exp $ */ /* @@ -873,6 +873,7 @@ lpattach (struct lpt_softc *sc, int unit) { struct ifnet *ifp = &sc->sc_if; + ifp->if_softc = sc; ifp->if_name = "lp"; ifp->if_unit = unit; ifp->if_mtu = LPMTU; @@ -887,7 +888,7 @@ lpattach (struct lpt_softc *sc, int unit) printf("lp%d: TCP/IP capable interface\n", unit); #if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_NULL, LPIPHDRLEN); + bpfattach(ifp, DLT_NULL, LPIPHDRLEN); #endif } /* @@ -1154,7 +1155,7 @@ lpintr (int unit) } #if NBPFILTER > 0 if (sc->sc_if.if_bpf) { - bpf_tap(sc->sc_if.if_bpf, sc->sc_ifbuf, len); + bpf_tap(&sc->sc_if, sc->sc_ifbuf, len); } #endif len -= LPIPHDRLEN; @@ -1356,7 +1357,7 @@ lpoutput (struct ifnet *ifp, struct mbuf *m, m0.m_len = 2; m0.m_data = (char *)&hdr; - bpf_mtap(ifp->if_bpf, &m0); + bpf_mtap(ifp, &m0); } #endif } diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 9db72e7..c22952b 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -37,7 +37,7 @@ * * @(#)bpf.c 8.2 (Berkeley) 3/28/94 * - * $Id: bpf.c,v 1.20 1995/12/08 23:21:46 phk Exp $ + * $Id: bpf.c,v 1.21 1995/12/14 09:53:10 phk Exp $ */ #include "bpfilter.h" @@ -264,7 +264,7 @@ bpf_attachd(d, bp) d->bd_next = bp->bif_dlist; bp->bif_dlist = d; - *bp->bif_driverp = bp; + bp->bif_ifp->if_bpf = bp; } /* @@ -304,7 +304,7 @@ bpf_detachd(d) /* * Let the driver know that there are no more listeners. */ - *d->bd_bif->bif_driverp = 0; + d->bd_bif->bif_ifp->if_bpf = 0; d->bd_bif = 0; } @@ -919,35 +919,20 @@ bpf_setif(d, ifr) struct ifreq *ifr; { struct bpf_if *bp; - char *cp; - int unit, s, error; + int s, error; + struct ifnet *theywant; + + theywant = ifunit(ifr->ifr_name); + if (theywant == 0) + return ENXIO; - /* - * Separate string into name part and unit number. Put a null - * byte at the end of the name part, and compute the number. - * If the a unit number is unspecified, the default is 0, - * as initialized above. XXX This should be common code. - */ - unit = 0; - cp = ifr->ifr_name; - cp[sizeof(ifr->ifr_name) - 1] = '\0'; - while (*cp++) { - if (*cp >= '0' && *cp <= '9') { - unit = *cp - '0'; - *cp++ = '\0'; - while (*cp) - unit = 10 * unit + *cp++ - '0'; - break; - } - } /* * Look through attached interfaces for the named one. */ for (bp = bpf_iflist; bp != 0; bp = bp->bif_next) { struct ifnet *ifp = bp->bif_ifp; - if (ifp == 0 || unit != ifp->if_unit - || strcmp(ifp->if_name, ifr->ifr_name) != 0) + if (ifp == 0 || ifp != theywant) continue; /* * We found the requested interface. @@ -1073,8 +1058,8 @@ bpf_select(dev, rw, p) * buffer. */ void -bpf_tap(arg, pkt, pktlen) - caddr_t arg; +bpf_tap(ifp, pkt, pktlen) + struct ifnet *ifp; register u_char *pkt; register u_int pktlen; { @@ -1086,7 +1071,7 @@ bpf_tap(arg, pkt, pktlen) * The only problem that could arise here is that if two different * interfaces shared any data. This is not the case. */ - bp = (struct bpf_if *)arg; + bp = ifp->if_bpf; for (d = bp->bif_dlist; d != 0; d = d->bd_next) { ++d->bd_rcount; slen = bpf_filter(d->bd_filter, pkt, pktlen, pktlen); @@ -1126,11 +1111,11 @@ bpf_mcopy(src_arg, dst_arg, len) * Incoming linkage from device drivers, when packet is in an mbuf chain. */ void -bpf_mtap(arg, m) - caddr_t arg; +bpf_mtap(ifp, m) + struct ifnet *ifp; struct mbuf *m; { - struct bpf_if *bp = (struct bpf_if *)arg; + struct bpf_if *bp = ifp->if_bpf; struct bpf_d *d; u_int pktlen, slen; struct mbuf *m0; @@ -1277,33 +1262,24 @@ bpf_freed(d) * size of the link header (variable length headers not yet supported). */ void -bpfattach(driverp, ifp, dlt, hdrlen) - caddr_t *driverp; +bpfattach(ifp, dlt, hdrlen) struct ifnet *ifp; u_int dlt, hdrlen; { struct bpf_if *bp; int i; -#if BSD < 199103 - static struct bpf_if bpf_ifs[NBPFILTER]; - static int bpfifno; - - bp = (bpfifno < NBPFILTER) ? &bpf_ifs[bpfifno++] : 0; -#else bp = (struct bpf_if *)malloc(sizeof(*bp), M_DEVBUF, M_DONTWAIT); -#endif if (bp == 0) panic("bpfattach"); bp->bif_dlist = 0; - bp->bif_driverp = (struct bpf_if **)driverp; bp->bif_ifp = ifp; bp->bif_dlt = dlt; bp->bif_next = bpf_iflist; bpf_iflist = bp; - *bp->bif_driverp = 0; + bp->bif_ifp->if_bpf = 0; /* * Compute the length of the bpf header. This is not necessarily diff --git a/sys/net/bpf.h b/sys/net/bpf.h index 626e7c6..ecc49b8 100644 --- a/sys/net/bpf.h +++ b/sys/net/bpf.h @@ -37,7 +37,7 @@ * * @(#)bpf.h 8.1 (Berkeley) 6/10/93 * - * $Id: bpf.h,v 1.7 1995/11/04 13:25:03 bde Exp $ + * $Id: bpf.h,v 1.8 1996/01/30 22:57:38 mpp Exp $ */ #ifndef _NET_BPF_H_ @@ -89,30 +89,6 @@ struct bpf_version { #define BPF_MAJOR_VERSION 1 #define BPF_MINOR_VERSION 1 -/* - * BPF ioctls - * - * The first set is for compatibility with Sun's pcc style - * header files. If your using gcc, we assume that you - * have run fixincludes so the latter set should work. - */ -#if (defined(sun) || defined(ibm032)) && !defined(__GNUC__) -#define BIOCGBLEN _IOR(B,102, u_int) -#define BIOCSBLEN _IOWR(B,102, u_int) -#define BIOCSETF _IOW(B,103, struct bpf_program) -#define BIOCFLUSH _IO(B,104) -#define BIOCPROMISC _IO(B,105) -#define BIOCGDLT _IOR(B,106, u_int) -#define BIOCGETIF _IOR(B,107, struct ifreq) -#define BIOCSETIF _IOW(B,108, struct ifreq) -#define BIOCSRTIMEOUT _IOW(B,109, struct timeval) -#define BIOCGRTIMEOUT _IOR(B,110, struct timeval) -#define BIOCGSTATS _IOR(B,111, struct bpf_stat) -#define BIOCIMMEDIATE _IOW(B,112, u_int) -#define BIOCVERSION _IOR(B,113, struct bpf_version) -#define BIOCGRSIG _IOR(B,114, u_int) -#define BIOCSRSIG _IOW(B,115, u_int) -#else #define BIOCGBLEN _IOR('B',102, u_int) #define BIOCSBLEN _IOWR('B',102, u_int) #define BIOCSETF _IOW('B',103, struct bpf_program) @@ -128,7 +104,6 @@ struct bpf_version { #define BIOCVERSION _IOR('B',113, struct bpf_version) #define BIOCGRSIG _IOR('B',114, u_int) #define BIOCSRSIG _IOW('B',115, u_int) -#endif /* * Structure prepended to each packet. @@ -239,9 +214,9 @@ struct bpf_insn { #ifdef KERNEL int bpf_validate __P((struct bpf_insn *, int)); -void bpf_tap __P((caddr_t, u_char *, u_int)); -void bpf_mtap __P((caddr_t, struct mbuf *)); -void bpfattach __P((caddr_t *, struct ifnet *, u_int, u_int)); +void bpf_tap __P((struct ifnet *, u_char *, u_int)); +void bpf_mtap __P((struct ifnet *, struct mbuf *)); +void bpfattach __P((struct ifnet *, u_int, u_int)); void bpfilterattach __P((int)); u_int bpf_filter __P((struct bpf_insn *, u_char *, u_int, u_int)); #endif diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h index dff9aca..8539114 100644 --- a/sys/net/bpfdesc.h +++ b/sys/net/bpfdesc.h @@ -37,7 +37,7 @@ * * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93 * - * $Id: bpfdesc.h,v 1.6 1995/12/14 09:53:11 phk Exp $ + * $Id: bpfdesc.h,v 1.7 1996/01/30 22:57:40 mpp Exp $ */ #ifndef _NET_BPFDESC_H_ @@ -95,7 +95,6 @@ struct bpf_d { struct bpf_if { struct bpf_if *bif_next; /* list of all interfaces */ struct bpf_d *bif_dlist; /* descriptor list */ - struct bpf_if **bif_driverp; /* pointer into softc */ u_int bif_dlt; /* link layer type */ u_int bif_hdrlen; /* length of header (with padding) */ struct ifnet *bif_ifp; /* corresponding interface */ diff --git a/sys/net/if.c b/sys/net/if.c index 62dc2fb..1894484 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if.c 8.3 (Berkeley) 1/4/94 - * $Id: if.c,v 1.25 1995/12/20 21:53:38 wollman Exp $ + * $Id: if.c,v 1.26 1996/01/24 21:08:54 phk Exp $ */ #include <sys/param.h> @@ -51,7 +51,6 @@ #include <net/if_dl.h> #include <net/if_types.h> #include <net/radix.h> -#include <ether.h> /* * System initialization @@ -161,11 +160,6 @@ if_attach(ifp) while (namelen != 0) sdl->sdl_data[--namelen] = 0xff; } - /* XXX -- Temporary fix before changing 10 ethernet drivers */ -#if NETHER > 0 - if (ifp->if_output == ether_output) - ether_ifattach(ifp); -#endif } /* * Locate an interface based on a complete address. diff --git a/sys/net/if.h b/sys/net/if.h index 3146396..16a731c 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if.h 8.1 (Berkeley) 6/10/93 - * $Id: if.h,v 1.26 1996/01/26 09:29:17 phk Exp $ + * $Id: if.h,v 1.27 1996/01/26 22:09:54 wollman Exp $ */ #ifndef _NET_IF_H_ @@ -127,7 +127,7 @@ struct ifnet { struct ifnet *if_next; /* all struct ifnets are chained */ struct ifaddr *if_addrlist; /* linked list of addresses per if */ int if_pcount; /* number of promiscuous listeners */ - caddr_t if_bpf; /* packet filter structure */ + struct bpf_if *if_bpf; /* packet filter structure */ u_short if_index; /* numeric abbreviation for this if */ short if_unit; /* sub-unit for lower level driver */ short if_timer; /* time 'til if_watchdog called */ diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c index 2d4b654..70c2b39 100644 --- a/sys/net/if_disc.c +++ b/sys/net/if_disc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * From: @(#)if_loop.c 8.1 (Berkeley) 6/10/93 - * $Id: if_disc.c,v 1.9 1995/12/02 17:11:09 bde Exp $ + * $Id: if_disc.c,v 1.10 1995/12/03 19:08:55 bde Exp $ */ /* @@ -106,7 +106,7 @@ discattach(dummy) ifp->if_addrlen = 0; if_attach(ifp); #if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_NULL, sizeof(u_int)); + bpfattach(ifp, DLT_NULL, sizeof(u_int)); #endif } @@ -144,7 +144,7 @@ dsoutput(ifp, m, dst, rt) m0.m_len = 4; m0.m_data = (char *)⁡ - bpf_mtap(dsif.if_bpf, &m0); + bpf_mtap(&dsif, &m0); } #endif m->m_pkthdr.rcvif = ifp; diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index e0b32b7..790311b 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if_loop.c 8.1 (Berkeley) 6/10/93 - * $Id: if_loop.c,v 1.16 1995/12/09 20:47:13 phk Exp $ + * $Id: if_loop.c,v 1.17 1996/02/05 19:34:27 wollman Exp $ */ /* @@ -115,7 +115,7 @@ loopattach(dummy) ifp->if_addrlen = 0; if_attach(ifp); #if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_NULL, sizeof(u_int)); + bpfattach(ifp, DLT_NULL, sizeof(u_int)); #endif } } @@ -157,7 +157,7 @@ looutput(ifp, m, dst, rt) m0.m_len = 4; m0.m_data = (char *)⁡ - bpf_mtap(ifp->if_bpf, &m0); + bpf_mtap(ifp, &m0); } #endif m->m_pkthdr.rcvif = ifp; diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index d059223..c633ab0 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -69,7 +69,7 @@ * Paul Mackerras (paulus@cs.anu.edu.au). */ -/* $Id: if_ppp.c,v 1.29 1995/12/14 09:53:13 phk Exp $ */ +/* $Id: if_ppp.c,v 1.30 1996/01/24 21:09:18 phk Exp $ */ /* from if_ppp.c,v 1.5 1995/08/16 01:36:38 paulus Exp */ /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ @@ -200,7 +200,7 @@ pppattach(dummy) sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; if_attach(&sc->sc_if); #if NBPFILTER > 0 - bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN); + bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN); #endif } register_netisr(NETISR_PPP, pppintr); @@ -710,8 +710,8 @@ pppoutput(ifp, m0, dst, rtp) /* * See if bpf wants to look at the packet. */ - if (sc->sc_bpf) - bpf_mtap(sc->sc_bpf, m0); + if (ifp->if_bpf) + bpf_mtap(ifp, m0); #endif /* @@ -1325,8 +1325,8 @@ ppp_inproc(sc, m) #if NBPFILTER > 0 /* See if bpf wants to look at the packet. */ - if (sc->sc_bpf) - bpf_mtap(sc->sc_bpf, m); + if (sc->sc_if.if_bpf) + bpf_mtap(&sc->sc_if, m); #endif rv = 0; diff --git a/sys/net/if_pppvar.h b/sys/net/if_pppvar.h index 4f3e3562..652042c 100644 --- a/sys/net/if_pppvar.h +++ b/sys/net/if_pppvar.h @@ -1,5 +1,5 @@ /* from Id: if_pppvar.h,v 1.1 1994/12/15 22:28:09 paulus Exp */ -/* $Id: if_pppvar.h,v 1.2 1995/10/31 20:24:11 peter Exp $ */ +/* $Id: if_pppvar.h,v 1.3 1996/01/30 22:57:49 mpp Exp $ */ /* * if_pppvar.h - private structures and declarations for PPP. * @@ -73,7 +73,6 @@ struct ppp_softc { #endif u_int sc_bytessent; /* count of octets sent */ u_int sc_bytesrcvd; /* count of octets received */ - caddr_t sc_bpf; /* hook for BPF */ enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */ struct compressor *sc_xcomp; /* transmit compressor */ void *sc_xc_state; /* transmit compressor state */ diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index a88f6b3..fc6b861 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if_sl.c 8.6 (Berkeley) 2/1/94 - * $Id: if_sl.c,v 1.34 1995/11/05 20:25:55 bde Exp $ + * $Id: if_sl.c,v 1.35 1995/12/14 09:53:14 phk Exp $ */ /* @@ -228,7 +228,7 @@ slattach(dummy) sc->sc_fastq.ifq_maxlen = 32; if_attach(&sc->sc_if); #if NBPFILTER > 0 - bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_SLIP, SLIP_HDRLEN); + bpfattach(&sc->sc_if, DLT_SLIP, SLIP_HDRLEN); #endif } } @@ -541,7 +541,7 @@ slstart(tp) * munged when this happens. */ #if NBPFILTER > 0 - if (sc->sc_bpf) { + if (sc->sc_if.if_bpf) { /* * We need to save the TCP/IP header before it's * compressed. To avoid complicated code, we just @@ -569,7 +569,7 @@ slstart(tp) &sc->sc_comp, 1); } #if NBPFILTER > 0 - if (sc->sc_bpf) { + if (sc->sc_if.if_bpf) { /* * Put the SLIP pseudo-"link header" in place. The * compressed header is now at the beginning of the @@ -577,7 +577,7 @@ slstart(tp) */ bpfbuf[SLX_DIR] = SLIPDIR_OUT; bcopy(mtod(m, caddr_t), &bpfbuf[SLX_CHDR], CHDR_LEN); - bpf_tap(sc->sc_bpf, bpfbuf, len + SLIP_HDRLEN); + bpf_tap(&sc->sc_if, bpfbuf, len + SLIP_HDRLEN); } #endif sc->sc_if.if_lastchange = time; @@ -802,7 +802,7 @@ slinput(c, tp) goto newpack; #if NBPFILTER > 0 - if (sc->sc_bpf) { + if (sc->sc_if.if_bpf) { /* * Save the compressed header, so we * can tack it on later. Note that we @@ -843,7 +843,7 @@ slinput(c, tp) goto error; } #if NBPFILTER > 0 - if (sc->sc_bpf) { + if (sc->sc_if.if_bpf) { /* * Put the SLIP pseudo-"link header" in place. * We couldn't do this any earlier since @@ -854,7 +854,7 @@ slinput(c, tp) hp[SLX_DIR] = SLIPDIR_IN; bcopy(chdr, &hp[SLX_CHDR], CHDR_LEN); - bpf_tap(sc->sc_bpf, hp, len + SLIP_HDRLEN); + bpf_tap(&sc->sc_if, hp, len + SLIP_HDRLEN); } #endif m = sl_btom(sc, len); diff --git a/sys/net/if_slvar.h b/sys/net/if_slvar.h index 5a76ac0..c73ca47 100644 --- a/sys/net/if_slvar.h +++ b/sys/net/if_slvar.h @@ -32,7 +32,7 @@ * * @(#)if_slvar.h 8.3 (Berkeley) 2/1/94 * - * $Id: if_slvar.h,v 1.8 1995/12/14 09:53:16 phk Exp $ + * $Id: if_slvar.h,v 1.9 1996/01/30 22:57:52 mpp Exp $ */ #ifndef _NET_IF_SLVAR_H_ @@ -61,7 +61,6 @@ struct sl_softc { #ifdef INET /* XXX */ struct slcompress sc_comp; /* tcp compression data */ #endif - caddr_t sc_bpf; /* BPF data */ }; /* internal flags */ diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index a9db860..2d92f58 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -137,7 +137,7 @@ tunattach(dummy) ifp->if_opackets = 0; if_attach(ifp); #if NBPFILTER > 0 - bpfattach(&tunctl[i].tun_bpf, ifp, DLT_NULL, sizeof(u_int)); + bpfattach(ifp, DLT_NULL, sizeof(u_int)); #endif } } @@ -329,7 +329,7 @@ tunoutput(ifp, m0, dst, rt) m0->m_data += sizeof(int); } - if (tp->tun_bpf) { + if (ifp->if_bpf) { /* * We need to prepend the address family as * a four byte field. Cons up a dummy header @@ -344,7 +344,7 @@ tunoutput(ifp, m0, dst, rt) m.m_len = 4; m.m_data = (char *)⁡ - bpf_mtap(tp->tun_bpf, &m); + bpf_mtap(ifp, &m); } #endif @@ -555,7 +555,7 @@ tunwrite(dev_t dev, struct uio *uio, int flag) top->m_pkthdr.rcvif = ifp; #if NBPFILTER > 0 - if (tunctl[unit].tun_bpf) { + if (ifp->if_bpf) { /* * We need to prepend the address family as * a four byte field. Cons up a dummy header @@ -570,7 +570,7 @@ tunwrite(dev_t dev, struct uio *uio, int flag) m.m_len = 4; m.m_data = (char *)⁡ - bpf_mtap(tunctl[unit].tun_bpf, &m); + bpf_mtap(ifp, &m); } #endif diff --git a/sys/net/if_tun.h b/sys/net/if_tun.h index b287636..abf184c 100644 --- a/sys/net/if_tun.h +++ b/sys/net/if_tun.h @@ -36,9 +36,6 @@ struct tun_softc { int tun_pgrp; /* the process group - if any */ struct selinfo tun_rsel; /* read select */ struct selinfo tun_wsel; /* write select (not used) */ -#if NBPFILTER > 0 - caddr_t tun_bpf; -#endif }; /* Maximum packet size */ diff --git a/sys/pci/if_de.c b/sys/pci/if_de.c index bf63619..b9516e8 100644 --- a/sys/pci/if_de.c +++ b/sys/pci/if_de.c @@ -21,7 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_de.c,v 1.41 1996/01/23 21:47:00 se Exp $ + * $Id: if_de.c,v 1.42 1996/01/26 09:29:26 phk Exp $ * */ @@ -1083,7 +1083,7 @@ tulip_rx_intr( eh = *mtod(m, struct ether_header *); #if NBPFILTER > 0 if (sc->tulip_bpf != NULL) - bpf_tap(sc->tulip_bpf, mtod(m, caddr_t), total_len); + bpf_tap(ifp, mtod(m, caddr_t), total_len); #endif if ((sc->tulip_if.if_flags & IFF_PROMISC) && (eh.ether_dhost[0] & 1) == 0 @@ -1223,7 +1223,7 @@ static ifnet_ret_t tulip_start( struct ifnet * const ifp) { - tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(ifp->if_unit); + tulip_softc_t * const sc = ifp->if_softc; struct ifqueue * const ifq = &ifp->if_snd; tulip_ringinfo_t * const ri = &sc->tulip_txinfo; struct mbuf *m, *m0, *next_m0; @@ -1374,7 +1374,7 @@ tulip_start( */ #if NBPFILTER > 0 if (sc->tulip_bpf != NULL) - bpf_mtap(sc->tulip_bpf, m); + bpf_mtap(ifp, m); #endif IF_ENQUEUE(&sc->tulip_txq, m); @@ -1869,7 +1869,7 @@ tulip_ioctl( ioctl_cmd_t cmd, caddr_t data) { - tulip_softc_t * const sc = TULIP_UNIT_TO_SOFTC(ifp->if_unit); + tulip_softc_t * const sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; @@ -1994,6 +1994,7 @@ tulip_attach( { struct ifnet * const ifp = &sc->tulip_if; + ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST; ifp->if_ioctl = tulip_ioctl; ifp->if_output = ether_output; @@ -2018,12 +2019,10 @@ tulip_attach( tulip_reset(sc); if_attach(ifp); -#if defined(__NetBSD__) ether_ifattach(ifp); -#endif #if NBPFILTER > 0 - bpfattach(&sc->tulip_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif } diff --git a/sys/pci/if_fxp.c b/sys/pci/if_fxp.c index 1fdf77d..fe68fa8 100644 --- a/sys/pci/if_fxp.c +++ b/sys/pci/if_fxp.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_fxp.c,v 1.9 1996/01/23 21:47:03 se Exp $ + * $Id: if_fxp.c,v 1.10 1996/01/26 09:29:28 phk Exp $ */ /* @@ -84,7 +84,6 @@ struct fxp_softc { struct arpcom arpcom; /* per-interface network data */ - caddr_t bpf; /* BPF token */ struct fxp_csr *csr; /* control/status registers */ struct fxp_cb_tx *cbl_base; /* base of TxCB list */ struct fxp_cb_tx *cbl_first; /* first active TxCB in list */ @@ -281,6 +280,7 @@ fxp_attach(config_id, unit) fxp_sc[unit] = sc; ifp = &sc->arpcom.ac_if; + ifp->if_softc = sc; ifp->if_unit = unit; ifp->if_name = "fxp"; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; @@ -297,8 +297,10 @@ fxp_attach(config_id, unit) * Attach the interface. */ if_attach(ifp); + ether_ifattach(ifp); + #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif splx(s); return; @@ -413,7 +415,7 @@ static void fxp_start(ifp) struct ifnet *ifp; { - struct fxp_softc *sc = (struct fxp_softc *)ifp; + struct fxp_softc *sc = ifp->if_softc; struct fxp_csr *csr = sc->csr; struct fxp_cb_tx *txp; struct mbuf *m, *mb_head; @@ -529,8 +531,8 @@ tbdinit: /* * Pass packet to bpf if there is a listener. */ - if (sc->bpf != NULL) - bpf_mtap(sc->bpf, mb_head); + if (ifp->if_bpf != NULL) + bpf_mtap(ifp, mb_head); #endif /* * Set a 5 second timer just in case we don't hear from the @@ -624,8 +626,8 @@ rcvloop: sizeof(struct ether_header); eh = mtod(m, struct ether_header *); #if NBPFILTER > 0 - if (sc->bpf != NULL) { - bpf_tap(sc->bpf, mtod(m, caddr_t), total_len); + if (ifp->if_bpf != NULL) { + bpf_tap(ifp, mtod(m, caddr_t), total_len); /* * Only pass this packet up if it is for us. */ @@ -790,7 +792,7 @@ static void fxp_init(ifp) struct ifnet *ifp; { - struct fxp_softc *sc = (struct fxp_softc *)ifp; + struct fxp_softc *sc = ifp->if_softc; struct fxp_cb_config *cbp; struct fxp_cb_ias *cb_ias; struct fxp_cb_tx *txp; @@ -1006,7 +1008,7 @@ fxp_ioctl(ifp, command, data) caddr_t data; { struct ifaddr *ifa = (struct ifaddr *) data; - struct fxp_softc *sc = (struct fxp_softc *)ifp; + struct fxp_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/pci/if_pdq.c b/sys/pci/if_pdq.c index 004f098..c13e364 100644 --- a/sys/pci/if_pdq.c +++ b/sys/pci/if_pdq.c @@ -21,7 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_pdq.c,v 1.12 1995/12/16 00:27:42 bde Exp $ + * $Id: if_pdq.c,v 1.13 1996/01/23 21:47:06 se Exp $ * */ @@ -121,9 +121,6 @@ typedef struct { struct arpcom sc_ac; void (*if_init) __P((int unit)); pdq_t *sc_pdq; -#if NBPFILTER > 0 && !defined(__FreeBSD__) && !defined(__bsdi__) - caddr_t sc_bpf; -#endif #if NFEA > 0 unsigned sc_iobase; #endif @@ -243,7 +240,7 @@ pdq_os_receive_pdu( sc->sc_if.if_ipackets++; #if NBPFILTER > 0 if (sc->sc_bpf != NULL) - bpf_mtap(sc->sc_bpf, m); + bpf_mtap(&sc->sc_if, m); if ((fh->fddi_fc & (FDDIFC_L|FDDIFC_F)) != FDDIFC_LLC_ASYNC) { m_freem(m); return; @@ -279,7 +276,7 @@ pdq_os_transmit_done( pdq_softc_t *sc = (pdq_softc_t *) pdq->pdq_os_ctx; #if NBPFILTER > 0 if (sc->sc_bpf != NULL) - bpf_mtap(sc->sc_bpf, m); + bpf_mtap(&sc->sc_if, m); #endif m_freem(m); sc->sc_if.if_opackets++; @@ -407,6 +404,7 @@ pdq_ifattach( { struct ifnet *ifp = &sc->sc_if; + ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST; sc->if_init = ifinit; @@ -419,7 +417,7 @@ pdq_ifattach( if_attach(ifp); fddi_ifattach(ifp); #if NBPFILTER > 0 - bpfattach(&sc->sc_bpf, ifp, DLT_FDDI, sizeof(struct fddi_header)); + bpfattach(ifp, DLT_FDDI, sizeof(struct fddi_header)); #endif } diff --git a/sys/pci/if_vx.c b/sys/pci/if_vx.c index fb9b305..1575799 100644 --- a/sys/pci/if_vx.c +++ b/sys/pci/if_vx.c @@ -253,6 +253,7 @@ vx_pci_attach( printf("Warning! Defective early revision adapter!\n"); } + ifp->if_softc = sc; ifp->if_unit = unit; ifp->if_name = "vx"; ifp->if_mtu = ETHERMTU; @@ -263,24 +264,8 @@ vx_pci_attach( ifp->if_watchdog = vxwatchdog; if_attach(ifp); + ether_ifattach(ifp); - /* - * Fill the hardware address into ifa_addr if we find an AF_LINK entry. - * We need to do this so bpf's can get the hardware addr of this card. - * netstat likes this too! - */ - ifa = ifp->if_addrlist; - while ((ifa != 0) && (ifa->ifa_addr != 0) && - (ifa->ifa_addr->sa_family != AF_LINK)) - ifa = ifa->ifa_next; - - if ((ifa != 0) && (ifa->ifa_addr != 0)) { - sdl = (struct sockaddr_dl *) ifa->ifa_addr; - sdl->sdl_type = IFT_ETHER; - sdl->sdl_alen = ETHER_ADDR_LEN; - sdl->sdl_slen = 0; - bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); - } /* we give some initial parameters */ sc->rx_avg_pkt = 128; @@ -307,7 +292,7 @@ vx_pci_attach( sc->top = sc->mcur = 0; #if NBPFILTER > 0 - bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); #endif pci_map_int(config_id, (void *) vxintr, (void *) unit, &net_imask); @@ -487,7 +472,7 @@ static void vxstart(ifp) struct ifnet *ifp; { - register struct vx_softc *sc = &vx_softc[ifp->if_unit]; + register struct vx_softc *sc = ifp->if_softc; register u_int len; register struct mbuf *m; struct mbuf *top; @@ -570,8 +555,8 @@ startagain: outb(BASE + VX_W1_TX_PIO_WR_1, 0); /* Padding */ #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, top); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, top); } #endif @@ -888,8 +873,8 @@ all_pkt: top->m_pkthdr.len = sc->cur_len; #if NBPFILTER > 0 - if (sc->bpf) { - bpf_mtap(sc->bpf, top); + if (sc->arpcom.ac_if.if_bpf) { + bpf_mtap(&sc->arpcom.ac_if, top); /* * Note that the interface cannot be in promiscuous mode if there are @@ -958,7 +943,7 @@ vxioctl(ifp, cmd, data) caddr_t data; { register struct ifaddr *ifa = (struct ifaddr *) data; - struct vx_softc *sc = &vx_softc[ifp->if_unit]; + struct vx_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; int s, error = 0; diff --git a/sys/pci/if_vxreg.h b/sys/pci/if_vxreg.h index cbd2735..03d49e5 100644 --- a/sys/pci/if_vxreg.h +++ b/sys/pci/if_vxreg.h @@ -63,7 +63,6 @@ struct vx_softc { short rx_latency; short rx_avg_pkt; short cur_len; - caddr_t bpf; /* BPF "magic cookie" */ u_short vx_connectors; /* Connectors on this card. */ int stat; /* some flags */ #define F_RX_FIRST 0x1 |