aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-11-06 15:31:02 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-07 21:29:00 (GMT)
commit422ef7d2056e982bbd83415f5a329e996b0c2608 (patch)
treeee7d77b826ed8d6cc2352f7c0af7740f14b6d3cb
parentd84d38935127dc6f64ed1c1b8aa986e85d99c9b6 (diff)
downloadhostap-422ef7d2056e982bbd83415f5a329e996b0c2608.zip
hostap-422ef7d2056e982bbd83415f5a329e996b0c2608.tar.gz
hostap-422ef7d2056e982bbd83415f5a329e996b0c2608.tar.bz2
wlantest: Create station list for each BSS
-rw-r--r--wlantest/Makefile1
-rw-r--r--wlantest/bss.c4
-rw-r--r--wlantest/process.c35
-rw-r--r--wlantest/sta.c48
-rw-r--r--wlantest/wlantest.h9
5 files changed, 97 insertions, 0 deletions
diff --git a/wlantest/Makefile b/wlantest/Makefile
index 983b330..cdd00a5 100644
--- a/wlantest/Makefile
+++ b/wlantest/Makefile
@@ -46,6 +46,7 @@ OBJS += readpcap.o
OBJS += monitor.o
OBJS += process.o
OBJS += bss.o
+OBJS += sta.o
OBJS += crc32.o
LIBS += -lpcap
diff --git a/wlantest/bss.c b/wlantest/bss.c
index 11b9248..70eb888 100644
--- a/wlantest/bss.c
+++ b/wlantest/bss.c
@@ -33,6 +33,7 @@ struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid)
bss = os_zalloc(sizeof(*bss));
if (bss == NULL)
return NULL;
+ dl_list_init(&bss->sta);
os_memcpy(bss->bssid, bssid, ETH_ALEN);
dl_list_add(&wt->bss, &bss->list);
wpa_printf(MSG_DEBUG, "Discovered new BSS - " MACSTR,
@@ -43,6 +44,9 @@ struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid)
void bss_deinit(struct wlantest_bss *bss)
{
+ struct wlantest_sta *sta, *n;
+ dl_list_for_each_safe(sta, n, &bss->sta, struct wlantest_sta, list)
+ sta_deinit(sta);
dl_list_del(&bss->list);
os_free(bss);
}
diff --git a/wlantest/process.c b/wlantest/process.c
index 448317e..d47b434 100644
--- a/wlantest/process.c
+++ b/wlantest/process.c
@@ -162,6 +162,38 @@ static void rx_mgmt_probe_resp(struct wlantest *wt, const u8 *data, size_t len)
}
+static void rx_mgmt_auth(struct wlantest *wt, const u8 *data, size_t len)
+{
+ const struct ieee80211_mgmt *mgmt;
+ struct wlantest_bss *bss;
+ struct wlantest_sta *sta;
+
+ mgmt = (const struct ieee80211_mgmt *) data;
+ bss = bss_get(wt, mgmt->bssid);
+ if (bss == NULL)
+ return;
+ if (os_memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN) == 0)
+ sta = sta_get(bss, mgmt->da);
+ else
+ sta = sta_get(bss, mgmt->sa);
+ if (sta == NULL)
+ return;
+
+ if (len < 24 + 6) {
+ wpa_printf(MSG_INFO, "Too short Authentication frame from "
+ MACSTR, MAC2STR(mgmt->sa));
+ return;
+ }
+
+ wpa_printf(MSG_DEBUG, "AUTH " MACSTR " -> " MACSTR
+ " (alg=%u trans=%u status=%u)",
+ MAC2STR(mgmt->sa), MAC2STR(mgmt->da),
+ le_to_host16(mgmt->u.auth.auth_alg),
+ le_to_host16(mgmt->u.auth.auth_transaction),
+ le_to_host16(mgmt->u.auth.status_code));
+}
+
+
static void rx_mgmt(struct wlantest *wt, const u8 *data, size_t len)
{
const struct ieee80211_hdr *hdr;
@@ -193,6 +225,9 @@ static void rx_mgmt(struct wlantest *wt, const u8 *data, size_t len)
case WLAN_FC_STYPE_PROBE_RESP:
rx_mgmt_probe_resp(wt, data, len);
break;
+ case WLAN_FC_STYPE_AUTH:
+ rx_mgmt_auth(wt, data, len);
+ break;
}
}
diff --git a/wlantest/sta.c b/wlantest/sta.c
new file mode 100644
index 0000000..fc84ee1
--- /dev/null
+++ b/wlantest/sta.c
@@ -0,0 +1,48 @@
+/*
+ * STA list
+ * Copyright (c) 2010, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#include "utils/includes.h"
+
+#include "utils/common.h"
+#include "wlantest.h"
+
+
+struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr)
+{
+ struct wlantest_sta *sta;
+
+ if (addr[0] & 0x01)
+ return NULL; /* Skip group addressed frames */
+
+ dl_list_for_each(sta, &bss->sta, struct wlantest_sta, list) {
+ if (os_memcmp(sta->addr, addr, ETH_ALEN) == 0)
+ return sta;
+ }
+
+ sta = os_zalloc(sizeof(*sta));
+ if (sta == NULL)
+ return NULL;
+ os_memcpy(sta->addr, addr, ETH_ALEN);
+ dl_list_add(&bss->sta, &sta->list);
+ wpa_printf(MSG_DEBUG, "Discovered new STA " MACSTR " in BSS " MACSTR,
+ MAC2STR(sta->addr), MAC2STR(bss->bssid));
+ return sta;
+}
+
+
+void sta_deinit(struct wlantest_sta *sta)
+{
+ dl_list_del(&sta->list);
+ os_free(sta);
+}
diff --git a/wlantest/wlantest.h b/wlantest/wlantest.h
index a6ad4eb..e65ca52 100644
--- a/wlantest/wlantest.h
+++ b/wlantest/wlantest.h
@@ -18,6 +18,11 @@
#include "utils/list.h"
+struct wlantest_sta {
+ struct dl_list list;
+ u8 addr[ETH_ALEN];
+};
+
struct wlantest_bss {
struct dl_list list;
u8 bssid[ETH_ALEN];
@@ -28,6 +33,7 @@ struct wlantest_bss {
int parse_error_reported;
u8 wpaie[257];
u8 rsnie[257];
+ struct dl_list sta; /* struct wlantest_sta */
};
struct wlantest {
@@ -50,4 +56,7 @@ void monitor_deinit(struct wlantest *wt);
struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid);
void bss_deinit(struct wlantest_bss *bss);
+struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr);
+void sta_deinit(struct wlantest_sta *sta);
+
#endif /* WLANTEST_H */