[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


pcap_setfilter Subroutine

Purpose

Loads a filter program into a packet capture device.

Library

pcap Library (libpcap.a)

Syntax


#include <pcap.h>


int pcap_setfilter(pcap_t * p, struct bpf_program * fp);

Description

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.

Parameters


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.

Return Values

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.

Related Information

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.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]