Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/net80211 Use proper BPF link type and track listen...
details: https://anonhg.NetBSD.org/src-all/rev/fd68ffef2a14
branches: trunk
changeset: 988605:fd68ffef2a14
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Mon Sep 20 16:51:59 2021 +0200
description:
Use proper BPF link type and track listeners.
diffstat:
sys/net80211/ieee80211_netbsd.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diffs (89 lines):
diff -r b89581c347b7 -r fd68ffef2a14 sys/net80211/ieee80211_netbsd.c
--- a/sys/net80211/ieee80211_netbsd.c Sun Sep 05 14:22:51 2021 +0200
+++ b/sys/net80211/ieee80211_netbsd.c Mon Sep 20 16:51:59 2021 +0200
@@ -75,6 +75,8 @@
static int ieee80211_sysctl_radar(SYSCTLFN_ARGS);
static int ieee80211_sysctl_vap_restart(SYSCTLFN_ARGS);
+static void bpf_track(struct bpf_if *, struct ifnet *, int, int);
+
static const char wlanname[] = "wlan";
static int wlan_clone_create(struct if_clone *, int, size_t, void*);
@@ -239,6 +241,7 @@
return EIO;
ieee80211_com_vincref(vap);
+ bpf_register_track_event(&vap->iv_rawbpf, bpf_track);
return 0;
}
@@ -256,6 +259,7 @@
ieee80211_vap_destroy(struct ieee80211vap *vap)
{
+ bpf_deregister_track_event(&vap->iv_rawbpf, bpf_track);
wlan_clone_destroy(vap->iv_ifp);
}
@@ -1246,17 +1250,14 @@
}
#endif
-#ifdef notyet
-static eventhandler_tag wlan_bpfevent;
-static eventhandler_tag wlan_ifllevent;
+static void
+bpf_track(struct bpf_if *bpf, struct ifnet *ifp, int dlt, int event)
+{
-static void
-bpf_track(void *arg, struct ifnet *ifp, int dlt, int attach)
-{
- /* NB: identify vap's by if_init */ // NNN won't work with urtwn ...
if (dlt == DLT_IEEE802_11_RADIO &&
ifp->if_init == ieee80211_init) {
struct ieee80211vap *vap = ifp->if_softc;
+
/*
* Track bpf radiotap listener state. We mark the vap
* to indicate if any listener is present and the com
@@ -1264,11 +1265,12 @@
* vap. This flag is used by drivers to prepare radiotap
* state only when needed.
*/
- if (attach) {
+ if (event == BPF_TRACK_EVENT_ATTACH) {
ieee80211_syncflag_ext(vap, IEEE80211_FEXT_BPF);
if (vap->iv_opmode == IEEE80211_M_MONITOR)
atomic_add_int(&vap->iv_ic->ic_montaps, 1);
- } else if (!bpf_peers_present(vap->iv_rawbpf)) {
+ } else if (event == BPF_TRACK_EVENT_DETACH &&
+ !bpf_peers_present(vap->iv_rawbpf)) {
ieee80211_syncflag_ext(vap, -IEEE80211_FEXT_BPF);
if (vap->iv_opmode == IEEE80211_M_MONITOR)
atomic_subtract_int(&vap->iv_ic->ic_montaps, 1);
@@ -1276,6 +1278,7 @@
}
}
+#ifdef notyet
/*
* Change MAC address on the vap (if was not started).
*/
@@ -1569,7 +1572,7 @@
{
ifp->if_type = IFT_ETHER;
ifp->if_hdrlen = ETHER_HDR_LEN;
- ifp->if_dlt = DLT_EN10MB;
+ ifp->if_dlt = DLT_IEEE802_11;
ifp->if_mtu = ETHERMTU;
ifp->if_output = ether_output;
ifp->_if_input = ether_input;
@@ -1580,5 +1583,5 @@
if_set_sadl(ifp, lla, ETHER_ADDR_LEN, !ETHER_IS_LOCAL(lla));
ifp->if_broadcastaddr = etherbroadcastaddr;
- bpf_attach(ifp, DLT_EN10MB, sizeof(struct ether_header));
+ bpf_attach(ifp, DLT_IEEE802_11, sizeof(struct ieee80211_frame));
}
Home |
Main Index |
Thread Index |
Old Index