View Source epcap_compile (epcap_compile v1.0.6)
Link to this section Summary
Link to this section Types
-type compile_options() ::
[{optimize, true | false} |
{netmask, non_neg_integer()} |
{dlt, integer()} |
{snaplen, integer()} |
{limit, integer()}].
Link to this section Functions
-spec compile(Filter :: iodata()) -> {ok, [binary()]} | {error, string()}.
Compile a PCAP filter to a BPF program
Filter is a string in pcap-filter(7) format.
compile/1 defaults to:
* optimization enabled
* an unspecified netmask (filters specifying the broadcast will return an error)
* datalinktype set to ethernet (DLT_EN10MB)
* a packet length of 65535 bytes
* a limit of 8192 bytes for filters. Filters larger than this limit will return {error, enomem}
. A limit less than 0 disables the length check.
examples
Examples
1> epcap_compile:compile("ip and ( src host 192.168.10.1 or dst host 192.168.10.
1 )").
{ok,[<<40,0,0,0,12,0,0,0>>,
<<21,0,0,5,0,8,0,0>>,
<<32,0,0,0,26,0,0,0>>,
<<21,0,2,0,1,10,168,192>>,
<<32,0,0,0,30,0,0,0>>,
<<21,0,0,1,1,10,168,192>>,
<<6,0,0,0,255,255,0,0>>,
<<6,0,0,0,0,0,0,0>>]}
-spec compile(Filter :: iodata(), compile_options()) -> {ok, [binary()]} | {error, string()}.
Compile a PCAP filter to a BPF program
Filter is a string in pcap-filter(7) format.
See pcap_compile(3PCAP) for documentation about each option.