April 2005
Intermediate to advanced
344 pages
11h 59m
English
pcap_compile — Prototype: int pcap_compile(pcap_t *p, struct bpf_program *fp, char *str, intoptimize, bpf_u_int32 netmask)
Purpose: pcap_compile is used to compile the
tcpdump format filter string
str into a BPF filter fp.
optimize controls whether the resulting code is
optimized (value 1) or not (value
0). netmask is the IPv4 netmask
of the network interface being used for capture. This value can be
obtained using pcap_lookupnet, or it can be
0, in which case some tests for IPv4 broadcast
addresses will not work correctly. pcap_compile
returns 0 on success, -1 on
error. You can find an example of using
pcap_compile in the Section 10.2.4
section earlier in this chapter.
Read now
Unlock full access