aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-11-06 16:10:34 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-07 21:29:01 (GMT)
commit021a6fe49954768221f025d644851579b1aa6c6c (patch)
treed3c7246252dff247017ad6542361275bc2cdf16a
parent2d73f0a875df46d03c16c5e54d5c935cfdc2ee75 (diff)
downloadhostap-021a6fe49954768221f025d644851579b1aa6c6c.zip
hostap-021a6fe49954768221f025d644851579b1aa6c6c.tar.gz
hostap-021a6fe49954768221f025d644851579b1aa6c6c.tar.bz2
wlantest: Maintain a copy of WPA/RSN IE from (Re)AssocReq
-rw-r--r--wlantest/rx_mgmt.c22
-rw-r--r--wlantest/sta.c24
-rw-r--r--wlantest/wlantest.h3
3 files changed, 49 insertions, 0 deletions
diff --git a/wlantest/rx_mgmt.c b/wlantest/rx_mgmt.c
index 843c2b5..2100a8a 100644
--- a/wlantest/rx_mgmt.c
+++ b/wlantest/rx_mgmt.c
@@ -192,6 +192,7 @@ static void rx_mgmt_assoc_req(struct wlantest *wt, const u8 *data, size_t len)
const struct ieee80211_mgmt *mgmt;
struct wlantest_bss *bss;
struct wlantest_sta *sta;
+ struct ieee802_11_elems elems;
mgmt = (const struct ieee80211_mgmt *) data;
bss = bss_get(wt, mgmt->bssid);
@@ -212,6 +213,16 @@ static void rx_mgmt_assoc_req(struct wlantest *wt, const u8 *data, size_t len)
MAC2STR(mgmt->sa), MAC2STR(mgmt->da),
le_to_host16(mgmt->u.assoc_req.capab_info),
le_to_host16(mgmt->u.assoc_req.listen_interval));
+
+ if (ieee802_11_parse_elems(mgmt->u.assoc_req.variable,
+ len - (mgmt->u.assoc_req.variable - data),
+ &elems, 0) == ParseFailed) {
+ wpa_printf(MSG_INFO, "Invalid IEs in Association Request "
+ "frame from " MACSTR, MAC2STR(mgmt->sa));
+ return;
+ }
+
+ sta_update_assoc(sta, &elems);
}
@@ -275,6 +286,7 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
const struct ieee80211_mgmt *mgmt;
struct wlantest_bss *bss;
struct wlantest_sta *sta;
+ struct ieee802_11_elems elems;
mgmt = (const struct ieee80211_mgmt *) data;
bss = bss_get(wt, mgmt->bssid);
@@ -296,6 +308,16 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
le_to_host16(mgmt->u.reassoc_req.capab_info),
le_to_host16(mgmt->u.reassoc_req.listen_interval),
MAC2STR(mgmt->u.reassoc_req.current_ap));
+
+ if (ieee802_11_parse_elems(mgmt->u.reassoc_req.variable,
+ len - (mgmt->u.reassoc_req.variable - data),
+ &elems, 0) == ParseFailed) {
+ wpa_printf(MSG_INFO, "Invalid IEs in Reassociation Request "
+ "frame from " MACSTR, MAC2STR(mgmt->sa));
+ return;
+ }
+
+ sta_update_assoc(sta, &elems);
}
diff --git a/wlantest/sta.c b/wlantest/sta.c
index fc84ee1..447bd7a 100644
--- a/wlantest/sta.c
+++ b/wlantest/sta.c
@@ -15,6 +15,7 @@
#include "utils/includes.h"
#include "utils/common.h"
+#include "common/ieee802_11_common.h"
#include "wlantest.h"
@@ -46,3 +47,26 @@ void sta_deinit(struct wlantest_sta *sta)
dl_list_del(&sta->list);
os_free(sta);
}
+
+
+void sta_update_assoc(struct wlantest_sta *sta, struct ieee802_11_elems *elems)
+{
+ if (elems->wpa_ie && elems->rsn_ie) {
+ wpa_printf(MSG_INFO, "Both WPA IE and RSN IE included in "
+ "Association Request frame from " MACSTR,
+ MAC2STR(sta->addr));
+ }
+
+ if (elems->rsn_ie) {
+ wpa_hexdump(MSG_DEBUG, "RSN IE", elems->rsn_ie - 2,
+ elems->rsn_ie_len + 2);
+ os_memcpy(sta->rsnie, elems->rsn_ie - 2,
+ elems->rsn_ie_len + 2);
+ } else if (elems->wpa_ie) {
+ wpa_hexdump(MSG_DEBUG, "WPA IE", elems->wpa_ie - 2,
+ elems->wpa_ie_len + 2);
+ os_memcpy(sta->rsnie, elems->wpa_ie - 2,
+ elems->wpa_ie_len + 2);
+ } else
+ sta->rsnie[0] = 0;
+}
diff --git a/wlantest/wlantest.h b/wlantest/wlantest.h
index 909e371..10ca61c 100644
--- a/wlantest/wlantest.h
+++ b/wlantest/wlantest.h
@@ -29,6 +29,7 @@ struct wlantest_sta {
STATE3 /* associated */
} state;
u16 aid;
+ u8 rsnie[257]; /* WPA/RSN IE */
};
struct wlantest_bss {
@@ -69,5 +70,7 @@ void bss_update(struct wlantest_bss *bss, struct ieee802_11_elems *elems);
struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr);
void sta_deinit(struct wlantest_sta *sta);
+void sta_update_assoc(struct wlantest_sta *sta,
+ struct ieee802_11_elems *elems);
#endif /* WLANTEST_H */