aboutsummaryrefslogtreecommitdiffstats
path: root/wlantest
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
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')
-rw-r--r--wlantest/readpcap.c2
-rw-r--r--wlantest/wlantest.c7
-rw-r--r--wlantest/wlantest.h1
-rw-r--r--wlantest/writepcap.c10
4 files changed, 18 insertions, 2 deletions
diff --git a/wlantest/readpcap.c b/wlantest/readpcap.c
index 7c3ce18..6c3853b 100644
--- a/wlantest/readpcap.c
+++ b/wlantest/readpcap.c
@@ -102,6 +102,8 @@ int read_cap_file(struct wlantest *wt, const char *fname)
write_pcap_with_radiotap(wt, data, hdr->caplen);
else
pcap_dump(wt->write_pcap_dumper, hdr, data);
+ if (wt->pcap_no_buffer)
+ pcap_dump_flush(wt->write_pcap_dumper);
}
if (hdr->caplen < hdr->len) {
add_note(wt, MSG_DEBUG, "pcap: Dropped incomplete "
diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c
index ab3b2fc..abe97d1 100644
--- a/wlantest/wlantest.c
+++ b/wlantest/wlantest.c
@@ -21,7 +21,7 @@ static void wlantest_terminate(int sig, void *signal_ctx)
static void usage(void)
{
- printf("wlantest [-cddhqqFt] [-i<ifname>] [-r<pcap file>] "
+ printf("wlantest [-cddhqqFNt] [-i<ifname>] [-r<pcap file>] "
"[-p<passphrase>]\n"
" [-I<wired ifname>] [-R<wired pcap file>] "
"[-P<RADIUS shared secret>]\n"
@@ -350,7 +350,7 @@ int main(int argc, char *argv[])
wlantest_init(&wt);
for (;;) {
- c = getopt(argc, argv, "cdf:Fhi:I:L:n:p:P:qr:R:tT:w:W:");
+ c = getopt(argc, argv, "cdf:Fhi:I:L:n:Np:P:qr:R:tT:w:W:");
if (c < 0)
break;
switch (c) {
@@ -383,6 +383,9 @@ int main(int argc, char *argv[])
case 'n':
wt.pcapng_file = optarg;
break;
+ case 'N':
+ wt.pcap_no_buffer = 1;
+ break;
case 'p':
add_passphrase(&wt, optarg);
break;
diff --git a/wlantest/wlantest.h b/wlantest/wlantest.h
index ced9baa..530accc 100644
--- a/wlantest/wlantest.h
+++ b/wlantest/wlantest.h
@@ -202,6 +202,7 @@ struct wlantest {
int last_mgmt_valid;
unsigned int assume_fcs:1;
+ unsigned int pcap_no_buffer:1;
char *notes[MAX_NOTES];
size_t num_notes;
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);