Compare commits

...

48 Commits
v1.7 ... v1.13

Author SHA1 Message Date
Jan Engelhardt
f96bc08f35 Xtables-addons 1.13 2009-03-23 15:50:42 +01:00
Jan Engelhardt
a0c791dc88 Upgrade to iptables 1.4.3 API 2009-03-19 11:05:26 +01:00
Jan Engelhardt
f717a91bc5 Merge branch 'ipv4options' 2009-03-19 11:03:26 +01:00
Jan Engelhardt
8bd5fc14ba libxt_ipv4options: add manpage 2009-03-19 10:34:27 +01:00
Jan Engelhardt
a51b16097b Add a reworked IPv4 options match - xt_ipv4options
This revision 1 of ipv4options makes it possible to match the
presence or absence of any of the 32 possible IP options, either all
or any of the options the user specified.
2009-03-08 23:38:12 +01:00
Jan Engelhardt
0bb538ba69 Xtables-addons 1.12 2009-03-07 03:24:21 +01:00
Jan Engelhardt
e11a07b230 build: fix compile issues with <= 2.6.19
Resolve compile breakage from commits
36f80be2f7 and
7b9ca945d4.
2009-03-07 02:58:36 +01:00
Jan Engelhardt
d263cfbd50 ipset: fast forward to 2.5.0 2009-03-07 01:33:31 +01:00
Jan Engelhardt
36f80be2f7 xt_TEE: enable routing by iif, nfmark and flowlabel
Patrick McHardy suggests in
http://marc.info/?l=netfilter-devel&m=123564267330117&w=2 that
routing should handle the clone more like its original.
2009-03-07 01:27:08 +01:00
Jan Engelhardt
7b9ca945d4 xt_LOGMARK: print incoming interface index 2009-03-07 01:15:48 +01:00
Jan Engelhardt
ffeb1da7d7 build: silence warning about ignored variable
The warning was:

	config.status: WARNING: 'extensions/ipset/GNUmakefile.in'
	seems to ignore the --datarootdir setting
2009-03-07 00:59:05 +01:00
Florian Westphal
d2d8712980 xt_TEE: resolve unknown symbol error with CONFIG_IPV6=n
WARNING: xt_TEE.ko needs unknown symbol ip6_route_output

Signed-off-by: Florian Westphal <fwestphal@astaro.com>
2009-03-07 00:48:16 +01:00
Jan Engelhardt
621cef39f5 revert "TEE: do not use TOS for routing"
Revert commit f77a8e2eda.

Patrick McHardy suggests in
http://marc.info/?l=netfilter-devel&m=123564267330117&w=2 that
routing should handle the clone more like its original.
2009-03-05 02:03:06 +01:00
Jan Engelhardt
08e6f23655 xt_lscan: rename from xt_portscan 2009-03-05 01:43:29 +01:00
Jan Engelhardt
4a25321191 doc: ipset: replace RW_LOCK_UNLOCKED
ipset uses RW_LOCK_UNLOCKED directly, but this is not quite right,
and causes compilation errors with 2.6.29-rt.
2009-03-05 01:30:02 +01:00
Jan Engelhardt
8c322a0119 ipset: replace RW_LOCK_UNLOCKED
ipset uses RW_LOCK_UNLOCKED directly, but this is not quite right,
and causes compilation errors with 2.6.29-rt.
2009-03-05 01:25:17 +01:00
Jan Engelhardt
bd39e4671e doc: remove old path examples 2009-02-24 19:14:10 +01:00
Jan Engelhardt
3d6bb5f86f doc: add changelog 2009-02-21 17:21:39 +01:00
Jan Engelhardt
ce03d0ee8e build: make kbuild call obey V 2009-02-21 16:54:49 +01:00
Jan Engelhardt
bca90ca2a7 build: trigger configure when GNUmakefile.in changed 2009-02-21 16:54:30 +01:00
Jan Engelhardt
08cb9e5584 Xtables-addons 1.10 2009-02-18 00:31:26 +01:00
Jan Engelhardt
1a8cc305af doc: add precise version information to INSTALL document 2009-02-11 16:56:35 +01:00
Jan Engelhardt
47a34e0ccf ipset: upgrade to ipset 2.4.9 2009-02-11 16:51:40 +01:00
Jan Engelhardt
36dab67658 Update .gitignore 2009-02-11 15:57:10 +01:00
Jan Engelhardt
7bb2957e47 compat: compile fixes for 2.6.29
2.6.29 removes at least NIP6, and NIPQUAD is scheduled to follow.
2009-02-11 15:56:33 +01:00
Jan Engelhardt
c168a2f142 Xtables-addons 1.9 2009-01-30 06:34:07 +01:00
Jan Engelhardt
68af6989b1 ipset: bump version to 2.4.7
Moving from ipset 2.4.5 to 2.4.7. Upstream changed, but
the Xtables-addons copy did not (issues were not present):

>2.4.7
>  - Typo which broke compilation with kernels < 2.6.28
>    fixed (reported by Richard Lucassen, Danny Rawlins)
>
>2.4.6
>   - Compatibility fix for kernels >= 2.6.28
2009-01-30 06:33:21 +01:00
Jan Engelhardt
446c67018a TEE: remove calls to check_inverse 2009-01-30 06:19:22 +01:00
Jan Engelhardt
0fe8e180c4 ipp2p: version bump
For cosmetics, or so. The recent bugfix warrants this I'd say.
2009-01-30 06:02:10 +01:00
Jan Engelhardt
7cdfc0ac3d Add xt_length2
xt_length2 provides exact layer-4,-5 and -7 length matching
besides the preexisting layer-3 length match.
2009-01-30 06:01:12 +01:00
Jan Engelhardt
85cab10371 Xtables-addons 1.8 2009-01-10 14:05:46 +01:00
Jan Engelhardt
61d8425cb6 Merge branch 'TEE6' 2009-01-10 14:03:04 +01:00
Jan Engelhardt
d49b6244c1 Merge branch 'TEE' 2009-01-10 14:03:03 +01:00
Jan Engelhardt
10c2b97786 Merge branch 'ipp2p' 2009-01-10 13:59:43 +01:00
Jan Engelhardt
9ed364ed36 TEE: collapse tee_tg_send{4,6} 2009-01-10 13:58:19 +01:00
Jan Engelhardt
b95e5f6417 TEE: IPv6 support for iptables module 2009-01-10 10:19:21 +01:00
Jan Engelhardt
4afebf88eb Merge branch 'TEE' into TEE6 2009-01-10 10:01:31 +01:00
Jan Engelhardt
d523158e92 TEE: iptables -nL and -L produced conversely output 2009-01-10 10:01:27 +01:00
Jan Engelhardt
1fd1787a1c TEE: limit iptables module to NFPROTO_IPV4
The code here is only usable with IPv4.
2009-01-10 09:57:44 +01:00
Jan Engelhardt
fbbca68790 ipp2p: partial revert of 3c8131b9
Revert part of 3c8131b976.

The transport header offset is not (yet) set by the time Netfilter
is invoked so using tcp_hdr/udp_hdr has undefined behavior.
2009-01-10 08:25:42 +01:00
Jan Engelhardt
4cdfd49637 ipp2p: add boundary check in search_all_kazaa
To avoid underflow on "end - 18", we must check for plen >= 18.
2009-01-10 06:11:13 +01:00
Jan Engelhardt
31c01cf107 portscan: update manpage about --grscan caveats 2009-01-10 05:23:43 +01:00
Jan Engelhardt
879e964f60 ipp2p: remove log flooding
Syslog was flooded by lots of messages due to if (plen >= 5) firing
on any packet, when it should have been plen < 5. Incidentally, this
turned up that plen also takes on huge nonsense values, assuming
underflow - yet to be investigated.
2009-01-10 04:47:14 +01:00
Jan Engelhardt
019c9de291 ipp2p: update help text
More suggestions from Stanley Pinchak.
2009-01-10 04:42:27 +01:00
Jan Engelhardt
af370f81f0 ipp2p: update manpage
(With suggestions from Stanley Pinchak.)
2009-01-09 20:24:41 +01:00
Jan Engelhardt
4aad07bdc4 TEE: IPv6 support 2008-11-21 01:15:21 +01:00
Jan Engelhardt
7a3f874753 TEE: various cleanups, add comments
Normalize function names in light of upcoming IPv6 support.
Reformat other lines.
Add comment note about tee_send4.
2008-11-21 01:15:03 +01:00
Jan Engelhardt
f77a8e2eda TEE: do not use TOS for routing
Otherwise the cloned packet may be subject to more policy routing
rules than expected.
2008-11-21 01:15:02 +01:00
54 changed files with 1573 additions and 415 deletions

22
INSTALL
View File

@@ -9,16 +9,23 @@ in combination with the kernel's Kbuild system.
# make install # make install
Prerequirements Supported configurations for this release
=============== =========================================
* iptables 1.4.1 * iptables >= 1.4.3
* kernel-source >= 2.6.17 with prepared build/output directory * kernel-source >= 2.6.17, no upper bound known
with prepared build/output directory
- CONFIG_NF_CONNTRACK or CONFIG_IP_NF_CONNTRACK - CONFIG_NF_CONNTRACK or CONFIG_IP_NF_CONNTRACK
- CONFIG_NF_CONNTRACK_MARK or CONFIG_IP_NF_CONNTRACK_MARK - CONFIG_NF_CONNTRACK_MARK or CONFIG_IP_NF_CONNTRACK_MARK
enabled =y or as module (=m) enabled =y or as module (=m)
Extra notes:
* in the kernel 2.6.18.x series, >= 2.6.18.5 is required
* requires that no vendor backports interfere
Selecting extensions Selecting extensions
==================== ====================
@@ -45,11 +52,8 @@ Configuring and compiling
xtables.h, should it not be within the standard C compiler xtables.h, should it not be within the standard C compiler
include path (/usr/include), or if you want to override it. include path (/usr/include), or if you want to override it.
The directory will be checked for xtables.h and The directory will be checked for xtables.h and
include/xtables.h. (This is to support the following specs:) include/xtables.h. (The latter to support both standard
/usr/include and the iptables source root.)
--with-xtables=/usr/src/xtables
--with-xtables=/usr/src/xtables/include
--with-xtables=/opt/xtables/include
--with-libxtdir= --with-libxtdir=

View File

@@ -1,7 +1,6 @@
# -*- Makefile -*- # -*- Makefile -*-
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = foreign subdir-objects
SUBDIRS = extensions SUBDIRS = extensions
man_MANS := xtables-addons.8 man_MANS := xtables-addons.8
@@ -15,6 +14,8 @@ extensions/%:
install-exec-local: install-exec-local:
depmod -a || :; depmod -a || :;
config.status: extensions/GNUmakefile.in
.PHONY: tarball .PHONY: tarball
tarball: tarball:
rm -Rf /tmp/xtables-addons-${PACKAGE_VERSION}; rm -Rf /tmp/xtables-addons-${PACKAGE_VERSION};

View File

@@ -1,9 +1,9 @@
AC_INIT([xtables-addons], [1.7]) AC_INIT([xtables-addons], [1.13])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AC_PROG_INSTALL AC_PROG_INSTALL
AM_INIT_AUTOMAKE([-Wall]) AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
AC_PROG_CC AC_PROG_CC
AM_PROG_CC_C_O AM_PROG_CC_C_O
AC_DISABLE_STATIC AC_DISABLE_STATIC
@@ -28,8 +28,11 @@ AC_ARG_WITH([xtlibdir],
[xtlibdir="$withval"], [xtlibdir="$withval"],
[xtlibdir='${libexecdir}/xtables']) [xtlibdir='${libexecdir}/xtables'])
AC_MSG_CHECKING([xtables.h presence]) #
# --with-xtables= overrides a possibly installed pkgconfig file.
#
if [[ -n "$xtables_location" ]]; then if [[ -n "$xtables_location" ]]; then
AC_MSG_CHECKING([xtables.h presence])
if [[ -f "$xtables_location/xtables.h" ]]; then if [[ -f "$xtables_location/xtables.h" ]]; then
AC_MSG_RESULT([$xtables_location/xtables.h]) AC_MSG_RESULT([$xtables_location/xtables.h])
xtables_CFLAGS="-I $xtables_location"; xtables_CFLAGS="-I $xtables_location";
@@ -37,7 +40,6 @@ if [[ -n "$xtables_location" ]]; then
AC_MSG_RESULT([$xtables_location/include/xtables.h]) AC_MSG_RESULT([$xtables_location/include/xtables.h])
xtables_CFLAGS="-I $xtables_location/include"; xtables_CFLAGS="-I $xtables_location/include";
fi; fi;
fi;
if [[ -z "$xtables_CFLAGS" ]]; then if [[ -z "$xtables_CFLAGS" ]]; then
if [[ -f "$includedir/xtables.h" ]]; then if [[ -f "$includedir/xtables.h" ]]; then
AC_MSG_RESULT([$includedir/xtables.h]) AC_MSG_RESULT([$includedir/xtables.h])
@@ -45,6 +47,9 @@ if [[ -z "$xtables_CFLAGS" ]]; then
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
fi; fi;
fi; fi;
else
PKG_CHECK_MODULES([libxtables], [xtables >= 1.4.3])
fi;
regular_CFLAGS="-D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 \ regular_CFLAGS="-D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 \
-D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations \ -D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations \

131
doc/changelog.txt Normal file
View File

@@ -0,0 +1,131 @@
Xtables-addons 1.13 (March 23 2009)
===================================
- added a reworked ipv4options match
- upgrade to iptables 1.4.3 API
Xtables-addons 1.12 (March 07 2009)
===================================
- ipset: fix for compilation with 2.6.29-rt
- ipset: fast forward to 2.5.0
- rename xt_portscan to xt_lscan ("low-level scan") because
"portscan" as a wor caused confusion
- xt_LOGMARK: print incoming interface index
- revert "TEE: do not use TOS for routing"
- xt_TEE: resolve unknown symbol error with CONFIG_IPV6=n
- xt_TEE: enable routing by iif, nfmark and flowlabel
Xtables-addons 1.10 (February 18 2009)
======================================
- compat: compile fixes for 2.6.29
- ipset: upgrade to ipset 2.4.9
Xtables-addons 1.9 (January 30 2009)
====================================
- add the xt_length2 extension
- xt_TEE: remove intrapositional '!' support
- ipset: upgrade to ipset 2.4.7
Xtables-addons 1.8 (January 10 2009)
====================================
- xt_TEE: IPv6 support
- xt_TEE: do not include TOS value in routing decision
- xt_TEE: fix switch-case inversion for name/IP display
- xt_ipp2p: update manpages and help text
- xt_ipp2p: remove log flooding
- xt_portscan: update manpage about --grscan option caveats
Xtables-addons 1.7 (December 25 2008)
=====================================
- xt_ECHO: compile fix
- avoid the use of "_init" which led to compile errors on some installations
- build: do not unconditionally install ipset
- doc: add manpages for xt_ECHO and xt_TEE
- xt_ipp2p: kazaa detection code cleanup
- xt_ipp2p: fix newline inspection in kazaa detection
- xt_ipp2p: ensure better array bounds checking
- xt_SYSRQ: improve security by hashing password
Xtables-addons 1.6 (November 18 2008)
=====================================
- build: support for Linux 2.6.17
- build: compile fixes for 2.6.18 and 2.6.19
- xt_ECHO: resolve compile errors in xt_ECHO
- xt_ipp2p: parenthesize unaligned-access macros
Xtables-addons 1.5.7 (September 01 2008)
========================================
- API layer: fix use of uninitialized 'hotdrop' variable
- API layer: move to pskb-based signatures
- xt_SYSRQ: compile fixes for Linux <= 2.6.19
- ipset: adjust semaphore.h include for Linux >= 2.6.27
- build: automatically run `depmod -a` on installation
- add reworked xt_fuzzy module
- add DHCP address match and mangle module
- xt_portscan: IPv6 support
- xt_SYSRQ: add missing module aliases
Xtables-addons 1.5.5 (August 03 2008)
=====================================
- manpage updates for xt_CHAOS, xt_IPMARK; README updates
- build: properly recognize external Kbuild/Mbuild files
- build: remove dependency on CONFIG_NETWORK_SECMARK
- add the xt_SYSRQ target
- add the xt_quota2 extension
- import ipset extension group
Xtables-addons 1.5.4.1 (April 26 2008)
======================================
- build: fix compile error for 2.6.18-stable
Xtables-addons 1.5.4 (April 09 2008)
====================================
- build: support building multiple files with one config option
- API layer: add check for pskb relocation
- doc: generate manpages
- xt_ECHO: catch skb_linearize out-of-memory condition
- xt_LOGMARK: add hook= and ctdir= fields in dump
- xt_LOGMARK: fix comma output in ctstatus= list
- xt_TEE: fix address copying bug
- xt_TEE: make skb writable before attempting checksum update
- add reworked xt_condition match
- add reworked xt_ipp2p match
- add reworked xt_IPMARK target
Xtables-addons 1.5.3 (March 22 2008)
====================================
- support for Linux 2.6.18
- add xt_ECHO sample target
- add reworked xt_geoip match
Xtables-addons 1.5.2 (March 04 2008)
====================================
- build: support for GNU make < 3.81 which does not have $(realpath)
Xtables-addons 1.5.1 (February 21 2008)
=======================================
- build: allow user to select what extensions to compile and install
- build: allow external proejcts to be downloaded into the tree
- xt_LOGMARK: dump classify mark, ctstate and ctstatus
- add xt_CHAOS, xt_DELUDE and xt_portscan from Chaostables
Xtables-addons 1.5.0 (February 11 2008)
=======================================
Initial release with:
- extensions: xt_LOGMARK, xt_TARPIT, xt_TEE
- support for Linux >= 2.6.19

