All of lore.kernel.org
 help / color / mirror / Atom feed
From: Essien Ita Essien <essiene@datavibe.net>
To: netfilter-devel@lists.netfilter.org
Subject: compiling libipq example
Date: Fri, 25 Feb 2005 09:36:48 +0100	[thread overview]
Message-ID: <421EE3A0.7000804@datavibe.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1800 bytes --]

Hi,

I'm trying to follow the tutorial in the libipq man page, with just a 
little modification, and i get a compile error when i try to access the 
ipq_packet_msg_t structure. I've checked where ipq_packet_msg_t is 
defined, and found it in <linux/netfilter_ipv4/ip_queue.h>, which i've 
found is conditionally included in <libipq.h> already. I even tried 
including straight into the program.

Any ideas what i'm doing wrong?

thanks.

The error i get is:

first.c: In function `main':
first.c:47: error: dereferencing pointer to incomplete type
first.c:51: error: dereferencing pointer to incomplete type



The program is:

#include <stdio.h>
#include <linux/netfilter.h>
#include <libipq.h>
#include <linux/ip.h>
#include <linux/tcp.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);

	while (1) {
		status = ipq_read(h,buf,BUFSIZE,0);
		if (status < 0)
			die(h);

		switch(ipq_message_type(buf)) {
			case NLMSG_ERROR:
				fprintf(stderr,"Recieved Error Message: %d\n",ipq_get_msgerr(buf));
				break;

			case IPQM_PACKET: {
				struct ipq_packet_msg_t *m = ipq_get_packet(buf);
				struct iphdr *ip = (struct iphdr*) m->payload; /*this line give the 
error*/
				fprintf(stdout,"Saddr: %d\nDaddr: %d\n",ip->saddr,ip->daddr);

				
				status = ipq_set_verdict(h,m->packet_id,NF_ACCEPT,0,NULL); /*this 
line also borks*/
				if (status < 0)
					die(h);

				break;

				}

			default:
				fprintf(stderr,"Unknown Message Type!\n");
		}

	}

	ipq_destroy_handle(h);
	return 0;
}

[-- Attachment #2: first.c --]
[-- Type: text/plain, Size: 1177 bytes --]

#include <stdio.h>
#include <linux/netfilter.h>
#include <libipq.h>
#include <linux/ip.h>
#include <linux/tcp.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);

	while (1) {
		status = ipq_read(h,buf,BUFSIZE,0);
		if (status < 0)
			die(h);

		switch(ipq_message_type(buf)) {
			case NLMSG_ERROR:
				fprintf(stderr,"Recieved Error Message: %d\n",ipq_get_msgerr(buf));
				break;

			case IPQM_PACKET: {
				struct ipq_packet_msg_t *m = ipq_get_packet(buf);
				struct iphdr *ip = (struct iphdr*) m->payload; /*this line give the error*/
				fprintf(stdout,"Saddr: %d\nDaddr: %d\n",ip->saddr,ip->daddr);

				
				status = ipq_set_verdict(h,m->packet_id,NF_ACCEPT,0,NULL); /*this line also borks*/
				if (status < 0)
					die(h);

				break;

				}

			default:
				fprintf(stderr,"Unknown Message Type!\n");
		}

	}

	ipq_destroy_handle(h);
	return 0;
}








             reply	other threads:[~2005-02-25  8:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-25  8:36 Essien Ita Essien [this message]
2005-03-03 12:54 ` compiling libipq example Patrick McHardy
2005-03-03 15:28   ` Essien Ita Essien
2005-03-03 13:17 ` Jonas Berlin
2005-03-03 15:26   ` Essien Ita Essien

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=421EE3A0.7000804@datavibe.net \
    --to=essiene@datavibe.net \
    --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.