wlantest: Maintain a copy of WPA/RSN IE from (Re)AssocReq
This commit is contained in:
parent
2d73f0a875
commit
021a6fe499
3 changed files with 49 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue