aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2012-04-07 09:49:31 (GMT)
committerJouni Malinen <j@w1.fi>2012-08-09 20:06:03 (GMT)
commitb742a17cce064e3286a1138f1d3acaf766c39946 (patch)
tree399dea9b8394127d55066c74b62f768a0304c847
parentf0b95bcf2960d590d00982fc4901d08f5edb4645 (diff)
downloadhostap-b742a17cce064e3286a1138f1d3acaf766c39946.zip
hostap-b742a17cce064e3286a1138f1d3acaf766c39946.tar.gz
hostap-b742a17cce064e3286a1138f1d3acaf766c39946.tar.bz2
Add RANGE=ALL|N1-N2 selection for ctrl_iface BSS command
Add ability to get information about several BSS's in one call. Signed-off-by: Dmitry Shmidt <dimitrysh@google.com> (cherry picked from commit eff1a95b9763a7b8b5e25c8ef1eb911ab479afa0)
-rw-r--r--wpa_supplicant/ctrl_iface.c65
1 files changed, 62 insertions, 3 deletions
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 2d9a6db..76ff9cd 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2389,10 +2389,54 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
u8 bssid[ETH_ALEN];
size_t i;
struct wpa_bss *bss;
+ struct wpa_bss *bsslast = NULL;
+ struct dl_list *next;
+ int ret = 0;
+ int len;
char *ctmp;
unsigned long mask = WPA_BSS_MASK_ALL;
- if (os_strcmp(cmd, "FIRST") == 0)
+ if (os_strncmp(cmd, "RANGE=", 6) == 0) {
+ if (os_strncmp(cmd + 6, "ALL", 3) == 0) {
+ bss = dl_list_first(&wpa_s->bss_id, struct wpa_bss,
+ list_id);
+ bsslast = dl_list_last(&wpa_s->bss_id, struct wpa_bss,
+ list_id);
+ } else { /* N1-N2 */
+ unsigned int id1, id2;
+
+ if ((ctmp = os_strchr(cmd + 6, '-')) == NULL) {
+ wpa_printf(MSG_INFO, "Wrong BSS range "
+ "format");
+ return 0;
+ }
+
+ id1 = atoi(cmd + 6);
+ bss = wpa_bss_get_id(wpa_s, id1);
+ id2 = atoi(ctmp + 1);
+ if (id2 == 0)
+ bsslast = dl_list_last(&wpa_s->bss_id,
+ struct wpa_bss,
+ list_id);
+ else {
+ bsslast = wpa_bss_get_id(wpa_s, id2);
+ if (bsslast == NULL && bss && id2 > id1) {
+ struct wpa_bss *tmp = bss;
+ for (;;) {
+ next = tmp->list_id.next;
+ if (next == &wpa_s->bss_id)
+ break;
+ tmp = dl_list_entry(
+ next, struct wpa_bss,
+ list_id);
+ if (tmp->id > id2)
+ break;
+ bsslast = tmp;
+ }
+ }
+ }
+ }
+ } else if (os_strcmp(cmd, "FIRST") == 0)
bss = dl_list_first(&wpa_s->bss, struct wpa_bss, list);
else if (os_strncmp(cmd, "ID-", 3) == 0) {
i = atoi(cmd + 3);
@@ -2401,7 +2445,7 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
i = atoi(cmd + 5);
bss = wpa_bss_get_id(wpa_s, i);
if (bss) {
- struct dl_list *next = bss->list_id.next;
+ next = bss->list_id.next;
if (next == &wpa_s->bss_id)
bss = NULL;
else
@@ -2439,7 +2483,22 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
if (bss == NULL)
return 0;
- return print_bss_info(wpa_s, bss, mask, buf, buflen);
+ if (bsslast == NULL)
+ bsslast = bss;
+ do {
+ len = print_bss_info(wpa_s, bss, mask, buf, buflen);
+ ret += len;
+ buf += len;
+ buflen -= len;
+ if (bss == bsslast)
+ break;
+ next = bss->list_id.next;
+ if (next == &wpa_s->bss_id)
+ break;
+ bss = dl_list_entry(next, struct wpa_bss, list_id);
+ } while (bss && len);
+
+ return ret;
}