]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Move punct_update_legacy_bw() into src/common
authorJouni Malinen <quic_jouni@quicinc.com>
Fri, 8 Mar 2024 08:10:41 +0000 (10:10 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 8 Mar 2024 08:13:12 +0000 (10:13 +0200)
This function is needed for more common operations so move it to a more
suitable location.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/ap/ieee802_11.c
src/ap/ieee802_11.h
src/ap/ieee802_11_he.c
src/ap/ieee802_11_vht.c
src/common/hw_features_common.c
src/common/hw_features_common.h

index 41508ff509c00959480347662bc908a4fd9d4cd2..77c4d30eee67d5c0bbaf3e6d4309a8de37ca1855 100644 (file)
@@ -8067,73 +8067,4 @@ u8 * hostapd_eid_mbssid(struct hostapd_data *hapd, u8 *eid, u8 *end,
        return eid;
 }
 
-
-static void punct_update_legacy_bw_80(u8 bitmap, u8 pri_chan, u8 *seg0)
-{
-       u8 first_chan = *seg0 - 6, sec_chan;
-
-       switch (bitmap) {
-       case 0x6:
-               *seg0 = 0;
-               return;
-       case 0x8:
-       case 0x4:
-       case 0x2:
-       case 0x1:
-       case 0xC:
-       case 0x3:
-               if (pri_chan < *seg0)
-                       *seg0 -= 4;
-               else
-                       *seg0 += 4;
-               break;
-       }
-
-       if (pri_chan < *seg0)
-               sec_chan = pri_chan + 4;
-       else
-               sec_chan = pri_chan - 4;
-
-       if (bitmap & BIT((sec_chan - first_chan) / 4))
-               *seg0 = 0;
-}
-
-
-static void punct_update_legacy_bw_160(u8 bitmap, u8 pri,
-                                      enum oper_chan_width *width, u8 *seg0)
-{
-       if (pri < *seg0) {
-               *seg0 -= 8;
-               if (bitmap & 0x0F) {
-                       *width = 0;
-                       punct_update_legacy_bw_80(bitmap & 0xF, pri, seg0);
-               }
-       } else {
-               *seg0 += 8;
-               if (bitmap & 0xF0) {
-                       *width = 0;
-                       punct_update_legacy_bw_80((bitmap & 0xF0) >> 4, pri,
-                                                 seg0);
-               }
-       }
-}
-
-
-void punct_update_legacy_bw(u16 bitmap, u8 pri, enum oper_chan_width *width,
-                           u8 *seg0, u8 *seg1)
-{
-       if (*width == CONF_OPER_CHWIDTH_80MHZ && (bitmap & 0xF)) {
-               *width = CONF_OPER_CHWIDTH_USE_HT;
-               punct_update_legacy_bw_80(bitmap & 0xF, pri, seg0);
-       }
-
-       if (*width == CONF_OPER_CHWIDTH_160MHZ && (bitmap & 0xFF)) {
-               *width = CONF_OPER_CHWIDTH_80MHZ;
-               *seg1 = 0;
-               punct_update_legacy_bw_160(bitmap & 0xFF, pri, width, seg0);
-       }
-
-       /* TODO: 320 MHz */
-}
-
 #endif /* CONFIG_NATIVE_WINDOWS */
index 5fd380a95512d4f3e48d7e4f523b72ab105e40b1..a35486d464061cd9aa27bec0651cbdf67f8de96d 100644 (file)
@@ -248,8 +248,6 @@ u8 * hostapd_eid_mbssid(struct hostapd_data *hapd, u8 *eid, u8 *end,
                        u8 **elem_offset,
                        const u8 *known_bss, size_t known_bss_len, u8 *rnr_eid,
                        u8 *rnr_count, u8 **rnr_offset, size_t rnr_len);
-void punct_update_legacy_bw(u16 bitmap, u8 pri_chan,
-                           enum oper_chan_width *width, u8 *seg0, u8 *seg1);
 bool hostapd_is_mld_ap(struct hostapd_data *hapd);
 const char * sae_get_password(struct hostapd_data *hapd,
                              struct sta_info *sta, const char *rx_id,
index 4b693a7c52526ab407162937f1d3fafba11b3448..3449326bef5d24546bb2b45be775bb58038412c7 100644 (file)
@@ -12,6 +12,7 @@
 #include "utils/common.h"
 #include "common/ieee802_11_defs.h"
 #include "common/ieee802_11_common.h"
+#include "common/hw_features_common.h"
 #include "hostapd.h"
 #include "ap_config.h"
 #include "beacon.h"
index e92851af98770708e6beb08a9ae6d6c570be5cd1..4dc325ce89bb731e92f9102201dfc8601e564841 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "utils/common.h"
 #include "common/ieee802_11_defs.h"
+#include "common/hw_features_common.h"
 #include "hostapd.h"
 #include "ap_config.h"
 #include "sta_info.h"
index ea547f7ea037a4e9f89fa96dea07d5e98637efd3..924370078ad86ec768844a49b1918507db563a30 100644 (file)
@@ -381,6 +381,75 @@ int check_40mhz_2g4(struct hostapd_hw_modes *mode,
 }
 
 
+static void punct_update_legacy_bw_80(u8 bitmap, u8 pri_chan, u8 *seg0)
+{
+       u8 first_chan = *seg0 - 6, sec_chan;
+
+       switch (bitmap) {
+       case 0x6:
+               *seg0 = 0;
+               return;
+       case 0x8:
+       case 0x4:
+       case 0x2:
+       case 0x1:
+       case 0xC:
+       case 0x3:
+               if (pri_chan < *seg0)
+                       *seg0 -= 4;
+               else
+                       *seg0 += 4;
+               break;
+       }
+
+       if (pri_chan < *seg0)
+               sec_chan = pri_chan + 4;
+       else
+               sec_chan = pri_chan - 4;
+
+       if (bitmap & BIT((sec_chan - first_chan) / 4))
+               *seg0 = 0;
+}
+
+
+static void punct_update_legacy_bw_160(u8 bitmap, u8 pri,
+                                      enum oper_chan_width *width, u8 *seg0)
+{
+       if (pri < *seg0) {
+               *seg0 -= 8;
+               if (bitmap & 0x0F) {
+                       *width = 0;
+                       punct_update_legacy_bw_80(bitmap & 0xF, pri, seg0);
+               }
+       } else {
+               *seg0 += 8;
+               if (bitmap & 0xF0) {
+                       *width = 0;
+                       punct_update_legacy_bw_80((bitmap & 0xF0) >> 4, pri,
+                                                 seg0);
+               }
+       }
+}
+
+
+void punct_update_legacy_bw(u16 bitmap, u8 pri, enum oper_chan_width *width,
+                           u8 *seg0, u8 *seg1)
+{
+       if (*width == CONF_OPER_CHWIDTH_80MHZ && (bitmap & 0xF)) {
+               *width = CONF_OPER_CHWIDTH_USE_HT;
+               punct_update_legacy_bw_80(bitmap & 0xF, pri, seg0);
+       }
+
+       if (*width == CONF_OPER_CHWIDTH_160MHZ && (bitmap & 0xFF)) {
+               *width = CONF_OPER_CHWIDTH_80MHZ;
+               *seg1 = 0;
+               punct_update_legacy_bw_160(bitmap & 0xFF, pri, width, seg0);
+       }
+
+       /* TODO: 320 MHz */
+}
+
+
 int hostapd_set_freq_params(struct hostapd_freq_params *data,
                            enum hostapd_hw_mode mode,
                            int freq, int channel, int enable_edmg,
index 8ce31e4f01e127aee6894c03282fda85bcdaab10..e791c33f1736ef836d8a2266a73239f63a6c2d52 100644 (file)
@@ -35,6 +35,8 @@ int check_40mhz_5g(struct wpa_scan_results *scan_res,
 int check_40mhz_2g4(struct hostapd_hw_modes *mode,
                    struct wpa_scan_results *scan_res, int pri_chan,
                    int sec_chan);
+void punct_update_legacy_bw(u16 bitmap, u8 pri_chan,
+                           enum oper_chan_width *width, u8 *seg0, u8 *seg1);
 int hostapd_set_freq_params(struct hostapd_freq_params *data,
                            enum hostapd_hw_mode mode,
                            int freq, int channel, int edmg, u8 edmg_channel,