summaryrefslogtreecommitdiffstats
path: root/_queue
diff options
context:
space:
mode:
Diffstat (limited to '_queue')
-rw-r--r--_queue/Makefile.am2
-rw-r--r--_queue/configure.in59
-rw-r--r--_queue/include/libnfnetlink_queue/libnfnetlink_queue.h2
-rw-r--r--_queue/src/Makefile.am3
-rw-r--r--_queue/src/libnfnetlink_queue.c4
-rw-r--r--_queue/utils/Makefile.am3
-rw-r--r--_queue/utils/ctnltest.c188
-rw-r--r--_queue/utils/nfqnl_test.c2
8 files changed, 62 insertions, 201 deletions
diff --git a/_queue/Makefile.am b/_queue/Makefile.am
index a580d1a..c2f4f23 100644
--- a/_queue/Makefile.am
+++ b/_queue/Makefile.am
@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = no-dependencies foreign
EXTRA_DIST = $(man_MANS) acinclude.m4
-SUBDIRS = include include/libnfnetlink_queue src utils
+SUBDIRS = include src utils
man_MANS = #nfnetlink_queue.3 nfnetlink_queue.7
diff --git a/_queue/configure.in b/_queue/configure.in
index f5cb3a2..5b77da2 100644
--- a/_queue/configure.in
+++ b/_queue/configure.in
@@ -1,12 +1,65 @@
dnl Process this file with autoconf to create configure.
-AC_INIT(libnfnetlink_queue.c)
+AC_INIT
+AC_CANONICAL_SYSTEM
+
AM_INIT_AUTOMAKE(libnfnetlink_queue, 0.10)
AC_PROG_CC
AC_EXEEXT
AM_PROG_LIBTOOL
+AC_PROG_INSTALL
+
AC_SUBST(LIBTOOL_DEPS)
-dnl Output the makefile
-AC_OUTPUT(Makefile)
+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/libnfnetlink_queue/libnfnetlink_queue.h b/_queue/include/libnfnetlink_queue/libnfnetlink_queue.h
index 1b807a7..b3aad73 100644
--- a/_queue/include/libnfnetlink_queue/libnfnetlink_queue.h
+++ b/_queue/include/libnfnetlink_queue/libnfnetlink_queue.h
@@ -11,7 +11,7 @@
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nfnetlink_queue.h>
-#include <libnfnetlink.h>
+#include <libnfnetlink/libnfnetlink.h>
#define NFQN
diff --git a/_queue/src/Makefile.am b/_queue/src/Makefile.am
index 4e49d41..5efa92c 100644
--- a/_queue/src/Makefile.am
+++ b/_queue/src/Makefile.am
@@ -14,6 +14,3 @@ libnfnetlink_queue_la_SOURCES = libnfnetlink_queue.c
libnfnetlink_queue_libipq_la_LDFLAGS = -Wc,-nostartfiles
libnfnetlink_queue_libipq_la_SOURCES = libipq_compat.c
-$(OBJECTS): libtool
-libtool: $(LIBTOOL_DEPS)
- $(SHELL) ./config.status --recheck
diff --git a/_queue/src/libnfnetlink_queue.c b/_queue/src/libnfnetlink_queue.c
index 389e945..d65c2eb 100644
--- a/_queue/src/libnfnetlink_queue.c
+++ b/_queue/src/libnfnetlink_queue.c
@@ -28,7 +28,9 @@
#include <linux/netlink.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nfnetlink_queue.h>
-#include "libnfnetlink_queue.h"
+
+#include <libnfnetlink/libnfnetlink.h>
+#include <libnfnetlink_queue/libnfnetlink_queue.h>
/***********************************************************************
* low level stuff
diff --git a/_queue/utils/Makefile.am b/_queue/utils/Makefile.am
index d66d819..d437579 100644
--- a/_queue/utils/Makefile.am
+++ b/_queue/utils/Makefile.am
@@ -6,6 +6,3 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -I${KERNELDIR}
nfqnl_test_LDFLAGS = $(all_libraries) -lnfnetlink_queue -lnfnetlink
-$(OBJECTS): libtool
-libtool: $(LIBTOOL_DEPS)
- $(SHELL) ./config.status --recheck
diff --git a/_queue/utils/ctnltest.c b/_queue/utils/ctnltest.c
deleted file mode 100644
index bd3173f..0000000
--- a/_queue/utils/ctnltest.c
+++ /dev/null
@@ -1,188 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
-
-
-#include <linux/types.h>
-#include <linux/netlink.h>
-#include <linux/netfilter/nfnetlink.h>
-
-#include "libctnetlink.h"
-
-static struct ctnl_handle *cth;
-
-char *display_tuple_flat(struct ip_conntrack_tuple *tuple)
-{
- static char buff[250];
- char psb[20];
- int len = 0;
-
- memset(buff, '\0', sizeof(buff));
- len += sprintf(buff + len, "%s:", inet_ntoa((struct in_addr){tuple->src.ip}));
- switch(tuple->dst.protonum) {
- case (IPPROTO_ICMP):
- len += sprintf(buff + len, "Icmp (id %d)",
- ntohs(tuple->src.u.icmp.id));
- break;
- case (IPPROTO_TCP):
- sprintf(psb, "%d", ntohs(tuple->src.u.tcp.port));
- len += sprintf(buff + len, "%s", psb);
- break;
- case (IPPROTO_UDP):
- sprintf(psb, "%d", ntohs(tuple->src.u.udp.port));
- len += sprintf(buff + len, "%s", psb);
- break;
- default:
- len += sprintf(buff + len, "Unknown");
- break;
- }
-
- len += sprintf(buff + len, "->");
- len += sprintf(buff + len, "%s:", inet_ntoa((struct in_addr){tuple->dst.ip}));
- switch(tuple->dst.protonum) {
- case (IPPROTO_ICMP):
- len += sprintf(buff + len, "Icmp (%d, code %d)",
- tuple->dst.u.icmp.type,
- tuple->dst.u.icmp.code);
- break;
- case (IPPROTO_TCP):
- sprintf(psb, "%d", ntohs(tuple->dst.u.tcp.port));
- len += sprintf(buff + len, "%s", psb);
- break;
- case (IPPROTO_UDP):
- sprintf(psb, "%d", ntohs(tuple->dst.u.udp.port));
- len += sprintf(buff + len, "%s", psb);
- break;
- default:
- len += sprintf(buff + len, "Unknown");
- break;
- }
-
- return (buff);
-}
-
-int ctnl_parse_attr(struct nfattr *tb[], int max, struct nfattr *cta, int len)
-{
- while(NFA_OK(cta, len)) {
- if(cta->nfa_type <= max)
- tb[cta->nfa_type] = cta;
- cta = NFA_NEXT(cta,len);
- }
- if (len)
- printf("ctnl_parse_attr: deficit (%d) len (%d).\n",
- len, cta->nfa_len);
- return 0;
-}
-
-#if 0
-int dump()
-{
- struct {
- struct nlmsghdr nlh;
- struct nfgenmsg nfmsg;
- } req;
- struct sockaddr_nl nladdr;
-
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
-
- req.nlh.nlmsg_len = sizeof(req);
- req.nlh.nlmsg_type = (NFNL_SUBSYS_CTNETLINK << 8)|CTNL_MSG_CT_GET;
- req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_DUMP|NLM_F_REQUEST;
- req.nlh.nlmsg_pid = 0;
- req.nlh.nlmsg_seq = 1;
- req.nfmsg.nfgen_family = AF_INET;
-
- return (sendto(ctnlfd, &req, sizeof(req), 0,
- (struct sockaddr *) &nladdr, sizeof(nladdr)));
-
-}
-#endif
-
-int print_msg(struct nfgenmsg *cm, size_t len)
-{
- struct nfattr *cb[CTA_MAX + 1];
-
- printf("ctm_family=0x%x\n", cm->nfgen_family);
-
- ctnl_parse_attr(cb, CTA_MAX, NFM_NFA(cm), len);
-
- if (cb[CTA_ORIG]) {
- printf("orig: %s\n",
- display_tuple_flat(NFA_DATA(cb[CTA_ORIG])));
- ctnl_del_conntrack(cth, NFA_DATA(cb[CTA_ORIG]), CTA_ORIG);
- }
- if (cb[CTA_RPLY])
- printf("rply: %s\n",
- display_tuple_flat(NFA_DATA(cb[CTA_RPLY])));
-
-
- return 0;
-}
-
-struct nlmsghdr *ctnl_get_packet(struct nlmsghdr **last_nlhdr,
- char *buf, size_t len)
-{
- struct nlmsghdr *nlh;
- size_t remain_len;
-
- if ((char *)(*last_nlhdr) > (buf + len) ||
- (char *)(*last_nlhdr) < buf)
- *last_nlhdr = NULL;
-
- if (!*last_nlhdr) {
- nlh = (struct nlmsghdr *) buf;
- if (!NLMSG_OK(nlh, len)) {
- printf("error parsing nlmsg\n");
- return NULL;
- }
- } else {
- /* we are n-th part of multipart mesasge */
- if ((*last_nlhdr)->nlmsg_type == NLMSG_DONE ||
- !((*last_nlhdr)->nlmsg_flags & NLM_F_MULTI)) {
- *last_nlhdr = NULL;
- return NULL;
- }
-
- remain_len = (len - ((char *)(*last_nlhdr) - buf));
- nlh = NLMSG_NEXT(*last_nlhdr, remain_len);
- }
-
- *last_nlhdr = nlh;
- return nlh;
-}
-
-int main(int argc, char **argv)
-{
- char buf[20480];
- struct nfgenmsg *last_cm = NULL, *cm;
- struct nlmsghdr *nlh;
- int len;
-
- cth = malloc(sizeof(*cth));
- if (ctnl_open(cth, 0) < 0) {
- exit(2);
- }
-
- ctnl_wilddump_request(cth, AF_INET, IPCTNL_MSG_CT_GET);
-
- while (len = recv(cth->nfnlh.fd, &buf, sizeof(buf), 0)) {
- printf("pkt received\n");
- while (nlh = ctnl_get_packet(&last_cm, (char *)&buf, len)) {
- printf(" decoding msg type 0x%04x\n", nlh->nlmsg_type);
- if (NFNL_SUBSYS_ID(nlh->nlmsg_type) ==
- NFNL_SUBSYS_CTNETLINK) {
- cm = NLMSG_DATA(nlh);
- print_msg(cm, nlh->nlmsg_len);
- }
- }
- }
-
- return 0;
-}
-
diff --git a/_queue/utils/nfqnl_test.c b/_queue/utils/nfqnl_test.c
index 834f5cb..ddc5fe9 100644
--- a/_queue/utils/nfqnl_test.c
+++ b/_queue/utils/nfqnl_test.c
@@ -4,7 +4,7 @@
#include <unistd.h>
#include <netinet/in.h>
-#include "libnfnetlink_queue.h"
+#include <libnfnetlink_queue/libnfnetlink_queue.h>
int main(int argc, char **argv)
{