I have a C file of the following .When I execute this in Fedora 7 version 2.6.21-1.3194.fc7 and
arch =i686 I get following errors

[root@kwi-11156f06184 Desktop]# cc test.c
test.c:3:20: error: libipq.h: No such file or directory
test.c: In function ‘main’:
test.c:12: error: ‘PF_INET’ undeclared (first use in this function)
test.c:12: error: (Each undeclared identifier is reported only once
test.c:12: error: for each function it appears in.)
test.c:12: warning: assignment makes pointer from integer without a cast

[root@kwi-11156f06184 Desktop]# cc test.c -libipq.h
test.c:3:20: error: libipq.h: No such file or directory
test.c: In function ‘main’:
test.c:12: error: ‘PF_INET’ undeclared (first use in this function)
test.c:12: error: (Each undeclared identifier is reported only once
test.c:12: error: for each function it appears in.)
test.c:12: warning: assignment makes pointer from integer without a cast

[root@kwi-11156f06184 Desktop]# cc test.c -libipq
test.c:3:20: error: libipq.h: No such file or directory
test.c: In function ‘main’:
test.c:12: error: ‘PF_INET’ undeclared (first use in this function)
test.c:12: error: (Each undeclared identifier is reported only once
test.c:12: error: for each function it appears in.)
test.c:12: warning: assignment makes pointer from integer without a cast

[root@kwi-11156f06184 Desktop]# cc -libipq test.c
test.c:3:20: error: libipq.h: No such file or directory
test.c: In function ‘main’:
test.c:12: error: ‘PF_INET’ undeclared (first use in this function)
test.c:12: error: (Each undeclared identifier is reported only once
test.c:12: error: for each function it appears in.)
test.c:12: warning: assignment makes pointer from integer without a cast

/* c file called test.c*/

#include <linux/netfilter.h>
#include <libipq.h>
#include <stdio.h>

int main()
{
  int retVal = 0;
  char buf[1000];
  struct ipq_handle* userHandle;

  userHandle = ipq_create_handle(0, PF_INET);
  if(userHandle == NULL)
  {
    printf("ipq_create_handle returned error\n");
    return -1;
  }

  retVal = ipq_read(userHandle, buf, 1000, 0);

  return 0;
}

my problem is how shall I include all these header files , so that my program works

any hints and suggestions
prethanks to helper

Recommended Answers

All 2 Replies

Does the file exist on you harddrive? If not:
Do you have the iptables-devel & libnet packages installed?

sounds like you dont have the libraries installed. probably want to use your package manager (yum, pup, whatever) to get it.. you can get it straight from Subversion, if you dont mind trusting their malformed ssl certificate
https://svn.netfilter.org/netfilter/trunk/iptables/libipq/

you probably also need the <socket.h> header. this should be standard with gcc.

also check with these guys for related info
http://www.packetfactory.net/Projects/Libnet/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.