From 26ad0be4f9dd70bcac7587e943eb64f05a2cbb36 Mon Sep 17 00:00:00 2001 From: Andrei Otcheretianski Date: Thu, 21 Dec 2023 08:49:32 +0200 Subject: [PATCH] AP: Allow hex format for puncturing bitmap It is much more convinient to specify the bitmap as a hex value. Allow it. Signed-off-by: Andrei Otcheretianski --- hostapd/config_file.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 1127d74f0..187e98813 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -2344,6 +2344,24 @@ static int get_hex_config(u8 *buf, size_t max_len, int line, } +#ifdef CONFIG_IEEE80211BE +static int get_u16(const char *pos, int line, u16 *ret_val) +{ + char *end; + long int val = strtol(pos, &end, 0); + + if (*end || val < 0 || val > 0xffff) { + wpa_printf(MSG_ERROR, "Line %d: Invalid value '%s'", + line, pos); + return -1; + } + + *ret_val = val; + return 0; +} +#endif /* CONFIG_IEEE80211BE */ + + static int hostapd_config_fill(struct hostapd_config *conf, struct hostapd_bss_config *bss, const char *buf, char *pos, int line) @@ -4809,7 +4827,8 @@ static int hostapd_config_fill(struct hostapd_config *conf, } else if (os_strcmp(buf, "eht_default_pe_duration") == 0) { conf->eht_default_pe_duration = atoi(pos); } else if (os_strcmp(buf, "punct_bitmap") == 0) { - conf->punct_bitmap = atoi(pos); + if (get_u16(pos, line, &conf->punct_bitmap)) + return 1; } else if (os_strcmp(buf, "punct_acs_threshold") == 0) { int val = atoi(pos);