Monitor 20/40 MHz channel width changes in beacons sent by our access point
authorstsp <stsp@openbsd.org>
Mon, 11 Oct 2021 09:02:01 +0000 (09:02 +0000)
committerstsp <stsp@openbsd.org>
Mon, 11 Oct 2021 09:02:01 +0000 (09:02 +0000)
and notify drivers when the channel width has changed.

sys/net80211/ieee80211_input.c
sys/net80211/ieee80211_var.h

index 99699b9..888a39c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ieee80211_input.c,v 1.238 2021/09/03 12:39:43 stsp Exp $      */
+/*     $OpenBSD: ieee80211_input.c,v 1.239 2021/10/11 09:02:01 stsp Exp $      */
 
 /*-
  * Copyright (c) 2001 Atsushi Onoe
@@ -1857,6 +1857,27 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m,
                if (updateprot && ic->ic_updateprot != NULL)
                        ic->ic_updateprot(ic);
 
+               /*
+                * Check if 40MHz channel mode has changed since last beacon.
+                */
+               if (htop && (ic->ic_bss->ni_flags & IEEE80211_NODE_HT) &&
+                   (ic->ic_htcaps & IEEE80211_HTCAP_CBW20_40)) {
+                       uint8_t chw_last, chw, sco_last, sco;
+                       chw_last = (ic->ic_bss->ni_htop0 & IEEE80211_HTOP0_CHW);
+                       chw = (ni->ni_htop0 & IEEE80211_HTOP0_CHW);
+                       sco_last =
+                           ((ic->ic_bss->ni_htop0 & IEEE80211_HTOP0_SCO_MASK)
+                           >> IEEE80211_HTOP0_SCO_SHIFT);
+                       sco = ((ni->ni_htop0 & IEEE80211_HTOP0_SCO_MASK) >>
+                           IEEE80211_HTOP0_SCO_SHIFT);
+                       ic->ic_bss->ni_htop0 = ni->ni_htop0;
+                       if (chw_last != chw || sco_last != sco) {
+                               if (ic->ic_updatechan != NULL)
+                                       ic->ic_updatechan(ic);
+                       }
+               } else if (htop)
+                       ic->ic_bss->ni_htop0 = ni->ni_htop0;
+
                /*
                 * Check if AP short slot time setting has changed
                 * since last beacon and give the driver a chance to
index a1b9660..174da13 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ieee80211_var.h,v 1.106 2021/10/11 09:01:06 stsp Exp $        */
+/*     $OpenBSD: ieee80211_var.h,v 1.107 2021/10/11 09:02:01 stsp Exp $        */
 /*     $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */
 
 /*-
@@ -246,6 +246,7 @@ struct ieee80211com {
        void                    (*ic_ampdu_rx_stop)(struct ieee80211com *,
                                    struct ieee80211_node *, u_int8_t);
        void                    (*ic_updateprot)(struct ieee80211com *);
+       void                    (*ic_updatechan)(struct ieee80211com *);
        int                     (*ic_bgscan_start)(struct ieee80211com *);
        struct timeout          ic_bgscan_timeout;
        uint32_t                ic_bgscan_fail;