]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wlantest: Use add_note() to annotate frames
authorJouni Malinen <j@w1.fi>
Sun, 26 May 2013 17:58:50 +0000 (20:58 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 26 May 2013 19:14:00 +0000 (22:14 +0300)
This adds debug information from wlantest into pcapng frame comments to
make the information more convenient to use, e.g., in Wireshark.

Signed-hostap: Jouni Malinen <j@w1.fi>

wlantest/bss.c
wlantest/process.c
wlantest/rx_data.c
wlantest/rx_eapol.c
wlantest/rx_ip.c
wlantest/rx_mgmt.c
wlantest/rx_tdls.c

index d554853a33fd8c5aaf122c3ffe3d5fad20b5dbb2..98d98efde6a4ed9451cd908e933d0c658ae51ce6 100644 (file)
@@ -157,8 +157,8 @@ void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
 
        if (elems->rsn_ie == NULL) {
                if (bss->rsnie[0]) {
-                       wpa_printf(MSG_INFO, "BSS " MACSTR " - RSN IE removed",
-                                  MAC2STR(bss->bssid));
+                       add_note(wt, MSG_INFO, "BSS " MACSTR
+                                " - RSN IE removed", MAC2STR(bss->bssid));
                        bss->rsnie[0] = 0;
                        update = 1;
                }
@@ -178,8 +178,8 @@ void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
 
        if (elems->wpa_ie == NULL) {
                if (bss->wpaie[0]) {
-                       wpa_printf(MSG_INFO, "BSS " MACSTR " - WPA IE removed",
-                                  MAC2STR(bss->bssid));
+                       add_note(wt, MSG_INFO, "BSS " MACSTR
+                                " - WPA IE removed", MAC2STR(bss->bssid));
                        bss->wpaie[0] = 0;
                        update = 1;
                }
@@ -211,8 +211,8 @@ void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
        if (bss->wpaie[0]) {
                if (wpa_parse_wpa_ie_wpa(bss->wpaie, 2 + bss->wpaie[1], &data)
                    < 0) {
-                       wpa_printf(MSG_INFO, "Failed to parse WPA IE from "
-                                  MACSTR, MAC2STR(bss->bssid));
+                       add_note(wt, MSG_INFO, "Failed to parse WPA IE from "
+                                MACSTR, MAC2STR(bss->bssid));
                } else {
                        bss->proto |= data.proto;
                        bss->pairwise_cipher |= data.pairwise_cipher;
@@ -226,8 +226,8 @@ void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
        if (bss->rsnie[0]) {
                if (wpa_parse_wpa_ie_rsn(bss->rsnie, 2 + bss->rsnie[1], &data)
                    < 0) {
-                       wpa_printf(MSG_INFO, "Failed to parse RSN IE from "
-                                  MACSTR, MAC2STR(bss->bssid));
+                       add_note(wt, MSG_INFO, "Failed to parse RSN IE from "
+                                MACSTR, MAC2STR(bss->bssid));
                } else {
                        bss->proto |= data.proto;
                        bss->pairwise_cipher |= data.pairwise_cipher;
index a788a36506ff4ca18a6ee293eaad2b96d0506434..5e75445fc5811662edd38242a5ef75b4425cb5ac 100644 (file)
@@ -100,12 +100,12 @@ static void rx_update_ps(struct wlantest *wt, const struct ieee80211_hdr *hdr,
        if (!to_ap) {
                if (sta->pwrmgt && !sta->pspoll) {
                        u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
-                       wpa_printf(MSG_DEBUG, "AP " MACSTR " sent a frame "
-                                  "(%u:%u) to a sleeping STA " MACSTR
-                                  " (seq=%u)",
-                                  MAC2STR(sta->bss->bssid),
-                                  type, stype, MAC2STR(sta->addr),
-                                  WLAN_GET_SEQ_SEQ(seq_ctrl));
+                       add_note(wt, MSG_DEBUG, "AP " MACSTR " sent a frame "
+                                "(%u:%u) to a sleeping STA " MACSTR
+                                " (seq=%u)",
+                                MAC2STR(sta->bss->bssid),
+                                type, stype, MAC2STR(sta->addr),
+                                WLAN_GET_SEQ_SEQ(seq_ctrl));
                } else
                        sta->pspoll = 0;
                return;
@@ -122,12 +122,12 @@ static void rx_update_ps(struct wlantest *wt, const struct ieee80211_hdr *hdr,
                 * maintain state through the frame exchange.
                 */
                if (sta->pwrmgt && !(fc & WLAN_FC_PWRMGT)) {
-                       wpa_printf(MSG_DEBUG, "STA " MACSTR " woke up from "
-                                  "sleep", MAC2STR(sta->addr));
+                       add_note(wt, MSG_DEBUG, "STA " MACSTR " woke up from "
+                                "sleep", MAC2STR(sta->addr));
                        sta->pwrmgt = 0;
                } else if (!sta->pwrmgt && (fc & WLAN_FC_PWRMGT)) {
-                       wpa_printf(MSG_DEBUG, "STA " MACSTR " went to sleep",
-                                  MAC2STR(sta->addr));
+                       add_note(wt, MSG_DEBUG, "STA " MACSTR " went to sleep",
+                                MAC2STR(sta->addr));
                        sta->pwrmgt = 1;
                }
        }
@@ -161,10 +161,10 @@ static int rx_duplicate(struct wlantest *wt, const struct ieee80211_hdr *hdr,
 
        if ((fc & WLAN_FC_RETRY) && hdr->seq_ctrl == *seq_ctrl) {
                u16 s = le_to_host16(hdr->seq_ctrl);
-               wpa_printf(MSG_MSGDUMP, "Ignore duplicated frame (seq=%u "
-                          "frag=%u A1=" MACSTR " A2=" MACSTR ")",
-                          WLAN_GET_SEQ_SEQ(s), WLAN_GET_SEQ_FRAG(s),
-                          MAC2STR(hdr->addr1), MAC2STR(hdr->addr2));
+               add_note(wt, MSG_MSGDUMP, "Ignore duplicated frame (seq=%u "
+                        "frag=%u A1=" MACSTR " A2=" MACSTR ")",
+                        WLAN_GET_SEQ_SEQ(s), WLAN_GET_SEQ_FRAG(s),
+                        MAC2STR(hdr->addr1), MAC2STR(hdr->addr2));
                return 1;
        }
 
@@ -181,8 +181,8 @@ static void rx_ack(struct wlantest *wt, const struct ieee80211_hdr *hdr)
 
        if (wt->last_len < 24 || (last->addr1[0] & 0x01) ||
            os_memcmp(hdr->addr1, last->addr2, ETH_ALEN) != 0) {
-               wpa_printf(MSG_MSGDUMP, "Unknown Ack frame (previous frame "
-                          "not seen)");
+               add_note(wt, MSG_MSGDUMP, "Unknown Ack frame (previous frame "
+                        "not seen)");
                return;
        }
 
@@ -277,7 +277,7 @@ void wlantest_process(struct wlantest *wt, const u8 *data, size_t len)
        wpa_hexdump(MSG_EXCESSIVE, "Process data", data, len);
 
        if (ieee80211_radiotap_iterator_init(&iter, (void *) data, len)) {
-               wpa_printf(MSG_INFO, "Invalid radiotap frame");
+               add_note(wt, MSG_INFO, "Invalid radiotap frame");
                return;
        }
 
@@ -288,8 +288,8 @@ void wlantest_process(struct wlantest *wt, const u8 *data, size_t len)
                if (ret == -ENOENT)
                        break;
                if (ret) {
-                       wpa_printf(MSG_INFO, "Invalid radiotap header: %d",
-                                  ret);
+                       add_note(wt, MSG_INFO, "Invalid radiotap header: %d",
+                                ret);
                        return;
                }
                switch (iter.this_arg_index) {
@@ -310,7 +310,7 @@ void wlantest_process(struct wlantest *wt, const u8 *data, size_t len)
        }
 
        if (iter.max_length == 8) {
-               wpa_printf(MSG_DEBUG, "Skip frame inserted by wlantest");
+               add_note(wt, MSG_DEBUG, "Skip frame inserted by wlantest");
                return;
        }
        frame = data + iter.max_length;
@@ -320,8 +320,8 @@ void wlantest_process(struct wlantest *wt, const u8 *data, size_t len)
                frame_len -= 4;
                fcspos = frame + frame_len;
                if (check_fcs(frame, frame_len, fcspos) < 0) {
-                       wpa_printf(MSG_EXCESSIVE, "Drop RX frame with invalid "
-                                  "FCS");
+                       add_note(wt, MSG_EXCESSIVE, "Drop RX frame with "
+                                "invalid FCS");
                        wt->fcs_error++;
                        return;
                }
@@ -332,6 +332,8 @@ void wlantest_process(struct wlantest *wt, const u8 *data, size_t len)
        if (!txflags)
                rx_frame(wt, frame, frame_len);
        else {
+               add_note(wt, MSG_EXCESSIVE, "TX status - process as RX of "
+                        "local frame");
                tx_status(wt, frame, frame_len, !failed);
                /* Process as RX frame to support local monitor interface */
                rx_frame(wt, frame, frame_len);
@@ -366,8 +368,8 @@ void wlantest_process_prism(struct wlantest *wt, const u8 *data, size_t len)
                frame_len -= 4;
                fcspos = frame + frame_len;
                if (check_fcs(frame, frame_len, fcspos) < 0) {
-                       wpa_printf(MSG_EXCESSIVE, "Drop RX frame with invalid "
-                                  "FCS");
+                       add_note(wt, MSG_EXCESSIVE, "Drop RX frame with "
+                                "invalid FCS");
                        wt->fcs_error++;
                        return;
                }
@@ -387,8 +389,8 @@ void wlantest_process_80211(struct wlantest *wt, const u8 *data, size_t len)
                len -= 4;
                fcspos = data + len;
                if (check_fcs(data, len, fcspos) < 0) {
-                       wpa_printf(MSG_EXCESSIVE, "Drop RX frame with invalid "
-                                  "FCS");
+                       add_note(wt, MSG_EXCESSIVE, "Drop RX frame with "
+                                "invalid FCS");
                        wt->fcs_error++;
                        return;
                }
index fea73cc1bbdc086ad7df2ebf7dd9d587a1cc6062..579c06a21d0c4f42049c0867e8d018884f0c5253 100644 (file)
@@ -108,45 +108,45 @@ static void rx_data_bss_prot_group(struct wlantest *wt,
        if (bss == NULL)
                return;
        if (len < 4) {
-               wpa_printf(MSG_INFO, "Too short group addressed data frame");
+               add_note(wt, MSG_INFO, "Too short group addressed data frame");
                return;
        }
 
        if (bss->group_cipher & (WPA_CIPHER_TKIP | WPA_CIPHER_CCMP) &&
            !(data[3] & 0x20)) {
-                   wpa_printf(MSG_INFO, "Expected TKIP/CCMP frame from "
-                              MACSTR " did not have ExtIV bit set to 1",
-                              MAC2STR(bss->bssid));
-                   return;
+               add_note(wt, MSG_INFO, "Expected TKIP/CCMP frame from "
+                        MACSTR " did not have ExtIV bit set to 1",
+                        MAC2STR(bss->bssid));
+               return;
        }
 
        if (bss->group_cipher == WPA_CIPHER_TKIP) {
                if (data[3] & 0x1f) {
-                       wpa_printf(MSG_INFO, "TKIP frame from " MACSTR " used "
-                                  "non-zero reserved bit",
-                                  MAC2STR(bss->bssid));
+                       add_note(wt, MSG_INFO, "TKIP frame from " MACSTR
+                                " used non-zero reserved bit",
+                                MAC2STR(bss->bssid));
                }
                if (data[1] != ((data[0] | 0x20) & 0x7f)) {
-                       wpa_printf(MSG_INFO, "TKIP frame from " MACSTR " used "
-                                  "incorrect WEPSeed[1] (was 0x%x, expected "
-                                  "0x%x)",
-                                  MAC2STR(bss->bssid), data[1],
-                                  (data[0] | 0x20) & 0x7f);
+                       add_note(wt, MSG_INFO, "TKIP frame from " MACSTR
+                                " used incorrect WEPSeed[1] (was 0x%x, "
+                                "expected 0x%x)",
+                                MAC2STR(bss->bssid), data[1],
+                                (data[0] | 0x20) & 0x7f);
                }
        } else if (bss->group_cipher == WPA_CIPHER_CCMP) {
                if (data[2] != 0 || (data[3] & 0x1f) != 0) {
-                       wpa_printf(MSG_INFO, "CCMP frame from " MACSTR " used "
-                                  "non-zero reserved bit",
-                                  MAC2STR(bss->bssid));
+                       add_note(wt, MSG_INFO, "CCMP frame from " MACSTR
+                                " used non-zero reserved bit",
+                                MAC2STR(bss->bssid));
                }
        }
 
        keyid = data[3] >> 6;
        if (bss->gtk_len[keyid] == 0 && bss->group_cipher != WPA_CIPHER_WEP40)
        {
-               wpa_printf(MSG_MSGDUMP, "No GTK known to decrypt the frame "
-                          "(A2=" MACSTR " KeyID=%d)",
-                          MAC2STR(hdr->addr2), keyid);
+               add_note(wt, MSG_MSGDUMP, "No GTK known to decrypt the frame "
+                        "(A2=" MACSTR " KeyID=%d)",
+                        MAC2STR(hdr->addr2), keyid);
                return;
        }
 
@@ -158,12 +158,12 @@ static void rx_data_bss_prot_group(struct wlantest *wt,
                ccmp_get_pn(pn, data);
        if (os_memcmp(pn, bss->rsc[keyid], 6) <= 0) {
                u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
-               wpa_printf(MSG_INFO, "CCMP/TKIP replay detected: A1=" MACSTR
-                          " A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
-                          MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
-                          MAC2STR(hdr->addr3),
-                          WLAN_GET_SEQ_SEQ(seq_ctrl),
-                          WLAN_GET_SEQ_FRAG(seq_ctrl));
+               add_note(wt, MSG_INFO, "CCMP/TKIP replay detected: A1=" MACSTR
+                        " A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
+                        MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
+                        MAC2STR(hdr->addr3),
+                        WLAN_GET_SEQ_SEQ(seq_ctrl),
+                        WLAN_GET_SEQ_FRAG(seq_ctrl));
                wpa_hexdump(MSG_INFO, "RX PN", pn, 6);
                wpa_hexdump(MSG_INFO, "RSC", bss->rsc[keyid], 6);
        }
@@ -183,7 +183,8 @@ skip_replay_det:
                os_memcpy(bss->rsc[keyid], pn, 6);
                write_pcap_decrypted(wt, (const u8 *) hdr, 24 + (qos ? 2 : 0),
                                     decrypted, dlen);
-       }
+       } else
+               add_note(wt, MSG_DEBUG, "Failed to decrypt frame");
        os_free(decrypted);
 }
 
@@ -244,49 +245,49 @@ static void rx_data_bss_prot(struct wlantest *wt,
        if ((sta == NULL ||
             (!sta->ptk_set && sta->pairwise_cipher != WPA_CIPHER_WEP40)) &&
            tk == NULL) {
-               wpa_printf(MSG_MSGDUMP, "No PTK known to decrypt the frame");
+               add_note(wt, MSG_MSGDUMP, "No PTK known to decrypt the frame");
                return;
        }
 
        if (len < 4) {
-               wpa_printf(MSG_INFO, "Too short encrypted data frame");
+               add_note(wt, MSG_INFO, "Too short encrypted data frame");
                return;
        }
 
        if (sta->pairwise_cipher & (WPA_CIPHER_TKIP | WPA_CIPHER_CCMP) &&
            !(data[3] & 0x20)) {
-                   wpa_printf(MSG_INFO, "Expected TKIP/CCMP frame from "
-                              MACSTR " did not have ExtIV bit set to 1",
-                              MAC2STR(src));
-                   return;
+               add_note(wt, MSG_INFO, "Expected TKIP/CCMP frame from "
+                        MACSTR " did not have ExtIV bit set to 1",
+                        MAC2STR(src));
+               return;
        }
 
        if (tk == NULL && sta->pairwise_cipher == WPA_CIPHER_TKIP) {
                if (data[3] & 0x1f) {
-                       wpa_printf(MSG_INFO, "TKIP frame from " MACSTR " used "
-                                  "non-zero reserved bit",
-                                  MAC2STR(hdr->addr2));
+                       add_note(wt, MSG_INFO, "TKIP frame from " MACSTR
+                                " used non-zero reserved bit",
+                                MAC2STR(hdr->addr2));
                }
                if (data[1] != ((data[0] | 0x20) & 0x7f)) {
-                       wpa_printf(MSG_INFO, "TKIP frame from " MACSTR " used "
-                                  "incorrect WEPSeed[1] (was 0x%x, expected "
-                                  "0x%x)",
-                                  MAC2STR(hdr->addr2), data[1],
-                                  (data[0] | 0x20) & 0x7f);
+                       add_note(wt, MSG_INFO, "TKIP frame from " MACSTR
+                                " used incorrect WEPSeed[1] (was 0x%x, "
+                                "expected 0x%x)",
+                                MAC2STR(hdr->addr2), data[1],
+                                (data[0] | 0x20) & 0x7f);
                }
        } else if (tk || sta->pairwise_cipher == WPA_CIPHER_CCMP) {
                if (data[2] != 0 || (data[3] & 0x1f) != 0) {
-                       wpa_printf(MSG_INFO, "CCMP frame from " MACSTR " used "
-                                  "non-zero reserved bit",
-                                  MAC2STR(hdr->addr2));
+                       add_note(wt, MSG_INFO, "CCMP frame from " MACSTR
+                                " used non-zero reserved bit",
+                                MAC2STR(hdr->addr2));
                }
        }
 
        keyid = data[3] >> 6;
        if (keyid != 0) {
-               wpa_printf(MSG_INFO, "Unexpected non-zero KeyID %d in "
-                          "individually addressed Data frame from " MACSTR,
-                          keyid, MAC2STR(hdr->addr2));
+               add_note(wt, MSG_INFO, "Unexpected non-zero KeyID %d in "
+                        "individually addressed Data frame from " MACSTR,
+                        keyid, MAC2STR(hdr->addr2));
        }
 
        if (qos)
@@ -312,12 +313,12 @@ static void rx_data_bss_prot(struct wlantest *wt,
                ccmp_get_pn(pn, data);
        if (os_memcmp(pn, rsc, 6) <= 0) {
                u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
-               wpa_printf(MSG_INFO, "CCMP/TKIP replay detected: A1=" MACSTR
-                          " A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
-                          MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
-                          MAC2STR(hdr->addr3),
-                          WLAN_GET_SEQ_SEQ(seq_ctrl),
-                          WLAN_GET_SEQ_FRAG(seq_ctrl));
+               add_note(wt, MSG_INFO, "CCMP/TKIP replay detected: A1=" MACSTR
+                        " A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
+                        MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
+                        MAC2STR(hdr->addr3),
+                        WLAN_GET_SEQ_SEQ(seq_ctrl),
+                        WLAN_GET_SEQ_FRAG(seq_ctrl));
                wpa_hexdump(MSG_INFO, "RX PN", pn, 6);
                wpa_hexdump(MSG_INFO, "RSC", rsc, 6);
        }
@@ -341,7 +342,8 @@ skip_replay_det:
                                dlen, 1, peer_addr);
                write_pcap_decrypted(wt, (const u8 *) hdr, 24 + (qos ? 2 : 0),
                                     decrypted, dlen);
-       }
+       } else
+               add_note(wt, MSG_DEBUG, "Failed to decrypt frame");
        os_free(decrypted);
 }
 
index a4e6e26e5d8b6ead9a87e6841b9a138cdbb902e7..b18b3cf36f6e715e288e05b877042f869825d418 100644 (file)
@@ -79,19 +79,20 @@ static void rx_data_eapol_key_1_of_4(struct wlantest *wt, const u8 *dst,
        eapol = (const struct ieee802_1x_hdr *) data;
        hdr = (const struct wpa_eapol_key *) (eapol + 1);
        if (is_zero(hdr->key_nonce, WPA_NONCE_LEN)) {
-               wpa_printf(MSG_INFO, "EAPOL-Key 1/4 from " MACSTR " used "
-                          "zero nonce", MAC2STR(src));
+               add_note(wt, MSG_INFO, "EAPOL-Key 1/4 from " MACSTR
+                        " used zero nonce", MAC2STR(src));
        }
        if (!is_zero(hdr->key_rsc, 8)) {
-               wpa_printf(MSG_INFO, "EAPOL-Key 1/4 from " MACSTR " used "
-                          "non-zero Key RSC", MAC2STR(src));
+               add_note(wt, MSG_INFO, "EAPOL-Key 1/4 from " MACSTR
+                        " used non-zero Key RSC", MAC2STR(src));
        }
        os_memcpy(sta->anonce, hdr->key_nonce, WPA_NONCE_LEN);
 }
 
 
-static int try_pmk(struct wlantest_bss *bss, struct wlantest_sta *sta,
-                  u16 ver, const u8 *data, size_t len,
+static int try_pmk(struct wlantest *wt, struct wlantest_bss *bss,
+                  struct wlantest_sta *sta, u16 ver,
+                  const u8 *data, size_t len,
                   struct wlantest_pmk *pmk)
 {
        struct wpa_ptk ptk;
@@ -112,6 +113,7 @@ static int try_pmk(struct wlantest_bss *bss, struct wlantest_sta *sta,
                 * Rekeying - use new PTK for EAPOL-Key frames, but continue
                 * using the old PTK for frame decryption.
                 */
+               add_note(wt, MSG_DEBUG, "Derived PTK during rekeying");
                os_memcpy(&sta->tptk, &ptk, sizeof(ptk));
                wpa_hexdump(MSG_DEBUG, "TPTK:KCK", sta->tptk.kck, 16);
                wpa_hexdump(MSG_DEBUG, "TPTK:KEK", sta->tptk.kek, 16);
@@ -122,6 +124,7 @@ static int try_pmk(struct wlantest_bss *bss, struct wlantest_sta *sta,
                sta->tptk_set = 1;
                return 0;
        }
+       add_note(wt, MSG_DEBUG, "Derived new PTK");
        os_memcpy(&sta->ptk, &ptk, sizeof(ptk));
        wpa_hexdump(MSG_DEBUG, "PTK:KCK", sta->ptk.kck, 16);
        wpa_hexdump(MSG_DEBUG, "PTK:KEK", sta->ptk.kek, 16);
@@ -145,16 +148,16 @@ static void derive_ptk(struct wlantest *wt, struct wlantest_bss *bss,
                   MAC2STR(sta->addr));
        dl_list_for_each(pmk, &bss->pmk, struct wlantest_pmk, list) {
                wpa_printf(MSG_DEBUG, "Try per-BSS PMK");
-               if (try_pmk(bss, sta, ver, data, len, pmk) == 0)
+               if (try_pmk(wt, bss, sta, ver, data, len, pmk) == 0)
                        return;
        }
 
        dl_list_for_each(pmk, &wt->pmk, struct wlantest_pmk, list) {
                wpa_printf(MSG_DEBUG, "Try global PMK");
-               if (try_pmk(bss, sta, ver, data, len, pmk) == 0)
+               if (try_pmk(wt, bss, sta, ver, data, len, pmk) == 0)
                        return;
        }
-       wpa_printf(MSG_DEBUG, "No matching PMK found to derive PTK");
+       add_note(wt, MSG_DEBUG, "No matching PMK found to derive PTK");
 }
 
 
@@ -181,12 +184,12 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
        eapol = (const struct ieee802_1x_hdr *) data;
        hdr = (const struct wpa_eapol_key *) (eapol + 1);
        if (is_zero(hdr->key_nonce, WPA_NONCE_LEN)) {
-               wpa_printf(MSG_INFO, "EAPOL-Key 2/4 from " MACSTR " used "
-                          "zero nonce", MAC2STR(src));
+               add_note(wt, MSG_INFO, "EAPOL-Key 2/4 from " MACSTR
+                        " used zero nonce", MAC2STR(src));
        }
        if (!is_zero(hdr->key_rsc, 8)) {
-               wpa_printf(MSG_INFO, "EAPOL-Key 2/4 from " MACSTR " used "
-                          "non-zero Key RSC", MAC2STR(src));
+               add_note(wt, MSG_INFO, "EAPOL-Key 2/4 from " MACSTR
+                        " used non-zero Key RSC", MAC2STR(src));
        }
        os_memcpy(sta->snonce, hdr->key_nonce, WPA_NONCE_LEN);
        key_info = WPA_GET_BE16(hdr->key_info);
@@ -194,25 +197,27 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
        derive_ptk(wt, bss, sta, key_info & WPA_KEY_INFO_TYPE_MASK, data, len);
 
        if (!sta->ptk_set && !sta->tptk_set) {
-               wpa_printf(MSG_DEBUG, "No PTK known to process EAPOL-Key 2/4");
+               add_note(wt, MSG_DEBUG,
+                        "No PTK known to process EAPOL-Key 2/4");
                return;
        }
 
        kck = sta->ptk.kck;
        if (sta->tptk_set) {
-               wpa_printf(MSG_DEBUG, "Use TPTK for validation EAPOL-Key MIC");
+               add_note(wt, MSG_DEBUG,
+                        "Use TPTK for validation EAPOL-Key MIC");
                kck = sta->tptk.kck;
        }
        if (check_mic(kck, key_info & WPA_KEY_INFO_TYPE_MASK, data, len) < 0) {
-               wpa_printf(MSG_INFO, "Mismatch in EAPOL-Key 2/4 MIC");
+               add_note(wt, MSG_INFO, "Mismatch in EAPOL-Key 2/4 MIC");
                return;
        }
-       wpa_printf(MSG_DEBUG, "Valid MIC found in EAPOL-Key 2/4");
+       add_note(wt, MSG_DEBUG, "Valid MIC found in EAPOL-Key 2/4");
 
        key_data = (const u8 *) (hdr + 1);
 
        if (wpa_supplicant_parse_ies(key_data, key_data_len, &ie) < 0) {
-               wpa_printf(MSG_INFO, "Failed to parse EAPOL-Key Key Data");
+               add_note(wt, MSG_INFO, "Failed to parse EAPOL-Key Key Data");
                return;
        }
 
@@ -221,9 +226,10 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
                            ie.wpa_ie, ie.wpa_ie_len);
                if (os_memcmp(ie.wpa_ie, sta->rsnie, ie.wpa_ie_len) != 0) {
                        struct ieee802_11_elems elems;
-                       wpa_printf(MSG_INFO, "Mismatch in WPA IE between "
-                                  "EAPOL-Key 2/4 and (Re)Association "
-                                  "Request from " MACSTR, MAC2STR(sta->addr));
+                       add_note(wt, MSG_INFO,
+                                "Mismatch in WPA IE between EAPOL-Key 2/4 "
+                                "and (Re)Association Request from " MACSTR,
+                                MAC2STR(sta->addr));
                        wpa_hexdump(MSG_INFO, "WPA IE in EAPOL-Key",
                                    ie.wpa_ie, ie.wpa_ie_len);
                        wpa_hexdump(MSG_INFO, "WPA IE in (Re)Association "
@@ -249,9 +255,10 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
                            ie.rsn_ie, ie.rsn_ie_len);
                if (os_memcmp(ie.rsn_ie, sta->rsnie, ie.rsn_ie_len) != 0) {
                        struct ieee802_11_elems elems;
-                       wpa_printf(MSG_INFO, "Mismatch in RSN IE between "
-                                  "EAPOL-Key 2/4 and (Re)Association "
-                                  "Request from " MACSTR, MAC2STR(sta->addr));
+                       add_note(wt, MSG_INFO,
+                                "Mismatch in RSN IE between EAPOL-Key 2/4 "
+                                "and (Re)Association Request from " MACSTR,
+                                MAC2STR(sta->addr));
                        wpa_hexdump(MSG_INFO, "RSN IE in EAPOL-Key",
                                    ie.rsn_ie, ie.rsn_ie_len);
                        wpa_hexdump(MSG_INFO, "RSN IE in (Re)Association "
@@ -274,7 +281,7 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
 }
 
 
-static u8 * decrypt_eapol_key_data_rc4(const u8 *kek,
+static u8 * decrypt_eapol_key_data_rc4(struct wlantest *wt, const u8 *kek,
                                       const struct wpa_eapol_key *hdr,
                                       size_t *len)
 {
@@ -289,7 +296,7 @@ static u8 * decrypt_eapol_key_data_rc4(const u8 *kek,
        os_memcpy(ek + 16, kek, 16);
        os_memcpy(buf, hdr + 1, keydatalen);
        if (rc4_skip(ek, 32, 256, buf, keydatalen)) {
-               wpa_printf(MSG_INFO, "RC4 failed");
+               add_note(wt, MSG_INFO, "RC4 failed");
                os_free(buf);
                return NULL;
        }
@@ -299,7 +306,7 @@ static u8 * decrypt_eapol_key_data_rc4(const u8 *kek,
 }
 
 
-static u8 * decrypt_eapol_key_data_aes(const u8 *kek,
+static u8 * decrypt_eapol_key_data_aes(struct wlantest *wt, const u8 *kek,
                                       const struct wpa_eapol_key *hdr,
                                       size_t *len)
 {
@@ -307,8 +314,8 @@ static u8 * decrypt_eapol_key_data_aes(const u8 *kek,
        u16 keydatalen = WPA_GET_BE16(hdr->key_data_length);
 
        if (keydatalen % 8) {
-               wpa_printf(MSG_INFO, "Unsupported AES-WRAP len %d",
-                          keydatalen);
+               add_note(wt, MSG_INFO, "Unsupported AES-WRAP len %d",
+                        keydatalen);
                return NULL;
        }
        keydatalen -= 8; /* AES-WRAP adds 8 bytes */
@@ -317,8 +324,9 @@ static u8 * decrypt_eapol_key_data_aes(const u8 *kek,
                return NULL;
        if (aes_unwrap(kek, keydatalen / 8, (u8 *) (hdr + 1), buf)) {
                os_free(buf);
-               wpa_printf(MSG_INFO, "AES unwrap failed - "
-                          "could not decrypt EAPOL-Key key data");
+               add_note(wt, MSG_INFO,
+                        "AES unwrap failed - could not decrypt EAPOL-Key "
+                        "key data");
                return NULL;
        }
 
@@ -327,31 +335,33 @@ static u8 * decrypt_eapol_key_data_aes(const u8 *kek,
 }
 
 
-static u8 * decrypt_eapol_key_data(const u8 *kek, u16 ver,
+static u8 * decrypt_eapol_key_data(struct wlantest *wt, const u8 *kek, u16 ver,
                                   const struct wpa_eapol_key *hdr,
                                   size_t *len)
 {
        switch (ver) {
        case WPA_KEY_INFO_TYPE_HMAC_MD5_RC4:
-               return decrypt_eapol_key_data_rc4(kek, hdr, len);
+               return decrypt_eapol_key_data_rc4(wt, kek, hdr, len);
        case WPA_KEY_INFO_TYPE_HMAC_SHA1_AES:
        case WPA_KEY_INFO_TYPE_AES_128_CMAC:
-               return decrypt_eapol_key_data_aes(kek, hdr, len);
+               return decrypt_eapol_key_data_aes(wt, kek, hdr, len);
        default:
-               wpa_printf(MSG_INFO, "Unsupported EAPOL-Key Key Descriptor "
-                          "Version %u", ver);
+               add_note(wt, MSG_INFO,
+                        "Unsupported EAPOL-Key Key Descriptor Version %u",
+                        ver);
                return NULL;
        }
 }
 
 
-static void learn_kde_keys(struct wlantest_bss *bss, struct wlantest_sta *sta,
+static void learn_kde_keys(struct wlantest *wt, struct wlantest_bss *bss,
+                          struct wlantest_sta *sta,
                           const u8 *buf, size_t len, const u8 *rsc)
 {
        struct wpa_eapol_ie_parse ie;
 
        if (wpa_supplicant_parse_ies(buf, len, &ie) < 0) {
-               wpa_printf(MSG_INFO, "Failed to parse EAPOL-Key Key Data");
+               add_note(wt, MSG_INFO, "Failed to parse EAPOL-Key Key Data");
                return;
        }
 
@@ -373,10 +383,11 @@ static void learn_kde_keys(struct wlantest_bss *bss, struct wlantest_sta *sta,
                        id = ie.gtk[0] & 0x03;
                        wpa_printf(MSG_DEBUG, "GTK KeyID=%u tx=%u",
                                   id, !!(ie.gtk[0] & 0x04));
-                       if ((ie.gtk[0] & 0xf8) || ie.gtk[1])
-                               wpa_printf(MSG_INFO, "GTK KDE: Reserved field "
-                                          "set: %02x %02x",
-                                          ie.gtk[0], ie.gtk[1]);
+                       if ((ie.gtk[0] & 0xf8) || ie.gtk[1]) {
+                               add_note(wt, MSG_INFO,
+                                        "GTK KDE: Reserved field set: "
+                                        "%02x %02x", ie.gtk[0], ie.gtk[1]);
+                       }
                        wpa_hexdump(MSG_DEBUG, "GTK", ie.gtk + 2,
                                    ie.gtk_len - 2);
                        bss->gtk_len[id] = ie.gtk_len - 2;
@@ -393,8 +404,8 @@ static void learn_kde_keys(struct wlantest_bss *bss, struct wlantest_sta *sta,
                        sta->gtk_idx = id;
                        wpa_hexdump(MSG_DEBUG, "RSC", bss->rsc[id], 6);
                } else {
-                       wpa_printf(MSG_INFO, "Invalid GTK KDE length %u",
-                                  (unsigned) ie.gtk_len);
+                       add_note(wt, MSG_INFO, "Invalid GTK KDE length %u",
+                                (unsigned) ie.gtk_len);
                }
        }
 
@@ -405,8 +416,8 @@ static void learn_kde_keys(struct wlantest_bss *bss, struct wlantest_sta *sta,
                        u16 id;
                        id = WPA_GET_LE16(ie.igtk);
                        if (id > 5) {
-                               wpa_printf(MSG_INFO, "Unexpected IGTK KeyID "
-                                          "%u", id);
+                               add_note(wt, MSG_INFO,
+                                        "Unexpected IGTK KeyID %u", id);
                        } else {
                                const u8 *ipn;
                                wpa_printf(MSG_DEBUG, "IGTK KeyID %u", id);
@@ -425,8 +436,8 @@ static void learn_kde_keys(struct wlantest_bss *bss, struct wlantest_sta *sta,
                                bss->igtk_idx = id;
                        }
                } else {
-                       wpa_printf(MSG_INFO, "Invalid IGTK KDE length %u",
-                                  (unsigned) ie.igtk_len);
+                       add_note(wt, MSG_INFO, "Invalid IGTK KDE length %u",
+                                (unsigned) ie.igtk_len);
                }
        }
 }
@@ -461,8 +472,8 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
        key_info = WPA_GET_BE16(hdr->key_info);
 
        if (os_memcmp(sta->anonce, hdr->key_nonce, WPA_NONCE_LEN) != 0) {
-               wpa_printf(MSG_INFO, "EAPOL-Key ANonce mismatch between 1/4 "
-                          "and 3/4");
+               add_note(wt, MSG_INFO,
+                        "EAPOL-Key ANonce mismatch between 1/4 and 3/4");
                recalc = 1;
        }
        os_memcpy(sta->anonce, hdr->key_nonce, WPA_NONCE_LEN);
@@ -472,37 +483,39 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
        }
 
        if (!sta->ptk_set && !sta->tptk_set) {
-               wpa_printf(MSG_DEBUG, "No PTK known to process EAPOL-Key 3/4");
+               add_note(wt, MSG_DEBUG,
+                        "No PTK known to process EAPOL-Key 3/4");
                return;
        }
 
        kek = sta->ptk.kek;
        kck = sta->ptk.kck;
        if (sta->tptk_set) {
-               wpa_printf(MSG_DEBUG, "Use TPTK for validation EAPOL-Key MIC");
+               add_note(wt, MSG_DEBUG,
+                        "Use TPTK for validation EAPOL-Key MIC");
                kck = sta->tptk.kck;
                kek = sta->tptk.kek;
        }
        if (check_mic(kck, key_info & WPA_KEY_INFO_TYPE_MASK, data, len) < 0) {
-               wpa_printf(MSG_INFO, "Mismatch in EAPOL-Key 3/4 MIC");
+               add_note(wt, MSG_INFO, "Mismatch in EAPOL-Key 3/4 MIC");
                return;
        }
-       wpa_printf(MSG_DEBUG, "Valid MIC found in EAPOL-Key 3/4");
+       add_note(wt, MSG_DEBUG, "Valid MIC found in EAPOL-Key 3/4");
 
        key_data = (const u8 *) (hdr + 1);
        if (!(key_info & WPA_KEY_INFO_ENCR_KEY_DATA)) {
                if (sta->proto & WPA_PROTO_RSN)
-                       wpa_printf(MSG_INFO, "EAPOL-Key 3/4 without "
-                                  "EncrKeyData bit");
+                       add_note(wt, MSG_INFO,
+                                "EAPOL-Key 3/4 without EncrKeyData bit");
                decrypted = key_data;
                decrypted_len = WPA_GET_BE16(hdr->key_data_length);
        } else {
                ver = key_info & WPA_KEY_INFO_TYPE_MASK;
-               decrypted_buf = decrypt_eapol_key_data(kek, ver, hdr,
+               decrypted_buf = decrypt_eapol_key_data(wt, kek, ver, hdr,
                                                       &decrypted_len);
                if (decrypted_buf == NULL) {
-                       wpa_printf(MSG_INFO, "Failed to decrypt EAPOL-Key Key "
-                                  "Data");
+                       add_note(wt, MSG_INFO,
+                                "Failed to decrypt EAPOL-Key Key Data");
                        return;
                }
                decrypted = decrypted_buf;
@@ -550,7 +563,7 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
        }
 
        if (wpa_supplicant_parse_ies(decrypted, decrypted_len, &ie) < 0) {
-               wpa_printf(MSG_INFO, "Failed to parse EAPOL-Key Key Data");
+               add_note(wt, MSG_INFO, "Failed to parse EAPOL-Key Key Data");
                os_free(decrypted_buf);
                return;
        }
@@ -558,9 +571,10 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
        if ((ie.wpa_ie &&
             os_memcmp(ie.wpa_ie, bss->wpaie, ie.wpa_ie_len) != 0) ||
            (ie.wpa_ie == NULL && bss->wpaie[0])) {
-               wpa_printf(MSG_INFO, "Mismatch in WPA IE between "
-                          "EAPOL-Key 3/4 and Beacon/Probe Response "
-                          "from " MACSTR, MAC2STR(bss->bssid));
+               add_note(wt, MSG_INFO,
+                        "Mismatch in WPA IE between EAPOL-Key 3/4 and "
+                        "Beacon/Probe Response from " MACSTR,
+                        MAC2STR(bss->bssid));
                wpa_hexdump(MSG_INFO, "WPA IE in EAPOL-Key",
                            ie.wpa_ie, ie.wpa_ie_len);
                wpa_hexdump(MSG_INFO, "WPA IE in Beacon/Probe "
@@ -572,9 +586,9 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
        if ((ie.rsn_ie &&
             os_memcmp(ie.rsn_ie, bss->rsnie, ie.rsn_ie_len) != 0) ||
            (ie.rsn_ie == NULL && bss->rsnie[0])) {
-               wpa_printf(MSG_INFO, "Mismatch in RSN IE between "
-                          "EAPOL-Key 3/4 and Beacon/Probe Response "
-                          "from " MACSTR, MAC2STR(bss->bssid));
+               add_note(wt, MSG_INFO, "Mismatch in RSN IE between EAPOL-Key "
+                        "3/4 and Beacon/Probe Response from " MACSTR,
+                        MAC2STR(bss->bssid));
                wpa_hexdump(MSG_INFO, "RSN IE in EAPOL-Key",
                            ie.rsn_ie, ie.rsn_ie_len);
                wpa_hexdump(MSG_INFO, "RSN IE in (Re)Association "
@@ -583,7 +597,7 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
                            bss->rsnie[0] ? 2 + bss->rsnie[1] : 0);
        }
 
-       learn_kde_keys(bss, sta, decrypted, decrypted_len, hdr->key_rsc);
+       learn_kde_keys(wt, bss, sta, decrypted, decrypted_len, hdr->key_rsc);
        os_free(decrypted_buf);
 }
 
@@ -684,7 +698,7 @@ static void rx_data_eapol_key_1_of_2(struct wlantest *wt, const u8 *dst,
                return;
        }
        ver = key_info & WPA_KEY_INFO_TYPE_MASK;
-       decrypted = decrypt_eapol_key_data(sta->ptk.kek, ver, hdr,
+       decrypted = decrypt_eapol_key_data(wt, sta->ptk.kek, ver, hdr,
                                           &decrypted_len);
        if (decrypted == NULL) {
                wpa_printf(MSG_INFO, "Failed to decrypt EAPOL-Key Key Data");
@@ -731,7 +745,7 @@ static void rx_data_eapol_key_1_of_2(struct wlantest *wt, const u8 *dst,
                                     decrypted, plain_len);
        }
        if (sta->proto & WPA_PROTO_RSN)
-               learn_kde_keys(bss, sta, decrypted, decrypted_len,
+               learn_kde_keys(wt, bss, sta, decrypted, decrypted_len,
                               hdr->key_rsc);
        else {
                int klen = bss->group_cipher == WPA_CIPHER_TKIP ? 32 : 16;
index 016004d0e73f30a00b54c5711e7af7eb535213a8..3192d128dfe3b22b40af28e1290aac59617017aa 100644 (file)
@@ -14,8 +14,8 @@
 #include "wlantest.h"
 
 
-static void ping_update(struct wlantest_sta *sta, int req, u32 src, u32 dst,
-                       u16 id, u16 seq)
+static void ping_update(struct wlantest *wt, struct wlantest_sta *sta, int req,
+                       u32 src, u32 dst, u16 id, u16 seq)
 {
        if (req) {
                sta->icmp_echo_req_src = src;
@@ -34,8 +34,8 @@ static void ping_update(struct wlantest_sta *sta, int req, u32 src, u32 dst,
                    sta->counters[WLANTEST_STA_COUNTER_REASSOCREQ_TX] == 0)
                        sta->counters[
                                WLANTEST_STA_COUNTER_PING_OK_FIRST_ASSOC]++;
-               wpa_printf(MSG_DEBUG, "ICMP echo (ping) match for STA " MACSTR,
-                          MAC2STR(sta->addr));
+               add_note(wt, MSG_DEBUG, "ICMP echo (ping) match for STA "
+                        MACSTR, MAC2STR(sta->addr));
        }
 }
 
@@ -68,15 +68,15 @@ static void rx_data_icmp(struct wlantest *wt, const u8 *bssid,
        addr.s_addr = dst;
        snprintf(buf, sizeof(buf), "%s", inet_ntoa(addr));
        addr.s_addr = src;
-       wpa_printf(MSG_DEBUG, "ICMP echo %s %s -> %s id=%04x seq=%u len=%u%s",
-                  hdr->type == ICMP_ECHO ? "request" : "response",
-                  inet_ntoa(addr), buf, id, seq, (unsigned) len - 8,
-                  peer_addr ? " [DL]" : "");
+       add_note(wt, MSG_DEBUG, "ICMP echo %s %s -> %s id=%04x seq=%u len=%u%s",
+                hdr->type == ICMP_ECHO ? "request" : "response",
+                inet_ntoa(addr), buf, id, seq, (unsigned) len - 8,
+                peer_addr ? " [DL]" : "");
 
        bss = bss_find(wt, bssid);
        if (bss == NULL) {
-               wpa_printf(MSG_INFO, "No BSS " MACSTR " known for ICMP packet",
-                          MAC2STR(bssid));
+               add_note(wt, MSG_INFO, "No BSS " MACSTR
+                        " known for ICMP packet", MAC2STR(bssid));
                return;
        }
 
@@ -85,14 +85,14 @@ static void rx_data_icmp(struct wlantest *wt, const u8 *bssid,
 
        sta = sta_find(bss, sta_addr);
        if (sta == NULL) {
-               wpa_printf(MSG_INFO, "No STA " MACSTR " known for ICMP packet",
-                          MAC2STR(sta_addr));
+               add_note(wt, MSG_INFO, "No STA " MACSTR
+                        " known for ICMP packet", MAC2STR(sta_addr));
                return;
        }
 
-       ping_update(sta, hdr->type == ICMP_ECHO, src, dst, id, seq);
+       ping_update(wt, sta, hdr->type == ICMP_ECHO, src, dst, id, seq);
        if (peer_addr && (sta = sta_find(bss, peer_addr)))
-               ping_update(sta, hdr->type == ICMP_ECHO, src, dst, id, seq);
+               ping_update(wt, sta, hdr->type == ICMP_ECHO, src, dst, id, seq);
 }
 
 
@@ -109,24 +109,24 @@ void rx_data_ip(struct wlantest *wt, const u8 *bssid, const u8 *sta_addr,
        if (len < sizeof(*ip))
                return;
        if (ip->version != 4) {
-               wpa_printf(MSG_DEBUG, "Unexpected IP protocol version %u in "
-                          "IPv4 packet (bssid=" MACSTR " str=" MACSTR
-                          " dst=" MACSTR ")", ip->version, MAC2STR(bssid),
-                          MAC2STR(src), MAC2STR(dst));
+               add_note(wt, MSG_DEBUG, "Unexpected IP protocol version %u in "
+                        "IPv4 packet (bssid=" MACSTR " str=" MACSTR
+                        " dst=" MACSTR ")", ip->version, MAC2STR(bssid),
+                        MAC2STR(src), MAC2STR(dst));
                return;
        }
        if (ip->ihl * 4 < sizeof(*ip)) {
-               wpa_printf(MSG_DEBUG, "Unexpected IP header length %u in "
-                          "IPv4 packet (bssid=" MACSTR " str=" MACSTR
-                          " dst=" MACSTR ")", ip->ihl, MAC2STR(bssid),
-                          MAC2STR(src), MAC2STR(dst));
+               add_note(wt, MSG_DEBUG, "Unexpected IP header length %u in "
+                        "IPv4 packet (bssid=" MACSTR " str=" MACSTR
+                        " dst=" MACSTR ")", ip->ihl, MAC2STR(bssid),
+                        MAC2STR(src), MAC2STR(dst));
                return;
        }
        if (ip->ihl * 4 > len) {
-               wpa_printf(MSG_DEBUG, "Truncated IP header (ihl=%u len=%u) in "
-                          "IPv4 packet (bssid=" MACSTR " str=" MACSTR
-                          " dst=" MACSTR ")", ip->ihl, (unsigned) len,
-                          MAC2STR(bssid), MAC2STR(src), MAC2STR(dst));
+               add_note(wt, MSG_DEBUG, "Truncated IP header (ihl=%u len=%u) "
+                        "in IPv4 packet (bssid=" MACSTR " str=" MACSTR
+                        " dst=" MACSTR ")", ip->ihl, (unsigned) len,
+                        MAC2STR(bssid), MAC2STR(src), MAC2STR(dst));
                return;
        }
 
index 0d72f225eba22c3bd4ec15369fd799941667e292..a2df0e9b24d47154a3d2d39d31d683ea951aac3b 100644 (file)
@@ -65,8 +65,8 @@ static void rx_mgmt_beacon(struct wlantest *wt, const u8 *data, size_t len)
                                   &elems, 0) == ParseFailed) {
                if (bss->parse_error_reported)
                        return;
-               wpa_printf(MSG_INFO, "Invalid IEs in a Beacon frame from "
-                          MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Invalid IEs in a Beacon frame from "
+                        MACSTR, MAC2STR(mgmt->sa));
                bss->parse_error_reported = 1;
                return;
        }
@@ -92,8 +92,8 @@ static void rx_mgmt_probe_resp(struct wlantest *wt, const u8 *data, size_t len)
                                   &elems, 0) == ParseFailed) {
                if (bss->parse_error_reported)
                        return;
-               wpa_printf(MSG_INFO, "Invalid IEs in a Probe Response frame "
-                          "from " MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Invalid IEs in a Probe Response frame "
+                        "from " MACSTR, MAC2STR(mgmt->sa));
                bss->parse_error_reported = 1;
                return;
        }
@@ -121,8 +121,8 @@ static void rx_mgmt_auth(struct wlantest *wt, const u8 *data, size_t len)
                return;
 
        if (len < 24 + 6) {
-               wpa_printf(MSG_INFO, "Too short Authentication frame from "
-                          MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short Authentication frame from "
+                        MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -136,9 +136,9 @@ static void rx_mgmt_auth(struct wlantest *wt, const u8 *data, size_t len)
 
        if (alg == 0 && trans == 2 && status == 0) {
                if (sta->state == STATE1) {
-                       wpa_printf(MSG_DEBUG, "STA " MACSTR
-                                  " moved to State 2 with " MACSTR,
-                                  MAC2STR(sta->addr), MAC2STR(bss->bssid));
+                       add_note(wt, MSG_DEBUG, "STA " MACSTR
+                                " moved to State 2 with " MACSTR,
+                                MAC2STR(sta->addr), MAC2STR(bss->bssid));
                        sta->state = STATE2;
                }
        }
@@ -150,28 +150,29 @@ static void rx_mgmt_auth(struct wlantest *wt, const u8 *data, size_t len)
 }
 
 
-static void deauth_all_stas(struct wlantest_bss *bss)
+static void deauth_all_stas(struct wlantest *wt, struct wlantest_bss *bss)
 {
        struct wlantest_sta *sta;
        dl_list_for_each(sta, &bss->sta, struct wlantest_sta, list) {
                if (sta->state == STATE1)
                        continue;
-               wpa_printf(MSG_DEBUG, "STA " MACSTR
-                          " moved to State 1 with " MACSTR,
-                          MAC2STR(sta->addr), MAC2STR(bss->bssid));
+               add_note(wt, MSG_DEBUG, "STA " MACSTR
+                        " moved to State 1 with " MACSTR,
+                        MAC2STR(sta->addr), MAC2STR(bss->bssid));
                sta->state = STATE1;
        }
 }
 
 
-static void tdls_link_down(struct wlantest_bss *bss, struct wlantest_sta *sta)
+static void tdls_link_down(struct wlantest *wt, struct wlantest_bss *bss,
+                          struct wlantest_sta *sta)
 {
        struct wlantest_tdls *tdls;
        dl_list_for_each(tdls, &bss->tdls, struct wlantest_tdls, list) {
                if ((tdls->init == sta || tdls->resp == sta) && tdls->link_up)
                {
-                       wpa_printf(MSG_DEBUG, "TDLS: Set link down based on "
-                                  "STA deauth/disassoc");
+                       add_note(wt, MSG_DEBUG, "TDLS: Set link down based on "
+                                "STA deauth/disassoc");
                        tdls->link_up = 0;
                }
        }
@@ -196,8 +197,8 @@ static void rx_mgmt_deauth(struct wlantest *wt, const u8 *data, size_t len,
                sta = sta_get(bss, mgmt->sa);
 
        if (len < 24 + 2) {
-               wpa_printf(MSG_INFO, "Too short Deauthentication frame from "
-                          MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short Deauthentication frame from "
+                        MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -210,7 +211,7 @@ static void rx_mgmt_deauth(struct wlantest *wt, const u8 *data, size_t len,
 
        if (sta == NULL) {
                if (valid && mgmt->da[0] == 0xff)
-                       deauth_all_stas(bss);
+                       deauth_all_stas(wt, bss);
                return;
        }
 
@@ -232,19 +233,19 @@ static void rx_mgmt_deauth(struct wlantest *wt, const u8 *data, size_t len,
                              WLANTEST_STA_COUNTER_INVALID_DEAUTH_TX]++;
 
        if (!valid) {
-               wpa_printf(MSG_INFO, "Do not change STA " MACSTR " State "
-                          "since Disassociation frame was not protected "
-                          "correctly", MAC2STR(sta->addr));
+               add_note(wt, MSG_INFO, "Do not change STA " MACSTR " State "
+                        "since Disassociation frame was not protected "
+                        "correctly", MAC2STR(sta->addr));
                return;
        }
 
        if (sta->state != STATE1) {
-               wpa_printf(MSG_DEBUG, "STA " MACSTR
-                          " moved to State 1 with " MACSTR,
-                          MAC2STR(sta->addr), MAC2STR(bss->bssid));
+               add_note(wt, MSG_DEBUG, "STA " MACSTR
+                        " moved to State 1 with " MACSTR,
+                        MAC2STR(sta->addr), MAC2STR(bss->bssid));
                sta->state = STATE1;
        }
-       tdls_link_down(bss, sta);
+       tdls_link_down(wt, bss, sta);
 }
 
 
@@ -264,8 +265,8 @@ static void rx_mgmt_assoc_req(struct wlantest *wt, const u8 *data, size_t len)
                return;
 
        if (len < 24 + 4) {
-               wpa_printf(MSG_INFO, "Too short Association Request frame "
-                          "from " MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short Association Request frame "
+                        "from " MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -280,8 +281,8 @@ static void rx_mgmt_assoc_req(struct wlantest *wt, const u8 *data, size_t len)
        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));
+               add_note(wt, MSG_INFO, "Invalid IEs in Association Request "
+                        "frame from " MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -315,8 +316,8 @@ static void rx_mgmt_assoc_resp(struct wlantest *wt, const u8 *data, size_t len)
                return;
 
        if (len < 24 + 6) {
-               wpa_printf(MSG_INFO, "Too short Association Response frame "
-                          "from " MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short Association Response frame "
+                        "from " MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -335,17 +336,17 @@ static void rx_mgmt_assoc_resp(struct wlantest *wt, const u8 *data, size_t len)
                size_t ies_len = len - (mgmt->u.assoc_resp.variable - data);
                if (ieee802_11_parse_elems(ies, ies_len, &elems, 0) ==
                    ParseFailed) {
-                       wpa_printf(MSG_INFO, "Failed to parse IEs in "
-                                  "AssocResp from " MACSTR,
-                                  MAC2STR(mgmt->sa));
+                       add_note(wt, MSG_INFO, "Failed to parse IEs in "
+                                "AssocResp from " MACSTR,
+                                MAC2STR(mgmt->sa));
                } else if (elems.timeout_int == NULL ||
                           elems.timeout_int_len != 5 ||
                           elems.timeout_int[0] !=
                           WLAN_TIMEOUT_ASSOC_COMEBACK) {
-                       wpa_printf(MSG_INFO, "No valid Timeout Interval IE "
-                                  "with Assoc Comeback time in AssocResp "
-                                  "(status=30) from " MACSTR,
-                                  MAC2STR(mgmt->sa));
+                       add_note(wt, MSG_INFO, "No valid Timeout Interval IE "
+                                "with Assoc Comeback time in AssocResp "
+                                "(status=30) from " MACSTR,
+                                MAC2STR(mgmt->sa));
                } else {
                        sta->counters[
                                WLANTEST_STA_COUNTER_ASSOCRESP_COMEBACK]++;
@@ -356,21 +357,22 @@ static void rx_mgmt_assoc_resp(struct wlantest *wt, const u8 *data, size_t len)
                return;
 
        if ((aid & 0xc000) != 0xc000) {
-               wpa_printf(MSG_DEBUG, "Two MSBs of the AID were not set to 1 "
-                          "in Association Response from " MACSTR,
-                          MAC2STR(mgmt->sa));
+               add_note(wt, MSG_DEBUG, "Two MSBs of the AID were not set to 1 "
+                        "in Association Response from " MACSTR,
+                        MAC2STR(mgmt->sa));
        }
        sta->aid = aid & 0xc000;
 
        if (sta->state < STATE2) {
-               wpa_printf(MSG_DEBUG, "STA " MACSTR " was not in State 2 when "
-                          "getting associated", MAC2STR(sta->addr));
+               add_note(wt, MSG_DEBUG,
+                        "STA " MACSTR " was not in State 2 when "
+                        "getting associated", MAC2STR(sta->addr));
        }
 
        if (sta->state < STATE3) {
-               wpa_printf(MSG_DEBUG, "STA " MACSTR
-                          " moved to State 3 with " MACSTR,
-                          MAC2STR(sta->addr), MAC2STR(bss->bssid));
+               add_note(wt, MSG_DEBUG, "STA " MACSTR
+                        " moved to State 3 with " MACSTR,
+                        MAC2STR(sta->addr), MAC2STR(bss->bssid));
                sta->state = STATE3;
        }
 }
@@ -393,8 +395,8 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
                return;
 
        if (len < 24 + 4 + ETH_ALEN) {
-               wpa_printf(MSG_INFO, "Too short Reassociation Request frame "
-                          "from " MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short Reassociation Request frame "
+                        "from " MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -410,8 +412,8 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
        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));
+               add_note(wt, MSG_INFO, "Invalid IEs in Reassociation Request "
+                        "frame from " MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -447,8 +449,8 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data,
                return;
 
        if (len < 24 + 6) {
-               wpa_printf(MSG_INFO, "Too short Reassociation Response frame "
-                          "from " MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short Reassociation Response frame "
+                        "from " MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -467,17 +469,17 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data,
                size_t ies_len = len - (mgmt->u.reassoc_resp.variable - data);
                if (ieee802_11_parse_elems(ies, ies_len, &elems, 0) ==
                    ParseFailed) {
-                       wpa_printf(MSG_INFO, "Failed to parse IEs in "
-                                  "ReassocResp from " MACSTR,
-                                  MAC2STR(mgmt->sa));
+                       add_note(wt, MSG_INFO, "Failed to parse IEs in "
+                                "ReassocResp from " MACSTR,
+                                MAC2STR(mgmt->sa));
                } else if (elems.timeout_int == NULL ||
                           elems.timeout_int_len != 5 ||
                           elems.timeout_int[0] !=
                           WLAN_TIMEOUT_ASSOC_COMEBACK) {
-                       wpa_printf(MSG_INFO, "No valid Timeout Interval IE "
-                                  "with Assoc Comeback time in ReassocResp "
-                                  "(status=30) from " MACSTR,
-                                  MAC2STR(mgmt->sa));
+                       add_note(wt, MSG_INFO, "No valid Timeout Interval IE "
+                                "with Assoc Comeback time in ReassocResp "
+                                "(status=30) from " MACSTR,
+                                MAC2STR(mgmt->sa));
                } else {
                        sta->counters[
                                WLANTEST_STA_COUNTER_REASSOCRESP_COMEBACK]++;
@@ -488,35 +490,36 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data,
                return;
 
        if ((aid & 0xc000) != 0xc000) {
-               wpa_printf(MSG_DEBUG, "Two MSBs of the AID were not set to 1 "
-                          "in Reassociation Response from " MACSTR,
-                          MAC2STR(mgmt->sa));
+               add_note(wt, MSG_DEBUG, "Two MSBs of the AID were not set to 1 "
+                        "in Reassociation Response from " MACSTR,
+                        MAC2STR(mgmt->sa));
        }
        sta->aid = aid & 0xc000;
 
        if (sta->state < STATE2) {
-               wpa_printf(MSG_DEBUG, "STA " MACSTR " was not in State 2 when "
-                          "getting associated", MAC2STR(sta->addr));
+               add_note(wt, MSG_DEBUG,
+                        "STA " MACSTR " was not in State 2 when "
+                        "getting associated", MAC2STR(sta->addr));
        }
 
        if (sta->state < STATE3) {
-               wpa_printf(MSG_DEBUG, "STA " MACSTR
-                          " moved to State 3 with " MACSTR,
-                          MAC2STR(sta->addr), MAC2STR(bss->bssid));
+               add_note(wt, MSG_DEBUG, "STA " MACSTR
+                        " moved to State 3 with " MACSTR,
+                        MAC2STR(sta->addr), MAC2STR(bss->bssid));
                sta->state = STATE3;
        }
 }
 
 
-static void disassoc_all_stas(struct wlantest_bss *bss)
+static void disassoc_all_stas(struct wlantest *wt, struct wlantest_bss *bss)
 {
        struct wlantest_sta *sta;
        dl_list_for_each(sta, &bss->sta, struct wlantest_sta, list) {
                if (sta->state <= STATE2)
                        continue;
-               wpa_printf(MSG_DEBUG, "STA " MACSTR
-                          " moved to State 2 with " MACSTR,
-                          MAC2STR(sta->addr), MAC2STR(bss->bssid));
+               add_note(wt, MSG_DEBUG, "STA " MACSTR
+                        " moved to State 2 with " MACSTR,
+                        MAC2STR(sta->addr), MAC2STR(bss->bssid));
                sta->state = STATE2;
        }
 }
@@ -540,8 +543,8 @@ static void rx_mgmt_disassoc(struct wlantest *wt, const u8 *data, size_t len,
                sta = sta_get(bss, mgmt->sa);
 
        if (len < 24 + 2) {
-               wpa_printf(MSG_INFO, "Too short Disassociation frame from "
-                          MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short Disassociation frame from "
+                        MACSTR, MAC2STR(mgmt->sa));
                return;
        }
 
@@ -554,7 +557,7 @@ static void rx_mgmt_disassoc(struct wlantest *wt, const u8 *data, size_t len,
 
        if (sta == NULL) {
                if (valid && mgmt->da[0] == 0xff)
-                       disassoc_all_stas(bss);
+                       disassoc_all_stas(wt, bss);
                return;
        }
 
@@ -578,24 +581,25 @@ static void rx_mgmt_disassoc(struct wlantest *wt, const u8 *data, size_t len,
                              WLANTEST_STA_COUNTER_INVALID_DISASSOC_TX]++;
 
        if (!valid) {
-               wpa_printf(MSG_INFO, "Do not change STA " MACSTR " State "
-                          "since Disassociation frame was not protected "
-                          "correctly", MAC2STR(sta->addr));
+               add_note(wt, MSG_INFO, "Do not change STA " MACSTR " State "
+                        "since Disassociation frame was not protected "
+                        "correctly", MAC2STR(sta->addr));
                return;
        }
 
        if (sta->state < STATE2) {
-               wpa_printf(MSG_DEBUG, "STA " MACSTR " was not in State 2 or 3 "
-                          "when getting disassociated", MAC2STR(sta->addr));
+               add_note(wt, MSG_DEBUG,
+                        "STA " MACSTR " was not in State 2 or 3 "
+                        "when getting disassociated", MAC2STR(sta->addr));
        }
 
        if (sta->state > STATE2) {
-               wpa_printf(MSG_DEBUG, "STA " MACSTR
-                          " moved to State 2 with " MACSTR,
-                          MAC2STR(sta->addr), MAC2STR(bss->bssid));
+               add_note(wt, MSG_DEBUG, "STA " MACSTR
+                        " moved to State 2 with " MACSTR,
+                        MAC2STR(sta->addr), MAC2STR(bss->bssid));
                sta->state = STATE2;
        }
-       tdls_link_down(bss, sta);
+       tdls_link_down(wt, bss, sta);
 }
 
 
@@ -612,10 +616,10 @@ static void rx_mgmt_action_sa_query_req(struct wlantest *wt,
                id = sta->ap_sa_query_tr;
        else
                id = sta->sta_sa_query_tr;
-       wpa_printf(MSG_INFO, "SA Query Request " MACSTR " -> " MACSTR
-                  " (trans_id=%02x%02x)%s",
-                  MAC2STR(mgmt->sa), MAC2STR(mgmt->da), rx_id[0], rx_id[1],
-                  valid ? "" : " (invalid protection)");
+       add_note(wt, MSG_INFO, "SA Query Request " MACSTR " -> " MACSTR
+                " (trans_id=%02x%02x)%s",
+                MAC2STR(mgmt->sa), MAC2STR(mgmt->da), rx_id[0], rx_id[1],
+                valid ? "" : " (invalid protection)");
        os_memcpy(id, mgmt->u.action.u.sa_query_req.trans_id, 2);
        if (os_memcmp(mgmt->sa, sta->addr, ETH_ALEN) == 0)
                sta->counters[valid ?
@@ -643,11 +647,11 @@ static void rx_mgmt_action_sa_query_resp(struct wlantest *wt,
        else
                id = sta->ap_sa_query_tr;
        match = os_memcmp(rx_id, id, 2) == 0;
-       wpa_printf(MSG_INFO, "SA Query Response " MACSTR " -> " MACSTR
-                  " (trans_id=%02x%02x; %s)%s",
-                  MAC2STR(mgmt->sa), MAC2STR(mgmt->da), rx_id[0], rx_id[1],
-                  match ? "match" : "mismatch",
-                  valid ? "" : " (invalid protection)");
+       add_note(wt, MSG_INFO, "SA Query Response " MACSTR " -> " MACSTR
+                " (trans_id=%02x%02x; %s)%s",
+                MAC2STR(mgmt->sa), MAC2STR(mgmt->da), rx_id[0], rx_id[1],
+                match ? "match" : "mismatch",
+                valid ? "" : " (invalid protection)");
        if (os_memcmp(mgmt->sa, sta->addr, ETH_ALEN) == 0)
                sta->counters[(valid && match) ?
                              WLANTEST_STA_COUNTER_VALID_SAQUERYRESP_TX :
@@ -665,16 +669,16 @@ static void rx_mgmt_action_sa_query(struct wlantest *wt,
                                    size_t len, int valid)
 {
        if (len < 24 + 2 + WLAN_SA_QUERY_TR_ID_LEN) {
-               wpa_printf(MSG_INFO, "Too short SA Query frame from " MACSTR,
-                          MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short SA Query frame from " MACSTR,
+                        MAC2STR(mgmt->sa));
                return;
        }
 
        if (len > 24 + 2 + WLAN_SA_QUERY_TR_ID_LEN) {
                size_t elen = len - (24 + 2 + WLAN_SA_QUERY_TR_ID_LEN);
-               wpa_printf(MSG_INFO, "Unexpected %u octets of extra data at "
-                          "the end of SA Query frame from " MACSTR,
-                          (unsigned) elen, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Unexpected %u octets of extra data at "
+                        "the end of SA Query frame from " MACSTR,
+                        (unsigned) elen, MAC2STR(mgmt->sa));
                wpa_hexdump(MSG_INFO, "SA Query extra data",
                            ((const u8 *) mgmt) + len - elen, elen);
        }
@@ -687,10 +691,10 @@ static void rx_mgmt_action_sa_query(struct wlantest *wt,
                rx_mgmt_action_sa_query_resp(wt, sta, mgmt, len, valid);
                break;
        default:
-               wpa_printf(MSG_INFO, "Unexpected SA Query action value %u "
-                          "from " MACSTR,
-                          mgmt->u.action.u.sa_query_req.action,
-                          MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Unexpected SA Query action value %u "
+                        "from " MACSTR,
+                        mgmt->u.action.u.sa_query_req.action,
+                        MAC2STR(mgmt->sa));
        }
 }
 
@@ -704,11 +708,11 @@ static void rx_mgmt_action(struct wlantest *wt, const u8 *data, size_t len,
 
        mgmt = (const struct ieee80211_mgmt *) data;
        if (mgmt->da[0] & 0x01) {
-               wpa_printf(MSG_DEBUG, "Group addressed Action frame: DA="
-                          MACSTR " SA=" MACSTR " BSSID=" MACSTR
-                          " category=%u",
-                          MAC2STR(mgmt->da), MAC2STR(mgmt->sa),
-                          MAC2STR(mgmt->bssid), mgmt->u.action.category);
+               add_note(wt, MSG_DEBUG, "Group addressed Action frame: DA="
+                        MACSTR " SA=" MACSTR " BSSID=" MACSTR
+                        " category=%u",
+                        MAC2STR(mgmt->da), MAC2STR(mgmt->sa),
+                        MAC2STR(mgmt->bssid), mgmt->u.action.category);
                return; /* Ignore group addressed Action frames for now */
        }
        bss = bss_get(wt, mgmt->bssid);
@@ -722,8 +726,8 @@ static void rx_mgmt_action(struct wlantest *wt, const u8 *data, size_t len,
                return;
 
        if (len < 24 + 1) {
-               wpa_printf(MSG_INFO, "Too short Action frame from "
-                          MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Too short Action frame from " MACSTR,
+                        MAC2STR(mgmt->sa));
                return;
        }
 
@@ -735,9 +739,9 @@ static void rx_mgmt_action(struct wlantest *wt, const u8 *data, size_t len,
 
        if (mgmt->u.action.category != WLAN_ACTION_PUBLIC &&
            sta->state < STATE3) {
-               wpa_printf(MSG_INFO, "Action frame sent when STA is not in "
-                          "State 3 (SA=" MACSTR " DATA=" MACSTR ")",
-                          MAC2STR(mgmt->sa), MAC2STR(mgmt->da));
+               add_note(wt, MSG_INFO, "Action frame sent when STA is not in "
+                        "State 3 (SA=" MACSTR " DATA=" MACSTR ")",
+                        MAC2STR(mgmt->sa), MAC2STR(mgmt->da));
        }
 
        switch (mgmt->u.action.category) {
@@ -813,9 +817,9 @@ static int check_bip(struct wlantest *wt, const u8 *data, size_t len)
            data[len - 17] != 16) {
                /* No MMIE */
                if (bss->rsn_capab & WPA_CAPABILITY_MFPC) {
-                       wpa_printf(MSG_INFO, "Robust group-addressed "
-                                  "management frame sent without BIP by "
-                                  MACSTR, MAC2STR(mgmt->sa));
+                       add_note(wt, MSG_INFO, "Robust group-addressed "
+                                "management frame sent without BIP by "
+                                MACSTR, MAC2STR(mgmt->sa));
                        bss->counters[WLANTEST_BSS_COUNTER_MISSING_BIP_MMIE]++;
                        return -1;
                }
@@ -825,13 +829,13 @@ static int check_bip(struct wlantest *wt, const u8 *data, size_t len)
        mmie = data + len - 16;
        keyid = WPA_GET_LE16(mmie);
        if (keyid & 0xf000) {
-               wpa_printf(MSG_INFO, "MMIE KeyID reserved bits not zero "
-                          "(%04x) from " MACSTR, keyid, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "MMIE KeyID reserved bits not zero "
+                        "(%04x) from " MACSTR, keyid, MAC2STR(mgmt->sa));
                keyid &= 0x0fff;
        }
        if (keyid < 4 || keyid > 5) {
-               wpa_printf(MSG_INFO, "Unexpected MMIE KeyID %u from " MACSTR,
-                          keyid, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Unexpected MMIE KeyID %u from " MACSTR,
+                        keyid, MAC2STR(mgmt->sa));
                bss->counters[WLANTEST_BSS_COUNTER_INVALID_BIP_MMIE]++;
                return 0;
        }
@@ -840,25 +844,25 @@ static int check_bip(struct wlantest *wt, const u8 *data, size_t len)
        wpa_hexdump(MSG_MSGDUMP, "MMIE MIC", mmie + 8, 8);
 
        if (!bss->igtk_set[keyid]) {
-               wpa_printf(MSG_DEBUG, "No IGTK known to validate BIP frame");
+               add_note(wt, MSG_DEBUG, "No IGTK known to validate BIP frame");
                return 0;
        }
 
        if (os_memcmp(mmie + 2, bss->ipn[keyid], 6) <= 0) {
-               wpa_printf(MSG_INFO, "BIP replay detected: SA=" MACSTR,
-                          MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "BIP replay detected: SA=" MACSTR,
+                        MAC2STR(mgmt->sa));
                wpa_hexdump(MSG_INFO, "RX IPN", mmie + 2, 6);
                wpa_hexdump(MSG_INFO, "Last RX IPN", bss->ipn[keyid], 6);
        }
 
        if (check_mmie_mic(bss->igtk[keyid], data, len) < 0) {
-               wpa_printf(MSG_INFO, "Invalid MMIE MIC in a frame from "
-                          MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Invalid MMIE MIC in a frame from "
+                        MACSTR, MAC2STR(mgmt->sa));
                bss->counters[WLANTEST_BSS_COUNTER_INVALID_BIP_MMIE]++;
                return -1;
        }
 
-       wpa_printf(MSG_DEBUG, "Valid MMIE MIC");
+       add_note(wt, MSG_DEBUG, "Valid MMIE MIC");
        os_memcpy(bss->ipn[keyid], mmie + 2, 6);
        bss->counters[WLANTEST_BSS_COUNTER_VALID_BIP_MMIE]++;
 
@@ -890,7 +894,7 @@ static u8 * mgmt_ccmp_decrypt(struct wlantest *wt, const u8 *data, size_t len,
        else
                sta = sta_get(bss, hdr->addr1);
        if (sta == NULL || !sta->ptk_set) {
-               wpa_printf(MSG_MSGDUMP, "No PTK known to decrypt the frame");
+               add_note(wt, MSG_MSGDUMP, "No PTK known to decrypt the frame");
                return NULL;
        }
 
@@ -898,22 +902,22 @@ static u8 * mgmt_ccmp_decrypt(struct wlantest *wt, const u8 *data, size_t len,
                return NULL;
 
        if (!(data[24 + 3] & 0x20)) {
-               wpa_printf(MSG_INFO, "Expected CCMP frame from " MACSTR
-                          " did not have ExtIV bit set to 1",
-                          MAC2STR(hdr->addr2));
+               add_note(wt, MSG_INFO, "Expected CCMP frame from " MACSTR
+                        " did not have ExtIV bit set to 1",
+                        MAC2STR(hdr->addr2));
                return NULL;
        }
 
        if (data[24 + 2] != 0 || (data[24 + 3] & 0x1f) != 0) {
-               wpa_printf(MSG_INFO, "CCMP mgmt frame from " MACSTR " used "
-                          "non-zero reserved bit", MAC2STR(hdr->addr2));
+               add_note(wt, MSG_INFO, "CCMP mgmt frame from " MACSTR " used "
+                        "non-zero reserved bit", MAC2STR(hdr->addr2));
        }
 
        keyid = data[24 + 3] >> 6;
        if (keyid != 0) {
-               wpa_printf(MSG_INFO, "Unexpected non-zero KeyID %d in "
-                          "individually addressed Management frame from "
-                          MACSTR, keyid, MAC2STR(hdr->addr2));
+               add_note(wt, MSG_INFO, "Unexpected non-zero KeyID %d in "
+                        "individually addressed Management frame from "
+                        MACSTR, keyid, MAC2STR(hdr->addr2));
        }
 
        if (os_memcmp(hdr->addr1, hdr->addr3, ETH_ALEN) == 0)
@@ -924,12 +928,12 @@ static u8 * mgmt_ccmp_decrypt(struct wlantest *wt, const u8 *data, size_t len,
        ccmp_get_pn(pn, data + 24);
        if (os_memcmp(pn, rsc, 6) <= 0) {
                u16 seq_ctrl = le_to_host16(hdr->seq_ctrl);
-               wpa_printf(MSG_INFO, "CCMP/TKIP replay detected: A1=" MACSTR
-                          " A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
-                          MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
-                          MAC2STR(hdr->addr3),
-                          WLAN_GET_SEQ_SEQ(seq_ctrl),
-                          WLAN_GET_SEQ_FRAG(seq_ctrl));
+               add_note(wt, MSG_INFO, "CCMP/TKIP replay detected: A1=" MACSTR
+                        " A2=" MACSTR " A3=" MACSTR " seq=%u frag=%u",
+                        MAC2STR(hdr->addr1), MAC2STR(hdr->addr2),
+                        MAC2STR(hdr->addr3),
+                        WLAN_GET_SEQ_SEQ(seq_ctrl),
+                        WLAN_GET_SEQ_FRAG(seq_ctrl));
                wpa_hexdump(MSG_INFO, "RX PN", pn, 6);
                wpa_hexdump(MSG_INFO, "RSC", rsc, 6);
        }
@@ -980,9 +984,9 @@ static int check_mgmt_ccmp(struct wlantest *wt, const u8 *data, size_t len)
        if ((sta->rsn_capab & WPA_CAPABILITY_MFPC) &&
            (sta->state == STATE3 ||
             WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_ACTION)) {
-               wpa_printf(MSG_INFO, "Robust individually-addressed "
-                          "management frame sent without CCMP by "
-                          MACSTR, MAC2STR(mgmt->sa));
+               add_note(wt, MSG_INFO, "Robust individually-addressed "
+                        "management frame sent without CCMP by "
+                        MACSTR, MAC2STR(mgmt->sa));
                return -1;
        }
 
@@ -1105,8 +1109,8 @@ static void rx_mgmt_deauth_ack(struct wlantest *wt,
        if (sta == NULL)
                return;
 
-       wpa_printf(MSG_DEBUG, "DEAUTH from " MACSTR " acknowledged by " MACSTR,
-                  MAC2STR(mgmt->sa), MAC2STR(mgmt->da));
+       add_note(wt, MSG_DEBUG, "DEAUTH from " MACSTR " acknowledged by "
+                MACSTR, MAC2STR(mgmt->sa), MAC2STR(mgmt->da));
        if (os_memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN) == 0) {
                int c;
                c = wt->last_mgmt_valid ?
@@ -1135,8 +1139,8 @@ static void rx_mgmt_disassoc_ack(struct wlantest *wt,
        if (sta == NULL)
                return;
 
-       wpa_printf(MSG_DEBUG, "DISASSOC from " MACSTR " acknowledged by "
-                  MACSTR, MAC2STR(mgmt->sa), MAC2STR(mgmt->da));
+       add_note(wt, MSG_DEBUG, "DISASSOC from " MACSTR " acknowledged by "
+                MACSTR, MAC2STR(mgmt->sa), MAC2STR(mgmt->da));
        if (os_memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN) == 0) {
                int c;
                c = wt->last_mgmt_valid ?
index 08a29a58843ba25f319fb8fec134be1d7661f0b4..1c506ac1d5b075df112938cf68a98226dd71f088 100644 (file)
@@ -28,11 +28,11 @@ static struct wlantest_tdls * get_tdls(struct wlantest *wt, const u8 *linkid,
        if (bss == NULL && bssid) {
                bss = bss_find(wt, bssid);
                if (bss)
-                       wpa_printf(MSG_INFO, "TDLS: Incorrect BSSID " MACSTR
-                                  " in LinkId?! (init=" MACSTR " resp="
-                                  MACSTR ")",
-                                  MAC2STR(linkid), MAC2STR(linkid + ETH_ALEN),
-                                  MAC2STR(linkid + 2 * ETH_ALEN));
+                       add_note(wt, MSG_INFO, "TDLS: Incorrect BSSID " MACSTR
+                                " in LinkId?! (init=" MACSTR " resp="
+                                MACSTR ")",
+                                MAC2STR(linkid), MAC2STR(linkid + ETH_ALEN),
+                                MAC2STR(linkid + 2 * ETH_ALEN));
        }
        if (bss == NULL)
                return NULL;
@@ -125,8 +125,8 @@ static int tdls_derive_tpk(struct wlantest_tdls *tdls, const u8 *bssid,
 }
 
 
-static int tdls_verify_mic(struct wlantest_tdls *tdls, u8 trans_seq,
-                          struct ieee802_11_elems *elems)
+static int tdls_verify_mic(struct wlantest *wt, struct wlantest_tdls *tdls,
+                          u8 trans_seq, struct ieee802_11_elems *elems)
 {
        u8 *buf, *pos;
        int len;
@@ -181,10 +181,10 @@ static int tdls_verify_mic(struct wlantest_tdls *tdls, u8 trans_seq,
        rx_ftie = (const struct rsn_ftie *) elems->ftie;
 
        if (os_memcmp(mic, rx_ftie->mic, 16) == 0) {
-               wpa_printf(MSG_DEBUG, "TDLS: Valid MIC");
+               add_note(wt, MSG_DEBUG, "TDLS: Valid MIC");
                return 0;
        }
-       wpa_printf(MSG_DEBUG, "TDLS: Invalid MIC");
+       add_note(wt, MSG_DEBUG, "TDLS: Invalid MIC");
        return -1;
 }
 
@@ -198,8 +198,8 @@ static void rx_data_tdls_setup_request(struct wlantest *wt, const u8 *bssid,
        struct wlantest_tdls *tdls;
 
        if (len < 3) {
-               wpa_printf(MSG_INFO, "Too short TDLS Setup Request " MACSTR
-                          " -> " MACSTR, MAC2STR(src), MAC2STR(dst));
+               add_note(wt, MSG_INFO, "Too short TDLS Setup Request " MACSTR
+                        " -> " MACSTR, MAC2STR(src), MAC2STR(dst));
                return;
        }
        wpa_printf(MSG_DEBUG, "TDLS Setup Request " MACSTR " -> "
@@ -230,8 +230,8 @@ static void rx_data_tdls_setup_response_failure(struct wlantest *wt,
        struct wlantest_sta *sta;
 
        if (status == WLAN_STATUS_SUCCESS) {
-               wpa_printf(MSG_INFO, "TDLS: Invalid TDLS Setup Response from "
-                          MACSTR, MAC2STR(sta_addr));
+               add_note(wt, MSG_INFO, "TDLS: Invalid TDLS Setup Response from "
+                        MACSTR, MAC2STR(sta_addr));
                return;
        }
 
@@ -245,13 +245,13 @@ static void rx_data_tdls_setup_response_failure(struct wlantest *wt,
        dl_list_for_each(tdls, &bss->tdls, struct wlantest_tdls, list) {
                if (tdls->resp == sta) {
                        if (dialog_token != tdls->dialog_token) {
-                               wpa_printf(MSG_DEBUG, "TDLS: Dialog token "
-                                          "mismatch in TDLS Setup Response "
-                                          "(failure)");
+                               add_note(wt, MSG_DEBUG, "TDLS: Dialog token "
+                                        "mismatch in TDLS Setup Response "
+                                        "(failure)");
                                break;
                        }
-                       wpa_printf(MSG_DEBUG, "TDLS: Found matching TDLS "
-                                  "setup session based on dialog token");
+                       add_note(wt, MSG_DEBUG, "TDLS: Found matching TDLS "
+                                "setup session based on dialog token");
                        tdls->counters[
                                WLANTEST_TDLS_COUNTER_SETUP_RESP_FAIL]++;
                        break;
@@ -270,8 +270,8 @@ static void rx_data_tdls_setup_response(struct wlantest *wt, const u8 *bssid,
        struct wlantest_tdls *tdls;
 
        if (len < 3) {
-               wpa_printf(MSG_INFO, "Too short TDLS Setup Response " MACSTR
-                          " -> " MACSTR, MAC2STR(src), MAC2STR(dst));
+               add_note(wt, MSG_INFO, "Too short TDLS Setup Response " MACSTR
+                        " -> " MACSTR, MAC2STR(src), MAC2STR(dst));
                return;
        }
        status = WPA_GET_LE16(data);
@@ -279,8 +279,8 @@ static void rx_data_tdls_setup_response(struct wlantest *wt, const u8 *bssid,
                   MACSTR " (status %d)",
                   MAC2STR(src), MAC2STR(dst), status);
        if (len < 5 && status == 0) {
-               wpa_printf(MSG_INFO, "Too short TDLS Setup Response " MACSTR
-                          " -> " MACSTR, MAC2STR(src), MAC2STR(dst));
+               add_note(wt, MSG_INFO, "Too short TDLS Setup Response " MACSTR
+                        " -> " MACSTR, MAC2STR(src), MAC2STR(dst));
                return;
        }
 
@@ -310,10 +310,10 @@ static void rx_data_tdls_setup_response(struct wlantest *wt, const u8 *bssid,
 
        if (tdls_derive_tpk(tdls, bssid, elems.ftie, elems.ftie_len) < 1)
                return;
-       if (tdls_verify_mic(tdls, 2, &elems) == 0) {
+       if (tdls_verify_mic(wt, tdls, 2, &elems) == 0) {
                tdls->dialog_token = data[2];
-               wpa_printf(MSG_DEBUG, "TDLS: Dialog Token for the link: %u",
-                          tdls->dialog_token);
+               add_note(wt, MSG_DEBUG, "TDLS: Dialog Token for the link: %u",
+                        tdls->dialog_token);
        }
 }
 
@@ -328,8 +328,8 @@ static void rx_data_tdls_setup_confirm_failure(struct wlantest *wt,
        struct wlantest_sta *sta;
 
        if (status == WLAN_STATUS_SUCCESS) {
-               wpa_printf(MSG_INFO, "TDLS: Invalid TDLS Setup Confirm from "
-                          MACSTR, MAC2STR(src));
+               add_note(wt, MSG_INFO, "TDLS: Invalid TDLS Setup Confirm from "
+                        MACSTR, MAC2STR(src));
                return;
        }
 
@@ -343,13 +343,13 @@ static void rx_data_tdls_setup_confirm_failure(struct wlantest *wt,
        dl_list_for_each(tdls, &bss->tdls, struct wlantest_tdls, list) {
                if (tdls->init == sta) {
                        if (dialog_token != tdls->dialog_token) {
-                               wpa_printf(MSG_DEBUG, "TDLS: Dialog token "
-                                          "mismatch in TDLS Setup Confirm "
-                                          "(failure)");
+                               add_note(wt, MSG_DEBUG, "TDLS: Dialog token "
+                                        "mismatch in TDLS Setup Confirm "
+                                        "(failure)");
                                break;
                        }
-                       wpa_printf(MSG_DEBUG, "TDLS: Found matching TDLS "
-                                  "setup session based on dialog token");
+                       add_note(wt, MSG_DEBUG, "TDLS: Found matching TDLS "
+                                "setup session based on dialog token");
                        tdls->counters[
                                WLANTEST_TDLS_COUNTER_SETUP_CONF_FAIL]++;
                        break;
@@ -369,8 +369,8 @@ static void rx_data_tdls_setup_confirm(struct wlantest *wt, const u8 *bssid,
        u8 link_id[3 * ETH_ALEN];
 
        if (len < 3) {
-               wpa_printf(MSG_INFO, "Too short TDLS Setup Confirm " MACSTR
-                          " -> " MACSTR, MAC2STR(src), MAC2STR(dst));
+               add_note(wt, MSG_INFO, "Too short TDLS Setup Confirm " MACSTR
+                        " -> " MACSTR, MAC2STR(src), MAC2STR(dst));
                return;
        }
        status = WPA_GET_LE16(data);
@@ -407,10 +407,10 @@ static void rx_data_tdls_setup_confirm(struct wlantest *wt, const u8 *bssid,
                        goto remove_reverse;
                return;
        }
-       if (tdls_verify_mic(tdls, 3, &elems) == 0) {
+       if (tdls_verify_mic(wt, tdls, 3, &elems) == 0) {
                tdls->dialog_token = data[2];
-               wpa_printf(MSG_DEBUG, "TDLS: Dialog Token for the link: %u",
-                          tdls->dialog_token);
+               add_note(wt, MSG_DEBUG, "TDLS: Dialog Token for the link: %u",
+                        tdls->dialog_token);
        }
 
 remove_reverse:
@@ -425,13 +425,14 @@ remove_reverse:
        os_memcpy(link_id + 2 * ETH_ALEN, elems.link_id + ETH_ALEN, ETH_ALEN);
        tdls = get_tdls(wt, link_id, 0, bssid);
        if (tdls) {
-               wpa_printf(MSG_DEBUG, "TDLS: Remove reverse link entry");
+               add_note(wt, MSG_DEBUG, "TDLS: Remove reverse link entry");
                tdls_deinit(tdls);
        }
 }
 
 
-static int tdls_verify_mic_teardown(struct wlantest_tdls *tdls, u8 trans_seq,
+static int tdls_verify_mic_teardown(struct wlantest *wt,
+                                   struct wlantest_tdls *tdls, u8 trans_seq,
                                    const u8 *reason_code,
                                    struct ieee802_11_elems *elems)
 {
@@ -479,10 +480,10 @@ static int tdls_verify_mic_teardown(struct wlantest_tdls *tdls, u8 trans_seq,
        rx_ftie = (const struct rsn_ftie *) elems->ftie;
 
        if (os_memcmp(mic, rx_ftie->mic, 16) == 0) {
-               wpa_printf(MSG_DEBUG, "TDLS: Valid MIC");
+               add_note(wt, MSG_DEBUG, "TDLS: Valid MIC");
                return 0;
        }
-       wpa_printf(MSG_DEBUG, "TDLS: Invalid MIC");
+       add_note(wt, MSG_DEBUG, "TDLS: Invalid MIC");
        return -1;
 }
 
@@ -515,7 +516,7 @@ static void rx_data_tdls_teardown(struct wlantest *wt, const u8 *bssid,
        if (tdls) {
                tdls->link_up = 0;
                tdls->counters[WLANTEST_TDLS_COUNTER_TEARDOWN]++;
-               tdls_verify_mic_teardown(tdls, 4, data, &elems);
+               tdls_verify_mic_teardown(wt, tdls, 4, data, &elems);
        }
 }