libnetfilter_queue naming problem
PATCH 1/1 libnetfilter_queue naming problem
Hi,
The following patch should help to solve the current problems of libnetfilter_queue (due to renaming).
I don't like the fact that it uses "struct nfattr* nfa[]" as parameter for high-level function because it is too much linked with the kernel implementation. But I do not have much time to find and propose a more elegant solution. Any idea ?
BR,
Signature · 3 lines
Éric Leblond, [email protected] Téléphone : 01 44 89 46 40, Fax : 01 44 89 45 01 INL, http://www.inl.fr
libnetfilter_queue/libnfnetlink_queue.h +0 -87
@@ -1,87 +0,0 @@ -/* libnfqnetlink.h: Header file for the Netfilter Queue library. -* -* (C) 2005 by Harald Welte <[email protected]> -* -* -* Changelog : -* (2005/08/11) added parsing function (Eric Leblond <[email protected]>) -* -* This software may be used and distributed according to the terms -* of the GNU General Public License, incorporated herein by reference. -*/ - -#ifndef __LIBCTNETLINK_H -#define __LIBCTNETLINK_H - -#include <libnfnetlink/libnfnetlink.h> - -#include <linux/netfilter/nfnetlink.h> -#include <linux/netfilter/nfnetlink_queue.h> - -struct nfqnl_handle ; -struct nfqnl_q_handle ; - -extern int nfqnl_errno; - -extern struct nfnl_handle *nfqnl_nfnlh (struct nfqnl_handle *h); -extern int nfqnl_fd (struct nfqnl_handle *h); - -typedef int nfqnl_callback (struct nfqnl_q_handle *gh,struct nfgenmsg *nfmsg, -struct nfattr *nfa[],void *data); - - -extern struct nfqnl_handle *nfqnl_open (void ); -extern int nfqnl_close (struct nfqnl_handle *h); - -extern int nfqnl_bind_pf (struct nfqnl_handle *h,u_int16_t pf); -extern int nfqnl_unbind_pf (struct nfqnl_handle *h,u_int16_t pf); - -extern struct nfqnl_q_handle *nfqnl_create_queue (struct nfqnl_handle *h, -u_int16_t num, -nfqnl_callback *cb, -void *data); -extern int nfqnl_destroy_queue (struct nfqnl_q_handle *qh); - -extern int nfqnl_handle_packet (struct nfqnl_handle *h,char *buf,int len); - -extern int nfqnl_set_mode (struct nfqnl_q_handle *qh, -u_int8_t mode,unsigned int len); - -extern int nfqnl_set_verdict (struct nfqnl_q_handle *qh, -u_int32_t id, -u_int32_t verdict, -u_int32_t data_len, -unsigned char *buf); - -extern int nfqnl_set_verdict_mark (struct nfqnl_q_handle *qh, -u_int32_t id, -u_int32_t verdict, -u_int32_t mark, -u_int32_t datalen, -unsigned char *buf); - -/* message parsing function */ - -extern struct nfqnl_msg_packet_hdr * -nfqnl_get_msg_packet_hdr (struct nfattr *nfa[]); - -extern u_int32_t nfqnl_get_nfmark (struct nfattr *nfa[]); - -extern struct nfqnl_msg_packet_timestamp * -nfqnl_get_timestamp (struct nfattr *nfa[]); - -/* return 0 if not set */ -extern u_int32_t nfqnl_get_indev (struct nfattr *nfa[]); -extern u_int32_t nfqnl_get_physindev (struct nfattr *nfa[]); -extern u_int32_t nfqnl_get_outdev (struct nfattr *nfa[]); -extern u_int32_t nfqnl_get_physoutdev (struct nfattr *nfa[]); - -extern struct nfqnl_msg_packet_hw *nfqnl_get_packet_hw (struct nfattr *nfa[]); - -/* return 0 if problem */ -extern int nfqnl_get_payload (struct nfattr *nfa[], -char ** data,unsigned int * datalen); - - - -#endif /* __LIBNFQNETLINK_H */
configure.in +2 -2
@@ -3,7 +3,7 @@ AC_INIT AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(libnfnetlink_queue, 0.0.10) +AM_INIT_AUTOMAKE(libnetfilter_queue, 0.0.11) AC_PROG_CC AC_EXEEXT
@@ -62,4 +62,4 @@ dnl Output the makefiles -AC_OUTPUT(Makefile include/Makefile include/libnfnetlink_queue/Makefile src/Makefile utils/Makefile) +AC_OUTPUT(Makefile include/Makefile include/libnetfilter_queue/Makefile src/Makefile utils/Makefile)
libnfnetlink_queue.c +0 -375
375 lines not on this page · raw message
Hi Eric,
Quoted 4 lines · Eric Leblond
I don't like the fact that it uses "struct nfattr* nfa[]" as parameter for high-level function because it is too much linked with the kernel implementation. But I do not have much time to find and propose a more elegant solution. Any idea ?
We can provide a higher level interface abstracted from the netlink sockets, let me see if I can do something.
In the meantime:
libnfnetlink_queue.c line 1
Quoted 12 lines
Index:
include/libnetfilter_queue/libnfnetlink_queue.h
===================================================================libnetfilter_queue/libnfnetlink_queue.h +0
-1@@ -1,87 +0,0 @@ -/* libnfqnetlink.h: Header file for the Netfilter Queue library. Index:
src/libnfnetlink_queue.c
===================================================================libnfnetlink_queue.c +0
-1@@ -1,375 +0,0 @@ -/* libnfqnetlink.c: generic library for access to nf_queue
This patch kills libnfnetlink_queue.[h|c], despite that I guess that your intention is renaming them to libnetfilter_queue.c, correct? ;)
cheers,
Pablo
Quoted 10 lines · Pablo Neira
Hi Eric,
Quoted 4 lines · Eric Leblond
I don't like the fact that it uses "struct nfattr* nfa[]" as parameter for high-level function because it is too much linked with the kernel implementation. But I do not have much time to find and propose a more elegant solution. Any idea ?
We can provide a higher level interface abstracted from the netlink sockets, let me see if I can do something.
Great ! I've thought about adding a simple opaque structure which encapsulate "struct nfattr* nfa[]". That should be enough as high level functions are already available.
Quoted 18 lines
In the meantime:
libnfnetlink_queue.c line 1
Quoted 12 lines
Index:
include/libnetfilter_queue/libnfnetlink_queue.h
===================================================================libnetfilter_queue/libnfnetlink_queue.h +0
-1@@ -1,87 +0,0 @@ -/* libnfqnetlink.h: Header file for the Netfilter Queue library. Index:
src/libnfnetlink_queue.c
===================================================================libnfnetlink_queue.c +0
-1@@ -1,375 +0,0 @@ -/* libnfqnetlink.c: generic library for access to nf_queue This patch kills libnfnetlink_queue.[h|c], despite that I guess that your intention is renaming them to
libnetfilter_queue.c, correct? ;)
Arghh, looks like svn diff is not working correctly on this point. I've done a svn rename on the concerned file but the implied add has not be taken into account by the diff.
I attach a patch with only the modifications to configure.in.
Quoted 3 lines
cheers,
Pablo
configure.in +2 -2
@@ -3,7 +3,7 @@ AC_INIT AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(libnfnetlink_queue, 0.0.10) +AM_INIT_AUTOMAKE(libnetfilter_queue, 0.0.11) AC_PROG_CC AC_EXEEXT
@@ -62,4 +62,4 @@ dnl Output the makefiles -AC_OUTPUT(Makefile include/Makefile include/libnfnetlink_queue/Makefile src/Makefile utils/Makefile) +AC_OUTPUT(Makefile include/Makefile include/libnetfilter_queue/Makefile src/Makefile utils/Makefile)
Quoted 10 lines · Eric Leblond
Quoted 6 lines
Quoted 4 lines
I don't like the fact that it uses "struct nfattr* nfa[]" as parameter for high-level function because it is too much linked with the kernel implementation. But I do not have much time to find and propose a more elegant solution. Any idea ?
We can provide a higher level interface abstracted from the netlink sockets, let me see if I can do something.
Great ! I've thought about adding a simple opaque structure which encapsulate "struct nfattr* nfa[]". That should be enough as high level functions are already available.
Yes, I think that's the way to go. That's how libnetfilter_conntrack is currently doing things.
cheers,
Pablo
I've renamed the files in svn now.
Signature · 5 lines
- Harald Welte <[email protected]> http://netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie