Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-19-2005, 04:10 AM   #1
LQ Newbie
Registered: May 2004
Distribution: RH9
Posts: 11

Rep: Reputation: 0
Angry Error while compiling packet capturing code on FC2

I wrote a packet sniffer on RH 9 using pcap library a year ago. Now i installed FC2 and tried to run the code there and i get this error:

Warning: Kernel filter failed: Invalid argument

when i run the program.

The program is as follows:

int main(int count, char *cmdln[])

pcap_t *devdes;
struct bpf_program fp;
bpf_u_int32 mask,netip;
char errbuf[PCAP_ERRBUF_SIZE];
int buffer;
int n;
int packet_captured;

printf("Arguments Required!!");
printf("\nUsage: ./filtercapn [expression] [n]\n");

n=-1; //This will put the capturing into infinite loop

//Open device for reading

printf("\npcap_open_live(): %s\n",errbuf);

//Get the network IP address and the network mask.

//Compile the packet condition into filter program

//Set the filter program

//Send each packet captured according to the filter to the packet_analyser()

return 0;

The error is comming in the pcap_filter() function as the kernel is not able to set the filter and gives the invalid filter error but the same filter string works fine with tcpdump.

Please help me out,

Rest is fine,


Last edited by Prakhardeep; 02-01-2005 at 03:54 AM.
Old 08-02-2011, 07:00 AM   #2
LQ Newbie
Registered: May 2009
Posts: 4

Rep: Reputation: 0
Have you got any fix for this
Old 08-02-2011, 10:32 AM   #3
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Do you really have to wake up a 6 year old thread
Old 08-10-2011, 04:55 AM   #4
LQ Newbie
Registered: May 2009
Posts: 4

Rep: Reputation: 0
I have similar issue with a Redhat system kernel, was wondering whether i should have a custom kernel to fix it


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Packet Filter to redirect a packet to a user level process akawale Linux - Networking 3 09-01-2006 12:06 PM
Problem in transferring packet capturing code fron RH9 to FC2 Prakhardeep Linux - Networking 0 02-01-2005 03:57 AM
lot of problem in capturing packet in promisc mode masood_gandhi Linux - Networking 2 11-26-2004 09:53 AM
capturing internet packet blackzone Linux - Security 3 09-15-2004 10:57 AM
Wierd error with ping WARNING: failed to install socket filter: Protocol not availabl abefroman Linux - Networking 4 03-25-2004 05:48 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:37 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration