Loads a filter program into a packet capture device.
pcap Library (libpcap.a)
#include <pcap.h>
int pcap_setfilter(pcap_t * p, struct bpf_program * fp);
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.
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.
The pcap_compile (pcap_compile Subroutine) subroutine, pcap_geterr (pcap_geterr Subroutine) subroutine, pcap_open_live (pcap_open_live Subroutine) subroutine, pcap_open_offline (pcap_open_offline Subroutine) subroutine, pcap_perror (pcap_perror Subroutine) subroutine.