From eb4923fdae82a8d9609762bfc87d3012e9f29414 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 24 Jan 2011 14:03:03 +0200 Subject: [PATCH] wlantest: Add counters for TDLS setup frames --- wlantest/rx_tdls.c | 18 +++++++++++++++--- wlantest/wlantest_cli.c | 5 +++++ wlantest/wlantest_ctrl.h | 5 +++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/wlantest/rx_tdls.c b/wlantest/rx_tdls.c index 05509b41c..fd18c0831 100644 --- a/wlantest/rx_tdls.c +++ b/wlantest/rx_tdls.c @@ -188,6 +188,7 @@ static void rx_data_tdls_setup_request(struct wlantest *wt, const u8 *bssid, const u8 *data, size_t len) { struct ieee802_11_elems elems; + struct wlantest_tdls *tdls; if (len < 3) return; @@ -201,7 +202,9 @@ static void rx_data_tdls_setup_request(struct wlantest *wt, const u8 *bssid, " initiator STA " MACSTR " responder STA " MACSTR, MAC2STR(elems.link_id), MAC2STR(elems.link_id + ETH_ALEN), MAC2STR(elems.link_id + 2 * ETH_ALEN)); - get_tdls(wt, elems.link_id); + tdls = get_tdls(wt, elems.link_id); + if (tdls) + tdls->counters[WLANTEST_TDLS_COUNTER_SETUP_REQ]++; } @@ -234,6 +237,10 @@ static void rx_data_tdls_setup_response(struct wlantest *wt, const u8 *bssid, tdls = get_tdls(wt, elems.link_id); if (!tdls) return; + if (status) + tdls->counters[WLANTEST_TDLS_COUNTER_SETUP_RESP_FAIL]++; + else + tdls->counters[WLANTEST_TDLS_COUNTER_SETUP_RESP_OK]++; if (tdls_derive_tpk(tdls, bssid, elems.ftie, elems.ftie_len) < 1) return; if (tdls_verify_mic(tdls, 2, &elems) == 0) { @@ -259,8 +266,6 @@ static void rx_data_tdls_setup_confirm(struct wlantest *wt, const u8 *bssid, wpa_printf(MSG_DEBUG, "TDLS Setup Confirm " MACSTR " -> " MACSTR " (status %d)", MAC2STR(src), MAC2STR(dst), status); - if (status != WLAN_STATUS_SUCCESS) - return; if (ieee802_11_parse_elems(data + 3, len - 3, &elems, 1) == ParseFailed || elems.link_id == NULL) @@ -273,6 +278,13 @@ static void rx_data_tdls_setup_confirm(struct wlantest *wt, const u8 *bssid, tdls = get_tdls(wt, elems.link_id); if (tdls == NULL) return; + if (status) + tdls->counters[WLANTEST_TDLS_COUNTER_SETUP_CONF_FAIL]++; + else + tdls->counters[WLANTEST_TDLS_COUNTER_SETUP_CONF_OK]++; + + if (status != WLAN_STATUS_SUCCESS) + return; tdls->link_up = 1; if (tdls_derive_tpk(tdls, bssid, elems.ftie, elems.ftie_len) < 1) diff --git a/wlantest/wlantest_cli.c b/wlantest/wlantest_cli.c index 4b99c0efb..05e0121e0 100644 --- a/wlantest/wlantest_cli.c +++ b/wlantest/wlantest_cli.c @@ -752,6 +752,11 @@ static const struct tdls_counters tdls_counters[] = { { "invalid_direct_link", WLANTEST_TDLS_COUNTER_INVALID_DIRECT_LINK }, { "valid_ap_path", WLANTEST_TDLS_COUNTER_VALID_AP_PATH }, { "invalid_ap_path", WLANTEST_TDLS_COUNTER_INVALID_AP_PATH }, + { "setup_req", WLANTEST_TDLS_COUNTER_SETUP_REQ }, + { "setup_resp_ok", WLANTEST_TDLS_COUNTER_SETUP_RESP_OK }, + { "setup_resp_fail", WLANTEST_TDLS_COUNTER_SETUP_RESP_FAIL }, + { "setup_conf_ok", WLANTEST_TDLS_COUNTER_SETUP_CONF_OK }, + { "setup_conf_fail", WLANTEST_TDLS_COUNTER_SETUP_CONF_FAIL }, { NULL, 0 } }; diff --git a/wlantest/wlantest_ctrl.h b/wlantest/wlantest_ctrl.h index be26eff14..9bcee2b43 100644 --- a/wlantest/wlantest_ctrl.h +++ b/wlantest/wlantest_ctrl.h @@ -114,6 +114,11 @@ enum wlantest_tdls_counter { WLANTEST_TDLS_COUNTER_INVALID_DIRECT_LINK, WLANTEST_TDLS_COUNTER_VALID_AP_PATH, WLANTEST_TDLS_COUNTER_INVALID_AP_PATH, + WLANTEST_TDLS_COUNTER_SETUP_REQ, + WLANTEST_TDLS_COUNTER_SETUP_RESP_OK, + WLANTEST_TDLS_COUNTER_SETUP_RESP_FAIL, + WLANTEST_TDLS_COUNTER_SETUP_CONF_OK, + WLANTEST_TDLS_COUNTER_SETUP_CONF_FAIL, NUM_WLANTEST_TDLS_COUNTER };