aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest/writepcap.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-11-26 22:10:53 (GMT)
committerJouni Malinen <j@w1.fi>2015-11-26 22:10:53 (GMT)
commite929eb39d6d874f694cb66b7aea7d112880993c7 (patch)
tree7db3333e15d24a7f5810aacf6f2789ec6ae47c19 /wlantest/writepcap.c
parentb25f04d44a9482681afa48959ba9c9caf1cb1f7b (diff)
downloadhostap-e929eb39d6d874f694cb66b7aea7d112880993c7.zip
hostap-e929eb39d6d874f694cb66b7aea7d112880993c7.tar.gz
hostap-e929eb39d6d874f694cb66b7aea7d112880993c7.tar.bz2
wlantest: Add -N command line argument to remove write buffering
This makes it easier to do live parsing of captured pcap files from wlantest without having to rename and restart the capture file. Packet writes are flushed to disk after each packet if -N is included in the command line. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wlantest/writepcap.c')
-rw-r--r--wlantest/writepcap.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/wlantest/writepcap.c b/wlantest/writepcap.c
index 28b306b..abd889f 100644
--- a/wlantest/writepcap.c
+++ b/wlantest/writepcap.c
@@ -59,6 +59,8 @@ void write_pcap_captured(struct wlantest *wt, const u8 *buf, size_t len)
h.caplen = len;
h.len = len;
pcap_dump(wt->write_pcap_dumper, &h, buf);
+ if (wt->pcap_no_buffer)
+ pcap_dump_flush(wt->write_pcap_dumper);
}
@@ -102,6 +104,8 @@ void write_pcap_decrypted(struct wlantest *wt, const u8 *buf1, size_t len1,
h.caplen = len;
h.len = len;
pcap_dump(wt->write_pcap_dumper, &h, buf);
+ if (wt->pcap_no_buffer)
+ pcap_dump_flush(wt->write_pcap_dumper);
}
@@ -181,6 +185,8 @@ int write_pcapng_init(struct wlantest *wt, const char *fname)
desc.link_type = LINKTYPE_IEEE802_11_RADIO;
desc.snap_len = 65535;
fwrite(&desc, sizeof(desc), 1, wt->pcapng);
+ if (wt->pcap_no_buffer)
+ fflush(wt->pcapng);
return 0;
}
@@ -263,6 +269,8 @@ static void write_pcapng_decrypted(struct wlantest *wt)
*block_len = pkt->block_total_len = pos - (u8 *) pkt;
fwrite(pkt, pos - (u8 *) pkt, 1, wt->pcapng);
+ if (wt->pcap_no_buffer)
+ fflush(wt->pcapng);
os_free(pkt);
}
@@ -337,6 +345,8 @@ void write_pcapng_write_read(struct wlantest *wt, int dlt,
*block_len = pkt->block_total_len = pos - (u8 *) pkt;
fwrite(pkt, pos - (u8 *) pkt, 1, wt->pcapng);
+ if (wt->pcap_no_buffer)
+ fflush(wt->pcapng);
os_free(pkt);