Forward declare struct bpf_if and use that as the type for bpf_if

instead of "void *".  Buys us oo times the type-safety for 0 times
the price.
(no functional change)
This commit is contained in:
pooka 2010-01-17 19:45:06 +00:00
parent d0d86c817a
commit 64da563d90
17 changed files with 57 additions and 59 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: anvar.h,v 1.19 2009/11/12 19:28:59 dyoung Exp $ */
/* $NetBSD: anvar.h,v 1.20 2010/01/17 19:45:06 pooka Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
@ -146,7 +146,7 @@ struct an_softc {
} sc_buf;
/* radiotap header */
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct an_rx_radiotap_header tap;
u_int8_t pad[64];

View File

@ -1,4 +1,4 @@
/* $NetBSD: athvar.h,v 1.29 2009/09/16 16:34:50 dyoung Exp $ */
/* $NetBSD: athvar.h,v 1.30 2010/01/17 19:45:06 pooka Exp $ */
/*-
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@ -243,7 +243,7 @@ struct ath_softc {
u_int16_t sc_ledoff; /* off time for current blink */
struct callout sc_ledtimer; /* led off timer */
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct ath_tx_radiotap_header th;
u_int8_t pad[64];

View File

@ -1,4 +1,4 @@
/* $NetBSD: atwvar.h,v 1.34 2010/01/08 20:02:39 dyoung Exp $ */
/* $NetBSD: atwvar.h,v 1.35 2010/01/17 19:45:06 pooka Exp $ */
/*
* Copyright (c) 2003, 2004 The NetBSD Foundation, Inc. All rights reserved.
@ -200,7 +200,7 @@ struct atw_softc {
u_int16_t *sc_srom;
u_int16_t sc_sromsz;
void * sc_radiobpf;
struct bpf_if * sc_radiobpf;
bus_dma_segment_t sc_cdseg; /* control data memory */
int sc_cdnseg; /* number of segments */

View File

@ -1,4 +1,4 @@
/* $NetBSD: pdqvar.h,v 1.41 2009/03/18 16:00:18 cegger Exp $ */
/* $NetBSD: pdqvar.h,v 1.42 2010/01/17 19:45:06 pooka Exp $ */
/*-
* Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com>
@ -348,7 +348,7 @@ typedef struct _pdq_os_ctx_t {
#if !defined(__bsdi__) || _BSDI_VERSION >= 199401
#define sc_bpf sc_if.if_bpf
#else
void *sc_bpf;
struct bpf_if *sc_bpf;
#endif
#if defined(PDQ_BUS_DMA)
#if !defined(__NetBSD__)

View File

@ -1,4 +1,4 @@
/* $NetBSD: rt2560var.h,v 1.6 2007/12/09 20:27:58 jmcneill Exp $ */
/* $NetBSD: rt2560var.h,v 1.7 2010/01/17 19:45:06 pooka Exp $ */
/* $OpenBSD: rt2560var.h,v 1.2 2006/01/14 12:43:27 damien Exp $ */
/*-
@ -150,7 +150,7 @@ struct rt2560_softc {
int dwelltime;
#if NBPFILTER > 0
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct rt2560_rx_radiotap_header th;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rt2661var.h,v 1.8 2008/04/29 22:21:45 scw Exp $ */
/* $NetBSD: rt2661var.h,v 1.9 2010/01/17 19:45:06 pooka Exp $ */
/* $OpenBSD: rt2661var.h,v 1.4 2006/02/25 12:56:47 damien Exp $ */
/*-
@ -159,7 +159,7 @@ struct rt2661_softc {
uint8_t bbp64;
#if NBPFILTER > 0
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct rt2661_rx_radiotap_header th;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtwvar.h,v 1.40 2010/01/08 20:02:39 dyoung Exp $ */
/* $NetBSD: rtwvar.h,v 1.41 2010/01/17 19:45:06 pooka Exp $ */
/*-
* Copyright (c) 2004, 2005 David Young. All rights reserved.
*
@ -458,7 +458,7 @@ struct rtw_softc {
struct rtw_mtbl sc_mtbl;
void * sc_radiobpf;
struct bpf_if * sc_radiobpf;
struct callout sc_scan_ch;
u_int sc_cur_chan;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wivar.h,v 1.62 2009/05/12 14:25:18 cegger Exp $ */
/* $NetBSD: wivar.h,v 1.63 2010/01/17 19:45:06 pooka Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@ -102,7 +102,7 @@ struct wi_softc {
bus_space_tag_t sc_iot; /* bus cookie */
bus_space_handle_t sc_ioh; /* bus i/o handle */
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
int sc_flags;
int sc_bap_id;
int sc_bap_off;