View File

@@ -3,6 +3,7 @@
.tmp_versions .tmp_versions
*.ko *.ko
*.mod.c *.mod.c
Module.markers
Module.symvers Module.symvers
Modules.symvers Modules.symvers
modules.order modules.order

View File

@@ -34,12 +34,14 @@ VU := 0
am__1verbose_CC_0 = @echo " CC " $@; am__1verbose_CC_0 = @echo " CC " $@;
am__1verbose_CCLD_0 = @echo " CCLD " $@; am__1verbose_CCLD_0 = @echo " CCLD " $@;
am__1verbose_GEN_0 = @echo " GEN " $@; am__1verbose_GEN_0 = @echo " GEN " $@;
am__1verbose_SILENT_0 = @
am__1verbose_CC_1 = @echo " CC " $@ "<-" $<; am__1verbose_CC_1 = @echo " CC " $@ "<-" $<;
am__1verbose_CCLD_1 = @echo " CCLD " $@ "<-" $^; am__1verbose_CCLD_1 = @echo " CCLD " $@ "<-" $^;
am__1verbose_GEN_1 = @echo " GEN " $@ "<-" $<; am__1verbose_GEN_1 = @echo " GEN " $@ "<-" $<;
am__verbose_CC = ${am__1verbose_CC_${VU}} am__verbose_CC = ${am__1verbose_CC_${VU}}
am__verbose_CCLD = ${am__1verbose_CCLD_${VU}} am__verbose_CCLD = ${am__1verbose_CCLD_${VU}}
am__verbose_GEN = ${am__1verbose_GEN_${VU}} am__verbose_GEN = ${am__1verbose_GEN_${VU}}
am__verbose_SILENT = ${am__1verbose_GEN_${VU}}
# #
@@ -93,13 +95,13 @@ distclean: clean
.PHONY: modules modules_install clean_modules .PHONY: modules modules_install clean_modules
modules: modules:
make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} modules; ${am__verbose_SILENT}if [ -n "${kbuilddir}" ]; then make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} modules; fi;
modules_install: modules_install:
make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} INSTALL_MOD_PATH=${DESTDIR} modules_install; ${am__verbose_SILENT}if [ -n "${kbuilddir}" ]; then make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} INSTALL_MOD_PATH=${DESTDIR} modules_install; fi;
clean_modules: clean_modules:
make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} clean; ${am__verbose_SILENT}if [ -n "${kbuilddir}" ]; then make -C ${kbuilddir} M=${abssrcdir} XA_TOPSRCDIR=${abstop_srcdir} clean; fi;
# #

View File

@@ -19,7 +19,9 @@ obj-${build_fuzzy} += xt_fuzzy.o
obj-${build_geoip} += xt_geoip.o obj-${build_geoip} += xt_geoip.o
obj-${build_ipp2p} += xt_ipp2p.o obj-${build_ipp2p} += xt_ipp2p.o
obj-${build_ipset} += ipset/ obj-${build_ipset} += ipset/
obj-${build_portscan} += xt_portscan.o obj-${build_ipv4options} += xt_ipv4options.o
obj-${build_length2} += xt_length2.o
obj-${build_lscan} += xt_lscan.o
obj-${build_quota2} += xt_quota2.o obj-${build_quota2} += xt_quota2.o
-include ${M}/*.Kbuild -include ${M}/*.Kbuild

View File

@@ -12,5 +12,7 @@ obj-${build_fuzzy} += libxt_fuzzy.so
obj-${build_geoip} += libxt_geoip.so obj-${build_geoip} += libxt_geoip.so
obj-${build_ipp2p} += libxt_ipp2p.so obj-${build_ipp2p} += libxt_ipp2p.so
obj-${build_ipset} += ipset/ obj-${build_ipset} += ipset/
obj-${build_portscan} += libxt_portscan.so obj-${build_ipv4options} += libxt_ipv4options.so
obj-${build_length2} += libxt_length2.so
obj-${build_lscan} += libxt_lscan.so
obj-${build_quota2} += libxt_quota2.so obj-${build_quota2} += libxt_quota2.so

View File

@@ -5,8 +5,11 @@ struct tcphdr;
struct udphdr; struct udphdr;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
# define skb_ifindex(skb) \
(((skb)->input_dev != NULL) ? (skb)->input_dev->ifindex : 0)
# define skb_nfmark(skb) (((struct sk_buff *)(skb))->nfmark) # define skb_nfmark(skb) (((struct sk_buff *)(skb))->nfmark)
#else #else
# define skb_ifindex(skb) (skb)->iif
# define skb_nfmark(skb) (((struct sk_buff *)(skb))->mark) # define skb_nfmark(skb) (((struct sk_buff *)(skb))->mark)
#endif #endif

View File

@@ -1,6 +1,7 @@
#ifndef _XTABLES_COMPAT_H #ifndef _XTABLES_COMPAT_H
#define _XTABLES_COMPAT_H 1 #define _XTABLES_COMPAT_H 1
#include <linux/kernel.h>
#include <linux/version.h> #include <linux/version.h>
#include "compat_skbuff.h" #include "compat_skbuff.h"
#include "compat_xtnu.h" #include "compat_xtnu.h"
@@ -70,6 +71,27 @@
# define csum_replace2 nf_csum_replace2 # define csum_replace2 nf_csum_replace2
#endif #endif
#if !defined(NIP6) && !defined(NIP6_FMT)
# define NIP6(addr) \
ntohs((addr).s6_addr16[0]), \
ntohs((addr).s6_addr16[1]), \
ntohs((addr).s6_addr16[2]), \
ntohs((addr).s6_addr16[3]), \
ntohs((addr).s6_addr16[4]), \
ntohs((addr).s6_addr16[5]), \
ntohs((addr).s6_addr16[6]), \
ntohs((addr).s6_addr16[7])
# define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
#endif
#if !defined(NIPQUAD) && !defined(NIPQUAD_FMT)
# define NIPQUAD(addr) \
((const unsigned char *)&addr)[0], \
((const unsigned char *)&addr)[1], \
((const unsigned char *)&addr)[2], \
((const unsigned char *)&addr)[3]
# define NIPQUAD_FMT "%u.%u.%u.%u"
#endif
#define ip_route_me_harder xtnu_ip_route_me_harder #define ip_route_me_harder xtnu_ip_route_me_harder
#define skb_make_writable xtnu_skb_make_writable #define skb_make_writable xtnu_skb_make_writable
#define xt_target xtnu_target #define xt_target xtnu_target

View File

@@ -2,6 +2,7 @@
top_srcdir := @top_srcdir@ top_srcdir := @top_srcdir@
srcdir := @srcdir@ srcdir := @srcdir@
datarootdir := @datarootdir@
abstop_srcdir := $(shell readlink -e ${top_srcdir}) abstop_srcdir := $(shell readlink -e ${top_srcdir})
abssrcdir := $(shell readlink -e ${srcdir}) abssrcdir := $(shell readlink -e ${srcdir})

View File

@@ -19,7 +19,7 @@
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/jhash.h> #include "ip_set_jhash.h"
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
@@ -877,7 +877,7 @@ ip_set_create(const char *name,
set = kmalloc(sizeof(struct ip_set), GFP_KERNEL); set = kmalloc(sizeof(struct ip_set), GFP_KERNEL);
if (!set) if (!set)
return -ENOMEM; return -ENOMEM;
set->lock = RW_LOCK_UNLOCKED; rwlock_init(&set->lock);
strncpy(set->name, name, IP_SET_MAXNAMELEN); strncpy(set->name, name, IP_SET_MAXNAMELEN);
set->binding = IP_SET_INVALID_ID; set->binding = IP_SET_INVALID_ID;
atomic_set(&set->ref, 0); atomic_set(&set->ref, 0);

View File

@@ -11,7 +11,7 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/jhash.h> #include "ip_set_jhash.h"
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/bitops.h> #include <asm/bitops.h>
@@ -42,8 +42,7 @@ iphash_id(struct ip_set *set, ip_set_ip_t *hash_ip, ip_set_ip_t ip)
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, id); elem = HARRAY_ELEM(map->members, ip_set_ip_t *, id);
if (*elem == *hash_ip) if (*elem == *hash_ip)
return id; return id;
/* No shortcut at testing - there can be deleted /* No shortcut - there can be deleted entries. */
* entries. */
} }
return UINT_MAX; return UINT_MAX;
} }
@@ -64,19 +63,22 @@ __iphash_add(struct ip_set_iphash *map, ip_set_ip_t *ip)
{ {
__u32 probe; __u32 probe;
u_int16_t i; u_int16_t i;
ip_set_ip_t *elem; ip_set_ip_t *elem, *slot = NULL;
for (i = 0; i < map->probes; i++) { for (i = 0; i < map->probes; i++) {
probe = jhash_ip(map, i, *ip) % map->hashsize; probe = jhash_ip(map, i, *ip) % map->hashsize;
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, probe); elem = HARRAY_ELEM(map->members, ip_set_ip_t *, probe);
if (*elem == *ip) if (*elem == *ip)
return -EEXIST; return -EEXIST;
if (!*elem) { if (!(slot || *elem))
*elem = *ip; slot = elem;
/* There can be deleted entries, must check all slots */
}
if (slot) {
*slot = *ip;
map->elements++; map->elements++;
return 0; return 0;
} }
}
/* Trigger rehashing */ /* Trigger rehashing */
return -EAGAIN; return -EAGAIN;
} }

View File

@@ -13,7 +13,7 @@
#include <linux/tcp.h> #include <linux/tcp.h>
#include <linux/udp.h> #include <linux/udp.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/jhash.h> #include "ip_set_jhash.h"
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/bitops.h> #include <asm/bitops.h>
@@ -49,8 +49,7 @@ ipporthash_id(struct ip_set *set, ip_set_ip_t *hash_ip,
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, id); elem = HARRAY_ELEM(map->members, ip_set_ip_t *, id);
if (*elem == *hash_ip) if (*elem == *hash_ip)
return id; return id;
/* No shortcut at testing - there can be deleted /* No shortcut - there can be deleted entries. */
* entries. */
} }
return UINT_MAX; return UINT_MAX;
} }
@@ -86,19 +85,22 @@ __ipporthash_add(struct ip_set_ipporthash *map, ip_set_ip_t *ip)
{ {
__u32 probe; __u32 probe;
u_int16_t i; u_int16_t i;
ip_set_ip_t *elem; ip_set_ip_t *elem, *slot = NULL;
for (i = 0; i < map->probes; i++) { for (i = 0; i < map->probes; i++) {
probe = jhash_ip(map, i, *ip) % map->hashsize; probe = jhash_ip(map, i, *ip) % map->hashsize;
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, probe); elem = HARRAY_ELEM(map->members, ip_set_ip_t *, probe);
if (*elem == *ip) if (*elem == *ip)
return -EEXIST; return -EEXIST;
if (!*elem) { if (!(slot || *elem))
*elem = *ip; slot = elem;
/* There can be deleted entries, must check all slots */
}
if (slot) {
*slot = *ip;
map->elements++; map->elements++;
return 0; return 0;
} }
}
/* Trigger rehashing */ /* Trigger rehashing */
return -EAGAIN; return -EAGAIN;
} }

View File

