From 90903a77efa396ca7079a74aa0e6cfd49c3a214a Mon Sep 17 00:00:00 2001 From: Vinit Deshpande Date: Tue, 2 Dec 2014 10:59:29 -0800 Subject: [PATCH] List all networks despite message limit of 4096 bytes This change creates 'LIST_NETWORK LAST_ID=x' form to allow retrieval of all networks saved in the system. Without this form, only first few (whatever fills in first 4096 bytes) can be retrieved. Signed-off-by: Vinit Deshpande --- wpa_supplicant/ctrl_iface.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 2a9fe6aae..adc2fd557 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2048,7 +2048,7 @@ static int wpa_supplicant_ctrl_iface_log_level(struct wpa_supplicant *wpa_s, static int wpa_supplicant_ctrl_iface_list_networks( - struct wpa_supplicant *wpa_s, char *buf, size_t buflen) + struct wpa_supplicant *wpa_s, char *cmd, char *buf, size_t buflen) { char *pos, *end; struct wpa_ssid *ssid; @@ -2063,6 +2063,17 @@ static int wpa_supplicant_ctrl_iface_list_networks( pos += ret; ssid = wpa_s->conf->ssid; + + /* skip over ssids until we find next one */ + if (cmd != NULL && os_strncmp(cmd, "LAST_ID=", 8) == 0) { + int last_id = atoi(cmd + 8); + if (last_id != -1) { + while (ssid != NULL && ssid->id <= last_id) { + ssid = ssid->next; + } + } + } + while (ssid) { ret = os_snprintf(pos, end - pos, "%d\t%s", ssid->id, @@ -7303,9 +7314,12 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, } else if (os_strncmp(buf, "LOG_LEVEL", 9) == 0) { reply_len = wpa_supplicant_ctrl_iface_log_level( wpa_s, buf + 9, reply, reply_size); + } else if (os_strncmp(buf, "LIST_NETWORKS ", 14) == 0) { + reply_len = wpa_supplicant_ctrl_iface_list_networks( + wpa_s, buf + 14, reply, reply_size); } else if (os_strcmp(buf, "LIST_NETWORKS") == 0) { reply_len = wpa_supplicant_ctrl_iface_list_networks( - wpa_s, reply, reply_size); + wpa_s, NULL, reply, reply_size); } else if (os_strcmp(buf, "DISCONNECT") == 0) { #ifdef CONFIG_SME wpa_s->sme.prev_bssid_set = 0;