From: Clemens Famulla-Conrad Date: Thu, 24 Jul 2025 16:03:59 +0000 (+0200) Subject: Add get function for global bgscan value X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=096b61bcf0f2f462c3587d74a5a8f24f747033b0;p=thirdparty%2Fhostap.git Add get function for global bgscan value Add a get() function for the global bgscan configuration value. This allow `wpa_cli dump` and `wpa_cli get bgscan` return the current value. If the value isn't set, the `wpa_cli dump` will output "bgscan=null" and `wpa_cli get bgscan` will fail, similar to STR() values. Signed-off-by: Clemens Famulla-Conrad --- diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index a0f71cfc6..0fead1f69 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -5429,6 +5429,31 @@ static int wpa_config_get_str(const char *name, struct wpa_config *config, } +static int wpa_config_get_bgscan(const char *name, struct wpa_config *config, + long offset, char *buf, size_t buflen, + int pretty_print) +{ + char **val = (char **) (((u8 *) config) + (long) offset); + int res; + + if (pretty_print) { + if (*val) + res = os_snprintf(buf, buflen, "%s=\"%s\"\n", name, + *val); + else + res = os_snprintf(buf, buflen, "%s=null\n", name); + } else if (!*val) { + return -1; + } else { + res = os_snprintf(buf, buflen, "\"%s\"", *val); + } + if (os_snprintf_error(buflen, res)) + res = -1; + + return res; +} + + #ifdef CONFIG_P2P static int wpa_config_get_ipv4(const char *name, struct wpa_config *config, long offset, char *buf, size_t buflen, @@ -5478,6 +5503,8 @@ static int wpa_config_process_mld_connect_bssid_pref( #define OFFSET(v) ((void *) &((struct wpa_config *) 0)->v) #define FUNC(f) #f, wpa_config_process_ ## f, NULL, OFFSET(f), NULL, NULL +#define FUNC_WITH_GET(f) #f, wpa_config_process_ ## f, wpa_config_get_ ## f, \ + OFFSET(f), NULL, NULL #define FUNC_NO_VAR(f) #f, wpa_config_process_ ## f, NULL, NULL, NULL, NULL #define _INT(f) #f, wpa_global_config_parse_int, wpa_config_get_int, OFFSET(f) #define INT(f) _INT(f), NULL, NULL @@ -5504,7 +5531,7 @@ static const struct global_parse_data global_fields[] = { { INT_RANGE(eapol_version, 1, 2), 0 }, #endif /* CONFIG_MACSEC */ { INT(ap_scan), 0 }, - { FUNC(bgscan), CFG_CHANGED_BGSCAN }, + { FUNC_WITH_GET(bgscan), CFG_CHANGED_BGSCAN }, #ifdef CONFIG_MESH { INT(user_mpm), 0 }, { INT_RANGE(max_peer_links, 0, 255), 0 },