From: Duncan Godfrey <d.j.godfrey@reading.ac.uk>
To: netfilter-devel@lists.netfilter.org
Subject: Just starting with libipq
Date: Thu, 05 May 2005 15:11:44 +0100 [thread overview]
Message-ID: <427A29A0.8020502@reading.ac.uk> (raw)
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;
}
next reply other threads:[~2005-05-05 14:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-05 14:11 Duncan Godfrey [this message]
2005-05-06 12:50 ` Just starting with libipq Jonas Berlin
2005-05-06 12:54 ` Jonas Berlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=427A29A0.8020502@reading.ac.uk \
--to=d.j.godfrey@reading.ac.uk \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.