]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ACS: Determine mode when using hw_mode=any
authorNeo Jou <neojou@gmail.com>
Mon, 13 Jan 2020 08:31:28 +0000 (16:31 +0800)
committerJouni Malinen <j@w1.fi>
Sat, 29 Feb 2020 09:23:03 +0000 (11:23 +0200)
Set iface->current_mode and iface->conf->hw_mode when completing ACS
based on the selected channel in the hw_mode=any case.

Signed-off-by: Neo Jou <neojou@gmail.com>
src/ap/hw_features.c

index f550bfe5e4927dcc5408be2d4af0dde9955ffab7..72de45cac4b3a799c44d0fa9946d0155acf7b673 100644 (file)
@@ -879,10 +879,43 @@ static int hostapd_is_usable_chans(struct hostapd_iface *iface)
 }
 
 
+static void hostapd_determine_mode(struct hostapd_iface *iface)
+{
+       int i;
+       enum hostapd_hw_mode target_mode;
+
+       if (iface->current_mode ||
+           iface->conf->hw_mode != HOSTAPD_MODE_IEEE80211ANY)
+               return;
+
+       if (iface->freq < 4000)
+               target_mode = HOSTAPD_MODE_IEEE80211G;
+       else if (iface->freq > 50000)
+               target_mode = HOSTAPD_MODE_IEEE80211AD;
+       else
+               target_mode = HOSTAPD_MODE_IEEE80211A;
+
+       for (i = 0; i < iface->num_hw_features; i++) {
+               struct hostapd_hw_modes *mode;
+
+               mode = &iface->hw_features[i];
+               if (mode->mode == target_mode) {
+                       iface->current_mode = mode;
+                       iface->conf->hw_mode = mode->mode;
+                       break;
+               }
+       }
+
+       if (!iface->current_mode)
+               wpa_printf(MSG_ERROR, "ACS: Cannot decide mode");
+}
+
+
 static enum hostapd_chan_status
 hostapd_check_chans(struct hostapd_iface *iface)
 {
        if (iface->freq) {
+               hostapd_determine_mode(iface);
                if (hostapd_is_usable_chans(iface))
                        return HOSTAPD_CHAN_VALID;
                else