aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2012-04-07 09:06:35 (GMT)
committerJouni Malinen <j@w1.fi>2012-08-09 20:05:56 (GMT)
commit8ea38f1366fa8cf16ff9bb5e14ed92d9c7698d1c (patch)
tree67ae8443340b8853d6ebceb055e38df2ffdb04fd
parent32e877fef742940d84b3c1af85224d56c59dd3f7 (diff)
downloadhostap-8ea38f1366fa8cf16ff9bb5e14ed92d9c7698d1c.zip
hostap-8ea38f1366fa8cf16ff9bb5e14ed92d9c7698d1c.tar.gz
hostap-8ea38f1366fa8cf16ff9bb5e14ed92d9c7698d1c.tar.bz2
Move ctrl_iface BSS command response generation into a separate function
This is in preparation for allowing multiple BSS entries to be fetched with a single command. Signed-off-by: Dmitry Shmidt <dimitrysh@google.com> (cherry picked from commit 61ce90857e7fb223da7cfd2e589a77de9d322933)
-rw-r--r--wpa_supplicant/ctrl_iface.c101
1 files changed, 55 insertions, 46 deletions
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 5445149..73a7dfb 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -2177,59 +2177,15 @@ static char * anqp_add_hex(char *pos, char *end, const char *title,
#endif /* CONFIG_INTERWORKING */
-static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
- const char *cmd, char *buf,
- size_t buflen)
+static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
+ char *buf, size_t buflen)
{
- u8 bssid[ETH_ALEN];
size_t i;
- struct wpa_bss *bss;
int ret;
char *pos, *end;
const u8 *ie, *ie2;
struct os_time now;
- 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);
- bss = wpa_bss_get_id(wpa_s, i);
- } else if (os_strncmp(cmd, "NEXT-", 5) == 0) {
- i = atoi(cmd + 5);
- bss = wpa_bss_get_id(wpa_s, i);
- if (bss) {
- struct dl_list *next = bss->list_id.next;
- if (next == &wpa_s->bss_id)
- bss = NULL;
- else
- bss = dl_list_entry(next, struct wpa_bss,
- list_id);
- }
-#ifdef CONFIG_P2P
- } else if (os_strncmp(cmd, "p2p_dev_addr=", 13) == 0) {
- if (hwaddr_aton(cmd + 13, bssid) == 0)
- bss = wpa_bss_get_p2p_dev_addr(wpa_s, bssid);
- else
- bss = NULL;
-#endif /* CONFIG_P2P */
- } else if (hwaddr_aton(cmd, bssid) == 0)
- bss = wpa_bss_get_bssid(wpa_s, bssid);
- else {
- struct wpa_bss *tmp;
- i = atoi(cmd);
- bss = NULL;
- dl_list_for_each(tmp, &wpa_s->bss_id, struct wpa_bss, list_id)
- {
- if (i-- == 0) {
- bss = tmp;
- break;
- }
- }
- }
-
- if (bss == NULL)
- return 0;
-
os_get_time(&now);
pos = buf;
end = buf + buflen;
@@ -2349,6 +2305,59 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
}
+static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
+ const char *cmd, char *buf,
+ size_t buflen)
+{
+ u8 bssid[ETH_ALEN];
+ size_t i;
+ struct wpa_bss *bss;
+
+ 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);
+ bss = wpa_bss_get_id(wpa_s, i);
+ } else if (os_strncmp(cmd, "NEXT-", 5) == 0) {
+ i = atoi(cmd + 5);
+ bss = wpa_bss_get_id(wpa_s, i);
+ if (bss) {
+ struct dl_list *next = bss->list_id.next;
+ if (next == &wpa_s->bss_id)
+ bss = NULL;
+ else
+ bss = dl_list_entry(next, struct wpa_bss,
+ list_id);
+ }
+#ifdef CONFIG_P2P
+ } else if (os_strncmp(cmd, "p2p_dev_addr=", 13) == 0) {
+ if (hwaddr_aton(cmd + 13, bssid) == 0)
+ bss = wpa_bss_get_p2p_dev_addr(wpa_s, bssid);
+ else
+ bss = NULL;
+#endif /* CONFIG_P2P */
+ } else if (hwaddr_aton(cmd, bssid) == 0)
+ bss = wpa_bss_get_bssid(wpa_s, bssid);
+ else {
+ struct wpa_bss *tmp;
+ i = atoi(cmd);
+ bss = NULL;
+ dl_list_for_each(tmp, &wpa_s->bss_id, struct wpa_bss, list_id)
+ {
+ if (i-- == 0) {
+ bss = tmp;
+ break;
+ }
+ }
+ }
+
+ if (bss == NULL)
+ return 0;
+
+ return print_bss_info(wpa_s, bss, buf, buflen);
+}
+
+
static int wpa_supplicant_ctrl_iface_ap_scan(
struct wpa_supplicant *wpa_s, char *cmd)
{