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>
This commit is contained in:
parent
2531517600
commit
0321bcdfa8
1 changed files with 37 additions and 1 deletions
|
@ -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 "
|
||||
|
|
Loading…
Reference in a new issue