aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-06-22 10:17:14 (GMT)
committerJouni Malinen <j@w1.fi>2013-06-22 10:17:14 (GMT)
commitde36e348f90c5d67af3650ef3a5296ed04cb6200 (patch)
treeffecade35a23a3a90bbf5052ec6abd396ca0eaaf /wlantest
parent8a901d750b1ee3b2bf892565ded62ee5dfd87d0b (diff)
downloadhostap-de36e348f90c5d67af3650ef3a5296ed04cb6200.zip
hostap-de36e348f90c5d67af3650ef3a5296ed04cb6200.tar.gz
hostap-de36e348f90c5d67af3650ef3a5296ed04cb6200.tar.bz2
wlantest: Always write radiotap pcap-ng
When writing pcap-ng files, always include a radiotap header even if there wasn't one in the input. For now just drop prism headers, I don't have any to test. Signed-hostap: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'wlantest')
-rw-r--r--wlantest/writepcap.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/wlantest/writepcap.c b/wlantest/writepcap.c
index 44a251d..58f01a0 100644
--- a/wlantest/writepcap.c
+++ b/wlantest/writepcap.c
@@ -272,12 +272,23 @@ void write_pcapng_write_read(struct wlantest *wt, int dlt,
u8 *pos;
u32 *block_len;
u64 timestamp;
- size_t len;
+ size_t len, datalen = hdr->caplen;
+ u8 rtap[] = {
+ 0x00 /* rev */,
+ 0x00 /* pad */,
+ 0x0a, 0x00, /* header len */
+ 0x02, 0x00, 0x00, 0x00, /* present flags */
+ 0x00, /* flags */
+ 0x00 /* pad */
+ };
+
+ if (wt->assume_fcs)
+ rtap[8] |= 0x10;
if (!wt->pcapng)
return;
- len = sizeof(*pkt) + hdr->len + 100 + notes_len(wt, 32);
+ len = sizeof(*pkt) + hdr->len + 100 + notes_len(wt, 32) + sizeof(rtap);
pkt = os_zalloc(len);
if (pkt == NULL)
return;
@@ -293,8 +304,29 @@ void write_pcapng_write_read(struct wlantest *wt, int dlt,
pkt->packet_len = hdr->len;
pos = (u8 *) (pkt + 1);
- os_memcpy(pos, data, hdr->caplen);
- pos += ALIGN32(hdr->caplen);
+
+ switch (dlt) {
+ case DLT_IEEE802_11_RADIO:
+ break;
+ case DLT_PRISM_HEADER:
+ /* remove prism header (could be kept ... lazy) */
+ pkt->captured_len -= WPA_GET_LE32(data + 4);
+ pkt->packet_len -= WPA_GET_LE32(data + 4);
+ datalen -= WPA_GET_LE32(data + 4);
+ data += WPA_GET_LE32(data + 4);
+ /* fall through */
+ case DLT_IEEE802_11:
+ pkt->captured_len += sizeof(rtap);
+ pkt->packet_len += sizeof(rtap);
+ os_memcpy(pos, &rtap, sizeof(rtap));
+ pos += sizeof(rtap);
+ break;
+ default:
+ return;
+ }
+
+ os_memcpy(pos, data, datalen);
+ pos += datalen + PAD32(pkt->captured_len);
pos = pcapng_add_comments(wt, pos);
block_len = (u32 *) pos;