summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2006-08-06 13:03:04 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2006-08-06 13:03:04 +0000
commit06657fb3267c92e8abdb21f118cbd6b4ac3273f6 (patch)
tree3001acc4fcfd3a38c729069ef05e8619440f7de7
parent1f53aa87a1f0189d697a29c357cf6a67f5221b34 (diff)
Add bpf hooks. Based on slightly modified diff from jsg.
ok jsg@
-rw-r--r--sys/dev/ic/acx.c68
-rw-r--r--sys/dev/ic/acx100.c3
-rw-r--r--sys/dev/ic/acx111.c3
-rw-r--r--sys/dev/ic/acxvar.h47
4 files changed, 117 insertions, 4 deletions
diff --git a/sys/dev/ic/acx.c b/sys/dev/ic/acx.c
index d8be1527cb1..e837d1f8cae 100644
--- a/sys/dev/ic/acx.c
+++ b/sys/dev/ic/acx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acx.c,v 1.23 2006/08/05 17:22:46 damien Exp $ */
+/* $OpenBSD: acx.c,v 1.24 2006/08/06 13:03:03 mglocker Exp $ */
/*
* Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
@@ -352,6 +352,19 @@ acx_attach(struct acx_softc *sc)
sc->sc_short_retry_limit = 7;
sc->sc_msdu_lifetime = 4096;
+#if NBPFILTER > 0
+ bpfattach(&sc->sc_drvbpf, ifp, DLT_IEEE802_11_RADIO,
+ sizeof(struct ieee80211_frame) + 64);
+
+ sc->sc_rxtap_len = sizeof(sc->sc_rxtapu);
+ sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
+ sc->sc_rxtap.wr_ihdr.it_present = htole32(ACX_RX_RADIOTAP_PRESENT);
+
+ sc->sc_txtap_len = sizeof(sc->sc_txtapu);
+ sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);
+ sc->sc_txtap.wt_ihdr.it_present = htole32(ACX_TX_RADIOTAP_PRESENT);
+#endif
+
return (0);
}
@@ -925,11 +938,21 @@ acx_start(struct ifnet *ifp)
/* TODO power save */
+#if NBPFILTER > 0
+ if (ifp->if_bpf != NULL)
+ bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);
+#endif
+
if ((m = ieee80211_encap(ifp, m, &ni)) == NULL) {
ifp->if_oerrors++;
continue;
}
+#if NBPFILTER > 0
+ if (ic->ic_rawbpf != NULL)
+ bpf_mtap(ic->ic_rawbpf, m, BPF_DIRECTION_OUT);
+#endif
+
node = (struct acx_node *)ni;
if (node->nd_txrate < 0) {
acx_node_init(sc, node);
@@ -962,6 +985,27 @@ acx_start(struct ifnet *ifp)
}
}
+#if NBPFILTER > 0
+ if (sc->sc_drvbpf != NULL) {
+ struct mbuf mb;
+ struct acx_tx_radiotap_hdr *tap = &sc->sc_txtap;
+
+ tap->wt_flags = 0;
+ tap->wt_rate = rate;
+ tap->wt_chan_freq =
+ htole16(ic->ic_bss->ni_chan->ic_freq);
+ tap->wt_chan_flags =
+ htole16(ic->ic_bss->ni_chan->ic_flags);
+
+ M_DUP_PKTHDR(&mb, m);
+ mb.m_data = (caddr_t)tap;
+ mb.m_len = sc->sc_txtap_len;
+ mb.m_next = m;
+ mb.m_pkthdr.len = mb.m_len;
+ bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_OUT);
+ }
+#endif
+
if (acx_encap(sc, buf, m, ni, rate) != 0) {
/*
* NOTE: `m' will be freed in acx_encap()
@@ -1269,6 +1313,28 @@ acx_rxeof(struct acx_softc *sc)
m->m_len = m->m_pkthdr.len = len;
m->m_pkthdr.rcvif = &ic->ic_if;
+#if NBPFILTER > 0
+ if (sc->sc_drvbpf != NULL) {
+ struct mbuf mb;
+ struct acx_rx_radiotap_hdr *tap = &sc->sc_rxtap;
+
+ tap->wr_flags = 0;
+ tap->wr_chan_freq =
+ htole16(ic->ic_bss->ni_chan->ic_freq);
+ tap->wr_chan_flags =
+ htole16(ic->ic_bss->ni_chan->ic_flags);
+ tap->wr_rssi = head->rbh_level;
+ tap->wr_max_rssi = 0; /* XXX */
+
+ M_DUP_PKTHDR(&mb, m);
+ mb.m_data = (caddr_t)tap;
+ mb.m_len = sc->sc_rxtap_len;
+ mb.m_next = m;
+ mb.m_pkthdr.len += mb.m_len;
+ bpf_mtap(sc->sc_drvbpf, &mb, BPF_DIRECTION_IN);
+ }
+#endif
+
ni = ieee80211_find_rxnode(ic, f);
ieee80211_input(ifp, m, ni, head->rbh_level,
diff --git a/sys/dev/ic/acx100.c b/sys/dev/ic/acx100.c
index 0575244c0c9..4c0965d7fd8 100644
--- a/sys/dev/ic/acx100.c
+++ b/sys/dev/ic/acx100.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acx100.c,v 1.6 2006/08/05 14:33:39 mglocker Exp $ */
+/* $OpenBSD: acx100.c,v 1.7 2006/08/06 13:03:03 mglocker Exp $ */
/*
* Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
@@ -70,6 +70,7 @@
#include <net80211/ieee80211.h>
#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
#include <dev/pci/pcireg.h>
diff --git a/sys/dev/ic/acx111.c b/sys/dev/ic/acx111.c
index 34f95adf32c..1e275ea9f32 100644
--- a/sys/dev/ic/acx111.c
+++ b/sys/dev/ic/acx111.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acx111.c,v 1.6 2006/08/05 13:06:50 mglocker Exp $ */
+/* $OpenBSD: acx111.c,v 1.7 2006/08/06 13:03:03 mglocker Exp $ */
/*
* Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
@@ -69,6 +69,7 @@
#endif
#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
#include <dev/pci/pcireg.h>
diff --git a/sys/dev/ic/acxvar.h b/sys/dev/ic/acxvar.h
index 5a67fabecf5..22cf0b4133e 100644
--- a/sys/dev/ic/acxvar.h
+++ b/sys/dev/ic/acxvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acxvar.h,v 1.8 2006/08/05 13:06:50 mglocker Exp $ */
+/* $OpenBSD: acxvar.h,v 1.9 2006/08/06 13:03:03 mglocker Exp $ */
/*
* Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
@@ -326,6 +326,33 @@ struct acx_stats {
uint64_t err_unkn; /* XXX unknown error */
};
+#define ACX_RX_RADIOTAP_PRESENT \
+ ((1 << IEEE80211_RADIOTAP_FLAGS) | \
+ (1 << IEEE80211_RADIOTAP_CHANNEL) | \
+ (1 << IEEE80211_RADIOTAP_RSSI))
+
+struct acx_rx_radiotap_hdr {
+ struct ieee80211_radiotap_header wr_ihdr;
+ uint8_t wr_flags;
+ uint16_t wr_chan_freq;
+ uint16_t wr_chan_flags;
+ uint8_t wr_rssi;
+ uint8_t wr_max_rssi;
+} __packed;
+
+#define ACX_TX_RADIOTAP_PRESENT \
+ ((1 << IEEE80211_RADIOTAP_FLAGS) | \
+ (1 << IEEE80211_RADIOTAP_RATE) | \
+ (1 << IEEE80211_RADIOTAP_CHANNEL)) \
+
+struct acx_tx_radiotap_hdr {
+ struct ieee80211_radiotap_header wt_ihdr;
+ uint8_t wt_flags;
+ uint8_t wt_rate;
+ uint16_t wt_chan_freq;
+ uint16_t wt_chan_flags;
+} __packed;
+
struct acx_softc {
/*
* sc_xxx are filled in by common code
@@ -436,6 +463,24 @@ struct acx_softc {
void (*chip_proc_wep_rxbuf)
(struct acx_softc *, struct mbuf *, int *);
+
+#if NBPFILTER > 0
+ caddr_t sc_drvbpf;
+
+ union {
+ struct acx_rx_radiotap_hdr th;
+ uint8_t pad[64];
+ } sc_rxtapu;
+#define sc_rxtap sc_rxtapu.th
+ int sc_rxtap_len;
+
+ union {
+ struct acx_tx_radiotap_hdr th;
+ uint8_t pad[64];
+ } sc_txtapu;
+#define sc_txtap sc_txtapu.th
+ int sc_txtap_len;
+#endif
};
#define ACX_FLAG_FW_LOADED 0x01