@@ -13,7 +13,7 @@
#include <linux/tcp.h> #include <linux/tcp.h>
#include <linux/udp.h> #include <linux/udp.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/jhash.h> #include "ip_set_jhash.h"
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/bitops.h> #include <asm/bitops.h>
@@ -51,8 +51,7 @@ ipportiphash_id(struct ip_set *set, ip_set_ip_t *hash_ip,
elem = HARRAY_ELEM(map->members, struct ipportip *, id); elem = HARRAY_ELEM(map->members, struct ipportip *, id);
if (elem->ip == *hash_ip && elem->ip1 == ip1) if (elem->ip == *hash_ip && elem->ip1 == ip1)
return id; return id;
/* No shortcut at testing - there can be deleted /* No shortcut - there can be deleted entries. */
* entries. */
} }
return UINT_MAX; return UINT_MAX;
} }
@@ -90,20 +89,23 @@ __ipportip_add(struct ip_set_ipportiphash *map,
{ {
__u32 probe; __u32 probe;
u_int16_t i; u_int16_t i;
struct ipportip *elem; struct ipportip *elem, *slot = NULL;
for (i = 0; i < map->probes; i++) { for (i = 0; i < map->probes; i++) {
probe = jhash_ip2(map, i, hash_ip, ip1) % map->hashsize; probe = jhash_ip2(map, i, hash_ip, ip1) % map->hashsize;
elem = HARRAY_ELEM(map->members, struct ipportip *, probe); elem = HARRAY_ELEM(map->members, struct ipportip *, probe);
if (elem->ip == hash_ip && elem->ip1 == ip1) if (elem->ip == hash_ip && elem->ip1 == ip1)
return -EEXIST; return -EEXIST;
if (!(elem->ip || elem->ip1)) { if (!(slot || elem->ip || elem->ip1))
elem->ip = hash_ip; slot = elem;
elem->ip1 = ip1; /* There can be deleted entries, must check all slots */
}
if (slot) {
slot->ip = hash_ip;
slot->ip1 = ip1;
map->elements++; map->elements++;
return 0; return 0;
} }
}
/* Trigger rehashing */ /* Trigger rehashing */
return -EAGAIN; return -EAGAIN;
} }

View File

@@ -13,7 +13,7 @@
#include <linux/tcp.h> #include <linux/tcp.h>
#include <linux/udp.h> #include <linux/udp.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/jhash.h> #include "ip_set_jhash.h"
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/bitops.h> #include <asm/bitops.h>
@@ -53,8 +53,7 @@ ipportnethash_id_cidr(struct ip_set *set, ip_set_ip_t *hash_ip,
elem = HARRAY_ELEM(map->members, struct ipportip *, id); elem = HARRAY_ELEM(map->members, struct ipportip *, id);
if (elem->ip == *hash_ip && elem->ip1 == ip1) if (elem->ip == *hash_ip && elem->ip1 == ip1)
return id; return id;
/* No shortcut at testing - there can be deleted /* No shortcut - there can be deleted entries. */
* entries. */
} }
return UINT_MAX; return UINT_MAX;
} }
@@ -137,20 +136,23 @@ __ipportnet_add(struct ip_set_ipportnethash *map,
{ {
__u32 probe; __u32 probe;
u_int16_t i; u_int16_t i;
struct ipportip *elem; struct ipportip *elem, *slot = NULL;
for (i = 0; i < map->probes; i++) { for (i = 0; i < map->probes; i++) {
probe = jhash_ip2(map, i, hash_ip, ip1) % map->hashsize; probe = jhash_ip2(map, i, hash_ip, ip1) % map->hashsize;
elem = HARRAY_ELEM(map->members, struct ipportip *, probe); elem = HARRAY_ELEM(map->members, struct ipportip *, probe);
if (elem->ip == hash_ip && elem->ip1 == ip1) if (elem->ip == hash_ip && elem->ip1 == ip1)
return -EEXIST; return -EEXIST;
if (!(elem->ip || elem->ip1)) { if (!(slot || elem->ip || elem->ip1))
elem->ip = hash_ip; slot = elem;
elem->ip1 = ip1; /* There can be deleted entries, must check all slots */
}
if (slot) {
slot->ip = hash_ip;
slot->ip1 = ip1;
map->elements++; map->elements++;
return 0; return 0;
} }
}
/* Trigger rehashing */ /* Trigger rehashing */
return -EAGAIN; return -EAGAIN;
} }

View File

@@ -1,148 +1,157 @@
#ifndef _LINUX_IPSET_JHASH_H #ifndef _LINUX_JHASH_H
#define _LINUX_IPSET_JHASH_H #define _LINUX_JHASH_H
/* This is a copy of linux/jhash.h but the types u32/u8 are changed
* to __u32/__u8 so that the header file can be included into
* userspace code as well. Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
*/
/* jhash.h: Jenkins hash support. /* jhash.h: Jenkins hash support.
* *
* Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net) * Copyright (C) 2006. Bob Jenkins (bob_jenkins@burtleburtle.net)
* *
* http://burtleburtle.net/bob/hash/ * http://burtleburtle.net/bob/hash/
* *
* These are the credits from Bob's sources: * These are the credits from Bob's sources:
* *
* lookup2.c, by Bob Jenkins, December 1996, Public Domain. * lookup3.c, by Bob Jenkins, May 2006, Public Domain.
* hash(), hash2(), hash3, and mix() are externally useful functions.
* Routines to test the hash are included if SELF_TEST is defined.
* You can use this free for any purpose. It has no warranty.
* *
* Copyright (C) 2003 David S. Miller (davem@redhat.com) * These are functions for producing 32-bit hashes for hash table lookup.
* hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
* are externally useful functions. Routines to test the hash are included
* if SELF_TEST is defined. You can use this free for any purpose. It's in
* the public domain. It has no warranty.
*
* Copyright (C) 2009 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu)
* *
* I've modified Bob's hash to be useful in the Linux kernel, and * I've modified Bob's hash to be useful in the Linux kernel, and
* any bugs present are surely my fault. -DaveM * any bugs present are my fault. Jozsef
*/ */
/* NOTE: Arguments are modified. */ #define __rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
/* __jhash_mix - mix 3 32-bit values reversibly. */
#define __jhash_mix(a,b,c) \ #define __jhash_mix(a,b,c) \
{ \ { \
a -= b; a -= c; a ^= (c>>13); \ a -= c; a ^= __rot(c, 4); c += b; \
b -= c; b -= a; b ^= (a<<8); \ b -= a; b ^= __rot(a, 6); a += c; \
c -= a; c -= b; c ^= (b>>13); \ c -= b; c ^= __rot(b, 8); b += a; \
a -= b; a -= c; a ^= (c>>12); \ a -= c; a ^= __rot(c,16); c += b; \
b -= c; b -= a; b ^= (a<<16); \ b -= a; b ^= __rot(a,19); a += c; \
c -= a; c -= b; c ^= (b>>5); \ c -= b; c ^= __rot(b, 4); b += a; \
a -= b; a -= c; a ^= (c>>3); \ }
b -= c; b -= a; b ^= (a<<10); \
c -= a; c -= b; c ^= (b>>15); \ /* __jhash_final - final mixing of 3 32-bit values (a,b,c) into c */
#define __jhash_final(a,b,c) \
{ \
c ^= b; c -= __rot(b,14); \
a ^= c; a -= __rot(c,11); \
b ^= a; b -= __rot(a,25); \
c ^= b; c -= __rot(b,16); \
a ^= c; a -= __rot(c,4); \
b ^= a; b -= __rot(a,14); \
c ^= b; c -= __rot(b,24); \
} }
/* The golden ration: an arbitrary value */ /* The golden ration: an arbitrary value */
#define JHASH_GOLDEN_RATIO 0x9e3779b9 #define JHASH_GOLDEN_RATIO 0xdeadbeef
/* The most generic version, hashes an arbitrary sequence /* The most generic version, hashes an arbitrary sequence
* of bytes. No alignment or length assumptions are made about * of bytes. No alignment or length assumptions are made about
* the input key. * the input key. The result depends on endianness.
*/ */
static inline __u32 jhash(void *key, __u32 length, __u32 initval) static inline u32 jhash(const void *key, u32 length, u32 initval)
{ {
__u32 a, b, c, len; u32 a,b,c;
__u8 *k = key; const u8 *k = key;
len = length; /* Set up the internal state */
a = b = JHASH_GOLDEN_RATIO; a = b = c = JHASH_GOLDEN_RATIO + length + initval;
c = initval;
while (len >= 12) {
a += (k[0] +((__u32)k[1]<<8) +((__u32)k[2]<<16) +((__u32)k[3]<<24));
b += (k[4] +((__u32)k[5]<<8) +((__u32)k[6]<<16) +((__u32)k[7]<<24));
c += (k[8] +((__u32)k[9]<<8) +((__u32)k[10]<<16)+((__u32)k[11]<<24));
/* all but the last block: affect some 32 bits of (a,b,c) */
while (length > 12) {
a += (k[0] + ((u32)k[1]<<8) + ((u32)k[2]<<16) + ((u32)k[3]<<24));
b += (k[4] + ((u32)k[5]<<8) + ((u32)k[6]<<16) + ((u32)k[7]<<24));
c += (k[8] + ((u32)k[9]<<8) + ((u32)k[10]<<16) + ((u32)k[11]<<24));
__jhash_mix(a, b, c); __jhash_mix(a, b, c);
length -= 12;
k += 12; k += 12;
len -= 12;
} }
c += length; /* last block: affect all 32 bits of (c) */
switch (len) { /* all the case statements fall through */
case 11: c += ((__u32)k[10]<<24); switch (length) {
case 10: c += ((__u32)k[9]<<16); case 12: c += (u32)k[11]<<24;
case 9 : c += ((__u32)k[8]<<8); case 11: c += (u32)k[10]<<16;
case 8 : b += ((__u32)k[7]<<24); case 10: c += (u32)k[9]<<8;
case 7 : b += ((__u32)k[6]<<16); case 9 : c += k[8];
case 6 : b += ((__u32)k[5]<<8); case 8 : b += (u32)k[7]<<24;
case 7 : b += (u32)k[6]<<16;
case 6 : b += (u32)k[5]<<8;
case 5 : b += k[4]; case 5 : b += k[4];
case 4 : a += ((__u32)k[3]<<24); case 4 : a += (u32)k[3]<<24;
case 3 : a += ((__u32)k[2]<<16); case 3 : a += (u32)k[2]<<16;
case 2 : a += ((__u32)k[1]<<8); case 2 : a += (u32)k[1]<<8;
case 1 : a += k[0]; case 1 : a += k[0];
}; __jhash_final(a, b, c);
case 0 :
__jhash_mix(a,b,c); break;
}
return c; return c;
} }
/* A special optimized version that handles 1 or more of __u32s. /* A special optimized version that handles 1 or more of u32s.
* The length parameter here is the number of __u32s in the key. * The length parameter here is the number of u32s in the key.
*/ */
static inline __u32 jhash2(__u32 *k, __u32 length, __u32 initval) static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
{ {
__u32 a, b, c, len; u32 a, b, c;
a = b = JHASH_GOLDEN_RATIO; /* Set up the internal state */
c = initval; a = b = c = JHASH_GOLDEN_RATIO + (length<<2) + initval;
len = length;
while (len >= 3) { /* handle most of the key */
while (length > 3) {
a += k[0]; a += k[0];
b += k[1]; b += k[1];
c += k[2]; c += k[2];
__jhash_mix(a, b, c); __jhash_mix(a, b, c);
k += 3; len -= 3; length -= 3;
k += 3;
} }
c += length * 4; /* handle the last 3 u32's */
/* all the case statements fall through */
switch (len) { switch (length) {
case 3: c += k[2];
case 2: b += k[1]; case 2: b += k[1];
case 1: a += k[0]; case 1: a += k[0];
}; __jhash_final(a, b, c);
case 0: /* case 0: nothing left to add */
__jhash_mix(a,b,c); break;
}
return c; return c;
} }
/* A special ultra-optimized versions that knows they are hashing exactly /* A special ultra-optimized versions that knows they are hashing exactly
* 3, 2 or 1 word(s). * 3, 2 or 1 word(s).
*
* NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
* done at the end is not done here.
*/ */
static inline __u32 jhash_3words(__u32 a, __u32 b, __u32 c, __u32 initval) static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
{ {
a += JHASH_GOLDEN_RATIO; a += JHASH_GOLDEN_RATIO + initval;
b += JHASH_GOLDEN_RATIO; b += JHASH_GOLDEN_RATIO + initval;
c += initval; c += JHASH_GOLDEN_RATIO + initval;
__jhash_mix(a, b, c); __jhash_final(a, b, c);
return c; return c;
} }
static inline __u32 jhash_2words(__u32 a, __u32 b, __u32 initval) static inline u32 jhash_2words(u32 a, u32 b, u32 initval)
{ {
return jhash_3words(a, b, 0, initval); return jhash_3words(0, a, b, initval);
} }
static inline __u32 jhash_1word(__u32 a, __u32 initval) static inline u32 jhash_1word(u32 a, u32 initval)
{ {
return jhash_3words(a, 0, 0, initval); return jhash_3words(0, 0, a, initval);
} }
#endif /* _LINUX_IPSET_JHASH_H */ #endif /* _LINUX_JHASH_H */

View File

@@ -11,7 +11,7 @@
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/jhash.h> #include "ip_set_jhash.h"
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/bitops.h> #include <asm/bitops.h>
@@ -44,6 +44,7 @@ nethash_id_cidr(const struct ip_set_nethash *map,
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, id); elem = HARRAY_ELEM(map->members, ip_set_ip_t *, id);
if (*elem == *hash_ip) if (*elem == *hash_ip)
return id; return id;
/* No shortcut - there can be deleted entries. */
} }
return UINT_MAX; return UINT_MAX;
} }
@@ -99,17 +100,21 @@ __nethash_add(struct ip_set_nethash *map, ip_set_ip_t *ip)
{ {
__u32 probe; __u32 probe;
u_int16_t i; u_int16_t i;
ip_set_ip_t *elem; ip_set_ip_t *elem, *slot = NULL;
for (i = 0; i < map->probes; i++) { for (i = 0; i < map->probes; i++) {
probe = jhash_ip(map, i, *ip) % map->hashsize; probe = jhash_ip(map, i, *ip) % map->hashsize;
elem = HARRAY_ELEM(map->members, ip_set_ip_t *, probe); elem = HARRAY_ELEM(map->members, ip_set_ip_t *, probe);
if (*elem == *ip) if (*elem == *ip)
return -EEXIST; return -EEXIST;
if (!*elem) { if (!(slot || *elem))
*elem = *ip; slot = elem;
return 0; /* There can be deleted entries, must check all slots */
} }
if (slot) {
*slot = *ip;
map->elements++;
return 0;
} }
/* Trigger rehashing */ /* Trigger rehashing */
return -EAGAIN; return -EAGAIN;

View File

@@ -602,8 +602,4 @@ Joakim Axelsson, Patrick Schaaf and Martin Josefsson.
.P .P
Sven Wegener wrote the iptreemap type. Sven Wegener wrote the iptreemap type.
.SH LAST REMARK .SH LAST REMARK
.BR "I stand on the shoulder of giants." .BR "I stand on the shoulders of giants."
.\" .. and did I mention that we are incredibly cool people?
.\" .. sexy, too ..
.\" .. witty, charming, powerful ..
.\" .. and most of all, modest ..

View File

@@ -30,7 +30,7 @@
#define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe" #define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe"
#endif #endif
#define IPSET_VERSION "2.4.5" #define IPSET_VERSION "2.5.0"
char program_name[] = "ipset"; char program_name[] = "ipset";
char program_version[] = IPSET_VERSION; char program_version[] = IPSET_VERSION;
@@ -629,7 +629,8 @@ void parse_ip(const char *str, ip_set_ip_t * ip)
"host/network `%s' resolves to serveral ip-addresses. " "host/network `%s' resolves to serveral ip-addresses. "
"Please specify one.", str); "Please specify one.", str);
*ip = ntohl(((struct in_addr *) host->h_addr_list[0])->s_addr); memcpy(&addr, host->h_addr_list[0], sizeof(struct in_addr));
*ip = ntohl(addr.s_addr);
return; return;
} }

View File

@@ -58,7 +58,7 @@ static void chaos_tg_check(unsigned int flags)
{ {
if (flags == (F_DELUDE | F_TARPIT)) if (flags == (F_DELUDE | F_TARPIT))
/* If flags == 0x03, both were specified, which should not be. */ /* If flags == 0x03, both were specified, which should not be. */
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"CHAOS: only one of --tarpit or --delude " "CHAOS: only one of --tarpit or --delude "
"may be specified"); "may be specified");
} }

View File

@@ -18,4 +18,4 @@ The randomness factor of not replying vs. replying can be set during load-time
of the xt_CHAOS module or during runtime in /sys/modules/xt_CHAOS/parameters. of the xt_CHAOS module or during runtime in /sys/modules/xt_CHAOS/parameters.
.PP .PP
See http://jengelh.medozas.de/projects/chaostables/ for more information See http://jengelh.medozas.de/projects/chaostables/ for more information
about CHAOS, DELUDE and portscan. about CHAOS, DELUDE and lscan.

View File

@@ -42,10 +42,10 @@ static int dhcpaddr_tg_parse(int c, char **argv, int invert,
switch (c) { switch (c) {
case 'M': case 'M':
param_act(P_ONLY_ONCE, "DHCPADDR", "--set-mac", *flags & F_MAC); xtables_param_act(XTF_ONLY_ONCE, "DHCPADDR", "--set-mac", *flags & F_MAC);
param_act(P_NO_INVERT, "DHCPADDR", "--set-mac", invert); xtables_param_act(XTF_NO_INVERT, "DHCPADDR", "--set-mac", invert);
if (!mac_parse(optarg, info->addr, &info->mask)) if (!mac_parse(optarg, info->addr, &info->mask))
param_act(P_BAD_VALUE, "DHCPADDR", "--set-mac", optarg); xtables_param_act(XTF_BAD_VALUE, "DHCPADDR", "--set-mac", optarg);
*flags |= F_MAC; *flags |= F_MAC;
return true; return true;
} }
@@ -56,7 +56,7 @@ static int dhcpaddr_tg_parse(int c, char **argv, int invert,
static void dhcpaddr_tg_check(unsigned int flags) static void dhcpaddr_tg_check(unsigned int flags)
{ {
if (flags == 0) if (flags == 0)
exit_error(PARAMETER_PROBLEM, "DHCPADDR target: " xtables_error(PARAMETER_PROBLEM, "DHCPADDR target: "
"--set-mac parameter required"); "--set-mac parameter required");
} }

View File

@@ -58,44 +58,44 @@ static int ipmark_tg_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case '1': case '1':
param_act(P_ONLY_ONCE, "IPMARK", "addr", *flags & FL_ADDR_USED); xtables_param_act(XTF_ONLY_ONCE, "IPMARK", "addr", *flags & FL_ADDR_USED);
param_act(P_NO_INVERT, "IPMARK", "addr", invert); xtables_param_act(XTF_NO_INVERT, "IPMARK", "addr", invert);
if (strcmp(optarg, "src") == 0) if (strcmp(optarg, "src") == 0)
info->selector = XT_IPMARK_SRC; info->selector = XT_IPMARK_SRC;
else if (strcmp(optarg, "dst") == 0) else if (strcmp(optarg, "dst") == 0)
info->selector = XT_IPMARK_DST; info->selector = XT_IPMARK_DST;
else else
exit_error(PARAMETER_PROBLEM, "Bad addr value `%s' - should be `src' or `dst'", optarg); xtables_error(PARAMETER_PROBLEM, "Bad addr value `%s' - should be `src' or `dst'", optarg);
*flags |= FL_ADDR_USED; *flags |= FL_ADDR_USED;
return true; return true;
case '2': case '2':
param_act(P_ONLY_ONCE, "IPMARK", "and-mask", *flags & FL_AND_MASK_USED); xtables_param_act(XTF_ONLY_ONCE, "IPMARK", "and-mask", *flags & FL_AND_MASK_USED);
param_act(P_NO_INVERT, "IPMARK", "and-mask", invert); xtables_param_act(XTF_NO_INVERT, "IPMARK", "and-mask", invert);
if (!strtonum(optarg, NULL, &n, 0, ~0U)) if (!xtables_strtoui(optarg, NULL, &n, 0, ~0U))
param_act(P_BAD_VALUE, "IPMARK", "and-mask", optarg); xtables_param_act(XTF_BAD_VALUE, "IPMARK", "and-mask", optarg);
info->andmask = n; info->andmask = n;
*flags |= FL_AND_MASK_USED; *flags |= FL_AND_MASK_USED;
return true; return true;
case '3': case '3':
param_act(P_ONLY_ONCE, "IPMARK", "or-mask", *flags & FL_OR_MASK_USED); xtables_param_act(XTF_ONLY_ONCE, "IPMARK", "or-mask", *flags & FL_OR_MASK_USED);
param_act(P_NO_INVERT, "IPMARK", "or-mask", invert); xtables_param_act(XTF_NO_INVERT, "IPMARK", "or-mask", invert);
if (!strtonum(optarg, NULL, &n, 0, ~0U)) if (!xtables_strtoui(optarg, NULL, &n, 0, ~0U))
param_act(P_BAD_VALUE, "IPMARK", "or-mask", optarg); xtables_param_act(XTF_BAD_VALUE, "IPMARK", "or-mask", optarg);
info->ormask = n; info->ormask = n;
*flags |= FL_OR_MASK_USED; *flags |= FL_OR_MASK_USED;
return true; return true;
case '4': case '4':
param_act(P_ONLY_ONCE, "IPMARK", "--shift", *flags & FL_SHIFT); xtables_param_act(XTF_ONLY_ONCE, "IPMARK", "--shift", *flags & FL_SHIFT);
param_act(P_NO_INVERT, "IPMARK", "--shift", invert); xtables_param_act(XTF_NO_INVERT, "IPMARK", "--shift", invert);
/* /*
* Anything >31 does not make sense for IPv4, but it still * Anything >31 does not make sense for IPv4, but it still
* does the right thing. * does the right thing.
*/ */
if (!strtonum(optarg, NULL, &n, 0, 128)) if (!xtables_strtoui(optarg, NULL, &n, 0, 128))
param_act(P_BAD_VALUE, "IPMARK", "--shift", optarg); xtables_param_act(XTF_BAD_VALUE, "IPMARK", "--shift", optarg);
info->shift = n; info->shift = n;
return true; return true;
} }
@@ -106,7 +106,7 @@ static int ipmark_tg_parse(int c, char **argv, int invert, unsigned int *flags,
static void ipmark_tg_check(unsigned int flags) static void ipmark_tg_check(unsigned int flags)
{ {
if (!(flags & FL_ADDR_USED)) if (!(flags & FL_ADDR_USED))
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"IPMARK target: Parameter --addr is required"); "IPMARK target: Parameter --addr is required");
} }

View File

