1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 20:29:03 +00:00

Do optimization of pcap filters via set_pcap_filter

Optimizing reduces BPF instructions from 45 to 10 for large-scan case.

Also use PCAP_NETMASK_UNKNOWN instead of 0 since we don't provide a
netmask.
This commit is contained in:
dmiller
2014-10-29 05:31:08 +00:00
parent f9474cd0fd
commit c7e5ad67b5

View File

@@ -4069,7 +4069,7 @@ void set_pcap_filter(const char *device, pcap_t *pd, const char *bpf, ...) {
netutil_fatal("%s called with too-large filter arg\n", __func__);
va_end(ap);
if (pcap_compile(pd, &fcode, buf, 0, 0) < 0)
if (pcap_compile(pd, &fcode, buf, 1, PCAP_NETMASK_UNKNOWN) < 0)
netutil_fatal("Error compiling our pcap filter: %s", pcap_geterr(pd));
if (pcap_setfilter(pd, &fcode) < 0)
netutil_fatal("Failed to set the pcap filter: %s\n", pcap_geterr(pd));