View File

@ -1,5 +1,5 @@
/* $OpenBSD: if_iwnvar.h,v 1.8 2008/12/03 17:17:08 damien Exp $ */
/* $NetBSD: if_iwnvar.h,v 1.6 2009/09/11 01:28:20 christos Exp $ */
/* $NetBSD: if_iwnvar.h,v 1.7 2010/01/17 19:45:06 pooka Exp $ */
/*-
* Copyright (c) 2007, 2008
@ -288,7 +288,7 @@ struct iwn_softc {
void *powerhook;
#if NBPFILTER > 0
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct iwn_rx_radiotap_header th;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_wpivar.h,v 1.13 2008/11/12 18:23:08 joerg Exp $ */
/* $NetBSD: if_wpivar.h,v 1.14 2010/01/17 19:45:06 pooka Exp $ */
/*-
* Copyright (c) 2006
@ -170,7 +170,7 @@ struct wpi_softc {
int sc_tx_timer;
#if NBPFILTER > 0
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct wpi_rx_radiotap_header th;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_rumvar.h,v 1.5 2009/05/29 18:49:21 plunky Exp $ */
/* $NetBSD: if_rumvar.h,v 1.6 2010/01/17 19:45:06 pooka Exp $ */
/* $OpenBSD: if_rumvar.h,v 1.7 2006/11/13 20:06:38 damien Exp $ */
/*-
@ -135,7 +135,7 @@ struct rum_softc {
uint8_t bbp17;
#if NBPFILTER > 0
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct rum_rx_radiotap_header th;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_uralvar.h,v 1.8 2007/06/09 12:13:12 kiyohara Exp $ */
/* $NetBSD: if_uralvar.h,v 1.9 2010/01/17 19:45:06 pooka Exp $ */
/* $OpenBSD: if_ralvar.h,v 1.2 2005/05/13 18:42:50 damien Exp $ */
/*-
@ -125,7 +125,7 @@ struct ural_softc {
int nb_ant;
#if NBPFILTER > 0
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct ural_rx_radiotap_header th;

View File

@ -1,5 +1,5 @@
/* $OpenBSD: if_zydreg.h,v 1.19 2006/11/30 19:28:07 damien Exp $ */
/* $NetBSD: if_zydreg.h,v 1.2 2007/06/16 11:18:45 kiyohara Exp $ */
/* $NetBSD: if_zydreg.h,v 1.3 2010/01/17 19:45:06 pooka Exp $ */
/*-
* Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr>
@ -1219,7 +1219,7 @@ struct zyd_softc {
int tx_timer;
#if NBPFILTER > 0
void * sc_drvbpf;
struct bpf_if * sc_drvbpf;
union {
struct zyd_rx_radiotap_header th;

View File

@ -1,4 +1,4 @@
/* $NetBSD: bpf.c,v 1.151 2010/01/15 22:16:46 pooka Exp $ */
/* $NetBSD: bpf.c,v 1.152 2010/01/17 19:45:06 pooka Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.151 2010/01/15 22:16:46 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.152 2010/01/17 19:45:06 pooka Exp $");
#if defined(_KERNEL_OPT)
#include "opt_bpf.h"
@ -1078,7 +1078,7 @@ bpf_setif(struct bpf_d *d, struct ifreq *ifr)
strcmp(ifp->if_xname, ifr->ifr_name) != 0)
continue;
/* skip additional entry */
if ((void **)bp->bif_driverp != &ifp->if_bpf)
if (bp->bif_driverp != &ifp->if_bpf)
continue;
/*
* We found the requested interface.
@ -1249,9 +1249,8 @@ bpf_kqfilter(struct file *fp, struct knote *kn)
* buffer.
*/
void
bpf_tap(void *arg, u_char *pkt, u_int pktlen)
bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen)
{
struct bpf_if *bp;
struct bpf_d *d;
u_int slen;
struct timespec ts;
@ -1262,7 +1261,6 @@ bpf_tap(void *arg, u_char *pkt, u_int pktlen)
* The only problem that could arise here is that if two different
* interfaces shared any data. This is not the case.
*/
bp = arg;
for (d = bp->bif_dlist; d != 0; d = d->bd_next) {
++d->bd_rcount;
++bpf_gstats.bs_recv;
@ -1341,9 +1339,8 @@ bpf_deliver(struct bpf_if *bp, void *(*cpfn)(void *, const void *, size_t),
* a buffer, and the tail is in an mbuf chain.
*/
void
bpf_mtap2(void *arg, void *data, u_int dlen, struct mbuf *m)
bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, struct mbuf *m)
{
struct bpf_if *bp = arg;
u_int pktlen;
struct mbuf mb;
@ -1366,10 +1363,9 @@ bpf_mtap2(void *arg, void *data, u_int dlen, struct mbuf *m)
* Incoming linkage from device drivers, when packet is in an mbuf chain.
*/
void
bpf_mtap(void *arg, struct mbuf *m)
bpf_mtap(struct bpf_if *bp, struct mbuf *m)
{
void *(*cpfn)(void *, const void *, size_t);
struct bpf_if *bp = arg;
u_int pktlen, buflen;
void *marg;
@ -1397,7 +1393,7 @@ bpf_mtap(void *arg, struct mbuf *m)
* try to free it or keep a pointer a to it).
*/
void
bpf_mtap_af(void *arg, uint32_t af, struct mbuf *m)
bpf_mtap_af(struct bpf_if *bp, uint32_t af, struct mbuf *m)
{
struct mbuf m0;
@ -1406,11 +1402,11 @@ bpf_mtap_af(void *arg, uint32_t af, struct mbuf *m)
m0.m_len = 4;
m0.m_data = (char *)&af;
bpf_mtap(arg, &m0);
bpf_mtap(bp, &m0);
}
void
bpf_mtap_et(void *arg, uint16_t et, struct mbuf *m)
bpf_mtap_et(struct bpf_if *bp, uint16_t et, struct mbuf *m)
{
struct mbuf m0;
@ -1424,7 +1420,7 @@ bpf_mtap_et(void *arg, uint16_t et, struct mbuf *m)
((uint32_t *)m0.m_data)[2] = 0;
((uint16_t *)m0.m_data)[6] = et;
bpf_mtap(arg, &m0);
bpf_mtap(bp, &m0);
}
#if NSL > 0 || NSTRIP > 0
@ -1435,7 +1431,7 @@ bpf_mtap_et(void *arg, uint16_t et, struct mbuf *m)
* in the input buffer.
*/
void
bpf_mtap_sl_in(void *arg, u_char *chdr, struct mbuf **m)
bpf_mtap_sl_in(struct bpf_if *bp, u_char *chdr, struct mbuf **m)
{
int s;
u_char *hp;
@ -1449,7 +1445,7 @@ bpf_mtap_sl_in(void *arg, u_char *chdr, struct mbuf **m)
(void)memcpy(&hp[SLX_CHDR], chdr, CHDR_LEN);
s = splnet();
bpf_mtap(arg, *m);
bpf_mtap(bp, *m);
splx(s);
m_adj(*m, SLIP_HDRLEN);
@ -1461,7 +1457,7 @@ bpf_mtap_sl_in(void *arg, u_char *chdr, struct mbuf **m)
* at the beginning of the mbuf.
*/
void
bpf_mtap_sl_out(void *arg, u_char *chdr, struct mbuf *m)
bpf_mtap_sl_out(struct bpf_if *bp, u_char *chdr, struct mbuf *m)
{
struct mbuf m0;
u_char *hp;
@ -1478,7 +1474,7 @@ bpf_mtap_sl_out(void *arg, u_char *chdr, struct mbuf *m)
(void)memcpy(&hp[SLX_CHDR], chdr, CHDR_LEN);
s = splnet();
bpf_mtap(arg, &m0);
bpf_mtap(bp, &m0);
splx(s);
m_freem(m);
}
@ -1626,7 +1622,7 @@ bpfattach(struct ifnet *ifp, u_int dlt, u_int hdrlen)
* (variable length headers not yet supported).
*/
void
bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen, void *driverp)
bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen, struct bpf_if **driverp)
{
struct bpf_if *bp;
bp = malloc(sizeof(*bp), M_DEVBUF, M_DONTWAIT);
@ -1700,7 +1696,7 @@ bpf_change_type(struct ifnet *ifp, u_int dlt, u_int hdrlen)
struct bpf_if *bp;
for (bp = bpf_iflist; bp != NULL; bp = bp->bif_next) {
if ((void **)bp->bif_driverp == &ifp->if_bpf)
if (bp->bif_driverp == &ifp->if_bpf)
break;
}
if (bp == NULL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: bpf.h,v 1.50 2009/01/13 19:10:52 christos Exp $ */
/* $NetBSD: bpf.h,v 1.51 2010/01/17 19:45:06 pooka Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
@ -258,16 +258,18 @@ struct bpf_dltlist {
};
#ifdef _KERNEL
struct bpf_if;
int bpf_validate(struct bpf_insn *, int);
void bpf_tap(void *, u_char *, u_int);
void bpf_mtap(void *, struct mbuf *);
void bpf_mtap2(void *, void *, u_int, struct mbuf *);
void bpf_mtap_af(void *, uint32_t, struct mbuf *);
void bpf_mtap_et(void *, uint16_t, struct mbuf *);
void bpf_mtap_sl_in(void *, u_char *, struct mbuf **);
void bpf_mtap_sl_out(void *, u_char *, struct mbuf *);
void bpf_tap(struct bpf_if *, u_char *, u_int);
void bpf_mtap(struct bpf_if *, struct mbuf *);
void bpf_mtap2(struct bpf_if *, void *, u_int, struct mbuf *);
void bpf_mtap_af(struct bpf_if *, uint32_t, struct mbuf *);
void bpf_mtap_et(struct bpf_if *, uint16_t, struct mbuf *);
void bpf_mtap_sl_in(struct bpf_if *, u_char *, struct mbuf **);
void bpf_mtap_sl_out(struct bpf_if *, u_char *, struct mbuf *);
void bpfattach(struct ifnet *, u_int, u_int);
void bpfattach2(struct ifnet *, u_int, u_int, void *);
void bpfattach2(struct ifnet *, u_int, u_int, struct bpf_if **);
void bpfdetach(struct ifnet *);
void bpf_change_type(struct ifnet *, u_int, u_int);
void bpfilterattach(int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if.h,v 1.145 2009/10/05 21:25:05 dyoung Exp $ */
/* $NetBSD: if.h,v 1.146 2010/01/17 19:45:06 pooka Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -213,7 +213,7 @@ struct ifnet { /* and the entries */
TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */
char if_xname[IFNAMSIZ]; /* external name (name + unit) */
int if_pcount; /* number of promiscuous listeners */
void * if_bpf; /* packet filter structure */
struct bpf_if *if_bpf; /* packet filter structure */
u_short if_index; /* numeric abbreviation for this if */
short if_timer; /* time 'til if_watchdog called */
short if_flags; /* up/down, broadcast, etc. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_var.h,v 1.27 2008/12/11 06:04:01 alc Exp $ */
/* $NetBSD: ieee80211_var.h,v 1.28 2010/01/17 19:45:07 pooka Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@ -143,7 +143,7 @@ struct ieee80211com {
u_int8_t ic_dtim_period; /* DTIM period */
u_int8_t ic_dtim_count; /* DTIM count for last bcn */
struct ifmedia ic_media; /* interface media config */
void * ic_rawbpf; /* packet filter structure */
struct bpf_if * ic_rawbpf; /* packet filter structure */
struct ieee80211_node *ic_bss; /* information for this node */
struct ieee80211_channel *ic_ibss_chan;
struct ieee80211_channel *ic_curchan; /* current channel */