Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:02:43+00:00 2026-06-02T07:02:43+00:00

A same program can be run successfully on Opensuse 12.1 (x64) While can’t be

  • 0

A same program can be run successfully on Opensuse 12.1 (x64)
While can’t be run on Fedora 16 (x64)
on Fedora 16 , it displayed “Err calling pcap_compile”
I don’t know what difference between these OS, I think they are quite same, But I make sure Opensuse 12.1 can filter and capture packet successfully.

int init_capture() {
int i;
char *dev;
char errbuf[PCAP_ERRBUF_SIZE];
pcap_t* descr;
const u_char *packet;
struct pcap_pkthdr hdr; /* pcap.h */
struct ether_header *eptr; /* net/ethernet.h */
struct bpf_program fp;
char portfilter[20]= "dst port 1521";
bpf_u_int32 maskp;
bpf_u_int32 netp;
/* grab a device to peak into... */
dev = pcap_lookupdev(errbuf);
if (dev == NULL) {
    printf("%s\n", errbuf);
    exit(1);
}
pcap_lookupnet(dev,&netp,&maskp,errbuf);
/* open device for reading */
descr = pcap_open_live(dev, BUFSIZ, 0, -1, errbuf);
if (descr == NULL) {
    printf("pcap_open_live(): %s\n", errbuf);
    exit(1);
}
if (pcap_compile(descr,&fp,portfilter,0,netp) == -1)
{
    printf("Err calling pcap_compile\n");
    exit(1);
}
if (pcap_setfilter(descr,&fp) == -1)
{
    printf("Err setting filter \n");
    exit(1);
}

/* allright here we call pcap_loop(..) and pass in our callback function */
/* int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)*/
/* If you are wondering what the user argument is all about, so am I!!   */
pcap_loop(descr, -1, capture_callback, NULL);

fprintf(stdout, "\nDone processing packets... wheew!\n");
return 0;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:02:47+00:00Added an answer on June 2, 2026 at 7:02 am

    If pcap_compile() fails, you should do

    printf("Err calling pcap_compile: %s\n", pcap_geterr(descr));
    

    and see what problem it’s reporting. That might help us determine what’s going wrong on Fedora; without knowing what the failure is, it’s hard to determine what how to fix it – the filter is one that should work on any link-layer type that supports IP, and pcap_lookupdev() should always return such a device.

    However, pcap_lookupnet() could conceivably fail if, for example, you’re opening a device that has no IPv4 address assigned to it. If it fails, you should probably just pass 0 as both netp and maskp – you might just initialize them to 0 before calling pcap_lookupnet(). That shouldn’t make a difference, however – the net and mask shouldn’t be required for a filter such as dst port 1521.

    (BTW, -1 is not a valid timeout argument to pcap_open_live() – I’d use 1000 instead – but that might be OK on Linux; the open would fail if it weren’t valid, but the open isn’t failing for you, as it’s reporting an error in pcap_compile().)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I avoid that a user starts the same program twice? The current
I've got a program that takes 3 arrays (which are the same length, can
I have an OpenGL-program using GLSL, that I can run just fine with the
hi i have a cuda program which run successfully here is code for cuda
Regarding the same program as my question a few minutes ago ... I added
After providing the same program which reads a random generated input file and echoes
Here I am running two instance of same program in two different terminals. The
I have made a program that scans rss feeds. This same program creates feeds
Here is some dprofpp -I output, for almost the same program on different input
In my program, function add_host runs when the program launches and at the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.