Compiles a filter expression into a filter program.
pcap Library (libpcap.a)
The pcap_compile subroutine is used to compile the string str into a filter program. This filter program will then be used to filter, or select, the desired packets.
Item | Description |
---|---|
netmask | Specifies the netmask of the network device. The netmask can be obtained from the pcap_lookupnet subroutine. |
optimize | Controls whether optimization on the resulting code is performed. |
p | Points to a packet capture descriptor returned from the pcap_open_offline or the pcap_open_live subroutine. |
program | Points to a bpf_program struct which will be filled in by the pcap_compile subroutine if the subroutine is successful. |
str | Contains the filter expression. |
Upon successful completion, the pcap_compile subroutine returns 0, and the program parameter will hold the filter program. If pcap_compile subroutine is unsuccessful, -1 is returned.