Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Forward declare struct bpf_if and use that as the type f...



details:   https://anonhg.NetBSD.org/src/rev/788baf34574e
branches:  trunk
changeset: 750870:788baf34574e
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sun Jan 17 19:45:06 2010 +0000

description:
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)

diffstat:

 sys/dev/ic/anvar.h           |   4 ++--
 sys/dev/ic/athvar.h          |   4 ++--
 sys/dev/ic/atwvar.h          |   4 ++--
 sys/dev/ic/pdqvar.h          |   4 ++--
 sys/dev/ic/rt2560var.h       |   4 ++--
 sys/dev/ic/rt2661var.h       |   4 ++--
 sys/dev/ic/rtwvar.h          |   4 ++--
 sys/dev/ic/wivar.h           |   4 ++--
 sys/dev/pci/if_iwnvar.h      |   4 ++--
 sys/dev/pci/if_wpivar.h      |   4 ++--
 sys/dev/usb/if_rumvar.h      |   4 ++--
 sys/dev/usb/if_uralvar.h     |   4 ++--
 sys/dev/usb/if_zydreg.h      |   4 ++--
 sys/net/bpf.c                |  36 ++++++++++++++++--------------------
 sys/net/bpf.h                |  20 +++++++++++---------
 sys/net/if.h                 |   4 ++--
 sys/net80211/ieee80211_var.h |   4 ++--
 17 files changed, 57 insertions(+), 59 deletions(-)

diffs (truncated from 463 to 300 lines):

diff -r 3e8e97906b28 -r 788baf34574e sys/dev/ic/anvar.h
--- a/sys/dev/ic/anvar.h        Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/ic/anvar.h        Sun Jan 17 19:45:06 2010 +0000
@@ -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@localhost>.  All rights reserved.
@@ -146,7 +146,7 @@
        }                       sc_buf;
 
        /* radiotap header */
-       void *                  sc_drvbpf;
+       struct bpf_if *                 sc_drvbpf;
        union {
                struct an_rx_radiotap_header    tap;
                u_int8_t                        pad[64];
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/ic/athvar.h
--- a/sys/dev/ic/athvar.h       Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/ic/athvar.h       Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        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];
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/ic/atwvar.h
--- a/sys/dev/ic/atwvar.h       Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/ic/atwvar.h       Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        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 */
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/ic/pdqvar.h
--- a/sys/dev/ic/pdqvar.h       Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/ic/pdqvar.h       Sun Jan 17 19:45:06 2010 +0000
@@ -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@localhost>
@@ -348,7 +348,7 @@
 #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__)
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/ic/rt2560var.h
--- a/sys/dev/ic/rt2560var.h    Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/ic/rt2560var.h    Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        int                     dwelltime;
 
 #if NBPFILTER > 0
-       void *                  sc_drvbpf;
+       struct bpf_if *         sc_drvbpf;
 
        union {
                struct rt2560_rx_radiotap_header th;
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/ic/rt2661var.h
--- a/sys/dev/ic/rt2661var.h    Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/ic/rt2661var.h    Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        uint8_t                         bbp64;
 
 #if NBPFILTER > 0
-       void *                  sc_drvbpf;
+       struct bpf_if *                 sc_drvbpf;
 
        union {
                struct rt2661_rx_radiotap_header th;
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/ic/rtwvar.h
--- a/sys/dev/ic/rtwvar.h       Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/ic/rtwvar.h       Sun Jan 17 19:45:06 2010 +0000
@@ -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_mtbl         sc_mtbl;
 
-       void *                  sc_radiobpf;
+       struct bpf_if *         sc_radiobpf;
 
        struct callout          sc_scan_ch;
        u_int                   sc_cur_chan;
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/ic/wivar.h
--- a/sys/dev/ic/wivar.h        Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/ic/wivar.h        Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        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;
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/pci/if_iwnvar.h
--- a/sys/dev/pci/if_iwnvar.h   Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/pci/if_iwnvar.h   Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        void                    *powerhook;
 
 #if NBPFILTER > 0
-       void *                  sc_drvbpf;
+       struct bpf_if *         sc_drvbpf;
 
        union {
                struct iwn_rx_radiotap_header th;
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/pci/if_wpivar.h
--- a/sys/dev/pci/if_wpivar.h   Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/pci/if_wpivar.h   Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        int                     sc_tx_timer;
 
 #if NBPFILTER > 0
-       void *                  sc_drvbpf;
+       struct bpf_if *         sc_drvbpf;
 
        union {
                struct wpi_rx_radiotap_header th;
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/usb/if_rumvar.h
--- a/sys/dev/usb/if_rumvar.h   Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/usb/if_rumvar.h   Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        uint8_t                         bbp17;
 
 #if NBPFILTER > 0
-       void *                          sc_drvbpf;
+       struct bpf_if *                 sc_drvbpf;
 
        union {
                struct rum_rx_radiotap_header th;
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/usb/if_uralvar.h
--- a/sys/dev/usb/if_uralvar.h  Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/usb/if_uralvar.h  Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
        int                     nb_ant;
 
 #if NBPFILTER > 0
-       void *                  sc_drvbpf;
+       struct bpf_if *         sc_drvbpf;
 
        union {
                struct ural_rx_radiotap_header th;
diff -r 3e8e97906b28 -r 788baf34574e sys/dev/usb/if_zydreg.h
--- a/sys/dev/usb/if_zydreg.h   Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/dev/usb/if_zydreg.h   Sun Jan 17 19:45:06 2010 +0000
@@ -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@localhost>
@@ -1219,7 +1219,7 @@
        int                             tx_timer;
 
 #if NBPFILTER > 0
-       void *                          sc_drvbpf;
+       struct bpf_if *                 sc_drvbpf;
 
        union {
                struct zyd_rx_radiotap_header th;
diff -r 3e8e97906b28 -r 788baf34574e sys/net/bpf.c
--- a/sys/net/bpf.c     Sun Jan 17 17:02:47 2010 +0000
+++ b/sys/net/bpf.c     Sun Jan 17 19:45:06 2010 +0000
@@ -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 @@
                    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 @@
  * 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 @@
         * 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 @@
  * 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 @@
  * 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)
 {



Home | Main Index | Thread Index | Old Index