]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_cli: Fetch the current BSSID list when starting interactive mode
authorJouni Malinen <j@w1.fi>
Sun, 5 May 2013 09:38:55 +0000 (12:38 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 5 May 2013 09:38:55 +0000 (12:38 +0300)
This makes tab completion work better in cases where wpa_cli is started
after wpa_supplicant has already discovered BSSes.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/wpa_cli.c

index 47a596e95627f037eb371a00838047f2c2f61ec3..d2d5dd9f93507973841404b5f1ddcbae44aec55a 100644 (file)
@@ -3289,6 +3289,37 @@ static void start_edit(void)
 }
 
 
+static void update_bssid_list(struct wpa_ctrl *ctrl)
+{
+       char buf[4096];
+       size_t len = sizeof(buf);
+       int ret;
+       char *cmd = "BSS RANGE=ALL MASK=0x2";
+       char *pos, *end;
+
+       if (ctrl == NULL)
+               return;
+       ret = wpa_ctrl_request(ctrl, cmd, os_strlen(cmd), buf, &len, NULL);
+       if (ret < 0)
+               return;
+       buf[len] = '\0';
+
+       pos = buf;
+       while (pos) {
+               pos = os_strstr(pos, "bssid=");
+               if (pos == NULL)
+                       break;
+               pos += 6;
+               end = os_strchr(pos, '\n');
+               if (end == NULL)
+                       break;
+               *end = '\0';
+               cli_txt_list_add(&bsses, pos);
+               pos = end + 1;
+       }
+}
+
+
 static void try_connection(void *eloop_ctx, void *timeout_ctx)
 {
        if (ctrl_ifname == NULL)
@@ -3304,6 +3335,8 @@ static void try_connection(void *eloop_ctx, void *timeout_ctx)
                return;
        }
 
+       update_bssid_list(ctrl_conn);
+
        if (warning_displayed)
                printf("Connection established.\n");