diff --git a/wlantest/readpcap.c b/wlantest/readpcap.c index 3ab40804e..6243bc847 100644 --- a/wlantest/readpcap.c +++ b/wlantest/readpcap.c @@ -13,6 +13,39 @@ #include "wlantest.h" +static void write_pcap_with_radiotap(struct wlantest *wt, + const u8 *data, size_t data_len) +{ + struct pcap_pkthdr h; + u8 rtap[] = { + 0x00 /* rev */, + 0x00 /* pad */, + 0x0a, 0x00, /* header len */ + 0x02, 0x00, 0x00, 0x00, /* present flags */ + 0x00, /* flags */ + 0x00 /* pad */ + }; + u8 *buf; + size_t len; + + if (wt->assume_fcs) + rtap[8] |= 0x10; + + os_memset(&h, 0, sizeof(h)); + h.ts = wt->write_pcap_time; + len = sizeof(rtap) + data_len; + buf = os_malloc(len); + if (buf == NULL) + return; + os_memcpy(buf, rtap, sizeof(rtap)); + os_memcpy(buf + sizeof(rtap), data, data_len); + h.caplen = len; + h.len = len; + pcap_dump(wt->write_pcap_dumper, &h, buf); + os_free(buf); +} + + int read_cap_file(struct wlantest *wt, const char *fname) { char errbuf[PCAP_ERRBUF_SIZE]; @@ -61,7 +94,10 @@ int read_cap_file(struct wlantest *wt, const char *fname) hdr->caplen, hdr->len); if (wt->write_pcap_dumper) { wt->write_pcap_time = hdr->ts; - pcap_dump(wt->write_pcap_dumper, hdr, data); + if (dlt == DLT_IEEE802_11) + write_pcap_with_radiotap(wt, data, hdr->caplen); + else + pcap_dump(wt->write_pcap_dumper, hdr, data); } if (hdr->caplen < hdr->len) { wpa_printf(MSG_DEBUG, "pcap: Dropped incomplete frame "