From 9be371437ed1f2122ad8efd2b1da6761ced33476 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 5 May 2013 12:38:55 +0300 Subject: [PATCH] wpa_cli: Fetch the current BSSID list when starting interactive mode This makes tab completion work better in cases where wpa_cli is started after wpa_supplicant has already discovered BSSes. Signed-hostap: Jouni Malinen --- wpa_supplicant/wpa_cli.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 47a596e95..d2d5dd9f9 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -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");