diff mbox series

[3/5] AP: Allow hex format for puncturing bitmap

Message ID 20231221064934.3887910-3-andrei.otcheretianski@intel.com
State Accepted
Headers show
Series None | expand

Commit Message

Andrei Otcheretianski Dec. 21, 2023, 6:49 a.m. UTC
It is much more convinient to specify the bitmap as a hex value.
Allow it.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 hostapd/config_file.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 1a49292b11..3d356e617a 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4768,8 +4768,20 @@  static int hostapd_config_fill(struct hostapd_config *conf,
 		conf->eht_phy_capab.mu_beamformer = atoi(pos);
 	} 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);
+#define PARSE_FORCE_U16(_config, _val)				\
+	} else if (os_strcmp(buf, #_val) == 0) {		\
+		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;				\
+		}						\
+								\
+		_config->_val = val;
+	PARSE_FORCE_U16(conf, punct_bitmap)
 	} else if (os_strcmp(buf, "punct_acs_threshold") == 0) {
 		int val = atoi(pos);