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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user