aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-02-06 03:36:30 (GMT)
committerJouni Malinen <j@w1.fi>2008-02-06 03:36:30 (GMT)
commit02602c237d709b9eeef2f49e39436e93c24b1ce6 (patch)
treea3eeab6f5a20befe024282df6a5a61363a440a00
parent07f0b45bcee7c2391a6559284a0c57459b37c3b5 (diff)
downloadhostap-history-02602c237d709b9eeef2f49e39436e93c24b1ce6.zip
hostap-history-02602c237d709b9eeef2f49e39436e93c24b1ce6.tar.gz
hostap-history-02602c237d709b9eeef2f49e39436e93c24b1ce6.tar.bz2
Replaced BSS first/next commands with BSS idx to avoid infinite loops
If the scan results included the same BSSID multiple times (e.g., from multi-band APs that do not have a separate BSSID for each band), the scan result iteration with "BSS first" and "BSS next <BSSID>" would end up in an infinite loop. The new mechanism uses a simpler design that iterates through the results using and index number for the BSS in the scan result array.
-rw-r--r--wpa_supplicant/ctrl_iface.c30
-rw-r--r--wpa_supplicant/doc/ctrl_iface.doxygen11
-rw-r--r--wpa_supplicant/wpa_cli.c12
-rw-r--r--wpa_supplicant/wpa_gui-qt4/scanresults.cpp16
4 files changed, 26 insertions, 43 deletions
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 498c456..d63aa5a 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -1226,8 +1226,6 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
size_t buflen)
{
u8 bssid[ETH_ALEN];
- int next = 0;
- int first = 0;
size_t i;
struct wpa_scan_results *results;
struct wpa_scan_res *bss;
@@ -1235,34 +1233,20 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
char *pos, *end;
const u8 *ie, *ie2;
- if (os_strcmp(cmd, "first") == 0) {
- first = 1;
- } else if (os_strncmp(cmd, "next ", 5) == 0) {
- next = 1;
- if (hwaddr_aton(cmd + 5, bssid))
- return -1;
- } else {
- if (hwaddr_aton(cmd, bssid))
- return -1;
- }
-
results = wpa_s->scan_res;
if (results == NULL)
return 0;
- for (i = 0; i < results->num; i++) {
- if (first)
- break;
-
- if (os_memcmp(bssid, results->res[i]->bssid, ETH_ALEN) == 0) {
- if (next)
- first = 1; /* pick next */
- else
+ if (hwaddr_aton(cmd, bssid) == 0) {
+ for (i = 0; i < results->num; i++) {
+ if (os_memcmp(bssid, results->res[i]->bssid, ETH_ALEN)
+ == 0)
break;
}
- }
+ } else
+ i = atoi(cmd);
- if (i >= results->num)
+ if (i >= results->num || results->res[i] == NULL)
return 0; /* no match found */
bss = results->res[i];
diff --git a/wpa_supplicant/doc/ctrl_iface.doxygen b/wpa_supplicant/doc/ctrl_iface.doxygen
index 2305c55..e908e0f 100644
--- a/wpa_supplicant/doc/ctrl_iface.doxygen
+++ b/wpa_supplicant/doc/ctrl_iface.doxygen
@@ -293,12 +293,11 @@ data that is available through \c SCAN_RESULTS but in a way that
avoids problems with large number of scan results not fitting in the
ctrl_iface messages.
-There are three subcommands for the \c BSS command: "BSS first"
-requests information for the first BSS in the scan results table, "BSS
-<BSSID>" requests information for the given BSS (based on BSSID in
-00:01:02:03:04:05 format), and "BSS next <previous BSSID>" requests
-information for the BSS following the specified BSS (to allow
-iteration through the scan results).
+There are two options for selecting the BSS with the \c BSS command:
+"BSS <idx>" requests information for the BSS identified by the index
+(0 .. size-1) in the scan results table and "BSS <BSSID>" requests
+information for the given BSS (based on BSSID in 00:01:02:03:04:05
+format).
BSS information is presented in following format. Please note that new
fields may be added to this field=value data, so the ctrl_iface user
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index c23afd2..bbe67f0 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -126,7 +126,7 @@ static const char *commands_help =
"disconnected\n"
" scan = request new BSS scan\n"
" scan_results = get latest scan results\n"
-" bss <<first> | <bssid> | <next bssid>> = get detailed scan result info\n"
+" bss <<idx> | <bssid>> = get detailed scan result info\n"
" get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> = "
"get capabilies\n"
" ap_scan <value> = set ap_scan parameter\n"
@@ -900,15 +900,13 @@ static int wpa_cli_cmd_bss(struct wpa_ctrl *ctrl, int argc, char *argv[])
char cmd[64];
int res;
- if (argc < 1 || argc > 2) {
- printf("Invalid BSS command: need either one or two "
- "arguments\n");
+ if (argc != 1) {
+ printf("Invalid BSS command: need one argument (index or "
+ "BSSID)\n");
return -1;
}
- res = os_snprintf(cmd, sizeof(cmd), "BSS %s%s%s", argv[0],
- (argc == 2) ? " " : "",
- (argc == 2) ? argv[1] : "");
+ res = os_snprintf(cmd, sizeof(cmd), "BSS %s", argv[0]);
if (res < 0 || (size_t) res >= sizeof(cmd))
return -1;
cmd[sizeof(cmd) - 1] = '\0';
diff --git a/wpa_supplicant/wpa_gui-qt4/scanresults.cpp b/wpa_supplicant/wpa_gui-qt4/scanresults.cpp
index 870ba0f..bceef8a 100644
--- a/wpa_supplicant/wpa_gui-qt4/scanresults.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/scanresults.cpp
@@ -56,14 +56,19 @@ void ScanResults::updateResults()
{
char reply[2048];
size_t reply_len;
-
+ int index;
+ char cmd[20];
+
scanResultsWidget->clear();
- QString cmd("BSS first");
+ index = 0;
while (wpagui) {
+ snprintf(cmd, sizeof(cmd), "BSS %d", index++);
+ if (index > 1000)
+ break;
+
reply_len = sizeof(reply) - 1;
- if (wpagui->ctrlRequest(cmd.toAscii().constData(), reply,
- &reply_len) < 0)
+ if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0)
break;
reply[reply_len] = '\0';
@@ -103,9 +108,6 @@ void ScanResults::updateResults()
if (bssid.isEmpty())
break;
-
- cmd = "BSS next ";
- cmd.append(bssid);
}
}