]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wlantest: Add radiotap header when re-writing DLT_IEEE802_11 file
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 17 Jan 2013 14:22:41 +0000 (16:22 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 17 Jan 2013 14:31:19 +0000 (16:31 +0200)
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>

wlantest/readpcap.c

index 3ab40804eeeff5aa5402c120eeeaca35689f2128..6243bc84767e3a8acbb8e927126ffed315499b83 100644 (file)
 #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 "