]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ACS/DFS: Support min_tx_power configuration
authorAlan Young <consult.awy@gmail.com>
Thu, 11 Nov 2021 16:40:05 +0000 (16:40 +0000)
committerJouni Malinen <j@w1.fi>
Sun, 12 Dec 2021 20:20:18 +0000 (22:20 +0200)
If min_tx_power is specified (default 0 dBm, i.e., no constraint), ACS
and DFS will not consider channels whose available max_tx_power is less
than the configured value.

This may be useful to exclude SRD (Short Range Device) channels which
may be limited to 13.9 dBm (25 mW) in some regulatory domains.

Signed-off-by: Alan Young <consult.awy@gmail.com>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/acs.c
src/ap/ap_config.h
src/ap/ap_drv_ops.c
src/ap/dfs.c

index daf3f37ad99e73cc52601b299b7c338afec823ea..b14728d1b507df65bc936b1ecf706f70c0e19ce8 100644 (file)
@@ -3193,6 +3193,16 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                conf->acs_freq_list_present = 1;
        } else if (os_strcmp(buf, "acs_exclude_6ghz_non_psc") == 0) {
                conf->acs_exclude_6ghz_non_psc = atoi(pos);
+       } else if (os_strcmp(buf, "min_tx_power") == 0) {
+               int val = atoi(pos);
+
+               if (val < 0 || val > 255) {
+                       wpa_printf(MSG_ERROR,
+                                  "Line %d: invalid min_tx_power %d (expected 0..255)",
+                                  line, val);
+                       return 1;
+               }
+               conf->min_tx_power = val;
        } else if (os_strcmp(buf, "beacon_int") == 0) {
                int val = atoi(pos);
                /* MIB defines range as 1..65535, but very small values
index 67d4cefb920b6a65ff04b1760523a7fd301872cc..3c2019f730485f4047566a95fd4eb8230cbfb4db 100644 (file)
@@ -225,6 +225,10 @@ channel=1
 # Default behavior is to include all PSC and non-PSC channels.
 #acs_exclude_6ghz_non_psc=1
 
+# Set minimum permitted max TX power (in dBm) for ACS and DFS channel selection.
+# (default 0, i.e., not constraint)
+#min_tx_power=20
+
 # Beacon interval in kus (1.024 ms) (default: 100; range 15..65535)
 beacon_int=100
 
index 46429f26543333961e6b1acfa9f999750ea56028..0030edc2a90f1271bb9d8d690dbf3d01bf39499b 100644 (file)
@@ -546,6 +546,9 @@ static void acs_survey_mode_interference_factor(
                if (!is_in_freqlist(iface, chan))
                        continue;
 
+               if (chan->max_tx_power < iface->conf->min_tx_power)
+                       continue;
+
                wpa_printf(MSG_DEBUG, "ACS: Survey analysis for channel %d (%d MHz)",
                           chan->chan, chan->freq);
 
@@ -673,6 +676,9 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
                if (!is_in_freqlist(iface, chan))
                        continue;
 
+               if (chan->max_tx_power < iface->conf->min_tx_power)
+                       continue;
+
                if (!chan_bw_allowed(chan, bw, 1, 1)) {
                        wpa_printf(MSG_DEBUG,
                                   "ACS: Channel %d: BW %u is not supported",
@@ -1047,6 +1053,9 @@ static int * acs_request_scan_add_freqs(struct hostapd_iface *iface,
                if (!is_in_freqlist(iface, chan))
                        continue;
 
+               if (chan->max_tx_power < iface->conf->min_tx_power)
+                       continue;
+
                *freq++ = chan->freq;
        }
 
index b8f791e56307ae13cd4b188f2f487eeb21e173a6..20e2afe2428f5e027fc3c878af4f1dc4519a8513 100644 (file)
@@ -953,6 +953,7 @@ struct hostapd_config {
        struct wpa_freq_range_list acs_freq_list;
        u8 acs_freq_list_present;
        int acs_exclude_dfs;
+       u8 min_tx_power;
        enum hostapd_hw_mode hw_mode; /* HOSTAPD_MODE_IEEE80211A, .. */
        int acs_exclude_6ghz_non_psc;
        enum {
index d1642d7dff1595feeeb814cc4ff83b239df2432a..e917736664bda196765fa989f13ec19ea2c7f961 100644 (file)
@@ -888,7 +888,8 @@ static void hostapd_get_hw_mode_any_channels(struct hostapd_data *hapd,
                        continue;
                if (!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
                    !(hapd->iface->conf->acs_exclude_dfs &&
-                     (chan->flag & HOSTAPD_CHAN_RADAR)))
+                     (chan->flag & HOSTAPD_CHAN_RADAR)) &&
+                   !(chan->max_tx_power < hapd->iface->conf->min_tx_power))
                        int_array_add_unique(freq_list, chan->freq);
        }
 }
index 03c99b175215ca352c98dcb2030122fce688b675..5c99ecfd017ecffe19856f40bcce6a07570ff429 100644 (file)
@@ -246,6 +246,9 @@ static int dfs_find_channel(struct hostapd_iface *iface,
                        continue;
                }
 
+               if (chan->max_tx_power < iface->conf->min_tx_power)
+                       continue;
+
                if (ret_chan && idx == channel_idx) {
                        wpa_printf(MSG_DEBUG, "Selected channel %d (%d)",
                                   chan->freq, chan->chan);