@@ -51,23 +51,23 @@ logmark_tg_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case 'l': /* --log-level */ case 'l': /* --log-level */
param_act(P_ONLY_ONCE, "LOGMARK", "--log-level", *flags & F_LEVEL); xtables_param_act(XTF_ONLY_ONCE, "LOGMARK", "--log-level", *flags & F_LEVEL);
param_act(P_NO_INVERT, "LOGMARK", "--log-level", invert); xtables_param_act(XTF_NO_INVERT, "LOGMARK", "--log-level", invert);
if (!strtonum(optarg, NULL, &x, 0, 8)) if (!xtables_strtoui(optarg, NULL, &x, 0, 8))
param_act(P_BAD_VALUE, "LOGMARK", "--log-level", optarg); xtables_param_act(XTF_BAD_VALUE, "LOGMARK", "--log-level", optarg);
info->level = x; info->level = x;
*flags |= F_LEVEL; *flags |= F_LEVEL;
return true; return true;
case 'p': /* --log-prefix */ case 'p': /* --log-prefix */
param_act(P_ONLY_ONCE, "LOGMARK", "--log-prefix", *flags & F_PREFIX); xtables_param_act(XTF_ONLY_ONCE, "LOGMARK", "--log-prefix", *flags & F_PREFIX);
param_act(P_NO_INVERT, "LOGMARK", "--log-prefix", invert); xtables_param_act(XTF_NO_INVERT, "LOGMARK", "--log-prefix", invert);
if (strlen(optarg) > sizeof(info->prefix)) if (strlen(optarg) > sizeof(info->prefix))
exit_error(PARAMETER_PROBLEM, "LOGMARK: Maximum " xtables_error(PARAMETER_PROBLEM, "LOGMARK: Maximum "
"prefix length is %zu", "prefix length is %zu",
sizeof(info->prefix)); sizeof(info->prefix));
if (strchr(optarg, '\n')) if (strchr(optarg, '\n'))
exit_error(PARAMETER_PROBLEM, "LOGMARK: Newlines not " xtables_error(PARAMETER_PROBLEM, "LOGMARK: Newlines not "
"allowed in log prefix"); "allowed in log prefix");
strncpy(info->prefix, optarg, sizeof(info->prefix)); strncpy(info->prefix, optarg, sizeof(info->prefix));
*flags |= F_PREFIX; *flags |= F_PREFIX;

View File

@@ -1,7 +1,7 @@
/* /*
* "TEE" target extension for iptables * "TEE" target extension for iptables
* Copyright © Sebastian Claßen <sebastian.classen [at] freenet.ag>, 2007 * Copyright © Sebastian Claßen <sebastian.classen [at] freenet.ag>, 2007
* Jan Engelhardt <jengelh [at] medozas de>, 2007 - 2008 * Jan Engelhardt <jengelh [at] medozas de>, 2007 - 2009
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License; either * modify it under the terms of the GNU General Public License; either
@@ -50,16 +50,37 @@ static int tee_tg_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case 'g': case 'g':
if (*flags & FLAG_GATEWAY) if (*flags & FLAG_GATEWAY)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Cannot specify --gw more than once"); "Cannot specify --gw more than once");
if (check_inverse(optarg, &invert, NULL, 0)) ia = xtables_numeric_to_ipaddr(optarg);
exit_error(PARAMETER_PROBLEM,
"Unexpected \"!\" after --gateway");
ia = numeric_to_ipaddr(optarg);
if (ia == NULL) if (ia == NULL)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Invalid IP address %s", optarg);
memcpy(&info->gw, ia, sizeof(*ia));
*flags |= FLAG_GATEWAY;
return true;
}
return false;
}
static int tee_tg6_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
struct xt_tee_tginfo *info = (void *)(*target)->data;
const struct in6_addr *ia;
switch (c) {
case 'g':
if (*flags & FLAG_GATEWAY)
xtables_error(PARAMETER_PROBLEM,
"Cannot specify --gw more than once");
ia = xtables_numeric_to_ip6addr(optarg);
if (ia == NULL)
xtables_error(PARAMETER_PROBLEM,
"Invalid IP address %s", optarg); "Invalid IP address %s", optarg);
memcpy(&info->gw, ia, sizeof(*ia)); memcpy(&info->gw, ia, sizeof(*ia));
@@ -73,7 +94,7 @@ static int tee_tg_parse(int c, char **argv, int invert, unsigned int *flags,
static void tee_tg_check(unsigned int flags) static void tee_tg_check(unsigned int flags)
{ {
if (flags == 0) if (flags == 0)
exit_error(PARAMETER_PROBLEM, "TEE target: " xtables_error(PARAMETER_PROBLEM, "TEE target: "
"--gateway parameter required"); "--gateway parameter required");
} }
@@ -83,21 +104,41 @@ static void tee_tg_print(const void *ip, const struct xt_entry_target *target,
const struct xt_tee_tginfo *info = (const void *)target->data; const struct xt_tee_tginfo *info = (const void *)target->data;
if (numeric) if (numeric)
printf("TEE gw:%s ", ipaddr_to_anyname(&info->gw.in)); printf("TEE gw:%s ", xtables_ipaddr_to_numeric(&info->gw.in));
else else
printf("TEE gw:%s ", ipaddr_to_numeric(&info->gw.in)); printf("TEE gw:%s ", xtables_ipaddr_to_anyname(&info->gw.in));
}
static void tee_tg6_print(const void *ip, const struct xt_entry_target *target,
int numeric)
{
const struct xt_tee_tginfo *info = (const void *)target->data;
if (numeric)
printf("TEE gw:%s ", xtables_ip6addr_to_numeric(&info->gw.in6));
else
printf("TEE gw:%s ", xtables_ip6addr_to_anyname(&info->gw.in6));
} }
static void tee_tg_save(const void *ip, const struct xt_entry_target *target) static void tee_tg_save(const void *ip, const struct xt_entry_target *target)
{ {
const struct xt_tee_tginfo *info = (const void *)target->data; const struct xt_tee_tginfo *info = (const void *)target->data;
printf("--gateway %s ", ipaddr_to_numeric(&info->gw.in)); printf("--gateway %s ", xtables_ipaddr_to_numeric(&info->gw.in));
}
static void tee_tg6_save(const void *ip, const struct xt_entry_target *target)
{
const struct xt_tee_tginfo *info = (const void *)target->data;
printf("--gateway %s ", xtables_ip6addr_to_numeric(&info->gw.in6));
} }
static struct xtables_target tee_tg_reg = { static struct xtables_target tee_tg_reg = {
.name = "TEE", .name = "TEE",
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.revision = 0,
.family = PF_INET,
.size = XT_ALIGN(sizeof(struct xt_tee_tginfo)), .size = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
.help = tee_tg_help, .help = tee_tg_help,
@@ -108,7 +149,23 @@ static struct xtables_target tee_tg_reg = {
.extra_opts = tee_tg_opts, .extra_opts = tee_tg_opts,
}; };
static struct xtables_target tee_tg6_reg = {
.name = "TEE",
.version = XTABLES_VERSION,
.revision = 0,
.family = PF_INET6,
.size = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
.help = tee_tg_help,
.parse = tee_tg6_parse,
.final_check = tee_tg_check,
.print = tee_tg6_print,
.save = tee_tg6_save,
.extra_opts = tee_tg_opts,
};
static __attribute__((constructor)) void tee_tg_ldr(void) static __attribute__((constructor)) void tee_tg_ldr(void)
{ {
xtables_register_target(&tee_tg_reg); xtables_register_target(&tee_tg_reg);
xtables_register_target(&tee_tg6_reg);
} }

View File

@@ -37,13 +37,13 @@ static int condition_parse(int c, char **argv, int invert, unsigned int *flags,
if (c == 'X') { if (c == 'X') {
if (*flags) if (*flags)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Can't specify multiple conditions"); "Can't specify multiple conditions");
if (strlen(optarg) < sizeof(info->name)) if (strlen(optarg) < sizeof(info->name))
strcpy(info->name, optarg); strcpy(info->name, optarg);
else else
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"File name too long"); "File name too long");
info->invert = invert; info->invert = invert;
@@ -57,7 +57,7 @@ static int condition_parse(int c, char **argv, int invert, unsigned int *flags,
static void condition_check(unsigned int flags) static void condition_check(unsigned int flags)
{ {
if (flags == 0) if (flags == 0)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"Condition match: must specify --condition"); "Condition match: must specify --condition");
} }

View File

@@ -41,10 +41,10 @@ static int dhcpaddr_mt_parse(int c, char **argv, int invert,
switch (c) { switch (c) {
case 'M': case 'M':
param_act(P_ONLY_ONCE, "dhcpaddr", "--mac", *flags & F_MAC); xtables_param_act(XTF_ONLY_ONCE, "dhcpaddr", "--mac", *flags & F_MAC);
param_act(P_NO_INVERT, "dhcpaddr", "--mac", invert); xtables_param_act(XTF_NO_INVERT, "dhcpaddr", "--mac", invert);
if (!mac_parse(optarg, info->addr, &info->mask)) if (!mac_parse(optarg, info->addr, &info->mask))
param_act(P_BAD_VALUE, "dhcpaddr", "--mac", optarg); xtables_param_act(XTF_BAD_VALUE, "dhcpaddr", "--mac", optarg);
if (invert) if (invert)
info->invert = true; info->invert = true;
*flags |= F_MAC; *flags |= F_MAC;
@@ -57,7 +57,7 @@ static int dhcpaddr_mt_parse(int c, char **argv, int invert,
static void dhcpaddr_mt_check(unsigned int flags) static void dhcpaddr_mt_check(unsigned int flags)
{ {
if (flags == 0) if (flags == 0)
exit_error(PARAMETER_PROBLEM, "dhcpaddr match: " xtables_error(PARAMETER_PROBLEM, "dhcpaddr match: "
"--mac parameter required"); "--mac parameter required");
} }

View File

@@ -54,22 +54,22 @@ static int fuzzy_mt_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case '1': case '1':
if (invert) if (invert)
exit_error(PARAMETER_PROBLEM,"Can't specify ! --lower-limit"); xtables_error(PARAMETER_PROBLEM,"Can't specify ! --lower-limit");
if (*flags & IPT_FUZZY_OPT_MINIMUM) if (*flags & IPT_FUZZY_OPT_MINIMUM)
exit_error(PARAMETER_PROBLEM,"Can't specify --lower-limit twice"); xtables_error(PARAMETER_PROBLEM,"Can't specify --lower-limit twice");
if (string_to_number(optarg,1,FUZZY_MAX_RATE,&num) == -1 || num < 1) if (!xtables_strtoui(optarg, NULL, &num, 1, FUZZY_MAX_RATE) == -1 || num < 1)
exit_error(PARAMETER_PROBLEM,"BAD --lower-limit"); xtables_error(PARAMETER_PROBLEM,"BAD --lower-limit");
info->minimum_rate = num; info->minimum_rate = num;
*flags |= IPT_FUZZY_OPT_MINIMUM; *flags |= IPT_FUZZY_OPT_MINIMUM;
return true; return true;
case '2': case '2':
if (invert) if (invert)
exit_error(PARAMETER_PROBLEM,"Can't specify ! --upper-limit"); xtables_error(PARAMETER_PROBLEM,"Can't specify ! --upper-limit");
if (*flags & IPT_FUZZY_OPT_MAXIMUM) if (*flags & IPT_FUZZY_OPT_MAXIMUM)
exit_error(PARAMETER_PROBLEM,"Can't specify --upper-limit twice"); xtables_error(PARAMETER_PROBLEM,"Can't specify --upper-limit twice");
if (string_to_number(optarg,1,FUZZY_MAX_RATE,&num) == -1 || num < 1) if (!xtables_strtoui(optarg, NULL, &num, 1, FUZZY_MAX_RATE) == -1 || num < 1)
exit_error(PARAMETER_PROBLEM,"BAD --upper-limit"); xtables_error(PARAMETER_PROBLEM,"BAD --upper-limit");
info->maximum_rate = num; info->maximum_rate = num;
*flags |= IPT_FUZZY_OPT_MAXIMUM; *flags |= IPT_FUZZY_OPT_MAXIMUM;
return true; return true;

View File

@@ -64,16 +64,16 @@ static struct geoip_subnet *geoip_get_subnets(const char *code, uint32_t *count)
if ((fd = open(buf, O_RDONLY)) < 0) { if ((fd = open(buf, O_RDONLY)) < 0) {
fprintf(stderr, "Could not open %s: %s\n", buf, strerror(errno)); fprintf(stderr, "Could not open %s: %s\n", buf, strerror(errno));
exit_error(OTHER_PROBLEM, "Could not read geoip database"); xtables_error(OTHER_PROBLEM, "Could not read geoip database");
} }
fstat(fd, &sb); fstat(fd, &sb);
if (sb.st_size % sizeof(struct geoip_subnet) != 0) if (sb.st_size % sizeof(struct geoip_subnet) != 0)
exit_error(OTHER_PROBLEM, "Database file %s seems to be " xtables_error(OTHER_PROBLEM, "Database file %s seems to be "
"corrupted", buf); "corrupted", buf);
subnets = malloc(sb.st_size); subnets = malloc(sb.st_size);
if (subnets == NULL) if (subnets == NULL)
exit_error(OTHER_PROBLEM, "geoip: insufficient memory"); xtables_error(OTHER_PROBLEM, "geoip: insufficient memory");
read(fd, subnets, sb.st_size); read(fd, subnets, sb.st_size);
close(fd); close(fd);
*count = sb.st_size / sizeof(struct geoip_subnet); *count = sb.st_size / sizeof(struct geoip_subnet);
@@ -103,7 +103,7 @@ check_geoip_cc(char *cc, u_int16_t cc_used[], u_int8_t count)
if (strlen(cc) != 2) /* Country must be 2 chars long according if (strlen(cc) != 2) /* Country must be 2 chars long according
to the ISO3166 standard */ to the ISO3166 standard */
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"geoip: invalid country code '%s'", cc); "geoip: invalid country code '%s'", cc);
// Verification will fail if chars aren't uppercased. // Verification will fail if chars aren't uppercased.
@@ -112,7 +112,7 @@ check_geoip_cc(char *cc, u_int16_t cc_used[], u_int8_t count)
if (isalnum(cc[i]) != 0) if (isalnum(cc[i]) != 0)
cc[i] = toupper(cc[i]); cc[i] = toupper(cc[i]);
else else
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"geoip: invalid country code '%s'", cc); "geoip: invalid country code '%s'", cc);
/* Convert chars into a single 16 bit integer. /* Convert chars into a single 16 bit integer.
@@ -140,7 +140,7 @@ static unsigned int parse_geoip_cc(const char *ccstr, uint16_t *cc,
buffer = strdup(ccstr); buffer = strdup(ccstr);
if (!buffer) if (!buffer)
exit_error(OTHER_PROBLEM, xtables_error(OTHER_PROBLEM,
"geoip: insufficient memory available"); "geoip: insufficient memory available");
for (cp = buffer, i = 0; cp && i < XT_GEOIP_MAX; cp = next, i++) for (cp = buffer, i = 0; cp && i < XT_GEOIP_MAX; cp = next, i++)
@@ -150,19 +150,19 @@ static unsigned int parse_geoip_cc(const char *ccstr, uint16_t *cc,
if ((cctmp = check_geoip_cc(cp, cc, count)) != 0) { if ((cctmp = check_geoip_cc(cp, cc, count)) != 0) {
if ((mem[count++].user = (unsigned long)geoip_load_cc(cp, cctmp)) == 0) if ((mem[count++].user = (unsigned long)geoip_load_cc(cp, cctmp)) == 0)
exit_error(OTHER_PROBLEM, xtables_error(OTHER_PROBLEM,
"geoip: insufficient memory available"); "geoip: insufficient memory available");
cc[count-1] = cctmp; cc[count-1] = cctmp;
} }
} }
if (cp) if (cp)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"geoip: too many countries specified"); "geoip: too many countries specified");
free(buffer); free(buffer);
if (count == 0) if (count == 0)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"geoip: don't know what happened"); "geoip: don't know what happened");
return count; return count;
@@ -176,7 +176,7 @@ static int geoip_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case '1': case '1':
if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST)) if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST))
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"geoip: Only exactly one of --source-country " "geoip: Only exactly one of --source-country "
"or --destination-country must be specified!"); "or --destination-country must be specified!");
@@ -190,7 +190,7 @@ static int geoip_parse(int c, char **argv, int invert, unsigned int *flags,
case '2': case '2':
if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST)) if (*flags & (XT_GEOIP_SRC | XT_GEOIP_DST))
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"geoip: Only exactly one of --source-country " "geoip: Only exactly one of --source-country "
"or --destination-country must be specified!"); "or --destination-country must be specified!");
@@ -210,7 +210,7 @@ static void
geoip_final_check(unsigned int flags) geoip_final_check(unsigned int flags)
{ {
if (!flags) if (!flags)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"geoip: missing arguments"); "geoip: missing arguments");
} }

View File

@@ -22,7 +22,7 @@
static void ipp2p_mt_help(void) static void ipp2p_mt_help(void)
{ {
printf( printf(
"IPP2P v%s options:\n" "ipp2p v%s match options:\n"
" --edk [tcp,udp] All known eDonkey/eMule/Overnet packets\n" " --edk [tcp,udp] All known eDonkey/eMule/Overnet packets\n"
" --dc [tcp] All known Direct Connect packets\n" " --dc [tcp] All known Direct Connect packets\n"
" --kazaa [tcp,udp] All known KaZaA packets\n" " --kazaa [tcp,udp] All known KaZaA packets\n"
@@ -32,19 +32,10 @@ static void ipp2p_mt_help(void)
" --winmx [tcp] All known WinMX\n" " --winmx [tcp] All known WinMX\n"
" --soul [tcp] All known SoulSeek\n" " --soul [tcp] All known SoulSeek\n"
" --ares [tcp] All known Ares\n\n" " --ares [tcp] All known Ares\n\n"
"EXPERIMENTAL protocols (please send feedback to: ipp2p@ipp2p.org) :\n" "EXPERIMENTAL protocols:\n"
" --mute [tcp] All known Mute packets\n" " --mute [tcp] All known Mute packets\n"
" --waste [tcp] All known Waste packets\n" " --waste [tcp] All known Waste packets\n"
" --xdcc [tcp] All known XDCC packets (only xdcc login)\n\n" " --xdcc [tcp] All known XDCC packets (only xdcc login)\n\n"
"DEBUG SUPPPORT, use only if you know why\n"
" --debug Generate kernel debug output, THIS WILL SLOW DOWN THE FILTER\n"
"\nIPP2P was intended for TCP only. Due to increasing usage of UDP we needed to change this.\n"
"You can now use -p udp to search UDP packets only or without -p switch to search UDP and TCP packets.\n"
"\nSee README included with this package for more details or visit http://www.ipp2p.org\n"
"\nExamples:\n"
" iptables -A FORWARD -m ipp2p --ipp2p -j MARK --set-mark 0x01\n"
" iptables -A FORWARD -p udp -m ipp2p --kazaa --bit -j DROP\n"
" iptables -A FORWARD -p tcp -m ipp2p --edk --soul -j DROP\n\n"
, IPP2P_VERSION); , IPP2P_VERSION);
} }
@@ -72,109 +63,109 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case '2': /*cmd: edk*/ case '2': /*cmd: edk*/
param_act(P_ONLY_ONCE, "--edk", *flags & IPP2P_EDK); xtables_param_act(XTF_ONLY_ONCE, "--edk", *flags & IPP2P_EDK);
param_act(P_NO_INVERT, "--edk", invert); xtables_param_act(XTF_NO_INVERT, "--edk", invert);
if (*flags & IPP2P_DATA_EDK) if (*flags & IPP2P_DATA_EDK)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"ipp2p: use `--edk' OR `--edk-data' but not both of them!"); "ipp2p: use `--edk' OR `--edk-data' but not both of them!");
*flags |= IPP2P_EDK; *flags |= IPP2P_EDK;
info->cmd |= IPP2P_EDK; info->cmd |= IPP2P_EDK;
break; break;
case '7': /*cmd: dc*/ case '7': /*cmd: dc*/
param_act(P_ONLY_ONCE, "--dc", *flags & IPP2P_DC); xtables_param_act(XTF_ONLY_ONCE, "--dc", *flags & IPP2P_DC);
param_act(P_NO_INVERT, "--dc", invert); xtables_param_act(XTF_NO_INVERT, "--dc", invert);
if (*flags & IPP2P_DATA_DC) if (*flags & IPP2P_DATA_DC)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"ipp2p: use `--dc' OR `--dc-data' but not both of them!"); "ipp2p: use `--dc' OR `--dc-data' but not both of them!");
*flags |= IPP2P_DC; *flags |= IPP2P_DC;
info->cmd |= IPP2P_DC; info->cmd |= IPP2P_DC;
break; break;
case '9': /*cmd: gnu*/ case '9': /*cmd: gnu*/
param_act(P_ONLY_ONCE, "--gnu", *flags & IPP2P_GNU); xtables_param_act(XTF_ONLY_ONCE, "--gnu", *flags & IPP2P_GNU);
param_act(P_NO_INVERT, "--gnu", invert); xtables_param_act(XTF_NO_INVERT, "--gnu", invert);
if (*flags & IPP2P_DATA_GNU) if (*flags & IPP2P_DATA_GNU)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"ipp2p: use `--gnu' OR `--gnu-data' but not both of them!"); "ipp2p: use `--gnu' OR `--gnu-data' but not both of them!");
*flags |= IPP2P_GNU; *flags |= IPP2P_GNU;
info->cmd |= IPP2P_GNU; info->cmd |= IPP2P_GNU;
break; break;
case 'a': /*cmd: kazaa*/ case 'a': /*cmd: kazaa*/
param_act(P_ONLY_ONCE, "--kazaa", *flags & IPP2P_KAZAA); xtables_param_act(XTF_ONLY_ONCE, "--kazaa", *flags & IPP2P_KAZAA);
param_act(P_NO_INVERT, "--kazaa", invert); xtables_param_act(XTF_NO_INVERT, "--kazaa", invert);
if (*flags & IPP2P_DATA_KAZAA) if (*flags & IPP2P_DATA_KAZAA)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!"); "ipp2p: use `--kazaa' OR `--kazaa-data' but not both of them!");
*flags |= IPP2P_KAZAA; *flags |= IPP2P_KAZAA;
info->cmd |= IPP2P_KAZAA; info->cmd |= IPP2P_KAZAA;
break; break;
case 'b': /*cmd: bit*/ case 'b': /*cmd: bit*/
param_act(P_ONLY_ONCE, "--kazaa", *flags & IPP2P_BIT); xtables_param_act(XTF_ONLY_ONCE, "--kazaa", *flags & IPP2P_BIT);
param_act(P_NO_INVERT, "--kazaa", invert); xtables_param_act(XTF_NO_INVERT, "--kazaa", invert);
*flags |= IPP2P_BIT; *flags |= IPP2P_BIT;
info->cmd |= IPP2P_BIT; info->cmd |= IPP2P_BIT;
break; break;
case 'c': /*cmd: apple*/ case 'c': /*cmd: apple*/
param_act(P_ONLY_ONCE, "--apple", *flags & IPP2P_APPLE); xtables_param_act(XTF_ONLY_ONCE, "--apple", *flags & IPP2P_APPLE);
param_act(P_NO_INVERT, "--apple", invert); xtables_param_act(XTF_NO_INVERT, "--apple", invert);
*flags |= IPP2P_APPLE; *flags |= IPP2P_APPLE;
info->cmd |= IPP2P_APPLE; info->cmd |= IPP2P_APPLE;
break; break;
case 'd': /*cmd: soul*/ case 'd': /*cmd: soul*/
param_act(P_ONLY_ONCE, "--soul", *flags & IPP2P_SOUL); xtables_param_act(XTF_ONLY_ONCE, "--soul", *flags & IPP2P_SOUL);
param_act(P_NO_INVERT, "--soul", invert); xtables_param_act(XTF_NO_INVERT, "--soul", invert);
*flags |= IPP2P_SOUL; *flags |= IPP2P_SOUL;
info->cmd |= IPP2P_SOUL; info->cmd |= IPP2P_SOUL;
break; break;
case 'e': /*cmd: winmx*/ case 'e': /*cmd: winmx*/
param_act(P_ONLY_ONCE, "--winmx", *flags & IPP2P_WINMX); xtables_param_act(XTF_ONLY_ONCE, "--winmx", *flags & IPP2P_WINMX);
param_act(P_NO_INVERT, "--winmx", invert); xtables_param_act(XTF_NO_INVERT, "--winmx", invert);
*flags |= IPP2P_WINMX; *flags |= IPP2P_WINMX;
info->cmd |= IPP2P_WINMX; info->cmd |= IPP2P_WINMX;
break; break;
case 'f': /*cmd: ares*/ case 'f': /*cmd: ares*/
param_act(P_ONLY_ONCE, "--ares", *flags & IPP2P_ARES); xtables_param_act(XTF_ONLY_ONCE, "--ares", *flags & IPP2P_ARES);
param_act(P_NO_INVERT, "--ares", invert); xtables_param_act(XTF_NO_INVERT, "--ares", invert);
*flags |= IPP2P_ARES; *flags |= IPP2P_ARES;
info->cmd |= IPP2P_ARES; info->cmd |= IPP2P_ARES;
break; break;
case 'g': /*cmd: mute*/ case 'g': /*cmd: mute*/
param_act(P_ONLY_ONCE, "--mute", *flags & IPP2P_MUTE); xtables_param_act(XTF_ONLY_ONCE, "--mute", *flags & IPP2P_MUTE);
param_act(P_NO_INVERT, "--mute", invert); xtables_param_act(XTF_NO_INVERT, "--mute", invert);
*flags |= IPP2P_MUTE; *flags |= IPP2P_MUTE;
info->cmd |= IPP2P_MUTE; info->cmd |= IPP2P_MUTE;
break; break;
case 'h': /*cmd: waste*/ case 'h': /*cmd: waste*/
param_act(P_ONLY_ONCE, "--waste", *flags & IPP2P_WASTE); xtables_param_act(XTF_ONLY_ONCE, "--waste", *flags & IPP2P_WASTE);
param_act(P_NO_INVERT, "--waste", invert); xtables_param_act(XTF_NO_INVERT, "--waste", invert);
*flags |= IPP2P_WASTE; *flags |= IPP2P_WASTE;
info->cmd |= IPP2P_WASTE; info->cmd |= IPP2P_WASTE;
break; break;
case 'i': /*cmd: xdcc*/ case 'i': /*cmd: xdcc*/
param_act(P_ONLY_ONCE, "--xdcc", *flags & IPP2P_XDCC); xtables_param_act(XTF_ONLY_ONCE, "--xdcc", *flags & IPP2P_XDCC);
param_act(P_NO_INVERT, "--xdcc", invert); xtables_param_act(XTF_NO_INVERT, "--xdcc", invert);
*flags |= IPP2P_XDCC; *flags |= IPP2P_XDCC;
info->cmd |= IPP2P_XDCC; info->cmd |= IPP2P_XDCC;
break; break;
case 'j': /*cmd: debug*/ case 'j': /*cmd: debug*/
param_act(P_ONLY_ONCE, "--debug", info->debug); xtables_param_act(XTF_ONLY_ONCE, "--debug", info->debug);
param_act(P_NO_INVERT, "--debug", invert); xtables_param_act(XTF_NO_INVERT, "--debug", invert);
info->debug = 1; info->debug = 1;
break; break;
default: default:
// exit_error(PARAMETER_PROBLEM, // xtables_error(PARAMETER_PROBLEM,
// "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n"); // "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
return 0; return 0;
} }
@@ -184,7 +175,7 @@ static int ipp2p_mt_parse(int c, char **argv, int invert, unsigned int *flags,
static void ipp2p_mt_check(unsigned int flags) static void ipp2p_mt_check(unsigned int flags)
{ {
if (!flags) if (!flags)
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n"); "\nipp2p-parameter problem: for ipp2p usage type: iptables -m ipp2p --help\n");
} }

View File

@@ -1,12 +1,12 @@
This module matches certain packets in P2P flows. It is not This module matches certain packets in P2P flows. It is not
designed to match all packets belonging to a P2P connection - designed to match all packets belonging to a P2P connection -
use IPP2P together with CONNMARK for this purpose. Also visit use IPP2P together with CONNMARK for this purpose.
http://www.ipp2p.org for detailed information. .PP
Use it together with -p tcp or -p udp to search these protocols Use it together with -p tcp or -p udp to search these protocols
only or without -p switch to search packets of both protocols. only or without -p switch to search packets of both protocols.
.PP
IPP2P provides the following options: IPP2P provides the following options, of which one or more may be specified
on the command line:
.TP .TP
.B "--edk " .B "--edk "
Matches as many eDonkey/eMule packets as possible. Matches as many eDonkey/eMule packets as possible.
@@ -38,3 +38,11 @@ Matches Ares and AresLite packets. Use together with -j DROP only.
.B "--debug " .B "--debug "
Prints some information about each hit into kernel logfile. May Prints some information about each hit into kernel logfile. May
produce huge logfiles so beware! produce huge logfiles so beware!
.PP
Note that ipp2p may not (and often, does not) identify all packets that are
exchanged as a result of running filesharing programs.
.PP
There is more information on http://ipp2p.org/ , but it has not been updated
since September 2006, and the syntax there is different from the ipp2p.c
provided in Xtables-addons; most importantly, the --ipp2p flag was removed due
to its ambiguity to match "all known" protocols.

View File

@@ -0,0 +1,177 @@
/*
* "ipv4options" match extension for iptables
* Coprygith © Jan Engelhardt, 2009
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License; either
* version 2 of the License, or any later version, as published by the
* Free Software Foundation.
*/
#include <getopt.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <xtables.h>
#include "xt_ipv4options.h"
/*
* Overview from http://www.networksorcery.com/enp/protocol/ip.htm
* Not providing strings for options that seem to be most distant in the past.
*/
static const char *const v4opt_names[32] = {
[ 1] = "nop",
[ 2] = "security", /* RFC 1108 */
[ 3] = "lsrr", /* RFC 791 */
[ 4] = "timestamp", /* RFC 781, 791 */
[ 7] = "record-route", /* RFC 791 */
[ 9] = "ssrr", /* RFC 791 */
[11] = "mtu-probe", /* RFC 1063 */
[12] = "mtu-reply", /* RFC 1063 */
[18] = "traceroute", /* RFC 1393 */
[20] = "router-alert", /* RFC 2113 */
};
static void ipv4options_mt_help(void)
{
printf(
"ipv4options match options:\n"
"--flags [!]symbol[,...] Match presence/absence (!) of option\n"
" (either by name or number)\n"
"--any Interpret --flags as OR-combined\n\n");
}
static const struct option ipv4options_mt_opts[] = {
{.name = "flags", .has_arg = true, .val = 'f'},
{.name = "any", .has_arg = false, .val = 'a'},
{NULL},
};
static void ipv4options_parse_flagspec(struct xt_ipv4options_mtinfo1 *info,
char *arg)
{
unsigned int i, opt;
bool inv;
char *p;
while (true) {
p = strchr(arg, ',');
if (p != NULL)
*p = '\0';
inv = false;
opt = 0;
if (*arg == '!') {
inv = true;
++arg;
}
for (i = 1; i < 32;++i)
if (v4opt_names[i] != NULL &&
strcmp(v4opt_names[i], arg) == 0) {
opt = i;
break;
}
if (opt == 0 &&
!xtables_strtoui(arg, NULL, &opt, 0, UINT8_MAX))
xtables_error(PARAMETER_PROBLEM,
"ipv4options: Bad option value \"%s\"", arg);
if (opt == 0)
xtables_error(PARAMETER_PROBLEM,
"ipv4options: Option value may not be zero");
info->map |= (1 << opt);
if (inv)
info->invert |= (1 << opt);
if (p == NULL)
break;
arg = p + 1;
}
}
static int ipv4options_mt_parse(int c, char **argv, int invert,
unsigned int *flags, const void *entry, struct xt_entry_match **match)
{
struct xt_ipv4options_mtinfo1 *info = (void *)(*match)->data;
switch (c) {
case 'a': /* --any */
xtables_param_act(XTF_NO_INVERT, "ipv4options", "--any", invert);
info->flags |= XT_V4OPTS_ANY;
return true;
case 'f': /* --flags */
xtables_param_act(XTF_NO_INVERT, "ipv4options", "--flags", invert);
ipv4options_parse_flagspec(info, optarg);
return true;
}
return false;
}
/* no checking of *flags - no IPv4 options is also valid */
static void ipv4options_print_flags(const struct xt_ipv4options_mtinfo1 *info,
bool numeric)
{
uint32_t tmp = info->map;
unsigned int i;
for (i = 1; i < 32; ++i)
if (tmp & (1 << i)) {
if (info->invert & (1 << i))
printf("!");
if (!numeric && v4opt_names[i] != NULL)
printf("%s", v4opt_names[i]);
else
printf("%u", i);
tmp &= ~(1 << i);
if (tmp)
printf(",");
}
}
static void ipv4options_mt_print(const void *ip,
const struct xt_entry_match *match, int numeric)
{
const struct xt_ipv4options_mtinfo1 *info = (void *)match->data;
printf("ipv4options %s ",
(info->flags & XT_V4OPTS_ANY) ? "any-of" : "all-of");
ipv4options_print_flags(info, numeric);
printf(" ");
}
static void ipv4options_mt_save(const void *ip,
const struct xt_entry_match *match)
{
const struct xt_ipv4options_mtinfo1 *info = (void *)match->data;
if (info->map != 0) {
printf("--flags ");
ipv4options_print_flags(info, true);
}
if (info->flags & XT_V4OPTS_ANY)
printf(" --any");
printf(" ");
}
static struct xtables_match ipv4options_mt_reg = {
.version = XTABLES_VERSION,
.name = "ipv4options",
.revision = 1,
.family = PF_INET,
.size = XT_ALIGN(sizeof(struct xt_ipv4options_mtinfo1)),
.userspacesize = XT_ALIGN(sizeof(struct xt_ipv4options_mtinfo1)),
.help = ipv4options_mt_help,
.parse = ipv4options_mt_parse,
.print = ipv4options_mt_print,
.save = ipv4options_mt_save,
.extra_opts = ipv4options_mt_opts,
};
static __attribute__((constructor)) void ipv4options_mt_ldr(void)
{
xtables_register_match(&ipv4options_mt_reg);
}

View File

@@ -0,0 +1,47 @@
The "ipv4options" module allows to match against a set of IPv4 header options.
.TP
\fB\-\-flags\fP [\fB!\fP]\fIsymbol\fP[\fB,\fP[\fB!\fP]\fIsymbol...\fP]
Specify the options that shall appear or not appear in the header. Each
symbol specification is delimited by a comma, and a '!' can be prefixed to
a symbol to negate its presence. Symbols are either the name of an IPv4 option
or its number. See examples below.
.TP
\fB\-\-any\fP
By default, all of the flags specified must be present/absent, that is, they
form an AND condition. Use the \-\-any flag instead to use an OR condition
where only at least one symbol spec must be true.
.PP
Known symbol names (and their number):
.PP
1 - \fBnop\fP
.PP
2 - \fBsecurity\fP - RFC 1108
.PP
3 - \fBlsrr\fP - Loose Source Routing, RFC 791
.PP
4 - \fBtimestamp\fP - RFC 781, 791
.PP
7 - \fBrecord\-route\fP - RFC 791
.PP
9 - \fBssrr\fP - Strict Source Routing, RFC 791
.PP
11 - \fBmtu\-probe\fP - RFC 1063
.PP
12 - \fBmtu\-reply\fP - RFC 1063
.PP
18 - \fBtraceroute\fP - RFC 1393
.PP
20 - \fBrouter-alert\fP - RFC 2113
.PP
Examples:
.PP
Match packets that have both Timestamp and NOP:
\-m ipv4options \-\-flags nop,timestamp
.PP
~ that have either of Timestamp or NOP, or both:
\-\-flags nop,timestamp \-\-any
.PP
~ that have Timestamp and no NOP: \-\-flags '!nop,timestamp'
.PP
~ that have either no NOP or a timestamp (or both conditions):
\-\-flags '!nop,timestamp' \-\-any

View File

@@ -0,0 +1,18 @@
This module matches the length of a packet against a specific value or range of
values.
.TP
[\fB!\fR] \fB--length\fR \fIlength\fR[\fB:\fR\fIlength\fR]
Match exact length or length range.
.TP
\fB--layer3\fR
Match the layer3 frame size (e.g. IPv4/v6 header plus payload).
.TP
\fB--layer4\fR
Match the layer4 frame size (e.g. TCP/UDP header plus payload).
.TP
\fB--layer5\fR
Match the layer5 frame size (e.g. TCP/UDP payload, often called layer7).
.PP
If no --layer* option is given, --layer3 is assumed by default. Note that using
--layer5 may not match a packet if it is not one of the recognized types
(currently TCP, UDP, UDPLite, ICMP, AH and ESP) or which has no 5th layer.

173
extensions/libxt_length2.c Normal file
View File

@@ -0,0 +1,173 @@
#include <getopt.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <xtables.h>
#include "xt_length2.h"
enum {
F_LAYER = 1 << 0,
F_LENGTH = 1 << 1,
XT_LENGTH_LAYER_MASK = XT_LENGTH_LAYER3 | XT_LENGTH_LAYER4 |
XT_LENGTH_LAYER5 | XT_LENGTH_LAYER7,
};
static void length_mt_help(void)
{
printf(
"length match options:\n"
" --layer3 Match against layer3 size (e.g. L4 + IPv6 header)\n"
" --layer4 Match against layer4 size (e.g. L5 + SCTP header)\n"
" --layer5 Match against layer5 size (e.g. L7 + chunk headers)\n"
" --layer7 Match against layer7 payload (e.g. SCTP payload)\n"
"[!] --length n[:n] Match packet length against value or range\n"
" of values (inclusive)\n"
);
}
static const struct option length_mt_opts[] = {
{.name = "layer3", .has_arg = false, .val = '3'},
{.name = "layer4", .has_arg = false, .val = '4'},
{.name = "layer5", .has_arg = false, .val = '5'},
{.name = "layer7", .has_arg = false, .val = '7'},
{.name = "length", .has_arg = true, .val = '='},
{NULL},
};
static void length_mt_init(struct xt_entry_match *match)
{
struct xt_length_mtinfo2 *info = (void *)match->data;
info->flags = XT_LENGTH_LAYER3;
}
static int length_mt_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_length_mtinfo2 *info = (void *)(*match)->data;
unsigned int from, to;
char *end;
switch (c) {
case '3': /* --layer3 */
xtables_param_act(XTF_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER);
info->flags &= ~XT_LENGTH_LAYER_MASK;
info->flags |= XT_LENGTH_LAYER3;
*flags |= F_LAYER;
return true;
case '4': /* --layer4 */
xtables_param_act(XTF_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER);
info->flags &= ~XT_LENGTH_LAYER_MASK;
info->flags |= XT_LENGTH_LAYER4;
*flags |= F_LAYER;
return true;
case '5': /* --layer5 */
xtables_param_act(XTF_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER);
info->flags &= ~XT_LENGTH_LAYER_MASK;
info->flags |= XT_LENGTH_LAYER5;
*flags |= F_LAYER;
return true;
case '7': /* --layer7 */
xtables_param_act(XTF_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER);
info->flags &= ~XT_LENGTH_LAYER_MASK;
info->flags |= XT_LENGTH_LAYER7;
*flags |= F_LAYER;
return true;
case '=': /* --length */
xtables_param_act(XTF_ONLY_ONCE, "length", "--length", *flags & F_LENGTH);
if (invert)
info->flags |= XT_LENGTH_INVERT;
if (!xtables_strtoui(optarg, &end, &from, 0, ~0U))
xtables_param_act(XTF_BAD_VALUE, "length", "--length", optarg);
to = from;
if (*end == ':')
if (!xtables_strtoui(end + 1, &end, &to, 0, ~0U))
xtables_param_act(XTF_BAD_VALUE, "length",
"--length", optarg);
if (*end != '\0')
xtables_param_act(XTF_BAD_VALUE, "length", "--length", optarg);
info->min = from;
info->max = to;
*flags |= F_LENGTH;
return true;
}
return false;
}
static void length_mt_check(unsigned int flags)
{
if (!(flags & F_LENGTH))
xtables_error(PARAMETER_PROBLEM,
"length: You must specify \"--length\"");
if (!(flags & F_LAYER))
fprintf(stderr, "iptables: length match: Defaulting to "
"--layer3. Consider specifying it explicitly.\n");
}
static void length_mt_print(const void *ip, const struct xt_entry_match *match,
int numeric)
{
const struct xt_length_mtinfo2 *info = (const void *)match->data;
if (info->flags & XT_LENGTH_LAYER3)
printf("layer3 ");
else if (info->flags & XT_LENGTH_LAYER4)
printf("layer4 ");
else if (info->flags & XT_LENGTH_LAYER5)
printf("layer5 ");
else if (info->flags & XT_LENGTH_LAYER7)
printf("layer7 ");
printf("length ");
if (info->flags & XT_LENGTH_INVERT)
printf("! ");
if (info->min == info->max)
printf("%u ", (unsigned int)info->min);
else
printf("%u-%u ", (unsigned int)info->min,
(unsigned int)info->max);
}
static void length_mt_save(const void *ip, const struct xt_entry_match *match)
{
const struct xt_length_mtinfo2 *info = (const void *)match->data;
if (info->flags & XT_LENGTH_LAYER3)
printf("--layer3 ");
else if (info->flags & XT_LENGTH_LAYER4)
printf("--layer4 ");
else if (info->flags & XT_LENGTH_LAYER5)
printf("--layer5 ");
else if (info->flags & XT_LENGTH_LAYER7)
printf("--layer7 ");
if (info->flags & XT_LENGTH_INVERT)
printf("! ");
printf("--length ");
if (info->min == info->max)
printf("%u ", (unsigned int)info->min);
else
printf("%u:%u ", (unsigned int)info->min,
(unsigned int)info->max);
}
static struct xtables_match length2_mt_reg = {
.version = XTABLES_VERSION,
.name = "length2",
.revision = 2,
.family = PF_UNSPEC,
.size = XT_ALIGN(sizeof(struct xt_length_mtinfo2)),
.userspacesize = XT_ALIGN(sizeof(struct xt_length_mtinfo2)),
.init = length_mt_init,
.help = length_mt_help,
.parse = length_mt_parse,
.final_check = length_mt_check,
.print = length_mt_print,
.save = length_mt_save,
.extra_opts = length_mt_opts,
};
static void _init(void)
{
xtables_register_match(&length2_mt_reg);
}

View File

@@ -1,6 +1,6 @@
/* /*
* "portscan" match extension for iptables * LSCAN match extension for iptables
* Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2006 - 2008 * Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2006 - 2009
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License; either * modify it under the terms of the GNU General Public License; either
@@ -16,9 +16,9 @@
#include <xtables.h> #include <xtables.h>
#include <linux/netfilter/x_tables.h> #include <linux/netfilter/x_tables.h>
#include "xt_portscan.h" #include "xt_lscan.h"
static const struct option portscan_mt_opts[] = { static const struct option lscan_mt_opts[] = {
{.name = "stealth", .has_arg = false, .val = 'x'}, {.name = "stealth", .has_arg = false, .val = 'x'},
{.name = "synscan", .has_arg = false, .val = 's'}, {.name = "synscan", .has_arg = false, .val = 's'},
{.name = "cnscan", .has_arg = false, .val = 'c'}, {.name = "cnscan", .has_arg = false, .val = 'c'},
@@ -26,10 +26,10 @@ static const struct option portscan_mt_opts[] = {
{NULL}, {NULL},
}; };
static void portscan_mt_help(void) static void lscan_mt_help(void)
{ {
printf( printf(
"portscan match options:\n" "lscan match options:\n"
"(Combining them will make them match by OR-logic)\n" "(Combining them will make them match by OR-logic)\n"
" --stealth Match TCP Stealth packets\n" " --stealth Match TCP Stealth packets\n"
" --synscan Match TCP SYN scans\n" " --synscan Match TCP SYN scans\n"
@@ -37,10 +37,10 @@ static void portscan_mt_help(void)
" --grscan Match Banner Grabbing scans\n"); " --grscan Match Banner Grabbing scans\n");
} }
static int portscan_mt_parse(int c, char **argv, int invert, static int lscan_mt_parse(int c, char **argv, int invert,
unsigned int *flags, const void *entry, struct xt_entry_match **match) unsigned int *flags, const void *entry, struct xt_entry_match **match)
{ {
struct xt_portscan_mtinfo *info = (void *)((*match)->data); struct xt_lscan_mtinfo *info = (void *)((*match)->data);
switch (c) { switch (c) {
case 'c': case 'c':
@@ -59,17 +59,17 @@ static int portscan_mt_parse(int c, char **argv, int invert,
return false; return false;
} }
static void portscan_mt_check(unsigned int flags) static void lscan_mt_check(unsigned int flags)
{ {
} }
static void portscan_mt_print(const void *ip, static void lscan_mt_print(const void *ip,
const struct xt_entry_match *match, int numeric) const struct xt_entry_match *match, int numeric)
{ {
const struct xt_portscan_mtinfo *info = (const void *)(match->data); const struct xt_lscan_mtinfo *info = (const void *)(match->data);
const char *s = ""; const char *s = "";
printf("portscan "); printf("lscan ");
if (info->match_stealth) { if (info->match_stealth) {
printf("STEALTH"); printf("STEALTH");
s = ","; s = ",";
@@ -87,9 +87,9 @@ static void portscan_mt_print(const void *ip,
printf(" "); printf(" ");
} }
static void portscan_mt_save(const void *ip, const struct xt_entry_match *match) static void lscan_mt_save(const void *ip, const struct xt_entry_match *match)
{ {
const struct xt_portscan_mtinfo *info = (const void *)(match->data); const struct xt_lscan_mtinfo *info = (const void *)(match->data);
if (info->match_stealth) if (info->match_stealth)
printf("--stealth "); printf("--stealth ");
@@ -101,22 +101,22 @@ static void portscan_mt_save(const void *ip, const struct xt_entry_match *match)
printf("--grscan "); printf("--grscan ");
} }
static struct xtables_match portscan_mt_reg = { static struct xtables_match lscan_mt_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "portscan", .name = "lscan",
.revision = 0, .revision = 0,
.family = AF_INET, .family = AF_INET,
.size = XT_ALIGN(sizeof(struct xt_portscan_mtinfo)), .size = XT_ALIGN(sizeof(struct xt_lscan_mtinfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_portscan_mtinfo)), .userspacesize = XT_ALIGN(sizeof(struct xt_lscan_mtinfo)),
.help = portscan_mt_help, .help = lscan_mt_help,
.parse = portscan_mt_parse, .parse = lscan_mt_parse,
.final_check = portscan_mt_check, .final_check = lscan_mt_check,
.print = portscan_mt_print, .print = lscan_mt_print,
.save = portscan_mt_save, .save = lscan_mt_save,
.extra_opts = portscan_mt_opts, .extra_opts = lscan_mt_opts,
}; };
static __attribute__((constructor)) void portscan_mt_ldr(void) static __attribute__((constructor)) void lscan_mt_ldr(void)
{ {
xtables_register_match(&portscan_mt_reg); xtables_register_match(&lscan_mt_reg);
} }

View File

@@ -1,4 +1,5 @@
Detects simple port scan attemps based upon the packet's contents. (This is Detects simple low-level scan attemps based upon the packet's contents.
(This is
different from other implementations, which also try to match the rate of new different from other implementations, which also try to match the rate of new
connections.) Note that an attempt is only discovered after it has been carried connections.) Note that an attempt is only discovered after it has been carried
out, but this information can be used in conjunction with other rules to block out, but this information can be used in conjunction with other rules to block
@@ -20,8 +21,12 @@ connection was torn down after completion of the 3-way handshake.
\fB--grscan\fR \fB--grscan\fR
Match if data in the connection only flew in the direction of the remote side, Match if data in the connection only flew in the direction of the remote side,
e.g. if the connection was terminated after a locally running daemon sent its e.g. if the connection was terminated after a locally running daemon sent its
identification. (e.g. openssh) identification. (E.g. openssh, smtp, ftpd.) This may falsely trigger on
warranted single-direction data flows, usually bulk data transfers such as
FTP DATA connections or IRC DCC. Grab Scan Detection should only be used on
ports where a protocol runs that is guaranteed to do a bidirectional exchange
of bytes.
.PP .PP
NOTE: Some clients (Windows XP for example) may do what looks like a SYN scan, NOTE: Some clients (Windows XP for example) may do what looks like a SYN scan,
so be advised to carefully use xt_portscan in conjunction with blocking rules, so be advised to carefully use xt_lscan in conjunction with blocking rules,
as it may lock out your very own internal network. as it may lock out your very own internal network.

View File

@@ -51,31 +51,31 @@ quota_mt2_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case 'g': case 'g':
param_act(P_ONLY_ONCE, "quota", "--grow", *flags & FL_GROW); xtables_param_act(XTF_ONLY_ONCE, "quota", "--grow", *flags & FL_GROW);
param_act(P_NO_INVERT, "quota", "--grow", invert); xtables_param_act(XTF_NO_INVERT, "quota", "--grow", invert);
info->flags |= XT_QUOTA_GROW; info->flags |= XT_QUOTA_GROW;
*flags |= FL_GROW; *flags |= FL_GROW;
return true; return true;
case 'n': case 'n':
/* zero termination done on behalf of the kernel module */ /* zero termination done on behalf of the kernel module */
param_act(P_ONLY_ONCE, "quota", "--name", *flags & FL_NAME); xtables_param_act(XTF_ONLY_ONCE, "quota", "--name", *flags & FL_NAME);
param_act(P_NO_INVERT, "quota", "--name", invert); xtables_param_act(XTF_NO_INVERT, "quota", "--name", invert);
strncpy(info->name, optarg, sizeof(info->name)); strncpy(info->name, optarg, sizeof(info->name));
*flags |= FL_NAME; *flags |= FL_NAME;
return true; return true;
case 'p': case 'p':
param_act(P_ONLY_ONCE, "quota", "--packets", *flags & FL_PACKET); xtables_param_act(XTF_ONLY_ONCE, "quota", "--packets", *flags & FL_PACKET);
param_act(P_NO_INVERT, "quota", "--packets", invert); xtables_param_act(XTF_NO_INVERT, "quota", "--packets", invert);
info->flags |= XT_QUOTA_PACKET; info->flags |= XT_QUOTA_PACKET;
*flags |= FL_PACKET; *flags |= FL_PACKET;
return true; return true;
case 'q': case 'q':
param_act(P_ONLY_ONCE, "quota", "--quota", *flags & FL_QUOTA); xtables_param_act(XTF_ONLY_ONCE, "quota", "--quota", *flags & FL_QUOTA);
if (invert) if (invert)
info->flags |= XT_QUOTA_INVERT; info->flags |= XT_QUOTA_INVERT;
info->quota = strtoull(optarg, &end, 0); info->quota = strtoull(optarg, &end, 0);
if (*end != '\0') if (*end != '\0')
exit_error(PARAMETER_PROBLEM, "quota match: " xtables_error(PARAMETER_PROBLEM, "quota match: "
"invalid value for --quota"); "invalid value for --quota");
*flags |= FL_QUOTA; *flags |= FL_QUOTA;
return true; return true;

View File

