[PATCH 1/2]: wpa_gui-qt4: get bssid count before iterating through scan results

Kel Modderman kel at otaku42.de
Fri Feb 1 00:04:39 EST 2008


Use the new "BSS count" ctrl interface command to determine upper limit of
how many bssid's are expected to be in the scan results.

When iterating through scan results in a loop, break when the amount of results
processed is equal to the upper limit.

Signed-off-by: Kel Modderman <kel at otaku42.de>
---
--- a/wpa_supplicant/wpa_gui-qt4/scanresults.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/scanresults.cpp
@@ -56,9 +56,25 @@
 {
 	char reply[2048];
 	size_t reply_len;
+	int bss_count = 0;
+	int bss_num = 0;
     
 	scanResultsWidget->clear();
-	QString cmd("BSS first");
+
+	QString cmd("BSS count");
+
+	reply_len = sizeof(reply) - 1;
+	if (wpagui->ctrlRequest(cmd.toAscii().constData(), reply, &reply_len)
+	    >= 0) {
+		reply[reply_len] = '\0';
+		if (memcmp(reply, "FAIL", 4) != 0)
+			bss_count = atoi(reply);
+	}
+
+	if (bss_count < 1)
+		return;
+
+	cmd = "BSS first";
 
 	while (wpagui) {
 		reply_len = sizeof(reply) - 1;
@@ -104,6 +120,10 @@
 		if (bssid.isEmpty())
 			break;
 
+		bss_num++;
+		if (bss_num == bss_count)
+			break;
+
 		cmd = "BSS next ";
 		cmd.append(bssid);
 	}
---


More information about the HostAP mailing list