]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Allow ACS channel list to be configured as frequencies (in MHz)
authorAnkita Bajaj <bankita@codeaurora.org>
Tue, 26 Nov 2019 05:49:32 +0000 (11:19 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 20 Dec 2019 11:19:52 +0000 (13:19 +0200)
The channel numbers are duplicated between 2.4 GHz / 5 GHz bands and 6
GHz band. Hence, add support to configure a list of frequencies to ACS
(freqlist) instead of a list of channel numbers (chanlist). Also, both 5
GHz and 6 GHz channels are referred by HOSTAPD_MODE_IEEE80211A. The 6
GHz channels alone can be configured by using both mode and frequency
list.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.c
src/ap/ap_config.h
src/ap/ap_drv_ops.c

index 25dc1fade7dc7d90358e5f0cd3d444072871742f..e489ec706d00d17c61ea4531ccd9b5cc925165c2 100644 (file)
@@ -3162,6 +3162,13 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                                   line);
                        return 1;
                }
+       } else if (os_strcmp(buf, "freqlist") == 0) {
+               if (freq_range_list_parse(&conf->acs_freq_list, pos)) {
+                       wpa_printf(MSG_ERROR, "Line %d: invalid frequency list",
+                                  line);
+                       return 1;
+               }
+               conf->acs_freq_list_present = 1;
        } else if (os_strcmp(buf, "beacon_int") == 0) {
                int val = atoi(pos);
                /* MIB defines range as 1..65535, but very small values
index 4cbe45190a4951afb0a813870058626f24456a8f..591386311a48730144c56753c4167d96195e5cbf 100644 (file)
@@ -205,6 +205,14 @@ channel=1
 #chanlist=100 104 108 112 116
 #chanlist=1 6 11-13
 
+# Frequency list restriction. This option allows hostapd to select one of the
+# provided frequencies when a frequency should be automatically selected.
+# Frequency list can be provided as range using hyphen ('-') or individual
+# frequencies can be specified by comma (',') separated values
+# Default: all frequencies allowed in selected hw_mode
+#freqlist=2437,5945,5965
+#freqlist=2437,5985-6105
+
 # Exclude DFS channels from ACS
 # This option can be used to exclude all DFS channels from the ACS channel list
 # in cases where the driver supports DFS channels.
index 70829679d9f86040521dcc0e521cf1166a237eda..68af3c1d167dcb648ae3179ad7188e12280ab0d5 100644 (file)
@@ -936,6 +936,7 @@ void hostapd_config_free(struct hostapd_config *conf)
        os_free(conf->supported_rates);
        os_free(conf->basic_rates);
        os_free(conf->acs_ch_list.range);
+       os_free(conf->acs_freq_list.range);
        os_free(conf->driver_params);
 #ifdef CONFIG_ACS
        os_free(conf->acs_chan_bias);
index 23416c6ebf332a44eb87c3a61bebd26eb7150b4e..a3b9b5d50697f8fceeb76890e8ee029e50a9e89e 100644 (file)
@@ -882,6 +882,8 @@ struct hostapd_config {
        u8 edmg_channel;
        u8 acs;
        struct wpa_freq_range_list acs_ch_list;
+       struct wpa_freq_range_list acs_freq_list;
+       u8 acs_freq_list_present;
        int acs_exclude_dfs;
        enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
        enum {
index 991e9ad62232d2cbbda5b83b306857589fedf150..bcacf8cc320582f4b216086bf95ea6115b3cb126 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "utils/common.h"
 #include "common/ieee802_11_defs.h"
+#include "common/ieee802_11_common.h"
 #include "common/hw_features_common.h"
 #include "wps/wps.h"
 #include "p2p/p2p.h"
@@ -855,10 +856,20 @@ static void hostapd_get_hw_mode_any_channels(struct hostapd_data *hapd,
        for (i = 0; i < mode->num_channels; i++) {
                struct hostapd_channel_data *chan = &mode->channels[i];
 
-               if ((acs_ch_list_all ||
-                    freq_range_list_includes(&hapd->iface->conf->acs_ch_list,
-                                             chan->chan)) &&
-                   !(chan->flag & HOSTAPD_CHAN_DISABLED) &&
+               if (!acs_ch_list_all &&
+                   (hapd->iface->conf->acs_freq_list.num &&
+                    !freq_range_list_includes(
+                            &hapd->iface->conf->acs_freq_list,
+                            chan->freq)))
+                       continue;
+               if (!acs_ch_list_all &&
+                   (!hapd->iface->conf->acs_freq_list_present &&
+                    hapd->iface->conf->acs_ch_list.num &&
+                    !freq_range_list_includes(
+                            &hapd->iface->conf->acs_ch_list,
+                            chan->chan)))
+                       continue;
+               if (!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
                    !(hapd->iface->conf->acs_exclude_dfs &&
                      (chan->flag & HOSTAPD_CHAN_RADAR)))
                        int_array_add_unique(freq_list, chan->freq);
@@ -898,8 +909,10 @@ int hostapd_drv_do_acs(struct hostapd_data *hapd)
         * If no chanlist config parameter is provided, include all enabled
         * channels of the selected hw_mode.
         */
-       if (!hapd->iface->conf->acs_ch_list.num)
-               acs_ch_list_all = 1;
+       if (hapd->iface->conf->acs_freq_list_present)
+               acs_ch_list_all = !hapd->iface->conf->acs_freq_list.num;
+       else
+               acs_ch_list_all = !hapd->iface->conf->acs_ch_list.num;
 
        if (hapd->iface->current_mode)
                selected_mode = hapd->iface->current_mode->mode;