From cf2cd3c648a19143a4754bd7c25b8a317b319023 Mon Sep 17 00:00:00 2001
From: Alan Young <consult.awy@gmail.com>
Date: Thu, 11 Nov 2021 16:40:05 +0000
Subject: [PATCH] ACS, DFS: Support min_tx_power configuration
If min_tx_power is specified (default 0 dBm) then 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 | 9 +++++++++
hostapd/hostapd.conf | 4 ++++
src/ap/acs.c | 9 +++++++++
src/ap/ap_config.c | 1 +
src/ap/ap_config.h | 1 +
src/ap/ap_drv_ops.c | 3 ++-
src/ap/dfs.c | 3 +++
7 files changed, 29 insertions(+), 1 deletion(-)
@@ -3193,6 +3193,15 @@ 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
@@ -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 & DFS channel selection.
+# (default 0)
+# min_tx_power=20
+
# Beacon interval in kus (1.024 ms) (default: 100; range 15..65535)
beacon_int=100
@@ -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;
}
@@ -262,6 +262,7 @@ struct hostapd_config * hostapd_config_defaults(void)
conf->acs = 0;
conf->acs_ch_list.num = 0;
+ conf->min_tx_power = 0;
#ifdef CONFIG_ACS
conf->acs_num_scans = 5;
#endif /* CONFIG_ACS */
@@ -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 {
@@ -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);
}
}
@@ -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);
--
2.25.1