aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/rx_data.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2010-11-11 23:00:31 (GMT)
committerJouni Malinen <j@w1.fi>2010-11-11 23:00:31 (GMT)
commit64f45d070b13f260c2e2f7bb21527f5a809b5cde (patch)
treeea1812b9811ae4e49a16cf1fd00a836e10e37a1d /wlantest/rx_data.c
parent5db8cf314ef169cd256483e32dcc49e31e605121 (diff)
downloadhostap-64f45d070b13f260c2e2f7bb21527f5a809b5cde.zip
hostap-64f45d070b13f260c2e2f7bb21527f5a809b5cde.tar.gz
hostap-64f45d070b13f260c2e2f7bb21527f5a809b5cde.tar.bz2
wlantest: Add option for writing a PCAP dump file
The output file includes all the capture (or read from wireless PCAP file) frames in their original contents and another copy of each frame that is decrypted in wlantest (including EAPOL-Key Key Data field).
Diffstat (limited to 'wlantest/rx_data.c')
-rw-r--r--wlantest/rx_data.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/wlantest/rx_data.c b/wlantest/rx_data.c
index 2ce7f88..1b6e4fc 100644
--- a/wlantest/rx_data.c
+++ b/wlantest/rx_data.c
@@ -427,6 +427,44 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
}
wpa_hexdump(MSG_DEBUG, "Decrypted EAPOL-Key Key Data",
decrypted, decrypted_len);
+ if (wt->write_pcap_dumper) {
+ /* Fill in a dummy Data frame header */
+ u8 buf[24 + 8 + sizeof(*eapol) + sizeof(*hdr)];
+ struct ieee80211_hdr *h;
+ struct wpa_eapol_key *k;
+ u8 *pos;
+ size_t plain_len;
+
+ plain_len = decrypted_len;
+ pos = decrypted;
+ while (pos + 1 < decrypted + decrypted_len) {
+ if (pos[0] == 0xdd && pos[1] == 0x00) {
+ /* Remove padding */
+ plain_len = pos - decrypted;
+ break;
+ }
+ pos += 2 + pos[1];
+ }
+
+ os_memset(buf, 0, sizeof(buf));
+ h = (struct ieee80211_hdr *) buf;
+ h->frame_control = host_to_le16(0x0208);
+ os_memcpy(h->addr1, dst, ETH_ALEN);
+ os_memcpy(h->addr2, src, ETH_ALEN);
+ os_memcpy(h->addr3, src, ETH_ALEN);
+ pos = (u8 *) (h + 1);
+ os_memcpy(pos, "\xaa\xaa\x03\x00\x00\x00\x88\x8e", 8);
+ pos += 8;
+ os_memcpy(pos, eapol, sizeof(*eapol));
+ pos += sizeof(*eapol);
+ os_memcpy(pos, hdr, sizeof(*hdr));
+ k = (struct wpa_eapol_key *) pos;
+ WPA_PUT_BE16(k->key_info,
+ key_info & ~WPA_KEY_INFO_ENCR_KEY_DATA);
+ WPA_PUT_BE16(k->key_data_length, plain_len);
+ write_pcap_decrypted(wt, buf, sizeof(buf),
+ decrypted, plain_len);
+ }
learn_kde_keys(bss, decrypted, decrypted_len, hdr->key_rsc);
os_free(decrypted);
}
@@ -820,6 +858,8 @@ static void rx_data_bss_prot_group(struct wlantest *wt,
if (decrypted) {
rx_data_process(wt, dst, src, decrypted, dlen, 1);
os_memcpy(bss->rsc[keyid], pn, 6);
+ write_pcap_decrypted(wt, (const u8 *) hdr, 24 + (qos ? 2 : 0),
+ decrypted, dlen);
}
os_free(decrypted);
}
@@ -896,6 +936,8 @@ static void rx_data_bss_prot(struct wlantest *wt,
if (decrypted) {
rx_data_process(wt, dst, src, decrypted, dlen, 1);
os_memcpy(rsc, pn, 6);
+ write_pcap_decrypted(wt, (const u8 *) hdr, 24 + (qos ? 2 : 0),
+ decrypted, dlen);
}
os_free(decrypted);
}