Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Add IEEE802.11 radiotap support. From Damien B...
details: https://anonhg.NetBSD.org/src/rev/c95f4e445e4c
branches: trunk
changeset: 569938:c95f4e445e4c
user: lukem <lukem%NetBSD.org@localhost>
date: Tue Sep 14 00:31:20 2004 +0000
description:
Add IEEE802.11 radiotap support. From Damien Bergamini.
diffstat:
sys/dev/pci/if_ipw.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
sys/dev/pci/if_ipwvar.h | 44 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 87 insertions(+), 3 deletions(-)
diffs (160 lines):
diff -r 3ae3266c7095 -r c95f4e445e4c sys/dev/pci/if_ipw.c
--- a/sys/dev/pci/if_ipw.c Tue Sep 14 00:27:26 2004 +0000
+++ b/sys/dev/pci/if_ipw.c Tue Sep 14 00:31:20 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ipw.c,v 1.3 2004/08/27 00:02:02 lukem Exp $ */
+/* $NetBSD: if_ipw.c,v 1.4 2004/09/14 00:31:20 lukem Exp $ */
/* Id: if_ipw.c,v 1.1.2.7 2004/08/20 11:20:11 damien Exp */
/*-
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.3 2004/08/27 00:02:02 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.4 2004/09/14 00:31:20 lukem Exp $");
/*-
* Intel(R) PRO/Wireless 2100 MiniPCI driver
@@ -67,6 +67,7 @@
#include <net/if_types.h>
#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_radiotap.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -267,6 +268,19 @@
ic->ic_newstate = ipw_newstate;
ieee80211_media_init(ifp, ipw_media_change, ieee80211_media_status);
+
+#if NBPFILTER > 0
+ bpfattach2(ifp, DLT_IEEE802_11_RADIO,
+ sizeof (struct ieee80211_frame) + 64, &sc->sc_drvbpf);
+
+ 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(IPW_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(IPW_TX_RADIOTAP_PRESENT);
+#endif
}
static int
@@ -277,6 +291,9 @@
ipw_reset(sc);
+#if NBPFILTER > 0
+ bpfdetach(ifp);
+#endif
ieee80211_ifdetach(ifp);
if_detach(ifp);
@@ -424,6 +441,19 @@
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = le32toh(status->len);
+#if NBPFILTER > 0
+ if (sc->sc_drvbpf != NULL) {
+ struct ipw_rx_radiotap_header *tap = &sc->sc_rxtap;
+
+ tap->wr_flags = 0;
+ tap->wr_antsignal = status->rssi;
+ tap->wr_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
+ tap->wr_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
+
+ bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m);
+ }
+#endif
+
wh = mtod(m, struct ieee80211_frame *);
if (ic->ic_opmode != IEEE80211_M_STA) {
@@ -678,6 +708,18 @@
return ENOBUFS;
}
+#if NBPFILTER > 0
+ if (sc->sc_drvbpf != NULL) {
+ struct ipw_tx_radiotap_header *tap = &sc->sc_txtap;
+
+ tap->wt_flags = 0;
+ tap->wt_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
+ tap->wt_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
+
+ bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m);
+ }
+#endif
+
wh = mtod(m, struct ieee80211_frame *);
shdr = TAILQ_FIRST(&sc->sc_free_shdr);
diff -r 3ae3266c7095 -r c95f4e445e4c sys/dev/pci/if_ipwvar.h
--- a/sys/dev/pci/if_ipwvar.h Tue Sep 14 00:27:26 2004 +0000
+++ b/sys/dev/pci/if_ipwvar.h Tue Sep 14 00:31:20 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ipwvar.h,v 1.3 2004/09/14 00:27:26 lukem Exp $ */
+/* $NetBSD: if_ipwvar.h,v 1.4 2004/09/14 00:31:20 lukem Exp $ */
/*-
* Copyright (c) 2004
@@ -50,6 +50,30 @@
TAILQ_ENTRY(ipw_soft_buf) next;
};
+struct ipw_rx_radiotap_header {
+ struct ieee80211_radiotap_header wr_ihdr;
+ u_int8_t wr_flags;
+ u_int16_t wr_chan_freq;
+ u_int16_t wr_chan_flags;
+ u_int8_t wr_antsignal;
+};
+
+#define IPW_RX_RADIOTAP_PRESENT \
+ ((1 << IEEE80211_RADIOTAP_FLAGS) | \
+ (1 << IEEE80211_RADIOTAP_CHANNEL) | \
+ (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
+
+struct ipw_tx_radiotap_header {
+ struct ieee80211_radiotap_header wt_ihdr;
+ u_int8_t wt_flags;
+ u_int16_t wt_chan_freq;
+ u_int16_t wt_chan_flags;
+};
+
+#define IPW_TX_RADIOTAP_PRESENT \
+ ((1 << IEEE80211_RADIOTAP_FLAGS) | \
+ (1 << IEEE80211_RADIOTAP_CHANNEL))
+
struct ipw_softc {
struct device sc_dev;
@@ -102,6 +126,24 @@
u_int32_t txcur;
u_int32_t txold;
u_int32_t rxcur;
+
+#if NBPFILTER > 0
+ struct bpf_if *sc_drvbpf;
+
+ union {
+ struct ipw_rx_radiotap_header th;
+ u_int8_t pad[64];
+ } sc_rxtapu;
+#define sc_rxtap sc_rxtapu.th
+ int sc_rxtap_len;
+
+ union {
+ struct ipw_tx_radiotap_header th;
+ u_int8_t pad[64];
+ } sc_txtapu;
+#define sc_txtap sc_txtapu.th
+ int sc_txtap_len;
+#endif
};
#define SIOCSLOADFW _IOW('i', 137, struct ifreq)
Home |
Main Index |
Thread Index |
Old Index