]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Select a valid secondary channel if both enabled
authorPeng Xu <pxu@qti.qualcomm.com>
Fri, 21 Apr 2017 00:05:25 +0000 (17:05 -0700)
committerJouni Malinen <j@w1.fi>
Sat, 29 Apr 2017 13:35:23 +0000 (16:35 +0300)
When starting AP in HT40 mode and both HT40+ and HT40- options are
specified in hostapd.conf, select a valid secondary channel for the AP
automatically.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hostapd/config_file.c
src/ap/ap_config.h
src/ap/hw_features.c

index 7b438060541f81c85ac5064632659cc023a70c2d..d4d0c92c9f8b1c1f099f05c1050ff14894965916 100644 (file)
@@ -1106,6 +1106,10 @@ static int hostapd_config_ht_capab(struct hostapd_config *conf,
                conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
                conf->secondary_channel = 1;
        }
+       if (os_strstr(capab, "[HT40+]") && os_strstr(capab, "[HT40-]")) {
+               conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
+               conf->ht40_plus_minus_allowed = 1;
+       }
        if (os_strstr(capab, "[SMPS-STATIC]")) {
                conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
                conf->ht_capab |= HT_CAP_INFO_SMPS_STATIC;
index 989b07107c9a2abe40a3828fb3ae043d59978743..498891c5471d649def8538745eb95b0ea3ba2e20 100644 (file)
@@ -724,6 +724,7 @@ struct hostapd_config {
        u8 vht_oper_chwidth;
        u8 vht_oper_centr_freq_seg0_idx;
        u8 vht_oper_centr_freq_seg1_idx;
+       u8 ht40_plus_minus_allowed;
 
        /* Use driver-generated interface addresses when adding multiple BSSs */
        u8 use_driver_iface_addr;
index 93d923af51970dd8ae36f702e1a02547c2fd6b5b..c677d30f4781cbf576e5d4a851c45aaab2c894be 100644 (file)
@@ -722,14 +722,33 @@ static int hostapd_is_usable_chan(struct hostapd_iface *iface,
 
 static int hostapd_is_usable_chans(struct hostapd_iface *iface)
 {
+       int secondary_chan;
+
        if (!hostapd_is_usable_chan(iface, iface->conf->channel, 1))
                return 0;
 
        if (!iface->conf->secondary_channel)
                return 1;
 
-       return hostapd_is_usable_chan(iface, iface->conf->channel +
-                                     iface->conf->secondary_channel * 4, 0);
+       if (!iface->conf->ht40_plus_minus_allowed)
+               return hostapd_is_usable_chan(
+                       iface, iface->conf->channel +
+                       iface->conf->secondary_channel * 4, 0);
+
+       /* Both HT40+ and HT40- are set, pick a valid secondary channel */
+       secondary_chan = iface->conf->channel + 4;
+       if (hostapd_is_usable_chan(iface, secondary_chan, 0)) {
+               iface->conf->secondary_channel = 1;
+               return 1;
+       }
+
+       secondary_chan = iface->conf->channel - 4;
+       if (hostapd_is_usable_chan(iface, secondary_chan, 0)) {
+               iface->conf->secondary_channel = -1;
+               return 1;
+       }
+
+       return 0;
 }