Loads a filter program into a packet capture device.
pcap Library (libpcap.a)
The pcap_setfilter subroutine is used to load a filter program into the packet capture device. This causes the capture of the packets defined by the filter to begin.
Item | Description |
---|---|
fp | Points to a filter program as returned from the pcap_compile subroutine. |
p | Points to a packet capture descriptor returned from the pcap_open_offline or the pcap_open_live subroutine. |
Upon successful completion, the pcap_setfilter subroutine returns 0. If the pcap_setfilter subroutine is unsuccessful, -1 is returned. In this case, the pcap_geterr subroutine can be used to get the error text, and the pcap_perror subroutine can be used to display the text.