[PATCH 1/2]: add "count" argument to bss ctrl interface command

Kel Modderman kel
Thu Jan 31 20:59:32 PST 2008


Add a count argument to the bss ctrl interface command that returns the number
of BSSID's in the current scan results to the caller.

This is useful for clients that wish to iterate through the scan results, as it
gives them a finite amount of iterations that they should perform.

If this is ok, I will update the docs too, but didn't worry about that yet in
case of NAK.

Signed-off-by: Kel Modderman <kel at otaku42.de>
---
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -1225,6 +1225,7 @@
 	u8 bssid[ETH_ALEN];
 	int next = 0;
 	int first = 0;
+	int count = 0;
 	size_t i;
 	struct wpa_scan_results *results;
 	struct wpa_scan_res *bss;
@@ -1232,7 +1233,9 @@
 	char *pos, *end;
 	const u8 *ie, *ie2;
 
-	if (os_strcmp(cmd, "first") == 0) {
+	if (os_strcmp(cmd, "count") == 0) {
+		count = 1;
+	} else if (os_strcmp(cmd, "first") == 0) {
 		first = 1;
 	} else if (os_strncmp(cmd, "next ", 5) == 0) {
 		next = 1;
@@ -1247,6 +1250,16 @@
 	if (results == NULL)
 		return 0;
 
+	if (count) {
+		pos = buf;
+		end = buf + buflen;
+		ret = snprintf(pos, end - pos, "%d\n", results->num);
+		if (ret < 0 || ret >= end - pos)
+			return pos - buf;
+		pos += ret;
+		return pos - buf;
+	}
+
 	for (i = 0; i < results->num; i++) {
 		if (first)
 			break;
---




More information about the Hostap mailing list