Commit ac8ed058 authored by garciay's avatar garciay

Add capability to capture without PCAP filter

parent e61c9f07
...@@ -101,18 +101,20 @@ public class PcapMultiplexer implements Runnable { ...@@ -101,18 +101,20 @@ public class PcapMultiplexer implements Runnable {
} }
captureThread = new Thread(this); captureThread = new Thread(this);
captureThread.start(); captureThread.start();
filter = String.format("ether proto 0x%04x", frameType); if (frameType != 0) {
System.out.println("New filter: " + filter); filter = String.format("ether proto 0x%04x", frameType);
System.out.println("New filter: " + filter);
// Apply filter // Apply filter
PcapBpfProgram bpfFilter = new PcapBpfProgram(); PcapBpfProgram bpfFilter = new PcapBpfProgram();
int optimize = 0; // 1 means true, 0 means false int optimize = 0; // 1 means true, 0 means false
int netmask = 0; int netmask = 0;
int r = pcap.compile(bpfFilter, filter, optimize, netmask); int r = pcap.compile(bpfFilter, filter, optimize, netmask);
if (r != Pcap.OK) { if (r != Pcap.OK) {
System.out.println("Filter error: " + pcap.getErr()); System.out.println("Filter error: " + pcap.getErr());
} }
pcap.setFilter(bpfFilter); pcap.setFilter(bpfFilter);
} // else, no filter
dumper = pcap.dumpOpen(client.getFileName()); dumper = pcap.dumpOpen(client.getFileName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment