* Just starting with libipq
@ 2005-05-05 14:11 Duncan Godfrey
2005-05-06 12:50 ` Jonas Berlin
0 siblings, 1 reply; 3+ messages in thread
From: Duncan Godfrey @ 2005-05-05 14:11 UTC (permalink / raw)
To: netfilter-devel
Hello,
I was wondering if someone would be able to help me, Im just starting
out with some libipq development and Im trying to compile some example
source code from a tutorial site (I have compiled the source on the man
page an it worked fine).
Everytime I compile it with gcc -o quick quick.c -libpq, I get the
following errors:
quick.c:56: error: dereferencing pointer to incomplete type
quick.c:58: error: dereferencing pointer to incomplete type
Has anyone else had a similar experience? Thanks in advance for any help.
Duncan
The code is:
#include <linux/netfilter.h>
#include <libipq.h>
#include <stdio.h>
#define BUFSIZE 2048
static void die(struct ipq_handle *h)
{
ipq_perror("passer");
ipq_destroy_handle(h);
exit(1);
}
int main(int argc, char **argv)
{
int status;
unsigned char buf[BUFSIZE];
struct ipq_handle *h;
h = ipq_create_handle(0, PF_INET);
if (!h)
die(h);
status = ipq_set_mode(h, IPQ_COPY_PACKET, BUFSIZE);
if (status < 0)
die(h);
do{
status = ipq_read(h, buf, BUFSIZE, 0);
if (status < 0)
die(h);
switch (ipq_message_type(buf)) {
case NLMSG_ERROR:
fprintf(stderr, "Received error message %d\n",
ipq_get_msgerr(buf));
break;
case IPQM_PACKET: {
ipq_packet_msg_t *m = ipq_get_packet(buf);
struct iphdr *ip = (struct iphdr*) m->payload;
struct tcphdr *tcp = (struct tcphdr*) (m->payload + (4 * ip->ihl));
int port = htons(tcp->dest);
status = ipq_set_verdict(h, m->packet_id,
NF_ACCEPT, 0, NULL);
if (status < 0)
die(h);
break;
}
default:
fprintf(stderr, "Unknown message type!\n");
break;
}
} while (1);
ipq_destroy_handle(h);
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Just starting with libipq
2005-05-05 14:11 Just starting with libipq Duncan Godfrey
@ 2005-05-06 12:50 ` Jonas Berlin
2005-05-06 12:54 ` Jonas Berlin
0 siblings, 1 reply; 3+ messages in thread
From: Jonas Berlin @ 2005-05-06 12:50 UTC (permalink / raw)
To: Duncan Godfrey; +Cc: netfilter-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoting Duncan Godfrey on 2005-05-05 14:11 UTC:
> I was wondering if someone would be able to help me, Im just starting
> out with some libipq development and Im trying to compile some example
> source code from a tutorial site (I have compiled the source on the man
> page an it worked fine).
>
> Everytime I compile it with gcc -o quick quick.c -libpq, I get the
> following errors:
- -lipq not -libipq :)
> quick.c:56: error: dereferencing pointer to incomplete type
> quick.c:58: error: dereferencing pointer to incomplete type
> struct iphdr *ip = (struct iphdr*) m->payload;
>
> struct tcphdr *tcp = (struct tcphdr*) (m->payload + (4 * ip->ihl));
The error message means gcc does not know of a struct/union that you are
using. So it has to be either the "m" variable or then "ip" and "tcp"
variables. In this case, it's the latter, you are missing these includes:
#include <linux/ip.h>
#include <linux/tcp.h>
Add them and it should work. Good luck :)
- --
- - xkr47
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCe2gHxyF48ZTvn+4RAjDdAJ0b2SMjV0xh/l84RBDdU4t+ClkjewCdFPhL
9lrHlGEIm1MBp68PkOQYizI=
=n7Wy
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Just starting with libipq
2005-05-06 12:50 ` Jonas Berlin
@ 2005-05-06 12:54 ` Jonas Berlin
0 siblings, 0 replies; 3+ messages in thread
From: Jonas Berlin @ 2005-05-06 12:54 UTC (permalink / raw)
To: Duncan Godfrey; +Cc: netfilter-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoting Jonas Berlin on 2005-05-06 12:50 UTC:
>>>quick.c:56: error: dereferencing pointer to incomplete type
>>>quick.c:58: error: dereferencing pointer to incomplete type
>
>
>>> struct iphdr *ip = (struct iphdr*) m->payload;
>>>
>>> struct tcphdr *tcp = (struct tcphdr*) (m->payload + (4 * ip->ihl));
Sorry for bad quote, the lines with errors were actually:
struct tcphdr *tcp = (struct tcphdr*) (m->payload + (4 * ip->ihl));
int port = htons(tcp->dest);
.. since the error message occurs when using a structure/union, not when
declaring it. Nevertheless, it was just my quote bug, the solution
stays the same :)
- --
- - xkr47
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCe2kCxyF48ZTvn+4RAqcLAKC1lDLBikCu4nnq+3xwtluH8L2v1wCfdhr/
vc8bGniDkxJ8veM9StUFYhA=
=PRXh
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-05-06 12:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-05 14:11 Just starting with libipq Duncan Godfrey
2005-05-06 12:50 ` Jonas Berlin
2005-05-06 12:54 ` Jonas Berlin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.