[PATCH 2/2] Add get function for global freq_list value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Clemens Famulla-Conrad <cfamullaconrad@xxxxxxxx>
---
 wpa_supplicant/config.c | 51 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 277bf2305..8b3430588 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -1417,6 +1417,27 @@ static int * wpa_config_parse_int_array(const char *value)
 	return freqs;
 }
 
+static int wpa_config_print_int_array(char *buf, size_t buflen, int *array)
+{
+	int res, tmp;
+
+	if (!array)
+		return -1;
+
+	res = 0;
+	for (;*array != 0; array++) {
+		tmp = os_snprintf(buf + res, buflen - res, "%d ", *array);
+		if (os_snprintf_error(buflen - res, tmp))
+			return -1;
+
+		res += tmp;
+	}
+	/* strip last space */
+	if (res > 0)
+		buf[--res] = '\0';
+
+	return res;
+}
 
 static int wpa_config_parse_scan_freq(const struct parse_data *data,
 				      struct wpa_ssid *ssid, int line,
@@ -5059,6 +5080,34 @@ static int wpa_config_get_bgscan (const char *name, struct wpa_config *config, l
 	return res;
 }
 
+static int wpa_config_get_freq_list (const char *name, struct wpa_config *config, long offset,
+		   char *buf, size_t buflen, int pretty_print)
+{
+	int **val = (int **) (((u8 *) config) + (long) offset);
+	int res, tmp;
+
+	if (pretty_print) {
+		if (*val) {
+			res = os_snprintf(buf, buflen, "%s=\n", name);
+			if (os_snprintf_error(buflen, res))
+				return -1;
+
+			if ((tmp = wpa_config_print_int_array(buf + res, buflen - res, *val)) == -1)
+				return -1;
+			res += tmp;
+		} else
+			res = os_snprintf(buf, buflen, "%s=null\n", name);
+
+	}else if (!*val)
+		return -1;
+	else
+		res = wpa_config_print_int_array(buf, buflen, *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,
@@ -5232,7 +5281,7 @@ static const struct global_parse_data global_fields[] = {
 	{ FUNC(ap_assocresp_elements), 0 },
 	{ FUNC(ap_vendor_elements), 0 },
 	{ INT_RANGE(ignore_old_scan_res, 0, 1), 0 },
-	{ FUNC(freq_list), 0 },
+	{ FUNC_WITH_GET(freq_list), 0 },
 	{ FUNC(initial_freq_list), 0},
 	{ INT(scan_cur_freq), 0 },
 	{ INT(scan_res_valid_for_connect), 0},
-- 
2.49.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux