aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2013-01-17 14:22:41 (GMT)
committerJouni Malinen <j@w1.fi>2013-01-17 14:31:19 (GMT)
commit0321bcdfa8466ae97da77cbc1998b31b53b1ee59 (patch)
tree53496ebbeb544589766602d7d1981e62b442c0c2
parent25315176008ba41ac20b00d748ae75e5869f890f (diff)
downloadhostap-0321bcdfa8466ae97da77cbc1998b31b53b1ee59.zip
hostap-0321bcdfa8466ae97da77cbc1998b31b53b1ee59.tar.gz
hostap-0321bcdfa8466ae97da77cbc1998b31b53b1ee59.tar.bz2
wlantest: Add radiotap header when re-writing DLT_IEEE802_11 file
When using DLT_IEEE802_11 datalink type in a pcap file, wlantest will now add a radiotap header to the re-written pcap file to make sure all frames in the output file will include the radiotap header. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
-rw-r--r--wlantest/readpcap.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/wlantest/readpcap.c b/wlantest/readpcap.c
index 3ab4080..6243bc8 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 "