From fcf38d20ea98d9e9ec033ad7617d755ecdab0275 Mon Sep 17 00:00:00 2001 From: "/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org" Date: Sun, 9 Oct 2005 15:34:34 +0000 Subject: hopefully the last renaming effort --- _queue/COPYING | 339 ------------------- _queue/Makefile.am | 11 - _queue/autogen.sh | 17 - _queue/configure.in | 65 ---- _queue/include/Makefile.am | 3 - _queue/include/libnfnetlink_queue/Makefile.am | 3 - _queue/include/libnfnetlink_queue/libipq.h | 88 ----- .../libnfnetlink_queue/libnfnetlink_queue.h | 87 ----- _queue/src/Makefile.am | 13 - _queue/src/libipq_compat.c | 352 ------------------- _queue/src/libnfnetlink_queue.c | 375 --------------------- _queue/utils/Makefile.am | 10 - _queue/utils/nfqnl_test.c | 120 ------- 13 files changed, 1483 deletions(-) delete mode 100644 _queue/COPYING delete mode 100644 _queue/Makefile.am delete mode 100755 _queue/autogen.sh delete mode 100644 _queue/configure.in delete mode 100644 _queue/include/Makefile.am delete mode 100644 _queue/include/libnfnetlink_queue/Makefile.am delete mode 100644 _queue/include/libnfnetlink_queue/libipq.h delete mode 100644 _queue/include/libnfnetlink_queue/libnfnetlink_queue.h delete mode 100644 _queue/src/Makefile.am delete mode 100644 _queue/src/libipq_compat.c delete mode 100644 _queue/src/libnfnetlink_queue.c delete mode 100644 _queue/utils/Makefile.am delete mode 100644 _queue/utils/nfqnl_test.c diff --git a/_queue/COPYING b/_queue/COPYING deleted file mode 100644 index a43ea21..0000000 --- a/_queue/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/_queue/Makefile.am b/_queue/Makefile.am deleted file mode 100644 index efc5f68..0000000 --- a/_queue/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 - -EXTRA_DIST = $(man_MANS) - -SUBDIRS = include src utils - -man_MANS = #nfnetlink_queue.3 nfnetlink_queue.7 - -$(OBJECTS): libtool -libtool: $(LIBTOOL_DEPS) - $(SHELL) ./config.status --recheck diff --git a/_queue/autogen.sh b/_queue/autogen.sh deleted file mode 100755 index 4999b58..0000000 --- a/_queue/autogen.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -run () -{ - echo "running: $*" - eval $* - - if test $? != 0 ; then - echo "error: while running '$*'" - exit 1 - fi -} - -run aclocal-1.6 -#run autoheader -run automake-1.6 -a -run autoconf diff --git a/_queue/configure.in b/_queue/configure.in deleted file mode 100644 index 4570284..0000000 --- a/_queue/configure.in +++ /dev/null @@ -1,65 +0,0 @@ -dnl Process this file with autoconf to create configure. - -AC_INIT -AC_CANONICAL_SYSTEM - -AM_INIT_AUTOMAKE(libnfnetlink_queue, 0.0.10) - -AC_PROG_CC -AC_EXEEXT -AM_PROG_LIBTOOL -AC_PROG_INSTALL - -AC_SUBST(LIBTOOL_DEPS) - -case $target in -*-*-linux*) ;; -*) AC_MSG_ERROR([Linux only, dude!]);; -esac - -AC_CHECK_LIB([nfnetlink], [nfnl_listen]) - -dnl-------------------------------- - -AC_DEFUN([NF_KERNEL_SOURCE],[ - - if test "$with_kernel" = ""; then - KERNEL="`uname -r`" - else - KERNEL="$with_kernel" - fi - - THIS_PREFIX="" - for i in "/lib/modules/$KERNEL/build/include" "$KERNEL" "$KERNEL/include" "/usr/src/linux-$KERNEL" "/usr/src/kernel-$KERNEL" "/usr/src/linux-headers-$KERNEL" "/usr/src/kernel-headers-$KERNEL" - do - AC_MSG_CHECKING([Looking for kernel source or headers in $i]) - if test -r "$i/linux/config.h" - then - THIS_PREFIX="$i" - AC_MSG_RESULT([found]) - break - fi - AC_MSG_RESULT([ ]) - done - if test -r "$THIS_PREFIX/linux/config.h" ; then - AC_SUBST(KERNELDIR,[$THIS_PREFIX]) - AC_MSG_RESULT([found]) - else - AC_MSG_ERROR([not found $THIS_PREFIX]) - fi - - # somehow add this as an include path -]) - -AC_ARG_WITH(kernel, - AC_HELP_STRING([--with-kernel=DIR], - [ Show location of kernel source. Default is to use uname -r and look in /lib/modules/KERNEL/build/include. ]), - NF_KERNEL_SOURCE($with_kernel),NF_KERNEL_SOURCE()) - -dnl-------------------------------- - - - - -dnl Output the makefiles -AC_OUTPUT(Makefile include/Makefile include/libnfnetlink_queue/Makefile src/Makefile utils/Makefile) diff --git a/_queue/include/Makefile.am b/_queue/include/Makefile.am deleted file mode 100644 index 4040f9f..0000000 --- a/_queue/include/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ - -SUBDIRS = libnfnetlink_queue - diff --git a/_queue/include/libnfnetlink_queue/Makefile.am b/_queue/include/libnfnetlink_queue/Makefile.am deleted file mode 100644 index ebdfd5c..0000000 --- a/_queue/include/libnfnetlink_queue/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ - -pkginclude_HEADERS = libnfnetlink_queue.h libipq.h - diff --git a/_queue/include/libnfnetlink_queue/libipq.h b/_queue/include/libnfnetlink_queue/libipq.h deleted file mode 100644 index 06c10c1..0000000 --- a/_queue/include/libnfnetlink_queue/libipq.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * libipq.h - * - * IPQ library for userspace. - * - * Author: James Morris - * - * Copyright (c) 2000-2001 Netfilter Core Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#ifndef _LIBIPQ_H -#define _LIBIPQ_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef KERNEL_64_USERSPACE_32 -#include "ip_queue_64.h" -typedef u_int64_t ipq_id_t; -#else -#include -typedef unsigned long ipq_id_t; -#endif - -#ifdef DEBUG_LIBIPQ -#include -#define LDEBUG(x...) fprintf(stderr, ## x) -#else -#define LDEBUG(x...) -#endif /* DEBUG_LIBIPQ */ - -/* FIXME: glibc sucks */ -#ifndef MSG_TRUNC -#define MSG_TRUNC 0x20 -#endif - -struct ipq_handle -{ - struct nfqnl_handle *nfqnlh; - struct nfqnl_q_handle *qh; - u_int8_t family; - u_int8_t blocking; -}; - -struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol); - -int ipq_destroy_handle(struct ipq_handle *h); - -ssize_t ipq_read(const struct ipq_handle *h, - unsigned char *buf, size_t len, int timeout); - -int ipq_set_mode(const struct ipq_handle *h, u_int8_t mode, size_t len); - -ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf); - -int ipq_message_type(const unsigned char *buf); - -int ipq_get_msgerr(const unsigned char *buf); - -int ipq_set_verdict(const struct ipq_handle *h, - ipq_id_t id, - unsigned int verdict, - size_t data_len, - unsigned char *buf); - -int ipq_ctl(const struct ipq_handle *h, int request, ...); - -char *ipq_errstr(void); -void ipq_perror(const char *s); - -#endif /* _LIBIPQ_H */ - diff --git a/_queue/include/libnfnetlink_queue/libnfnetlink_queue.h b/_queue/include/libnfnetlink_queue/libnfnetlink_queue.h deleted file mode 100644 index 9c2b40d..0000000 --- a/_queue/include/libnfnetlink_queue/libnfnetlink_queue.h +++ /dev/null @@ -1,87 +0,0 @@ -/* libnfqnetlink.h: Header file for the Netfilter Queue library. - * - * (C) 2005 by Harald Welte - * - * - * Changelog : - * (2005/08/11) added parsing function (Eric Leblond ) - * - * 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 - -#include -#include - -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 */ diff --git a/_queue/src/Makefile.am b/_queue/src/Makefile.am deleted file mode 100644 index c75d708..0000000 --- a/_queue/src/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ - -INCLUDES = $(all_includes) -I$(top_srcdir)/include -I${KERNELDIR} -AM_CFLAGS=-fPIC -Wall -LIBS= - -lib_LTLIBRARIES = libnfnetlink_queue.la libnfnetlink_queue_libipq.la - -libnfnetlink_queue_la_LDFLAGS = -Wc,-nostartfiles -libnfnetlink_queue_la_SOURCES = libnfnetlink_queue.c - -libnfnetlink_queue_libipq_la_LDFLAGS = -Wc,-nostartfiles -libnfnetlink_queue_libipq_la_SOURCES = libipq_compat.c - diff --git a/_queue/src/libipq_compat.c b/_queue/src/libipq_compat.c deleted file mode 100644 index d263aed..0000000 --- a/_queue/src/libipq_compat.c +++ /dev/null @@ -1,352 +0,0 @@ -/* - * libipq - backwards compatibility library for libnfnetlink_queue - * - * (C) 2005 by Harald Welte - * - * Based on original libipq.c, - * Author: James Morris - * 07-11-2001 Modified by Fernando Anton to add support for IPv6. - * Copyright (c) 2000-2001 Netfilter Core Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -/**************************************************************************** - * - * Private interface - * - ****************************************************************************/ - -enum { - IPQ_ERR_NONE = 0, - IPQ_ERR_IMPL, - IPQ_ERR_HANDLE, - IPQ_ERR_SOCKET, - IPQ_ERR_BIND, - IPQ_ERR_BUFFER, - IPQ_ERR_RECV, - IPQ_ERR_NLEOF, - IPQ_ERR_ADDRLEN, - IPQ_ERR_STRUNC, - IPQ_ERR_RTRUNC, - IPQ_ERR_NLRECV, - IPQ_ERR_SEND, - IPQ_ERR_SUPP, - IPQ_ERR_RECVBUF, - IPQ_ERR_TIMEOUT, - IPQ_ERR_PROTOCOL -}; -#define IPQ_MAXERR IPQ_ERR_PROTOCOL - -struct ipq_errmap_t { - int errcode; - char *message; -} ipq_errmap[] = { - { IPQ_ERR_NONE, "Unknown error" }, - { IPQ_ERR_IMPL, "Implementation error" }, - { IPQ_ERR_HANDLE, "Unable to create netlink handle" }, - { IPQ_ERR_SOCKET, "Unable to create netlink socket" }, - { IPQ_ERR_BIND, "Unable to bind netlink socket" }, - { IPQ_ERR_BUFFER, "Unable to allocate buffer" }, - { IPQ_ERR_RECV, "Failed to receive netlink message" }, - { IPQ_ERR_NLEOF, "Received EOF on netlink socket" }, - { IPQ_ERR_ADDRLEN, "Invalid peer address length" }, - { IPQ_ERR_STRUNC, "Sent message truncated" }, - { IPQ_ERR_RTRUNC, "Received message truncated" }, - { IPQ_ERR_NLRECV, "Received error from netlink" }, - { IPQ_ERR_SEND, "Failed to send netlink message" }, - { IPQ_ERR_SUPP, "Operation not supported" }, - { IPQ_ERR_RECVBUF, "Receive buffer size invalid" }, - { IPQ_ERR_TIMEOUT, "Timeout"}, - { IPQ_ERR_PROTOCOL, "Invalid protocol specified" } -}; - -static int ipq_errno = IPQ_ERR_NONE; - -#if 0 -static ssize_t ipq_netlink_sendto(const struct ipq_handle *h, - const void *msg, size_t len); - -static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h, - unsigned char *buf, size_t len, - int timeout); - -static ssize_t ipq_netlink_sendmsg(const struct ipq_handle *h, - const struct msghdr *msg, - unsigned int flags); - -static char *ipq_strerror(int errcode); - -static ssize_t ipq_netlink_sendto(const struct ipq_handle *h, - const void *msg, size_t len) -{ - int status = sendto(h->fd, msg, len, 0, - (struct sockaddr *)&h->peer, sizeof(h->peer)); - if (status < 0) - ipq_errno = IPQ_ERR_SEND; - return status; -} - -static ssize_t ipq_netlink_sendmsg(const struct ipq_handle *h, - const struct msghdr *msg, - unsigned int flags) -{ - int status = sendmsg(h->fd, msg, flags); - if (status < 0) - ipq_errno = IPQ_ERR_SEND; - return status; -} - -static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h, - unsigned char *buf, size_t len, - int timeout) -{ - unsigned int addrlen; - int status; - struct nlmsghdr *nlh; - - if (len < sizeof(struct nlmsgerr)) { - ipq_errno = IPQ_ERR_RECVBUF; - return -1; - } - addrlen = sizeof(h->peer); - - if (timeout != 0) { - int ret; - struct timeval tv; - fd_set read_fds; - - if (timeout < 0) { - /* non-block non-timeout */ - tv.tv_sec = 0; - tv.tv_usec = 0; - } else { - tv.tv_sec = timeout / 1000000; - tv.tv_usec = timeout % 1000000; - } - - FD_ZERO(&read_fds); - FD_SET(h->fd, &read_fds); - ret = select(h->fd+1, &read_fds, NULL, NULL, &tv); - if (ret < 0) { - if (errno == EINTR) { - return 0; - } else { - ipq_errno = IPQ_ERR_RECV; - return -1; - } - } - if (!FD_ISSET(h->fd, &read_fds)) { - ipq_errno = IPQ_ERR_TIMEOUT; - return 0; - } - } - status = recvfrom(h->fd, buf, len, 0, - (struct sockaddr *)&h->peer, &addrlen); - if (status < 0) { - ipq_errno = IPQ_ERR_RECV; - return status; - } - if (addrlen != sizeof(h->peer)) { - ipq_errno = IPQ_ERR_RECV; - return -1; - } - if (h->peer.nl_pid != 0) { - ipq_errno = IPQ_ERR_RECV; - return -1; - } - if (status == 0) { - ipq_errno = IPQ_ERR_NLEOF; - return -1; - } - nlh = (struct nlmsghdr *)buf; - if (nlh->nlmsg_flags & MSG_TRUNC || nlh->nlmsg_len > status) { - ipq_errno = IPQ_ERR_RTRUNC; - return -1; - } - return status; -} -#endif - -static char *ipq_strerror(int errcode) -{ - if (errcode < 0 || errcode > IPQ_MAXERR) - errcode = IPQ_ERR_IMPL; - return ipq_errmap[errcode].message; -} - -/**************************************************************************** - * - * Public interface - * - ****************************************************************************/ - -/* - * Create and initialise an ipq handle. - */ -struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol) -{ - int status; - struct ipq_handle *h; - - h = (struct ipq_handle *)malloc(sizeof(struct ipq_handle)); - if (h == NULL) { - ipq_errno = IPQ_ERR_HANDLE; - return NULL; - } - - memset(h, 0, sizeof(struct ipq_handle)); - - h->nfqnlh = nfqnl_open(); - if (!h->nfqnlh) { - ipq_errno = IPQ_ERR_SOCKET; - goto err_free; - } - - if (protocol == PF_INET) - status = nfqnl_bind_pf(h->nfqnlh, PF_INET); - else if (protocol == PF_INET6) - status = nfqnl_bind_pf(h->nfqnlh, PF_INET6); - else { - ipq_errno = IPQ_ERR_PROTOCOL; - goto err_close; - } - h->family = protocol; - if (status < 0) { - ipq_errno = IPQ_ERR_BIND; - goto err_close; - } - - h->qh = nfqnl_create_queue(h->nfqnlh, 0, NULL, NULL); - if (!h->qh) { - ipq_errno = IPQ_ERR_BIND; - goto err_close; - } - - return h; - -err_close: - nfqnl_close(h->nfqnlh); -err_free: - free(h); - return NULL; -} - -/* - * No error condition is checked here at this stage, but it may happen - * if/when reliable messaging is implemented. - */ -int ipq_destroy_handle(struct ipq_handle *h) -{ - if (h) { - nfqnl_close(h->nfqnlh); - free(h); - } - return 0; -} - -int ipq_set_mode(const struct ipq_handle *h, - u_int8_t mode, size_t range) -{ - return nfqnl_set_mode(h->qh, mode, range); -} - -/* - * timeout is in microseconds (1 second is 1000000 (1 million) microseconds) - * - */ -ssize_t ipq_read(const struct ipq_handle *h, - unsigned char *buf, size_t len, int timeout) -{ - struct nfattr *tb[NFQA_MAX]; - struct nlmsghdr *nlh = (struct nlmsghdr *)buf; - struct nfgenmsg *msg = NULL; - struct nfattr *nfa; - - //return ipq_netlink_recvfrom(h, buf, len, timeout); - - /* This really sucks. We have to copy the whole packet - * in order to build a data structure that is compatible to - * the old ipq interface... */ - - nfa = nfnl_parse_hdr(nfqnl_nfnlh(h->nfqnlh), nlh, &msg); - if (!msg || !nfa) - return 0; - - if (msg->nfgen_family != h->family) - return 0; - - nfnl_parse_attr(tb, NFQA_MAX, nfa, 0xffff); - - - return 0; -} - -int ipq_message_type(const unsigned char *buf) -{ - return ((struct nlmsghdr*)buf)->nlmsg_type; -} - -int ipq_get_msgerr(const unsigned char *buf) -{ - struct nlmsghdr *h = (struct nlmsghdr *)buf; - struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); - return -err->error; -} - -ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf) -{ - return NLMSG_DATA((struct nlmsghdr *)(buf)); -} - -int ipq_set_verdict(const struct ipq_handle *h, - ipq_id_t id, - unsigned int verdict, - size_t data_len, - unsigned char *buf) -{ - return nfqnl_set_verdict(h->qh, id, verdict, data_len, buf); -} - -/* Not implemented yet */ -int ipq_ctl(const struct ipq_handle *h, int request, ...) -{ - return 1; -} - -char *ipq_errstr(void) -{ - return ipq_strerror(ipq_errno); -} - -void ipq_perror(const char *s) -{ - if (s) - fputs(s, stderr); - else - fputs("ERROR", stderr); - if (ipq_errno) - fprintf(stderr, ": %s", ipq_errstr()); - if (errno) - fprintf(stderr, ": %s", strerror(errno)); - fputc('\n', stderr); -} diff --git a/_queue/src/libnfnetlink_queue.c b/_queue/src/libnfnetlink_queue.c deleted file mode 100644 index 10ece48..0000000 --- a/_queue/src/libnfnetlink_queue.c +++ /dev/null @@ -1,375 +0,0 @@ -/* libnfqnetlink.c: generic library for access to nf_queue - * - * (C) 2005 by Harald Welte - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -struct nfqnl_handle -{ - struct nfnl_handle nfnlh; - struct nfqnl_q_handle *qh_list; -}; - -struct nfqnl_q_handle -{ - struct nfqnl_q_handle *next; - struct nfqnl_handle *h; - u_int16_t id; - - nfqnl_callback *cb; - void *data; -}; - - -int nfqnl_errno; - -/*********************************************************************** - * low level stuff - ***********************************************************************/ - -static void del_qh(struct nfqnl_q_handle *qh) -{ - struct nfqnl_q_handle *cur_qh, *prev_qh = NULL; - - for (cur_qh = qh->h->qh_list; cur_qh; cur_qh = cur_qh->next) { - if (cur_qh == qh) { - if (prev_qh) - prev_qh->next = qh->next; - else - qh->h->qh_list = qh->next; - return; - } - prev_qh = cur_qh; - } -} - -static void add_qh(struct nfqnl_q_handle *qh) -{ - qh->next = qh->h->qh_list; - qh->h->qh_list = qh; -} - -static struct nfqnl_q_handle *find_qh(struct nfqnl_handle *h, u_int16_t id) -{ - struct nfqnl_q_handle *qh; - - for (qh = h->qh_list; qh; qh = qh->next) { - if (qh->id == id) - return qh; - } - return NULL; -} - -/* build a NFQNL_MSG_CONFIG message */ - static int -__build_send_cfg_msg(struct nfqnl_handle *h, u_int8_t command, - u_int16_t queuenum, u_int16_t pf) -{ - char buf[NFNL_HEADER_LEN - +NFA_LENGTH(sizeof(struct nfqnl_msg_config_cmd))]; - struct nfqnl_msg_config_cmd cmd; - struct nlmsghdr *nmh = (struct nlmsghdr *) buf; - - nfnl_fill_hdr(&h->nfnlh, nmh, 0, AF_UNSPEC, queuenum, - NFQNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK); - - cmd.command = command; - cmd.pf = htons(pf); - nfnl_addattr_l(nmh, sizeof(buf), NFQA_CFG_CMD, &cmd, sizeof(cmd)); - - return nfnl_talk(&h->nfnlh, nmh, 0, 0, NULL, NULL, NULL); -} - -static int __nfqnl_rcv_pkt(struct nlmsghdr *nlh, struct nfattr *nfa[], - void *data) -{ - struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); - struct nfqnl_handle *h = data; - u_int16_t queue_num = ntohs(nfmsg->res_id); - struct nfqnl_q_handle *qh = find_qh(h, queue_num); - - if (!qh) - return -ENODEV; - - if (!qh->cb) - return -ENODEV; - - return qh->cb(qh, nfmsg, nfa, qh->data); -} - -static struct nfnl_callback pkt_cb = { - .call = &__nfqnl_rcv_pkt, - .attr_count = NFQA_MAX, -}; - -/* public interface */ - -struct nfnl_handle *nfqnl_nfnlh(struct nfqnl_handle *h) -{ - return &h->nfnlh; -} - -int nfqnl_fd(struct nfqnl_handle *h) -{ - return nfnl_fd(nfqnl_nfnlh(h)); -} - -struct nfqnl_handle *nfqnl_open(void) -{ - struct nfqnl_handle *h; - int err; - - h = malloc(sizeof(*h)); - if (!h) - return NULL; - - memset(h, 0, sizeof(*h)); - - err = nfnl_open(&h->nfnlh, NFNL_SUBSYS_QUEUE, NFQNL_MSG_MAX, 0); - if (err < 0) { - nfqnl_errno = err; - goto out_free; - } - - pkt_cb.data = h; - err = nfnl_callback_register(&h->nfnlh, NFQNL_MSG_PACKET, &pkt_cb); - if (err < 0) { - nfqnl_errno = err; - goto out_close; - } - - return h; -out_close: - nfnl_close(&h->nfnlh); -out_free: - free(h); - return NULL; -} - -int nfqnl_close(struct nfqnl_handle *h) -{ - int ret = nfnl_close(&h->nfnlh); - if (ret == 0) - free(h); - return ret; -} - -/* bind nf_queue from a specific protocol family */ -int nfqnl_bind_pf(struct nfqnl_handle *h, u_int16_t pf) -{ - return __build_send_cfg_msg(h, NFQNL_CFG_CMD_PF_BIND, 0, pf); -} - -/* unbind nf_queue from a specific protocol family */ -int nfqnl_unbind_pf(struct nfqnl_handle *h, u_int16_t pf) -{ - return __build_send_cfg_msg(h, NFQNL_CFG_CMD_PF_UNBIND, 0, pf); -} - -/* bind this socket to a specific queue number */ -struct nfqnl_q_handle *nfqnl_create_queue(struct nfqnl_handle *h, - u_int16_t num, - nfqnl_callback *cb, - void *data) -{ - int ret; - struct nfqnl_q_handle *qh; - - if (find_qh(h, num)) - return NULL; - - qh = malloc(sizeof(*qh)); - - memset(qh, 0, sizeof(*qh)); - qh->h = h; - qh->id = num; - qh->cb = cb; - qh->data = data; - - ret = __build_send_cfg_msg(h, NFQNL_CFG_CMD_BIND, num, 0); - if (ret < 0) { - nfqnl_errno = ret; - free(qh); - return NULL; - } - - add_qh(qh); - return qh; -} - -/* unbind this socket from a specific queue number */ -int nfqnl_destroy_queue(struct nfqnl_q_handle *qh) -{ - int ret = __build_send_cfg_msg(qh->h, NFQNL_CFG_CMD_UNBIND, qh->id, 0); - if (ret == 0) { - del_qh(qh); - free(qh); - } - - return ret; -} - -int nfqnl_handle_packet(struct nfqnl_handle *h, char *buf, int len) -{ - return nfnl_handle_packet(&h->nfnlh, buf, len); -} - -int nfqnl_set_mode(struct nfqnl_q_handle *qh, - u_int8_t mode, u_int32_t range) -{ - char buf[NFNL_HEADER_LEN - +NFA_LENGTH(sizeof(struct nfqnl_msg_config_params))]; - struct nfqnl_msg_config_params params; - struct nlmsghdr *nmh = (struct nlmsghdr *) buf; - - nfnl_fill_hdr(&qh->h->nfnlh, nmh, 0, AF_UNSPEC, qh->id, - NFQNL_MSG_CONFIG, NLM_F_REQUEST|NLM_F_ACK); - - params.copy_range = htonl(range); - params.copy_mode = mode; - nfnl_addattr_l(nmh, sizeof(buf), NFQA_CFG_PARAMS, ¶ms, - sizeof(params)); - - return nfnl_talk(&qh->h->nfnlh, nmh, 0, 0, NULL, NULL, NULL); -} - -static int __set_verdict(struct nfqnl_q_handle *qh, u_int32_t id, - u_int32_t verdict, u_int32_t mark, int set_mark, - u_int32_t data_len, unsigned char *data) -{ - struct nfqnl_msg_verdict_hdr vh; - char buf[NFNL_HEADER_LEN - +NFA_LENGTH(sizeof(mark)) - +NFA_LENGTH(sizeof(vh))]; - struct nlmsghdr *nmh = (struct nlmsghdr *) buf; - - struct iovec iov[3]; - int nvecs; - - memset(iov, 0, sizeof(iov)); - - vh.verdict = htonl(verdict); - vh.id = htonl(id); - - nfnl_fill_hdr(&qh->h->nfnlh, nmh, 0, AF_UNSPEC, qh->id, - NFQNL_MSG_VERDICT, NLM_F_REQUEST); - - /* add verdict header */ - nfnl_addattr_l(nmh, sizeof(buf), NFQA_VERDICT_HDR, &vh, sizeof(vh)); - - if (set_mark) - nfnl_addattr32(nmh, sizeof(buf), NFQA_MARK, mark); - - iov[0].iov_base = nmh; - iov[0].iov_len = NLMSG_TAIL(nmh) - (void *)nmh; - nvecs = 1; - - if (data_len) { - struct nfattr data_attr; - - nfnl_build_nfa_iovec(&iov[1], &data_attr, NFQA_PAYLOAD, - data_len, data); - nvecs += 2; - } - - return nfnl_sendiov(&qh->h->nfnlh, iov, nvecs, 0); -} - -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) -{ - return __set_verdict(qh, id, verdict, 0, 0, data_len, buf); -} - -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) -{ - return __set_verdict(qh, id, verdict, mark, 1, datalen, buf); -} - -/************************************************************* - * Message parsing functions - *************************************************************/ - -struct nfqnl_msg_packet_hdr *nfqnl_get_msg_packet_hdr(struct nfattr *nfa[]) -{ - return nfnl_get_pointer_to_data(nfa, NFQA_PACKET_HDR, - struct nfqnl_msg_packet_hdr); -} - -uint32_t nfqnl_get_nfmark(struct nfattr *nfa[]) -{ - return ntohl(nfnl_get_data(nfa, NFQA_MARK, u_int32_t)); -} - -struct nfqnl_msg_packet_timestamp *nfqnl_get_timestamp(struct nfattr *nfa[]) -{ - return nfnl_get_pointer_to_data(nfa, NFQA_TIMESTAMP, - struct nfqnl_msg_packet_timestamp); -} - -/* all nfqnl_get_*dev() functions return 0 if not set, since linux only allows - * ifindex >= 1, see net/core/dev.c:2600 (in 2.6.13.1) */ -u_int32_t nfqnl_get_indev(struct nfattr *nfa[]) -{ - return ntohl(nfnl_get_data(nfa, NFQA_IFINDEX_INDEV, u_int32_t)); -} - -u_int32_t nfqnl_get_physindev(struct nfattr *nfa[]) -{ - return ntohl(nfnl_get_data(nfa, NFQA_IFINDEX_PHYSINDEV, u_int32_t)); -} - -u_int32_t nfqnl_get_outdev(struct nfattr *nfa[]) -{ - return ntohl(nfnl_get_data(nfa, NFQA_IFINDEX_OUTDEV, u_int32_t)); -} - -u_int32_t nfqnl_get_physoutdev(struct nfattr *nfa[]) -{ - return ntohl(nfnl_get_data(nfa, NFQA_IFINDEX_PHYSOUTDEV, u_int32_t)); -} - -struct nfqnl_msg_packet_hw *nfqnl_get_packet_hw(struct nfattr *nfa[]) -{ - return nfnl_get_pointer_to_data(nfa, NFQA_HWADDR, - struct nfqnl_msg_packet_hw); -} - -int nfqnl_get_payload(struct nfattr *nfa[], char **data, - unsigned int *datalen) -{ - *data = nfnl_get_pointer_to_data(nfa, NFQA_PAYLOAD, char*); - if (*data) { - *datalen = NFA_PAYLOAD(nfa[NFQA_PAYLOAD-1]); - return 1; - } - return 0; -} diff --git a/_queue/utils/Makefile.am b/_queue/utils/Makefile.am deleted file mode 100644 index c7ed00b..0000000 --- a/_queue/utils/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ - -INCLUDES = $(all_includes) -I$(top_srcdir)/include -I${KERNELDIR} - -bin_PROGRAMS = nfqnl_test - -nfqnl_test_SOURCES = nfqnl_test.c -nfqnl_test_LDADD = ../src/libnfnetlink_queue.la -nfqnl_test_LDFLAGS = -dynamic - - diff --git a/_queue/utils/nfqnl_test.c b/_queue/utils/nfqnl_test.c deleted file mode 100644 index ae8c072..0000000 --- a/_queue/utils/nfqnl_test.c +++ /dev/null @@ -1,120 +0,0 @@ - -#include -#include -#include -#include -#include /* for NF_ACCEPT */ - -#include - -/* returns packet id */ -static u_int32_t print_pkt (struct nfattr *tb[]) -{ - int id = 0; - struct nfqnl_msg_packet_hdr *ph; - u_int32_t mark,ifi; - int ret; - unsigned int datalength; - char * data; - - ph = nfqnl_get_msg_packet_hdr(tb); - if (ph){ - id = ntohl(ph->packet_id); - printf("hw_protocol=0x%04x hook=%u id=%u ", - ntohs(ph->hw_protocol), ph->hook, id); - } - - mark = nfqnl_get_nfmark(tb); - if (mark) - printf("mark=%u ", mark); - - ifi = nfqnl_get_indev(tb); - if (ifi) - printf("indev=%u ", ifi); - - ifi = nfqnl_get_outdev(tb); - if (ifi) - printf("outdev=%u ", ifi); - - ret = nfqnl_get_payload(tb, &data, &datalength); - if (ret) - printf("payload_len=%d ", datalength); - - fputc('\n', stdout); - - return id; -} - - -static int cb(struct nfqnl_q_handle *qh, struct nfgenmsg *nfmsg, - struct nfattr *nfa[], void *data) -{ - u_int32_t id = print_pkt(nfa); - printf("entering callback\n"); - return nfqnl_set_verdict(qh, id, NF_ACCEPT, 0, NULL); -} - -int main(int argc, char **argv) -{ - struct nfqnl_handle *h; - struct nfqnl_q_handle *qh; - struct nfnl_handle *nh; - int fd; - int rv; - char buf[4096]; - - printf("opening library handle\n"); - h = nfqnl_open(); - if (!h) { - fprintf(stderr, "error during nfqnl_open()\n"); - exit(1); - } - - printf("unbinding existing nf_queue handler for AF_INET (if any)\n"); - if (nfqnl_unbind_pf(h, AF_INET) < 0) { - fprintf(stderr, "error during nfqnl_unbind_pf()\n"); - exit(1); - } - - printf("binding nfnetlink_queue as nf_queue handler for AF_INET\n"); - if (nfqnl_bind_pf(h, AF_INET) < 0) { - fprintf(stderr, "error during nfqnl_bind_pf()\n"); - exit(1); - } - - printf("binding this socket to queue '0'\n"); - qh = nfqnl_create_queue(h, 0, &cb, NULL); - if (!qh) { - fprintf(stderr, "error during nfqnl_create_queue()\n"); - exit(1); - } - - printf("setting copy_packet mode\n"); - if (nfqnl_set_mode(qh, NFQNL_COPY_PACKET, 0xffff) < 0) { - fprintf(stderr, "can't set packet_copy mode\n"); - exit(1); - } - - nh = nfqnl_nfnlh(h); - fd = nfnl_fd(nh); - - while ((rv = recv(fd, buf, sizeof(buf), 0)) && rv >= 0) { - printf("pkt received\n"); - nfqnl_handle_packet(h, buf, rv); - } - - printf("unbinding from queue 0\n"); - nfqnl_destroy_queue(qh); - -#ifdef INSANE - /* normally, applications SHOULD NOT issue this command, since - * it detaches other programs/sockets from AF_INET, too ! */ - printf("unbinding from AF_INET\n"); - nfqnl_unbind_pf(h, AF_INET); -#endif - - printf("closing library handle\n"); - nfqnl_close(h); - - exit(0); -} -- cgit v1.2.3