PCAP_COMPILE(3) Library Functions Manual PCAP_COMPILE(3)NAME
pcap_compile - compile a filter expression
SYNOPSIS
#include <pcap/pcap.h>
int pcap_compile(pcap_t *p, struct bpf_program *fp,
const char *str, int optimize, bpf_u_int32 netmask);
DESCRIPTION
pcap_compile() is used to compile the string str into a filter program. See pcap-filter(7) for the syntax of that string. program is a
pointer to a bpf_program struct and is filled in by pcap_compile(). optimize controls whether optimization on the resulting code is per-
formed. netmask specifies the IPv4 netmask of the network on which packets are being captured; it is used only when checking for IPv4
broadcast addresses in the filter program. If the netmask of the network on which packets are being captured isn't known to the program,
or if packets are being captured on the Linux "any" pseudo-interface that can capture on more than one network, a value of PCAP_NET-
MASK_UNKNOWN can be supplied; tests for IPv4 broadcast addresses will fail to compile, but all other tests in the filter program will be
OK.
RETURN VALUE
pcap_compile() returns 0 on success and -1 on failure. If -1 is returned, pcap_geterr() or pcap_perror() may be called with p as an argu-
ment to fetch or display the error text.
SEE ALSO pcap(3), pcap_setfilter(3), pcap_freecode(3), pcap_geterr(3), pcap-filter(7)
1 December 2009 PCAP_COMPILE(3)
Check Out this Related Man Page
PCAP_COMPILE(3PCAP)PCAP_COMPILE(3PCAP)NAME
pcap_compile - compile a filter expression
SYNOPSIS
#include <pcap/pcap.h>
int pcap_compile(pcap_t *p, struct bpf_program *fp,
const char *str, int optimize, bpf_u_int32 netmask);
DESCRIPTION
pcap_compile() is used to compile the string str into a filter program. See pcap-filter(7) for the syntax of that string. program is a
pointer to a bpf_program struct and is filled in by pcap_compile(). optimize controls whether optimization on the resulting code is per-
formed. netmask specifies the IPv4 netmask of the network on which packets are being captured; it is used only when checking for IPv4
broadcast addresses in the filter program. If the netmask of the network on which packets are being captured isn't known to the program,
or if packets are being captured on the Linux "any" pseudo-interface that can capture on more than one network, a value of PCAP_NET-
MASK_UNKNOWN can be supplied; tests for IPv4 broadcast addresses will fail to compile, but all other tests in the filter program will be
OK.
RETURN VALUE
pcap_compile() returns 0 on success and -1 on failure. If -1 is returned, pcap_geterr() or pcap_perror() may be called with p as an argu-
ment to fetch or display the error text.
SEE ALSO pcap(3PCAP), pcap_setfilter(3PCAP), pcap_freecode(3PCAP), pcap_geterr(3PCAP), pcap-filter(7)
7 April 2014 PCAP_COMPILE(3PCAP)
i keep getting the following error with the code segment below when i try to compile the program.
parse error before '('
parse error before ')'
stray '\' in program
this is the code segment and the error is on the second line of the segment
#define DEBUG(fmt) if(traceflag) {... (1 Reply)
Hi All,
I tried to compile a C program but i am getting error while Linking . it says Undefined reference to ' ' (here it gives a method name which is defined Globally ).
Can any body tell the resaon and remedy for the same . Iam stuck up here .
Thanks (3 Replies)
Hi all,
I'm trying to write a program that has some data it wants to send through a filter program(in this case tr), and then recieve the output from that filter program. The way I'm trying to do it is by setting up two pipes between the programs and piping the data in through one pipe and back... (2 Replies)
Hello everybody!!
I am currently doing my intership and I need some tips for Pcap.h.
I search some tips tp filter my paquets in a C program with the Pcap.h librairy. The onlys thing I have found is thaht I can filter low level protocol with their name like (tcp/udp..). But for the higher... (3 Replies)
Hi,
I am new at UNIX and programing in general and only have a basic knowledge of C++. I am helping out with some research at a college and was given the task to sort through captured packets via IP addresses. I was wondering if anyone could help me with writing a code which filters through pcap... (1 Reply)
Hi,
I am new at UNIX and programing in general and only have a basic knowledge of C++. I am helping out with some research at a college and was given the task to sort through captured packets via IP addresses. I was wondering if anyone could help me with writing a code which filters through pcap... (4 Replies)
hi,
I am trying to configure one of my interfaces, but after reboot - i lose the changes to the netmask & broadcast address.
I have added an entry in /etc/netmasks, but it doesnt pick up the new settings. any ideas - much appreciated.
before reboot:
eri0:... (3 Replies)
Hi
I'm reading about the libpcap documentation. I see that with the function:
pcap_setfilter ( pcap_t *p, struct bpf_program *fp)
we can choose to take one packet instead another.
I read that the struct bpf_program allow us to create a packet filter , ....so if I want just sample some... (2 Replies)
Hello all, i need your quick help. I have assignment project class to make a program using pcap library to spoofing DNS in linux environment. Can anyone help me, because i'm newbie in network security and in C?:confused:
Regards,
ptrfw (1 Reply)
I tried to compile the files in basic_dump_ex using cygwin :
/cygdrive/c/WpdPack/Examples-pcap/basic_dump_ex
$make
but I got this :
cc -g -O -mno-cygwin -I ../../include -c -o basic_dump_ex.o basic_dump_ex.c
cc: error: unrecognized command line option ‘-mno-cygwin’... (6 Replies)