Skip to contentSkip to conversation

libnetfilter_queue man page

DISCUSSION Julien DHERSIN 2 participants 3 messages Feb 27, 2007 – Mar 2, 2007 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

First, thanks for the documentation. It was helpful for me to understand the code.

But, I still have a question : I would like to add an extension in filtered IPv6 multicast packets headers. Do you think, I can do this in the userspace using libnetfilter queue ? And, how precisely does it work ? Is it something like this :

1. Activate the hook NF_IP6_LOCAL_OUT with an iptables rule
2. Launch my software with libnetfilter_queue
3. Modify the header
4. Return the whole packet to netfilter

Do I have tocreate a specific kernel module ?

Thanks for your responses.

Regards,
Julien

#1 lore raw
Quoted 5 lines · Julien DHERSIN

But, I still have a question : I would like to add an extension in filtered IPv6
multicast packets headers. Do you think, I can do this in the userspace using libnetfilter queue ? And, how precisely does it work ? Is it something like this :

Yes, you can process packets from userspace via libnetfilter_queue.

Quoted 1 line

1. Activate the hook NF_IP6_LOCAL_OUT with an iptables rule

ip6tables -I OUTPUT -j NFQUEUE

Quoted 3 lines

2. Launch my software with libnetfilter_queue
3. Modify the header
4. Return the whole packet to netfilter

Correct.

Quoted 1 line

Do I have tocreate a specific kernel module ?

Not necessarily, you can do it from userspace, anyway this question also depends on your needs.

Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
#2 lore raw

Thanks for your answers.
But, I still have some troubles with this library. My following code doesn't seem to work. Have you any idea ?

static int read_pkt (struct nfq_data *nfa) {
	int payload_len;
	struct ip6_hdr * ip6_hdrs;
	char * payload;
	struct in6_addr * ip6_dest;
	char dst[16];	/* char dst[INET6_ADDRSTRLEN]; */

	payload_len = nfq_get_payload(nfa, &payload);
	if (payload_len == -1)
		printf("Error : nfq_get_payload\n");
	printf("Length : %d\n", payload_len);

	ip6_hdrs = malloc(payload_len);
	if(!ip6_hdrs)
		printf("Error : malloc\n");

	if(!memcpy(ip6_hdrs, payload, payload_len))
		printf("Error : memcpy\n");

	if (!inet_ntop(AF_INET6, &(ip6_hdrs)->ip6_dst, dst, sizeof(dst)))
		fprintf(stdout, "dest: %s\n", dst);

	free(ip6_hdrs);
}

And I didn't find any way to cast my payload to cmsg structure (in order to use the routine defined in RFC3542). Then, I would use some functions such as inet6_rth_init() to add options in the Hop-by-hop extension. But maybe I'm on the wrong way.

Thanks for your help.

cu,
Julien

2007/2/28, Pablo Neira Ayuso <[email protected]>:

Quoted 28 lines
Quoted 5 lines · Julien DHERSIN

But, I still have a question : I would like to add an extension in filtered IPv6
multicast packets headers. Do you think, I can do this in the userspace using libnetfilter queue ? And, how precisely does it work ? Is it something like this :

Yes, you can process packets from userspace via libnetfilter_queue.

Quoted 1 line

1. Activate the hook NF_IP6_LOCAL_OUT with an iptables rule

ip6tables -I OUTPUT -j NFQUEUE

Quoted 3 lines

2. Launch my software with libnetfilter_queue
3. Modify the header
4. Return the whole packet to netfilter

Correct.

Quoted 1 line

Do I have tocreate a specific kernel module ?

Not necessarily, you can do it from userspace, anyway this question also depends on your needs.

--
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris