wlantest: Add STA counters for disconnect reason 6/7 RX

These can be useful in tests involving association state mismatch
between the AP and the STA (i.e., STA assumes it is still associated
but the AP does not have association state). In such a case, the AP
would be sending out unprotected Deauthentication or Disassociation
frames with reason code 6 or 7 depending on what frame is triggering
this.
This commit is contained in:
Jouni Malinen 2011-10-26 00:06:06 +03:00 committed by Jouni Malinen
parent 1d21e9dd5a
commit 62f05ce9c5
3 changed files with 26 additions and 2 deletions

View file

@ -190,6 +190,7 @@ static void rx_mgmt_deauth(struct wlantest *wt, const u8 *data, size_t len,
const struct ieee80211_mgmt *mgmt; const struct ieee80211_mgmt *mgmt;
struct wlantest_bss *bss; struct wlantest_bss *bss;
struct wlantest_sta *sta; struct wlantest_sta *sta;
u16 fc, reason;
mgmt = (const struct ieee80211_mgmt *) data; mgmt = (const struct ieee80211_mgmt *) data;
bss = bss_get(wt, mgmt->bssid); bss = bss_get(wt, mgmt->bssid);
@ -206,10 +207,11 @@ static void rx_mgmt_deauth(struct wlantest *wt, const u8 *data, size_t len,
return; return;
} }
reason = le_to_host16(mgmt->u.deauth.reason_code);
wpa_printf(MSG_DEBUG, "DEAUTH " MACSTR " -> " MACSTR wpa_printf(MSG_DEBUG, "DEAUTH " MACSTR " -> " MACSTR
" (reason=%u) (valid=%d)", " (reason=%u) (valid=%d)",
MAC2STR(mgmt->sa), MAC2STR(mgmt->da), MAC2STR(mgmt->sa), MAC2STR(mgmt->da),
le_to_host16(mgmt->u.deauth.reason_code), valid); reason, valid);
wpa_hexdump(MSG_MSGDUMP, "DEAUTH payload", data + 24, len - 24); wpa_hexdump(MSG_MSGDUMP, "DEAUTH payload", data + 24, len - 24);
if (sta == NULL) { if (sta == NULL) {
@ -225,6 +227,12 @@ static void rx_mgmt_deauth(struct wlantest *wt, const u8 *data, size_t len,
sta->counters[WLANTEST_STA_COUNTER_DEAUTH_RX_ASLEEP]++; sta->counters[WLANTEST_STA_COUNTER_DEAUTH_RX_ASLEEP]++;
else else
sta->counters[WLANTEST_STA_COUNTER_DEAUTH_RX_AWAKE]++; sta->counters[WLANTEST_STA_COUNTER_DEAUTH_RX_AWAKE]++;
fc = le_to_host16(mgmt->frame_control);
if (!(fc & WLAN_FC_ISWEP) && reason == 6)
sta->counters[WLANTEST_STA_COUNTER_DEAUTH_RX_RC6]++;
else if (!(fc & WLAN_FC_ISWEP) && reason == 7)
sta->counters[WLANTEST_STA_COUNTER_DEAUTH_RX_RC7]++;
} else } else
sta->counters[valid ? WLANTEST_STA_COUNTER_VALID_DEAUTH_TX : sta->counters[valid ? WLANTEST_STA_COUNTER_VALID_DEAUTH_TX :
WLANTEST_STA_COUNTER_INVALID_DEAUTH_TX]++; WLANTEST_STA_COUNTER_INVALID_DEAUTH_TX]++;
@ -526,6 +534,7 @@ static void rx_mgmt_disassoc(struct wlantest *wt, const u8 *data, size_t len,
const struct ieee80211_mgmt *mgmt; const struct ieee80211_mgmt *mgmt;
struct wlantest_bss *bss; struct wlantest_bss *bss;
struct wlantest_sta *sta; struct wlantest_sta *sta;
u16 fc, reason;
mgmt = (const struct ieee80211_mgmt *) data; mgmt = (const struct ieee80211_mgmt *) data;
bss = bss_get(wt, mgmt->bssid); bss = bss_get(wt, mgmt->bssid);
@ -542,10 +551,11 @@ static void rx_mgmt_disassoc(struct wlantest *wt, const u8 *data, size_t len,
return; return;
} }
reason = le_to_host16(mgmt->u.disassoc.reason_code);
wpa_printf(MSG_DEBUG, "DISASSOC " MACSTR " -> " MACSTR wpa_printf(MSG_DEBUG, "DISASSOC " MACSTR " -> " MACSTR
" (reason=%u) (valid=%d)", " (reason=%u) (valid=%d)",
MAC2STR(mgmt->sa), MAC2STR(mgmt->da), MAC2STR(mgmt->sa), MAC2STR(mgmt->da),
le_to_host16(mgmt->u.disassoc.reason_code), valid); reason, valid);
wpa_hexdump(MSG_MSGDUMP, "DISASSOC payload", data + 24, len - 24); wpa_hexdump(MSG_MSGDUMP, "DISASSOC payload", data + 24, len - 24);
if (sta == NULL) { if (sta == NULL) {
@ -563,6 +573,12 @@ static void rx_mgmt_disassoc(struct wlantest *wt, const u8 *data, size_t len,
else else
sta->counters[ sta->counters[
WLANTEST_STA_COUNTER_DISASSOC_RX_AWAKE]++; WLANTEST_STA_COUNTER_DISASSOC_RX_AWAKE]++;
fc = le_to_host16(mgmt->frame_control);
if (!(fc & WLAN_FC_ISWEP) && reason == 6)
sta->counters[WLANTEST_STA_COUNTER_DISASSOC_RX_RC6]++;
else if (!(fc & WLAN_FC_ISWEP) && reason == 7)
sta->counters[WLANTEST_STA_COUNTER_DISASSOC_RX_RC7]++;
} else } else
sta->counters[valid ? WLANTEST_STA_COUNTER_VALID_DISASSOC_TX : sta->counters[valid ? WLANTEST_STA_COUNTER_VALID_DISASSOC_TX :
WLANTEST_STA_COUNTER_INVALID_DISASSOC_TX]++; WLANTEST_STA_COUNTER_INVALID_DISASSOC_TX]++;

View file

@ -552,6 +552,10 @@ static const struct sta_counters sta_counters[] = {
{ "disassoc_rx_asleep", WLANTEST_STA_COUNTER_DISASSOC_RX_ASLEEP }, { "disassoc_rx_asleep", WLANTEST_STA_COUNTER_DISASSOC_RX_ASLEEP },
{ "disassoc_rx_awake", WLANTEST_STA_COUNTER_DISASSOC_RX_AWAKE }, { "disassoc_rx_awake", WLANTEST_STA_COUNTER_DISASSOC_RX_AWAKE },
{ "prot_data_tx", WLANTEST_STA_COUNTER_PROT_DATA_TX }, { "prot_data_tx", WLANTEST_STA_COUNTER_PROT_DATA_TX },
{ "deauth_rx_rc6", WLANTEST_STA_COUNTER_DEAUTH_RX_RC6 },
{ "deauth_rx_rc7", WLANTEST_STA_COUNTER_DEAUTH_RX_RC7 },
{ "disassoc_rx_rc6", WLANTEST_STA_COUNTER_DISASSOC_RX_RC6 },
{ "disassoc_rx_rc7", WLANTEST_STA_COUNTER_DISASSOC_RX_RC7 },
{ NULL, 0 } { NULL, 0 }
}; };

View file

@ -107,6 +107,10 @@ enum wlantest_sta_counter {
WLANTEST_STA_COUNTER_DISASSOC_RX_ASLEEP, WLANTEST_STA_COUNTER_DISASSOC_RX_ASLEEP,
WLANTEST_STA_COUNTER_DISASSOC_RX_AWAKE, WLANTEST_STA_COUNTER_DISASSOC_RX_AWAKE,
WLANTEST_STA_COUNTER_PROT_DATA_TX, WLANTEST_STA_COUNTER_PROT_DATA_TX,
WLANTEST_STA_COUNTER_DEAUTH_RX_RC6,
WLANTEST_STA_COUNTER_DEAUTH_RX_RC7,
WLANTEST_STA_COUNTER_DISASSOC_RX_RC6,
WLANTEST_STA_COUNTER_DISASSOC_RX_RC7,
NUM_WLANTEST_STA_COUNTER NUM_WLANTEST_STA_COUNTER
}; };