@@ -19,7 +19,7 @@ static bool mac_parse(const char *addr, unsigned char *dest, uint8_t *mask)
*mask = 48; *mask = 48;
if (*end == '/') { if (*end == '/') {
if (!strtonum(end + 1, &end, &value, 0, 48)) if (!xtables_strtoui(end + 1, &end, &value, 0, 48))
return false; return false;
if (*end != '\0') if (*end != '\0')
return false; return false;

View File

@@ -38,9 +38,10 @@ logmark_tg(struct sk_buff **pskb, const struct xt_target_param *par)
enum ip_conntrack_info ctinfo; enum ip_conntrack_info ctinfo;
bool prev = false; bool prev = false;
printk("<%u>%.*s""hook=%s nfmark=0x%x secmark=0x%x classify=0x%x", printk("<%u>%.*s""iif=%d hook=%s nfmark=0x%x "
"secmark=0x%x classify=0x%x",
info->level, (unsigned int)sizeof(info->prefix), info->prefix, info->level, (unsigned int)sizeof(info->prefix), info->prefix,
hook_names[par->hooknum], skb_ifindex(skb), hook_names[par->hooknum],
skb_nfmark(skb), skb_secmark(skb), skb->priority); skb_nfmark(skb), skb_secmark(skb), skb->priority);
ct = nf_ct_get(skb, &ctinfo); ct = nf_ct_get(skb, &ctinfo);

View File

@@ -1,7 +1,7 @@
/* /*
* "TEE" target extension for Xtables * "TEE" target extension for Xtables
* Copyright © Sebastian Claßen <sebastian.classen [at] freenet de>, 2007 * Copyright © Sebastian Claßen <sebastian.classen [at] freenet de>, 2007
* Jan Engelhardt <jengelh [at] medozas de>, 2007 * Jan Engelhardt <jengelh [at] medozas de>, 2007 - 2008
* *
* based on ipt_ROUTE.c from Cédric de Launois * based on ipt_ROUTE.c from Cédric de Launois
* <delaunois [at] info ucl ac be> * <delaunois [at] info ucl ac be>
@@ -17,6 +17,7 @@
#include <net/checksum.h> #include <net/checksum.h>
#include <net/icmp.h> #include <net/icmp.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/ip6_route.h>
#include <net/route.h> #include <net/route.h>
#include <linux/netfilter/x_tables.h> #include <linux/netfilter/x_tables.h>
@@ -25,11 +26,14 @@
# include <net/netfilter/nf_conntrack.h> # include <net/netfilter/nf_conntrack.h>
static struct nf_conn tee_track; static struct nf_conn tee_track;
#endif #endif
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
# define WITH_IPV6 1
#endif
#include "compat_xtables.h" #include "compat_xtables.h"
#include "xt_TEE.h" #include "xt_TEE.h"
static const union nf_inet_addr zero_address; static const union nf_inet_addr tee_zero_address;
/* /*
* Try to route the packet according to the routing keys specified in * Try to route the packet according to the routing keys specified in
@@ -47,21 +51,24 @@ static const union nf_inet_addr zero_address;
* true - if the packet was succesfully routed to the * true - if the packet was succesfully routed to the
* destination desired * destination desired
*/ */
static bool tee_routing(struct sk_buff *skb, static bool
const struct xt_tee_tginfo *info) tee_tg_route4(struct sk_buff *skb, const struct xt_tee_tginfo *info)
{ {
const struct iphdr *iph = ip_hdr(skb);
int err; int err;
struct rtable *rt; struct rtable *rt;
struct iphdr *iph = ip_hdr(skb); struct flowi fl;
struct flowi fl = {
.nl_u = { memset(&fl, 0, sizeof(fl));
.ip4_u = { fl.iif = skb_ifindex(skb);
.daddr = info->gw.ip, #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
.tos = RT_TOS(iph->tos), fl.nl_u.ip4_u.fwmark = skb_nfmark(skb);
.scope = RT_SCOPE_UNIVERSE, #else
} fl.mark = skb_nfmark(skb);
} #endif
}; fl.nl_u.ip4_u.daddr = info->gw.ip;
fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
fl.nl_u.ip4_u.scope = RT_SCOPE_UNIVERSE;
/* Trying to route the packet using the standard routing table. */ /* Trying to route the packet using the standard routing table. */
err = ip_route_output_key(&init_net, &rt, &fl); err = ip_route_output_key(&init_net, &rt, &fl);
@@ -72,22 +79,14 @@ static bool tee_routing(struct sk_buff *skb,
return false; return false;
} }
/* Drop old route. */
dst_release(skb->dst); dst_release(skb->dst);
skb->dst = NULL;
/*
* Success if no oif specified or if the oif correspond to the
* one desired.
* [SC]: always the case, because we have no oif.
*/
skb->dst = &rt->u.dst; skb->dst = &rt->u.dst;
skb->dev = skb->dst->dev; skb->dev = skb->dst->dev;
skb->protocol = htons(ETH_P_IP); skb->protocol = htons(ETH_P_IP);
return true; return true;
} }
static bool dev_hh_avail(const struct net_device *dev) static inline bool dev_hh_avail(const struct net_device *dev)
{ {
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23)
return dev->hard_header != NULL; return dev->hard_header != NULL;
@@ -103,14 +102,14 @@ static bool dev_hh_avail(const struct net_device *dev)
* POST: the packet is sent with the link layer header pushed * POST: the packet is sent with the link layer header pushed
* the packet is destroyed * the packet is destroyed
*/ */
static void tee_ip_direct_send(struct sk_buff *skb) static void tee_tg_send(struct sk_buff *skb)
{ {
const struct dst_entry *dst = skb->dst; const struct dst_entry *dst = skb->dst;
const struct net_device *dev = dst->dev; const struct net_device *dev = dst->dev;
unsigned int hh_len = LL_RESERVED_SPACE(dev); unsigned int hh_len = LL_RESERVED_SPACE(dev);
/* Be paranoid, rather than too clever. */ /* Be paranoid, rather than too clever. */
if (unlikely(skb_headroom(skb) < hh_len) && dev_hh_avail(dev)) { if (unlikely(skb_headroom(skb) < hh_len && dev_hh_avail(dev))) {
struct sk_buff *skb2; struct sk_buff *skb2;
skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev)); skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
@@ -142,7 +141,7 @@ static void tee_ip_direct_send(struct sk_buff *skb)
* packets when we see they already have that ->nfct. * packets when we see they already have that ->nfct.
*/ */
static unsigned int static unsigned int
tee_tg(struct sk_buff **pskb, const struct xt_target_param *par) tee_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
{ {
const struct xt_tee_tginfo *info = par->targinfo; const struct xt_tee_tginfo *info = par->targinfo;
struct sk_buff *skb = *pskb; struct sk_buff *skb = *pskb;
@@ -200,29 +199,125 @@ tee_tg(struct sk_buff **pskb, const struct xt_target_param *par)
nf_conntrack_get(skb->nfct); nf_conntrack_get(skb->nfct);
#endif #endif
if (tee_routing(skb, info)) /*
tee_ip_direct_send(skb); * Normally, we would just use ip_local_out. Because iph->check is
* already correct, we could take a shortcut and call dst_output
* [forwards to ip_output] directly. ip_output however will invoke
* Netfilter hooks and cause reentrancy. So we skip that too and go
* directly to ip_finish_output. Since we should not do XFRM, control
* passes to ip_finish_output2. That function is not exported, so it is
* copied here as tee_ip_direct_send.
*
* We do no XFRM on the cloned packet on purpose! The choice of
* iptables match options will control whether the raw packet or the
* transformed version is cloned.
*
* Also on purpose, no fragmentation is done, to preserve the
* packet as best as possible.
*/
if (tee_tg_route4(skb, info))
tee_tg_send(skb);
return XT_CONTINUE; return XT_CONTINUE;
} }
#ifdef WITH_IPV6
static bool
tee_tg_route6(struct sk_buff *skb, const struct xt_tee_tginfo *info)
{
const struct ipv6hdr *iph = ipv6_hdr(skb);
struct dst_entry *dst;
struct flowi fl;
memset(&fl, 0, sizeof(fl));
fl.iif = skb_ifindex(skb);
#if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 19)
fl.nl_u.ip6_u.fwmark = skb_nfmark(skb);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
fl.mark = skb_nfmark(skb);
#endif
fl.nl_u.ip6_u.daddr = info->gw.in6;
fl.nl_u.ip6_u.flowlabel = ((iph->flow_lbl[0] & 0xF) << 16) |
(iph->flow_lbl[1] << 8) | iph->flow_lbl[2];
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 25)
dst = ip6_route_output(NULL, &fl);
#else
dst = ip6_route_output(dev_net(skb->dev), NULL, &fl);
#endif
if (dst == NULL) {
if (net_ratelimit())
printk(KERN_ERR "ip6_route_output failed for tee\n");
return false;
}
dst_release(skb->dst);
skb->dst = dst;
skb->dev = skb->dst->dev;
skb->protocol = htons(ETH_P_IPV6);
return true;
}
static unsigned int
tee_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
{
const struct xt_tee_tginfo *info = par->targinfo;
struct sk_buff *skb = *pskb;
/* Try silence. */
#ifdef WITH_CONNTRACK
if (skb->nfct == &tee_track.ct_general)
return NF_DROP;
#endif
if ((skb = skb_copy(skb, GFP_ATOMIC)) == NULL)
return XT_CONTINUE;
#ifdef WITH_CONNTRACK
nf_conntrack_put(skb->nfct);
skb->nfct = &tee_track.ct_general;
skb->nfctinfo = IP_CT_NEW;
nf_conntrack_get(skb->nfct);
#endif
if (tee_tg_route6(skb, info))
tee_tg_send(skb);
return XT_CONTINUE;
}
#endif /* WITH_IPV6 */
static bool tee_tg_check(const struct xt_tgchk_param *par) static bool tee_tg_check(const struct xt_tgchk_param *par)
{ {
const struct xt_tee_tginfo *info = par->targinfo; const struct xt_tee_tginfo *info = par->targinfo;
/* 0.0.0.0 and :: not allowed */ /* 0.0.0.0 and :: not allowed */
return memcmp(&info->gw, &zero_address, sizeof(zero_address)) != 0; return memcmp(&info->gw, &tee_zero_address,
sizeof(tee_zero_address)) != 0;
} }
static struct xt_target tee_tg_reg __read_mostly = { static struct xt_target tee_tg_reg[] __read_mostly = {
{
.name = "TEE", .name = "TEE",
.revision = 0, .revision = 0,
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.table = "mangle", .table = "mangle",
.target = tee_tg, .target = tee_tg4,
.targetsize = sizeof(struct xt_tee_tginfo), .targetsize = sizeof(struct xt_tee_tginfo),
.checkentry = tee_tg_check, .checkentry = tee_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
},
#ifdef WITH_IPV6
{
.name = "TEE",
.revision = 0,
.family = NFPROTO_IPV6,
.table = "mangle",
.target = tee_tg6,
.targetsize = sizeof(struct xt_tee_tginfo),
.checkentry = tee_tg_check,
.me = THIS_MODULE,
},
#endif
}; };
static int __init tee_tg_init(void) static int __init tee_tg_init(void)
@@ -241,19 +336,20 @@ static int __init tee_tg_init(void)
tee_track.status |= IPS_NAT_DONE_MASK; tee_track.status |= IPS_NAT_DONE_MASK;
#endif #endif
return xt_register_target(&tee_tg_reg); return xt_register_targets(tee_tg_reg, ARRAY_SIZE(tee_tg_reg));
} }
static void __exit tee_tg_exit(void) static void __exit tee_tg_exit(void)
{ {
xt_unregister_target(&tee_tg_reg); xt_unregister_targets(tee_tg_reg, ARRAY_SIZE(tee_tg_reg));
/* [SC]: shoud not we cleanup tee_track here? */ /* [SC]: shoud not we cleanup tee_track here? */
} }
module_init(tee_tg_init); module_init(tee_tg_init);
module_exit(tee_tg_exit); module_exit(tee_tg_exit);
MODULE_AUTHOR("Sebastian Claßen <sebastian.classen@freenet.ag>"); MODULE_AUTHOR("Sebastian Claßen <sebastian.classen@freenet.ag>");
MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>"); MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_DESCRIPTION("Xtables: Reroute packet copy"); MODULE_DESCRIPTION("Xtables: Reroute packet copy");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_TEE"); MODULE_ALIAS("ipt_TEE");
MODULE_ALIAS("ip6t_TEE");

View File

@@ -603,8 +603,13 @@ search_all_kazaa(const unsigned char *payload, const unsigned int plen)
{ {
uint16_t c, end, rem; uint16_t c, end, rem;
if (plen >= 5) { if (plen < 5)
printk(KERN_WARNING KBUILD_MODNAME ": %s: plen (%u) < 5\n", /* too short for anything we test for - early bailout */
return 0;
if (plen >= 65535) {
/* Something seems _really_ fishy */
printk(KERN_WARNING KBUILD_MODNAME ": %s: plen (%u) >= 65535\n",
__func__, plen); __func__, plen);
return 0; return 0;
} }
@@ -618,6 +623,10 @@ search_all_kazaa(const unsigned char *payload, const unsigned int plen)
if (memcmp(payload, "GET /", 5) != 0) if (memcmp(payload, "GET /", 5) != 0)
return 0; return 0;
if (plen < 18)
/* The next tests would not succeed anyhow. */
return 0;
end = plen - 18; end = plen - 18;
rem = plen - 5; rem = plen - 5;
for (c = 5; c < end; ++c, --rem) { for (c = 5; c < end; ++c, --rem) {
@@ -828,7 +837,7 @@ ipp2p_mt(const struct sk_buff *skb, const struct xt_match_param *par)
switch (ip->protocol) { switch (ip->protocol) {
case IPPROTO_TCP: /* what to do with a TCP packet */ case IPPROTO_TCP: /* what to do with a TCP packet */
{ {
const struct tcphdr *tcph = tcp_hdr(skb); const struct tcphdr *tcph = (const void *)ip + ip_hdrlen(skb);
if (tcph->fin) return 0; /* if FIN bit is set bail out */ if (tcph->fin) return 0; /* if FIN bit is set bail out */
if (tcph->syn) return 0; /* if SYN bit is set bail out */ if (tcph->syn) return 0; /* if SYN bit is set bail out */
@@ -855,7 +864,7 @@ ipp2p_mt(const struct sk_buff *skb, const struct xt_match_param *par)
case IPPROTO_UDP: /* what to do with an UDP packet */ case IPPROTO_UDP: /* what to do with an UDP packet */
{ {
const struct udphdr *udph = udp_hdr(skb); const struct udphdr *udph = (const void *)ip + ip_hdrlen(skb);
while (udp_list[i].command) { while (udp_list[i].command) {
if ((info->cmd & udp_list[i].command) == udp_list[i].command && if ((info->cmd & udp_list[i].command) == udp_list[i].command &&

View File

@@ -1,6 +1,6 @@
#ifndef __IPT_IPP2P_H #ifndef __IPT_IPP2P_H
#define __IPT_IPP2P_H #define __IPT_IPP2P_H
#define IPP2P_VERSION "0.9" #define IPP2P_VERSION "0.10"
enum { enum {
IPP2N_EDK, IPP2N_EDK,

View File

@@ -0,0 +1,72 @@
/*
* xt_ipv4opts - Netfilter module to match IPv4 options
* Copyright © Jan Engelhardt, 2009
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License; either
* version 2 of the License, or any later version, as published by the
* Free Software Foundation.
*/
#include <linux/ip.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/netfilter/x_tables.h>
#include <net/ip.h>
#include "xt_ipv4options.h"
#include "compat_xtables.h"
static uint32_t ipv4options_rd(const uint8_t *data, int len)
{
uint32_t opts = 0;
while (len >= 2) {
opts |= 1 << (data[0] & 0x1F);
len -= data[1];
data += data[1];
}
return opts;
}
static bool ipv4options_mt(const struct sk_buff *skb,
const struct xt_match_param *par)
{
const struct xt_ipv4options_mtinfo1 *info = par->matchinfo;
const struct iphdr *iph = ip_hdr(skb);
uint32_t opts = 0;
uint16_t len = ip_hdrlen(skb) - sizeof(struct iphdr);
if (len > 0)
opts = ipv4options_rd((const void *)iph +
sizeof(struct iphdr), len);
opts ^= info->invert;
opts &= info->map;
return (info->flags & XT_V4OPTS_ANY) ? opts : opts == info->map;
}
static struct xt_match ipv4options_mt_reg __read_mostly = {
.name = "ipv4options",
.revision = 1,
.family = NFPROTO_IPV4,
.match = ipv4options_mt,
.matchsize = XT_ALIGN(sizeof(struct xt_ipv4options_mtinfo1)),
.me = THIS_MODULE,
};
static int __init ipv4options_mt_init(void)
{
return xt_register_match(&ipv4options_mt_reg);
}
static void __exit ipv4options_mt_exit(void)
{
xt_unregister_match(&ipv4options_mt_reg);
}
MODULE_DESCRIPTION("Xatblse: IPv4 option match");
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_ipv4options");
module_init(ipv4options_mt_init);
module_exit(ipv4options_mt_exit);

View File

@@ -0,0 +1,26 @@
#ifndef _LINUX_NETFILTER_XT_IPV4OPTIONS_H
#define _LINUX_NETFILTER_XT_IPV4OPTIONS_H 1
/* IPv4 allows for a 5-bit option number - 32 options */
/**
* %XT_V4OPTS_ALL: all options in @map must be present (respecting @invert)
* %XT_V4OPTS_ANY: any of the option in @map
*/
enum xt_ipv4options_flags {
XT_V4OPTS_ALL = 1 << 0,
XT_V4OPTS_ANY = 1 << 1,
};
/**
* @map: bitmask of options that should appear
* @invert: inversion map
* @flags: see above
*/
struct xt_ipv4options_mtinfo1 {
__u32 map;
__u32 invert;
__u8 flags;
};
#endif /* _LINUX_NETFILTER_XT_IPV4OPTIONS_H */

262
extensions/xt_length2.c Normal file
View File

@@ -0,0 +1,262 @@
/*
* xt_length - Netfilter module to match packet length
* Copyright © Jan Engelhardt <jengelh@medozas.de>, 2007 - 2009
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License; either
* version 2 of the License, or any later version, as published by the
* Free Software Foundation.
*/
#include <linux/dccp.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/icmp.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/sctp.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <net/ip.h>
#include <net/ipv6.h>
#include <linux/netfilter/x_tables.h>
#include <linux/netfilter_ipv6/ip6_tables.h>
#include "xt_length2.h"
#include "compat_xtables.h"
#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
# define WITH_IPV6 1
#endif
#ifndef NEXTHDR_IPV4
# define NEXTHDR_IPV4 4
#endif
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_DESCRIPTION("Xtables: Packet length (Layer3,4,5) match");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_length2");
MODULE_ALIAS("ip6t_length2");
static bool
xtlength_layer5_tcp(unsigned int *length, const struct sk_buff *skb,
unsigned int offset)
{
const struct tcphdr *tcph;
struct tcphdr buf;
tcph = skb_header_pointer(skb, offset, sizeof(buf), &buf);
if (tcph == NULL)
return false;
*length = skb->len - offset;
if (*length >= 4 * tcph->doff)
*length -= 4 * tcph->doff;
return true;
}
static bool
xtlength_layer5_dccp(unsigned int *length, const struct sk_buff *skb,
unsigned int offset)
{
const struct dccp_hdr *dh;
struct dccp_hdr dhbuf;
dh = skb_header_pointer(skb, offset, sizeof(dhbuf), &dhbuf);
if (dh == NULL)
return false;
*length = skb->len - offset;
if (*length >= 4 * dh->dccph_doff)
*length -= 4 * dh->dccph_doff;
return true;
}
static inline bool
xtlength_layer5(unsigned int *length, const struct sk_buff *skb,
unsigned int prot, unsigned int offset)
{
switch (prot) {
case IPPROTO_TCP:
return xtlength_layer5_tcp(length, skb, offset);
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
*length = skb->len - offset - sizeof(struct udphdr);
return true;
case IPPROTO_SCTP:
*length = skb->len - offset - sizeof(struct sctphdr);
return true;
case IPPROTO_DCCP:
return xtlength_layer5_dccp(length, skb, offset);
case IPPROTO_ICMP:
*length = skb->len - offset - sizeof(struct icmphdr);
return true;
case IPPROTO_ICMPV6:
*length = skb->len - offset -
offsetof(struct icmp6hdr, icmp6_dataun);
return true;
case IPPROTO_AH:
*length = skb->len - offset - sizeof(struct ip_auth_hdr);
return true;
case IPPROTO_ESP:
*length = skb->len - offset - sizeof(struct ip_esp_hdr);
return true;
}
return false;
}
static bool
xtlength_layer7_sctp(unsigned int *length, const struct sk_buff *skb,
unsigned int offset)
{
const struct sctp_chunkhdr *ch;
struct sctp_chunkhdr chbuf;
unsigned int pos;
*length = 0;
for (pos = sizeof(struct sctphdr); pos < skb->len;
pos += ntohs(ch->length))
{
ch = skb_header_pointer(skb, offset + pos,
sizeof(chbuf), &chbuf);
if (ch == NULL)
return false;
if (ch->type != SCTP_CID_DATA)
continue;
*length += ntohs(ch->length);
}
return true;
}
static bool xtlength_layer7(unsigned int *length, const struct sk_buff *skb,
unsigned int proto, unsigned int offset)
{
switch (proto) {
case IPPROTO_SCTP:
return xtlength_layer7_sctp(length, skb, offset);
default:
return xtlength_layer5(length, skb, proto, offset);
}
}
/**
* llayer4_proto - figure out the L4 protocol in an IPv6 packet
* @skb: skb pointer
* @offset: position at which L4 starts (equal to 'protoff' in IPv4 code)
* @hotdrop: hotdrop pointer
*
* Searches for a recognized L4 header. On success, fills in @offset and
* returns the protocol number. If not found, %NEXTHDR_MAX is returned.
* On error, @hotdrop is set.
*/
static unsigned int
llayer4_proto(const struct sk_buff *skb, unsigned int *offset, bool *hotdrop)
{
/*
* Do encapsulation first so that %NEXTHDR_TCP does not hit the TCP
* part in an IPv6-in-IPv6 encapsulation.
*/
static const unsigned int types[] =
{IPPROTO_IPV6, IPPROTO_IPIP, IPPROTO_ESP, IPPROTO_AH,
IPPROTO_ICMP, IPPROTO_TCP, IPPROTO_UDP, IPPROTO_UDPLITE,
IPPROTO_SCTP, IPPROTO_DCCP};
unsigned int i;
int err;
for (i = 0; i < ARRAY_SIZE(types); ++i) {
err = ipv6_find_hdr(skb, offset, types[i], NULL);
if (err >= 0)
return types[i];
if (err != -ENOENT) {
*hotdrop = true;
break;
}
}
return NEXTHDR_MAX;
}
static bool
length2_mt(const struct sk_buff *skb, const struct xt_match_param *par)
{
const struct xt_length_mtinfo2 *info = par->matchinfo;
const struct iphdr *iph = ip_hdr(skb);
unsigned int len = 0;
bool hit = true;
if (info->flags & XT_LENGTH_LAYER3)
len = ntohs(iph->tot_len);
else if (info->flags & XT_LENGTH_LAYER4)
len = ntohs(iph->tot_len) - par->thoff;
else if (info->flags & XT_LENGTH_LAYER5)
hit = xtlength_layer5(&len, skb, iph->protocol, par->thoff);
else if (info->flags & XT_LENGTH_LAYER7)
hit = xtlength_layer7(&len, skb, iph->protocol, par->thoff);
if (!hit)
return false;
return (len >= info->min && len <= info->max) ^
!!(info->flags & XT_LENGTH_INVERT);
}
#ifdef WITH_IPV6
static bool
length2_mt6(const struct sk_buff *skb, const struct xt_match_param *par)
{
const struct xt_length_mtinfo2 *info = par->matchinfo;
const struct ipv6hdr *iph = ipv6_hdr(skb);
unsigned int len = 0, l4proto;
unsigned int thoff = par->thoff;
bool hit = true;
if (info->flags & XT_LENGTH_LAYER3) {
len = sizeof(struct ipv6hdr) + ntohs(iph->payload_len);
} else {
l4proto = llayer4_proto(skb, &thoff, par->hotdrop);
if (l4proto == NEXTHDR_MAX)
return false;
if (info->flags & XT_LENGTH_LAYER4)
len = skb->len - thoff;
else if (info->flags & XT_LENGTH_LAYER5)
hit = xtlength_layer5(&len, skb, l4proto, thoff);
else if (info->flags & XT_LENGTH_LAYER7)
hit = xtlength_layer7(&len, skb, l4proto, thoff);
}
if (!hit)
return false;
return (len >= info->min && len <= info->max) ^
!!(info->flags & XT_LENGTH_INVERT);
}
#endif
static struct xt_match length2_mt_reg[] __read_mostly = {
{
.name = "length2",
.revision = 2,
.family = NFPROTO_IPV4,
.match = length2_mt,
.matchsize = sizeof(struct xt_length_mtinfo2),
.me = THIS_MODULE,
},
#ifdef WITH_IPV6
{
.name = "length2",
.revision = 2,
.family = NFPROTO_IPV6,
.match = length2_mt6,
.matchsize = sizeof(struct xt_length_mtinfo2),
.me = THIS_MODULE,
},
#endif
};
static int __init length2_mt_init(void)
{
return xt_register_matches(length2_mt_reg, ARRAY_SIZE(length2_mt_reg));
}
static void __exit length2_mt_exit(void)
{
xt_unregister_matches(length2_mt_reg, ARRAY_SIZE(length2_mt_reg));
}
module_init(length2_mt_init);
module_exit(length2_mt_exit);

22
extensions/xt_length2.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef _LINUX_NETFILTER_XT_LENGTH2_H
#define _LINUX_NETFILTER_XT_LENGTH2_H
enum {
XT_LENGTH_INVERT = 1 << 0,
/* IP header plus payload */
XT_LENGTH_LAYER3 = 1 << 1,
/* Strip IP header: */
XT_LENGTH_LAYER4 = 1 << 2,
/* Strip TCP/UDP/etc. header */
XT_LENGTH_LAYER5 = 1 << 3,
/* TCP/UDP/SCTP payload */
XT_LENGTH_LAYER7 = 1 << 4,
};
struct xt_length_mtinfo2 {
u_int32_t min, max;
u_int16_t flags;
};
#endif /* _LINUX_NETFILTER_XT_LENGTH2_H */

View File

@@ -1,8 +1,8 @@
config NETFILTER_XT_MATCH_PORTSCAN config NETFILTER_XT_MATCH_LSCAN
tristate '"portscan" target support' tristate '"lscan" match support'
depends on NETFILTER_XTABLES && NETFILTER_ADVANCED depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
---help--- ---help---
The portscan match allows to match on the basic types of nmap The LSCAN match allows to match on the basic types of nmap
scans: Stealth Scan, SYN scan and connect scan. It can also match scans: Stealth Scan, SYN scan and connect scan. It can also match
"grab-only" connections, i.e. where data flows in only one "grab-only" connections, i.e. where data flows in only one
direction. direction.

View File

@@ -1,6 +1,6 @@
/* /*
* portscan match for netfilter * LSCAN match for netfilter
* Copyright © CC Computer Consultants GmbH, 2006 - 2008 * Copyright © Jan Engelhardt, 2006 - 2009
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License; either version * it under the terms of the GNU General Public License; either version
@@ -17,8 +17,7 @@
#include <linux/version.h> #include <linux/version.h>
#include <linux/netfilter/x_tables.h> #include <linux/netfilter/x_tables.h>
#include <linux/netfilter/xt_tcpudp.h> #include <linux/netfilter/xt_tcpudp.h>
//#include <net/netfilter/nf_conntrack.h> #include "xt_lscan.h"
#include "xt_portscan.h"
#include "compat_xtables.h" #include "compat_xtables.h"
#define PFX KBUILD_MODNAME ": " #define PFX KBUILD_MODNAME ": "
@@ -103,8 +102,8 @@ static inline bool tflg_synack(const struct tcphdr *th)
(TCP_FLAG_SYN | TCP_FLAG_ACK); (TCP_FLAG_SYN | TCP_FLAG_ACK);
} }
/* portscan functions */ /* lscan functions */
static inline bool portscan_mt_stealth(const struct tcphdr *th) static inline bool lscan_mt_stealth(const struct tcphdr *th)
{ {
/* /*
* "Connection refused" replies to our own probes must not be matched. * "Connection refused" replies to our own probes must not be matched.
@@ -126,7 +125,7 @@ static inline bool portscan_mt_stealth(const struct tcphdr *th)
return !tflg_syn(th); return !tflg_syn(th);
} }
static inline unsigned int portscan_mt_full(int mark, static inline unsigned int lscan_mt_full(int mark,
enum ip_conntrack_info ctstate, bool loopback, const struct tcphdr *tcph, enum ip_conntrack_info ctstate, bool loopback, const struct tcphdr *tcph,
unsigned int payload_len) unsigned int payload_len)
{ {
@@ -172,9 +171,9 @@ static inline unsigned int portscan_mt_full(int mark,
} }
static bool static bool
portscan_mt(const struct sk_buff *skb, const struct xt_match_param *par) lscan_mt(const struct sk_buff *skb, const struct xt_match_param *par)
{ {
const struct xt_portscan_mtinfo *info = par->matchinfo; const struct xt_lscan_mtinfo *info = par->matchinfo;
enum ip_conntrack_info ctstate; enum ip_conntrack_info ctstate;
const struct tcphdr *tcph; const struct tcphdr *tcph;
struct nf_conn *ctdata; struct nf_conn *ctdata;
@@ -187,7 +186,7 @@ portscan_mt(const struct sk_buff *skb, const struct xt_match_param *par)
/* Check for invalid packets: -m conntrack --ctstate INVALID */ /* Check for invalid packets: -m conntrack --ctstate INVALID */
if ((ctdata = nf_ct_get(skb, &ctstate)) == NULL) { if ((ctdata = nf_ct_get(skb, &ctstate)) == NULL) {
if (info->match_stealth) if (info->match_stealth)
return portscan_mt_stealth(tcph); return lscan_mt_stealth(tcph);
/* /*
* If @ctdata is NULL, we cannot match the other scan * If @ctdata is NULL, we cannot match the other scan
* types, return. * types, return.
@@ -196,7 +195,7 @@ portscan_mt(const struct sk_buff *skb, const struct xt_match_param *par)
} }
/* /*
* If -m portscan was previously applied to this packet, the rules we * If -m lscan was previously applied to this packet, the rules we
* simulate must not be run through again. And for speedup, do not call * simulate must not be run through again. And for speedup, do not call
* it either when the connection is already VALID. * it either when the connection is already VALID.
*/ */
@@ -204,7 +203,7 @@ portscan_mt(const struct sk_buff *skb, const struct xt_match_param *par)
(skb_nfmark(skb) & packet_mask) != mark_seen) { (skb_nfmark(skb) & packet_mask) != mark_seen) {
unsigned int n; unsigned int n;
n = portscan_mt_full(ctdata->mark & connmark_mask, ctstate, n = lscan_mt_full(ctdata->mark & connmark_mask, ctstate,
par->in == init_net__loopback_dev, tcph, par->in == init_net__loopback_dev, tcph,
skb->len - par->thoff - 4 * tcph->doff); skb->len - par->thoff - 4 * tcph->doff);
@@ -217,9 +216,9 @@ portscan_mt(const struct sk_buff *skb, const struct xt_match_param *par)
(info->match_gr && ctdata->mark == mark_grscan); (info->match_gr && ctdata->mark == mark_grscan);
} }
static bool portscan_mt_check(const struct xt_mtchk_param *par) static bool lscan_mt_check(const struct xt_mtchk_param *par)
{ {
const struct xt_portscan_mtinfo *info = par->matchinfo; const struct xt_lscan_mtinfo *info = par->matchinfo;
if ((info->match_stealth & ~1) || (info->match_syn & ~1) || if ((info->match_stealth & ~1) || (info->match_syn & ~1) ||
(info->match_cn & ~1) || (info->match_gr & ~1)) { (info->match_cn & ~1) || (info->match_gr & ~1)) {
@@ -229,44 +228,44 @@ static bool portscan_mt_check(const struct xt_mtchk_param *par)
return true; return true;
} }
static struct xt_match portscan_mt_reg[] __read_mostly = { static struct xt_match lscan_mt_reg[] __read_mostly = {
{ {
.name = "portscan", .name = "lscan",
.revision = 0, .revision = 0,
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.match = portscan_mt, .match = lscan_mt,
.checkentry = portscan_mt_check, .checkentry = lscan_mt_check,
.matchsize = sizeof(struct xt_portscan_mtinfo), .matchsize = sizeof(struct xt_lscan_mtinfo),
.proto = IPPROTO_TCP, .proto = IPPROTO_TCP,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
{ {
.name = "portscan", .name = "lscan",
.revision = 0, .revision = 0,
.family = NFPROTO_IPV6, .family = NFPROTO_IPV6,
.match = portscan_mt, .match = lscan_mt,
.checkentry = portscan_mt_check, .checkentry = lscan_mt_check,
.matchsize = sizeof(struct xt_portscan_mtinfo), .matchsize = sizeof(struct xt_lscan_mtinfo),
.proto = IPPROTO_TCP, .proto = IPPROTO_TCP,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
}; };
static int __init portscan_mt_init(void) static int __init lscan_mt_init(void)
{ {
return xt_register_matches(portscan_mt_reg, return xt_register_matches(lscan_mt_reg,
ARRAY_SIZE(portscan_mt_reg)); ARRAY_SIZE(lscan_mt_reg));
} }
static void __exit portscan_mt_exit(void) static void __exit lscan_mt_exit(void)
{ {
xt_unregister_matches(portscan_mt_reg, ARRAY_SIZE(portscan_mt_reg)); xt_unregister_matches(lscan_mt_reg, ARRAY_SIZE(lscan_mt_reg));
} }
module_init(portscan_mt_init); module_init(lscan_mt_init);
module_exit(portscan_mt_exit); module_exit(lscan_mt_exit);
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>"); MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_DESCRIPTION("Xtables: \"portscan\" match"); MODULE_DESCRIPTION("Xtables: Low-level scan (e.g. nmap) match");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_portscan"); MODULE_ALIAS("ipt_lscan");
MODULE_ALIAS("ip6t_portscan"); MODULE_ALIAS("ip6t_lscan");

8
extensions/xt_lscan.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef _LINUX_NETFILTER_XT_LSCAN_H
#define _LINUX_NETFILTER_XT_LSCAN_H 1
struct xt_lscan_mtinfo {
uint8_t match_stealth, match_syn, match_cn, match_gr;
};
#endif /* _LINUX_NETFILTER_XT_LSCAN_H */

View File

@@ -1,8 +0,0 @@
#ifndef _LINUX_NETFILTER_XT_PORTSCAN_H
#define _LINUX_NETFILTER_XT_PORTSCAN_H 1
struct xt_portscan_mtinfo {
uint8_t match_stealth, match_syn, match_cn, match_gr;
};
#endif /* _LINUX_NETFILTER_XT_PORTSCAN_H */

View File

@@ -14,5 +14,7 @@ build_fuzzy=m
build_geoip=m build_geoip=m
build_ipp2p=m build_ipp2p=m
build_ipset=m build_ipset=m
build_portscan=m build_ipv4options=m
build_length2=m
build_lscan=m
build_quota2=m build_quota2=m

View File

@@ -1,9 +1,9 @@
.TH xtables\-addons 8 "v1.7 (2008\-12\-25)" "" "v1.7 (2008\-12\-25)" .TH xtables\-addons 8 "v1.12 (2009\-03\-23)" "" "v1.13 (2009\-03\-23)"
.SH NAME .SH Name
Xtables\-addons - additional extensions for iptables, ip6tables, etc. Xtables\-addons - additional extensions for iptables, ip6tables, etc.
.SH TARGETS .SH Targets
.\" @TARGET@ .\" @TARGET@
.SH MATCHES .SH Matches
.\" @MATCHES@ .\" @MATCHES@
.SH "SEE ALSO" .SH "SEE ALSO"
\fBiptables\fP(8), \fBip6tables\fP(8) \fBiptables\fP(8), \fBip6tables\fP(8)