Compare commits

...

68 Commits
v1.10 ... v1.15

Author SHA1 Message Date
Jan Engelhardt
fe7a66f3cb Xtables-addons 1.15 2009-04-30 20:58:23 +02:00
Jan Engelhardt
a13650f94d Merge branch 'RAWNAT' 2009-04-30 20:35:59 +02:00
Jan Engelhardt
73e7b5ead1 compat_xtables: fix compilation with <= 2.6.19
Once upon a time there was no such checksumming...
2009-04-30 20:35:48 +02:00
Jan Engelhardt
e5920cc577 Merge branch 'iface' 2009-04-30 19:41:56 +02:00
Jan Engelhardt
39655fe83b iface: fix compilation with <= 2.6.27
Need to include compat_xtables.h to get all the definitions for older
kernels.
Also, net namespaces are not available before 2.6.24.
2009-04-30 19:41:31 +02:00
Jan Engelhardt
9df309a14a iface: remove unused .data field
Neither is it anywhere used, but compat_xtables does not provide it
either.
2009-04-28 10:04:36 +02:00
Jan Engelhardt
5e2085a45f build: reword RH5-unsupported warning 2009-04-28 01:41:57 +02:00
Jan Engelhardt
4bcb7077c0 Merge branch 'iface' 2009-04-27 20:50:05 +02:00
Jan Engelhardt
000c2d73fd iface: must use __u types in header files 2009-04-27 20:46:25 +02:00
Jan Engelhardt
e89c5d976a iface: move private struct xt_iface_flag_pairs to .c file 2009-04-27 20:46:09 +02:00
Jan Engelhardt
f5ed98fbf5 iface: update documentation
For one, the tabs must go as they cause alignment problems. Also
update the manpage with proper markup.
2009-04-26 23:20:38 +02:00
Jan Engelhardt
60c4162087 iface: replace --lower_up by --lower-up 2009-04-26 22:22:20 +02:00
Jan Engelhardt
074a7d6cb7 iface: remove --promiscous flag
The spelling is difficult (actually it is "promiscuous"), and one
option should be enough. Keeping --promisc.
2009-04-26 22:21:27 +02:00
Jan Engelhardt
a6ba463c43 iface: remove redundant fields and use bool 2009-04-26 22:13:06 +02:00
Jan Engelhardt
be2061c520 iface: constify data arrays 2009-04-26 22:13:05 +02:00
Jan Engelhardt
3f96deb0f0 iface: remove define for internal array size
The macro was only used inside kernel code and not relevant to
user-space anyway.
2009-04-26 22:07:53 +02:00
Jan Engelhardt
6d8ce3acae iface: dissolve module name/revision macros
The module name will unlikely be changing anytime soon. And if the
revision increases, we cannot just bump the number (well, in
Xtables-addons we can, but it would not be the case for the core
kernel). So let's not get into bad habits.
2009-04-26 22:07:43 +02:00
Jan Engelhardt
f6c317710f iface: remove version/revision from helptext
XTABLES_VERSION does not contain anything meaningful to display.
Printing the revision is not of value too, I think.
2009-04-26 22:01:30 +02:00
Jan Engelhardt
6799806300 iface: use NFPROTO_* 2009-04-26 21:59:41 +02:00
Jan Engelhardt
0d36136f54 iface: some command decoupling 2009-04-26 21:56:53 +02:00
Jan Engelhardt
e1fc5f2086 iface: remove redundant parentheses 2009-04-26 21:56:25 +02:00
Jan Engelhardt
9d5f4bf468 Merge branch 'RAWNAT' 2009-04-26 21:47:43 +02:00
Jan Engelhardt
637516f2d4 RAWNAT: add extension's kernel and userspace modules
RAWNAT provides stateless 1:1 network address translation.
2009-04-26 21:44:54 +02:00
Jan Engelhardt
b427c930f2 build: add kernel version check to configure 2009-04-26 20:22:40 +02:00
Roman Hoog Antink
34f39756ec condition: fix intrapositional negation sign 2009-04-17 16:12:30 +02:00
Bryan Duff
e36c7575fc condition: compile fix for 2.6.30-rc 2009-04-17 16:01:45 +02:00
Jan Engelhardt
0a23bd2580 doc: update changelog 2009-04-14 21:43:13 +02:00
Jan Engelhardt
03aeed615d RAWNAT: add the rawpost tables for IPv4/IPv6 2009-04-11 00:35:58 +02:00
Jan Engelhardt
49018e2ff7 Merge branch 'sf/master' 2009-04-11 00:33:28 +02:00
Jan Engelhardt
50d14a33c0 ipp2p: fix typo in error message
Reference: http://bugs.gentoo.org/show_bug.cgi?id=250407
Reported-by: Mike <empx@gmx.de>
2009-04-10 19:42:59 +02:00
Jan Engelhardt
c64a78ffcc ipp2p: fix bogus varargs call
Reference: http://bugs.gentoo.org/show_bug.cgi?id=250407
Reported-by: Mike <empx@gmx.de>
2009-04-10 19:34:56 +02:00
Jan Engelhardt
1aae519356 iface: remove DEBUGP 2009-04-05 10:59:12 +02:00
Jan Engelhardt
af5823b407 iface: remove redundant functions 2009-04-05 10:50:45 +02:00
Jan Engelhardt
9b198fe6e7 iface: import version 20081029 2009-04-05 10:37:05 +02:00
Jan Engelhardt
4997b326f6 fuzzy: fix bogus comparison logic leftover from move to new 1.4.3 API 2009-04-05 10:36:16 +02:00
Jriri Moravec
c288ecdb9c dhcpmac: fix rename leftover from typo 2009-04-04 01:14:32 +02:00
Jan Engelhardt
f21e372402 ipp2p: print ipp2p module name when run from iptables -L 2009-04-04 00:45:20 +02:00
Eray Aslan
927dd88dc4 SYSRQ: fix manpage typo 2009-04-02 10:37:55 +02:00
Jan Engelhardt
7dd96ec357 Xtables-addons 1.14 2009-03-31 22:55:29 +02:00
Jan Engelhardt
ba6aa51f91 SYSRQ: do proper L4 header access in IPv6 code 2009-03-27 21:06:26 +01:00
Jan Engelhardt
beb7546e20 SYSRQ: ignore non-UDP packets 2009-03-27 20:27:03 +01:00
Jan Engelhardt
67579079e0 layer: block use of DEBUGP
As per "Writing Netfilter Modules" e-book 20090326 section 4.8, one
should use pr_debug instead.
2009-03-27 00:00:44 +01:00
Jan Engelhardt
3a632a9bc5 dhcpmac: rename from dhcpaddr 2009-03-26 21:55:10 +01:00
Jan Engelhardt
45b2e64d82 desc: add informational Kconfig descriptions 2009-03-26 21:32:44 +01:00
Jan Engelhardt
538d74b5d8 Update my email address 2009-03-25 22:10:42 +01:00
Jan Engelhardt
e3988b50b5 Add the "STEAL" target from the "demos" branch 2009-03-25 19:54:25 +01:00
Jan Engelhardt
f4b8440fba libxt_geoip: geoip: remove XT_ALIGN from .userspacesize when used with offsetof
XT_ALIGN rounds up to the nearest multiple of 64 bits, but that is wrong
for .userspacesize if it is less than .matchsize/.targetsize.
2009-03-24 08:27:41 +01:00
Changli Gao
d3ee3a0c3c libxt_fuzzy: need to account for kernel-level modified variables in .userspacesize
When reviewing the code, I found there maybe a bug in libxt_fuzzy.c.
If a user wants to delete this match, he will get an error reported,
and the command fails. As the fields after maximum_rate in
xt_fuzzy_mtinfo will be altered in kernel space, we should assign the
userspacesize with the value offsetof(struct xt_fuzzy_mtinfo,
packets_total) instead.
2009-03-24 08:26:24 +01:00
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
76 changed files with 2629 additions and 411 deletions

10
INSTALL
View File

@@ -12,8 +12,7 @@ in combination with the kernel's Kbuild system.
Supported configurations for this release Supported configurations for this release
========================================= =========================================
* iptables >= 1.4.1 * iptables >= 1.4.3
upper bound: iptables <= 1.4.3-rc1
* kernel-source >= 2.6.17, no upper bound known * kernel-source >= 2.6.17, no upper bound known
with prepared build/output directory with prepared build/output directory
@@ -53,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.10]) AC_INIT([xtables-addons], [1.15])
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,13 +40,15 @@ 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])
else else
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
fi; fi;
fi;
else
PKG_CHECK_MODULES([libxtables], [xtables >= 1.4.3])
fi; 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 \
@@ -58,6 +63,37 @@ if [[ -n "$ksourcedir" ]]; then
kinclude_CFLAGS="$kinclude_CFLAGS -I $ksourcedir/include"; kinclude_CFLAGS="$kinclude_CFLAGS -I $ksourcedir/include";
fi; fi;
#
# check kernel version
#
if grep -q "CentOS release 5\." /etc/redhat-release 2>/dev/null ||
grep -q "Red Hat Enterprise Linux Server release 5" /etc/redhat-release 2>/dev/null; then
# しまった!
# Well, just a warning. Maybe the admin updated the kernel.
echo "WARNING: This distribution's shipped kernel is not supported.";
fi;
krel="$(make -sC ${kbuilddir} kernelrelease)";
krel="${krel%%-*}";
kmajor="${krel%%.*}";
krel="${krel#*.}";
kminor="${krel%%.*}";
krel="${krel#*.}";
kmicro="${krel%%.*}";
krel="${krel#*.}";
kstable="${krel%%.*}";
if test -z "$kstable"; then
kstable=0;
fi;
echo "Found kernel version $kmajor.$kminor.$kmicro.$kstable in $kbuilddir";
if test "$kmajor" -gt 2 -o "$kminor" -gt 6 -o "$kmicro" -gt 30; then
echo "WARNING: You are trying a newer kernel. Results may vary. :-)";
elif test \( "$kmajor" -lt 2 -o "$kminor" -lt 6 -o "$kmicro" -lt 17 \) -o \
\( "$kmajor" -eq 2 -a "$kminor" -eq 6 -a "$kmicro" -eq 18 -a \
"$kstable" -lt 5 \); then
echo "ERROR: That kernel version is not supported. Please see INSTALL for minimum configuration.";
exit 1;
fi;
AC_SUBST([regular_CFLAGS]) AC_SUBST([regular_CFLAGS])
AC_SUBST([xtables_CFLAGS]) AC_SUBST([xtables_CFLAGS])
AC_SUBST([kinclude_CFLAGS]) AC_SUBST([kinclude_CFLAGS])

155
doc/changelog.txt Normal file
View File

@@ -0,0 +1,155 @@
Xtables-addons 1.15 (April 30 2009)
===================================
- build: add kernel version check to configure
- condition: compile fix for 2.6.30-rc
- condition: fix intrapositional negation sign
- fuzzy: fix bogus comparison logic leftover from move to new 1.4.3 API
- ipp2p: fix bogus varargs call
- ipp2p: fix typo in error message
- added "iface" match
- added rawpost table (for use with RAWNAT)
- added RAWSNAT/RAWDNAT targets
Xtables-addons 1.14 (March 31 2009)
===================================
- fuzzy: need to account for kernel-level modified variables in .userspacesize
- geoip: remove XT_ALIGN from .userspacesize when used with offsetof
- SYSRQ: ignore non-UDP packets
- SYSRQ: do proper L4 header access in IPv6 code
(must not use tcp/udp_hdr in input path)
- add "STEAL" target
- dhcpmac: rename from dhcpaddr
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 word 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

@@ -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

@@ -7,20 +7,24 @@ obj-m += compat_xtables.o
obj-${build_CHAOS} += xt_CHAOS.o obj-${build_CHAOS} += xt_CHAOS.o
obj-${build_DELUDE} += xt_DELUDE.o obj-${build_DELUDE} += xt_DELUDE.o
obj-${build_DHCPADDR} += xt_DHCPADDR.o obj-${build_DHCPMAC} += xt_DHCPMAC.o
obj-${build_ECHO} += xt_ECHO.o obj-${build_ECHO} += xt_ECHO.o
obj-${build_IPMARK} += xt_IPMARK.o obj-${build_IPMARK} += xt_IPMARK.o
obj-${build_LOGMARK} += xt_LOGMARK.o obj-${build_LOGMARK} += xt_LOGMARK.o
obj-${build_RAWNAT} += xt_RAWNAT.o iptable_rawpost.o ip6table_rawpost.o
obj-${build_SYSRQ} += xt_SYSRQ.o obj-${build_SYSRQ} += xt_SYSRQ.o
obj-${build_STEAL} += xt_STEAL.o
obj-${build_TARPIT} += xt_TARPIT.o obj-${build_TARPIT} += xt_TARPIT.o
obj-${build_TEE} += xt_TEE.o obj-${build_TEE} += xt_TEE.o
obj-${build_condition} += xt_condition.o obj-${build_condition} += xt_condition.o
obj-${build_fuzzy} += xt_fuzzy.o obj-${build_fuzzy} += xt_fuzzy.o
obj-${build_geoip} += xt_geoip.o obj-${build_geoip} += xt_geoip.o
obj-${build_iface} += xt_iface.o
obj-${build_ipp2p} += xt_ipp2p.o obj-${build_ipp2p} += xt_ipp2p.o
obj-${build_ipset} += ipset/ obj-${build_ipset} += ipset/
obj-${build_ipv4options} += xt_ipv4options.o
obj-${build_length2} += xt_length2.o obj-${build_length2} += xt_length2.o
obj-${build_portscan} += xt_portscan.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

@@ -1,17 +1,21 @@
obj-${build_CHAOS} += libxt_CHAOS.so obj-${build_CHAOS} += libxt_CHAOS.so
obj-${build_DELUDE} += libxt_DELUDE.so obj-${build_DELUDE} += libxt_DELUDE.so
obj-${build_DHCPADDR} += libxt_DHCPADDR.so libxt_dhcpaddr.so obj-${build_DHCPMAC} += libxt_DHCPMAC.so libxt_dhcpmac.so
obj-${build_ECHO} += libxt_ECHO.so obj-${build_ECHO} += libxt_ECHO.so
obj-${build_IPMARK} += libxt_IPMARK.so obj-${build_IPMARK} += libxt_IPMARK.so
obj-${build_LOGMARK} += libxt_LOGMARK.so obj-${build_LOGMARK} += libxt_LOGMARK.so
obj-${build_RAWNAT} += libxt_RAWDNAT.so libxt_RAWSNAT.so
obj-${build_STEAL} += libxt_STEAL.so
obj-${build_SYSRQ} += libxt_SYSRQ.so obj-${build_SYSRQ} += libxt_SYSRQ.so
obj-${build_TARPIT} += libxt_TARPIT.so obj-${build_TARPIT} += libxt_TARPIT.so
obj-${build_TEE} += libxt_TEE.so obj-${build_TEE} += libxt_TEE.so
obj-${build_condition} += libxt_condition.so obj-${build_condition} += libxt_condition.so
obj-${build_fuzzy} += libxt_fuzzy.so obj-${build_fuzzy} += libxt_fuzzy.so
obj-${build_geoip} += libxt_geoip.so obj-${build_geoip} += libxt_geoip.so
obj-${build_iface} += libxt_iface.so
obj-${build_ipp2p} += libxt_ipp2p.so obj-${build_ipp2p} += libxt_ipp2p.so
obj-${build_ipset} += ipset/ obj-${build_ipset} += ipset/
obj-${build_ipv4options} += libxt_ipv4options.so
obj-${build_length2} += libxt_length2.so obj-${build_length2} += libxt_length2.so
obj-${build_portscan} += libxt_portscan.so obj-${build_lscan} += libxt_lscan.so
obj-${build_quota2} += libxt_quota2.so obj-${build_quota2} += libxt_quota2.so

View File

@@ -0,0 +1,87 @@
#ifndef XTA_COMPAT_RAWPOST_H
#define XTA_COMPAT_RAWPOST_H 1
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
typedef struct sk_buff sk_buff_t;
#else
typedef struct sk_buff *sk_buff_t;
#endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 21)
#define XT_TARGET_INIT(__name, __size) \
{ \
.target.u.user = { \
.target_size = XT_ALIGN(__size), \
.name = __name, \
}, \
}
#define IPT_ENTRY_INIT(__size) \
{ \
.target_offset = sizeof(struct ipt_entry), \
.next_offset = (__size), \
}
#define IPT_STANDARD_INIT(__verdict) \
{ \
.entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \
.target = XT_TARGET_INIT(IPT_STANDARD_TARGET, \
sizeof(struct xt_standard_target)), \
.target.verdict = -(__verdict) - 1, \
}
#define IPT_ERROR_INIT \
{ \
.entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \
.target = XT_TARGET_INIT(IPT_ERROR_TARGET, \
sizeof(struct ipt_error_target)), \
.target.errorname = "ERROR", \
}
#define IP6T_ENTRY_INIT(__size) \
{ \
.target_offset = sizeof(struct ip6t_entry), \
.next_offset = (__size), \
}
#define IP6T_STANDARD_INIT(__verdict) \
{ \
.entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \
.target = XT_TARGET_INIT(IP6T_STANDARD_TARGET, \
sizeof(struct ip6t_standard_target)), \
.target.verdict = -(__verdict) - 1, \
}
#define IP6T_ERROR_INIT \
{ \
.entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \
.target = XT_TARGET_INIT(IP6T_ERROR_TARGET, \
sizeof(struct ip6t_error_target)), \
.target.errorname = "ERROR", \
}
#endif /* 2.6.21 */
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 20)
# include <linux/netfilter_ipv6/ip6_tables.h>
/* Standard entry */
struct ip6t_standard
{
struct ip6t_entry entry;
struct ip6t_standard_target target;
};
struct ip6t_error_target
{
struct ip6t_entry_target target;
char errorname[IP6T_FUNCTION_MAXNAMELEN];
};
struct ip6t_error
{
struct ip6t_entry entry;
struct ip6t_error_target target;
};
#endif /* 2.6.20 */
#endif /* XTA_COMPAT_RAWPOST_H */

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

@@ -20,11 +20,6 @@
#include "compat_skbuff.h" #include "compat_skbuff.h"
#include "compat_xtnu.h" #include "compat_xtnu.h"
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
typedef __u16 __bitwise __sum16;
typedef __u32 __bitwise __wsum;
#endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 22) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 22)
static int xtnu_match_run(const struct sk_buff *skb, static int xtnu_match_run(const struct sk_buff *skb,
const struct net_device *in, const struct net_device *out, const struct net_device *in, const struct net_device *out,
@@ -447,6 +442,30 @@ int xtnu_ip_route_output_key(void *net, struct rtable **rp, struct flowi *flp)
return ip_route_output_flow(rp, flp, NULL, 0); return ip_route_output_flow(rp, flp, NULL, 0);
} }
EXPORT_SYMBOL_GPL(xtnu_ip_route_output_key); EXPORT_SYMBOL_GPL(xtnu_ip_route_output_key);
void xtnu_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
__be32 from, __be32 to, bool pseudohdr)
{
__be32 diff[] = {~from, to};
const void *dv = diff; /* kludge for < v2.6.19-555-g72685fc */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
if (skb->ip_summed != CHECKSUM_PARTIAL) {
*sum = csum_fold(csum_partial(dv, sizeof(diff),
~csum_unfold(*sum)));
if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr)
skb->csum = ~csum_partial(dv, sizeof(diff),
~skb->csum);
} else if (pseudohdr) {
*sum = ~csum_fold(csum_partial(dv, sizeof(diff),
csum_unfold(*sum)));
}
#else
*sum = csum_fold(csum_partial(dv, sizeof(diff),
~csum_unfold(*sum)));
#endif
}
EXPORT_SYMBOL_GPL(xtnu_proto_csum_replace4);
#endif #endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
@@ -468,7 +487,7 @@ static inline __wsum xtnu_csum_unfold(__sum16 n)
return (__force __wsum)n; return (__force __wsum)n;
} }
static inline void xtnu_csum_replace4(__sum16 *sum, __be32 from, __be32 to) void xtnu_csum_replace4(__sum16 *sum, __be32 from, __be32 to)
{ {
__be32 diff[] = {~from, to}; __be32 diff[] = {~from, to};
*sum = csum_fold(csum_partial((char *)diff, sizeof(diff), *sum = csum_fold(csum_partial((char *)diff, sizeof(diff),

View File

@@ -6,6 +6,8 @@
#include "compat_skbuff.h" #include "compat_skbuff.h"
#include "compat_xtnu.h" #include "compat_xtnu.h"
#define DEBUGP Use__pr_debug__instead
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17)
# warning Kernels below 2.6.17 not supported. # warning Kernels below 2.6.17 not supported.
#endif #endif
@@ -35,6 +37,7 @@
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
# define neigh_hh_output xtnu_neigh_hh_output # define neigh_hh_output xtnu_neigh_hh_output
# define IPPROTO_UDPLITE 136 # define IPPROTO_UDPLITE 136
# define CSUM_MANGLED_0 ((__force __sum16)0xffff)
#endif #endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24)
@@ -67,8 +70,12 @@
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
# define csum_replace2 xtnu_csum_replace2 # define csum_replace2 xtnu_csum_replace2
# define csum_replace4 xtnu_csum_replace4
# define inet_proto_csum_replace4 xtnu_proto_csum_replace4
#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24) #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24)
# define csum_replace2 nf_csum_replace2 # define csum_replace2 nf_csum_replace2
# define csum_replace4 nf_csum_replace4
# define inet_proto_csum_replace4 xtnu_proto_csum_replace4
#endif #endif
#if !defined(NIP6) && !defined(NIP6_FMT) #if !defined(NIP6) && !defined(NIP6_FMT)

View File

@@ -9,6 +9,10 @@
typedef _Bool bool; typedef _Bool bool;
enum { false = 0, true = 1, }; enum { false = 0, true = 1, };
#endif #endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
typedef __u16 __bitwise __sum16;
typedef __u32 __bitwise __wsum;
#endif
struct flowi; struct flowi;
struct hh_cache; struct hh_cache;
@@ -122,6 +126,13 @@ static inline struct xtnu_target *xtcompat_nutarget(const struct xt_target *t)
return q; return q;
} }
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
static inline __wsum csum_unfold(__sum16 n)
{
return (__force __wsum)n;
}
#endif
extern int xtnu_ip_local_out(struct sk_buff *); extern int xtnu_ip_local_out(struct sk_buff *);
extern int xtnu_ip_route_me_harder(struct sk_buff **, unsigned int); extern int xtnu_ip_route_me_harder(struct sk_buff **, unsigned int);
extern int xtnu_skb_make_writable(struct sk_buff **, unsigned int); extern int xtnu_skb_make_writable(struct sk_buff **, unsigned int);
@@ -138,6 +149,9 @@ extern struct xt_match *xtnu_request_find_match(unsigned int,
const char *, uint8_t); const char *, uint8_t);
extern int xtnu_neigh_hh_output(struct hh_cache *, struct sk_buff *); extern int xtnu_neigh_hh_output(struct hh_cache *, struct sk_buff *);
extern void xtnu_csum_replace2(__u16 __bitwise *, __be16, __be16); extern void xtnu_csum_replace2(__u16 __bitwise *, __be16, __be16);
extern void xtnu_csum_replace4(__u16 __bitwise *, __be32, __be32);
extern void xtnu_proto_csum_replace4(__u16 __bitwise *, struct sk_buff *,
__be32, __be32, bool);
extern int xtnu_skb_linearize(struct sk_buff *); extern int xtnu_skb_linearize(struct sk_buff *);
#endif /* _COMPAT_XTNU_H */ #endif /* _COMPAT_XTNU_H */

View File

@@ -0,0 +1,105 @@
/*
* rawpost table for ip6_tables
* written by Jan Engelhardt <jengelh [at] medozas de>, 2008 - 2009
* placed in the Public Domain
*/
#include <linux/module.h>
#include <linux/netfilter_ipv6/ip6_tables.h>
#include <net/ip.h>
#include "compat_xtables.h"
#include "compat_rawpost.h"
enum {
RAWPOST_VALID_HOOKS = 1 << NF_INET_POST_ROUTING,
};
static struct {
struct ip6t_replace repl;
struct ip6t_standard entries[1];
struct ip6t_error term;
} rawpost6_initial __initdata = {
.repl = {
.name = "rawpost",
.valid_hooks = RAWPOST_VALID_HOOKS,
.num_entries = 2,
.size = sizeof(struct ip6t_standard) +
sizeof(struct ip6t_error),
.hook_entry = {
[NF_INET_POST_ROUTING] = 0,
},
.underflow = {
[NF_INET_POST_ROUTING] = 0,
},
},
.entries = {
IP6T_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */
},
.term = IP6T_ERROR_INIT, /* ERROR */
};
static struct xt_table *rawpost6_ptable;
static struct xt_table rawpost6_itable = {
.name = "rawpost",
.af = NFPROTO_IPV6,
.valid_hooks = RAWPOST_VALID_HOOKS,
.me = THIS_MODULE,
};
static unsigned int rawpost6_hook_fn(unsigned int hook, sk_buff_t *skb,
const struct net_device *in, const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
return ip6t_do_table(skb, hook, in, out, rawpost6_ptable);
#else
return ip6t_do_table(skb, hook, in, out, rawpost6_ptable, NULL);
#endif
}
static struct nf_hook_ops rawpost6_hook_ops __read_mostly = {
.hook = rawpost6_hook_fn,
.pf = NFPROTO_IPV6,
.hooknum = NF_INET_POST_ROUTING,
.priority = NF_IP6_PRI_LAST,
.owner = THIS_MODULE,
};
static int __init rawpost6_table_init(void)
{
int ret;
rwlock_init(&rawpost6_itable.lock);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
rawpost6_ptable = ip6t_register_table(&init_net, &rawpost6_itable,
&rawpost6_initial.repl);
if (IS_ERR(rawpost6_ptable))
return PTR_ERR(rawpost6_ptable);
#else
ret = ip6t_register_table(&rawpost6_itable, &rawpost6_initial.repl);
if (ret < 0)
return ret;
rawpost6_ptable = &rawpost6_itable;
#endif
ret = nf_register_hook(&rawpost6_hook_ops);
if (ret < 0)
goto out;
return ret;
out:
ip6t_unregister_table(rawpost6_ptable);
return ret;
}
static void __exit rawpost6_table_exit(void)
{
nf_unregister_hook(&rawpost6_hook_ops);
ip6t_unregister_table(rawpost6_ptable);
}
module_init(rawpost6_table_init);
module_exit(rawpost6_table_exit);
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_LICENSE("GPL");

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

@@ -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

@@ -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.9" #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

@@ -0,0 +1,107 @@
/*
* rawpost table for ip_tables
* written by Jan Engelhardt <jengelh [at] medozas de>, 2008 - 2009
* placed in the Public Domain
*/
#include <linux/module.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/version.h>
#include <net/ip.h>
#include "compat_xtables.h"
#include "compat_rawpost.h"
enum {
RAWPOST_VALID_HOOKS = 1 << NF_INET_POST_ROUTING,
};
static struct {
struct ipt_replace repl;
struct ipt_standard entries[1];
struct ipt_error term;
} rawpost4_initial __initdata = {
.repl = {
.name = "rawpost",
.valid_hooks = RAWPOST_VALID_HOOKS,
.num_entries = 2,
.size = sizeof(struct ipt_standard) +
sizeof(struct ipt_error),
.hook_entry = {
[NF_INET_POST_ROUTING] = 0,
},
.underflow = {
[NF_INET_POST_ROUTING] = 0,
},
},
.entries = {
IPT_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */
},
.term = IPT_ERROR_INIT, /* ERROR */
};
static struct xt_table *rawpost4_ptable;
static struct xt_table rawpost4_itable = {
.name = "rawpost",
.af = NFPROTO_IPV4,
.valid_hooks = RAWPOST_VALID_HOOKS,
.me = THIS_MODULE,
};
static unsigned int rawpost4_hook_fn(unsigned int hook, sk_buff_t *skb,
const struct net_device *in, const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
return ipt_do_table(skb, hook, in, out, rawpost4_ptable);
#else
return ipt_do_table(skb, hook, in, out, rawpost4_ptable, NULL);
#endif
}
static struct nf_hook_ops rawpost4_hook_ops __read_mostly = {
.hook = rawpost4_hook_fn,
.pf = NFPROTO_IPV4,
.hooknum = NF_INET_POST_ROUTING,
.priority = NF_IP_PRI_LAST,
.owner = THIS_MODULE,
};
static int __init rawpost4_table_init(void)
{
int ret;
rwlock_init(&rawpost4_itable.lock);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
rawpost4_ptable = ipt_register_table(&init_net, &rawpost4_itable,
&rawpost4_initial.repl);
if (IS_ERR(rawpost4_ptable))
return PTR_ERR(rawpost4_ptable);
#else
ret = ipt_register_table(&rawpost4_itable, &rawpost4_initial.repl);
if (ret < 0)
return ret;
rawpost4_ptable = &rawpost4_itable;
#endif
ret = nf_register_hook(&rawpost4_hook_ops);
if (ret < 0)
goto out;
return ret;
out:
ipt_unregister_table(rawpost4_ptable);
return ret;
}
static void __exit rawpost4_table_exit(void)
{
nf_unregister_hook(&rawpost4_hook_ops);
ipt_unregister_table(rawpost4_ptable);
}
module_init(rawpost4_table_init);
module_exit(rawpost4_table_exit);
MODULE_DESCRIPTION("Xtables: rawpost table for use with RAWNAT");
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_LICENSE("GPL");

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

@@ -1,101 +0,0 @@
/*
* "DHCPADDR" target extension for iptables
* Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008
*
* 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 <stdlib.h>
#include <string.h>
#include <netinet/ether.h>
#include <xtables.h>
#include "xt_DHCPADDR.h"
#include "mac.c"
enum {
F_MAC = 1 << 0,
};
static const struct option dhcpaddr_tg_opts[] = {
{.name = "set-mac", .has_arg = true, .val = 'M'},
{NULL},
};
static void dhcpaddr_tg_help(void)
{
printf(
"DHCPADDDR target options:\n"
" --set-mac lladdr[/mask] Set MAC address in DHCP Client Host field\n"
);
}
static int dhcpaddr_tg_parse(int c, char **argv, int invert,
unsigned int *flags, const void *entry, struct xt_entry_target **target)
{
struct dhcpaddr_info *info = (void *)(*target)->data;
switch (c) {
case 'M':
param_act(P_ONLY_ONCE, "DHCPADDR", "--set-mac", *flags & F_MAC);
param_act(P_NO_INVERT, "DHCPADDR", "--set-mac", invert);
if (!mac_parse(optarg, info->addr, &info->mask))
param_act(P_BAD_VALUE, "DHCPADDR", "--set-mac", optarg);
*flags |= F_MAC;
return true;
}
return false;
}
static void dhcpaddr_tg_check(unsigned int flags)
{
if (flags == 0)
exit_error(PARAMETER_PROBLEM, "DHCPADDR target: "
"--set-mac parameter required");
}
static void dhcpaddr_tg_print(const void *ip,
const struct xt_entry_target *target, int numeric)
{
const struct dhcpaddr_info *info = (void *)target->data;
printf("DHCPADDR %s" DH_MAC_FMT "/%u ",
info->invert ? "!" : "", DH_MAC_HEX(info->addr), info->mask);
}
static void dhcpaddr_tg_save(const void *ip,
const struct xt_entry_target *target)
{
const struct dhcpaddr_info *info = (const void *)target->data;
if (info->invert)
printf("! ");
printf("--set-mac " DH_MAC_FMT "/%u ",
DH_MAC_HEX(info->addr), info->mask);
}
static struct xtables_target dhcpaddr_tg_reg = {
.version = XTABLES_VERSION,
.name = "DHCPADDR",
.revision = 0,
.family = PF_INET,
.size = XT_ALIGN(sizeof(struct dhcpaddr_info)),
.userspacesize = XT_ALIGN(sizeof(struct dhcpaddr_info)),
.help = dhcpaddr_tg_help,
.parse = dhcpaddr_tg_parse,
.final_check = dhcpaddr_tg_check,
.print = dhcpaddr_tg_print,
.save = dhcpaddr_tg_save,
.extra_opts = dhcpaddr_tg_opts,
};
static __attribute__((constructor)) void dhcpaddr_tg_ldr(void)
{
xtables_register_target(&dhcpaddr_tg_reg);
}

101
extensions/libxt_DHCPMAC.c Normal file
View File

@@ -0,0 +1,101 @@
/*
* "DHCPMAC" target extension for iptables
* Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008
*
* 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 <stdlib.h>
#include <string.h>
#include <netinet/ether.h>
#include <xtables.h>
#include "xt_DHCPMAC.h"
#include "mac.c"
enum {
F_MAC = 1 << 0,
};
static const struct option dhcpmac_tg_opts[] = {
{.name = "set-mac", .has_arg = true, .val = 'M'},
{NULL},
};
static void dhcpmac_tg_help(void)
{
printf(
"DHCPMAC target options:\n"
" --set-mac lladdr[/mask] Set MAC address in DHCP Client Host field\n"
);
}
static int dhcpmac_tg_parse(int c, char **argv, int invert,
unsigned int *flags, const void *entry, struct xt_entry_target **target)
{
struct dhcpmac_info *info = (void *)(*target)->data;
switch (c) {
case 'M':
xtables_param_act(XTF_ONLY_ONCE, "DHCPMAC", "--set-mac", *flags & F_MAC);
xtables_param_act(XTF_NO_INVERT, "DHCPMAC", "--set-mac", invert);
if (!mac_parse(optarg, info->addr, &info->mask))
xtables_param_act(XTF_BAD_VALUE, "DHCPMAC", "--set-mac", optarg);
*flags |= F_MAC;
return true;
}
return false;
}
static void dhcpmac_tg_check(unsigned int flags)
{
if (flags == 0)
xtables_error(PARAMETER_PROBLEM, "DHCPMAC target: "
"--set-mac parameter required");
}
static void dhcpmac_tg_print(const void *ip,
const struct xt_entry_target *target, int numeric)
{
const struct dhcpmac_info *info = (void *)target->data;
printf("DHCPMAC %s" DH_MAC_FMT "/%u ",
info->invert ? "!" : "", DH_MAC_HEX(info->addr), info->mask);
}
static void dhcpmac_tg_save(const void *ip,
const struct xt_entry_target *target)
{
const struct dhcpmac_info *info = (const void *)target->data;
if (info->invert)
printf("! ");
printf("--set-mac " DH_MAC_FMT "/%u ",
DH_MAC_HEX(info->addr), info->mask);
}
static struct xtables_target dhcpmac_tg_reg = {
.version = XTABLES_VERSION,
.name = "DHCPMAC",
.revision = 0,
.family = PF_INET,
.size = XT_ALIGN(sizeof(struct dhcpmac_info)),
.userspacesize = XT_ALIGN(sizeof(struct dhcpmac_info)),
.help = dhcpmac_tg_help,
.parse = dhcpmac_tg_parse,
.final_check = dhcpmac_tg_check,
.print = dhcpmac_tg_print,
.save = dhcpmac_tg_save,
.extra_opts = dhcpmac_tg_opts,
};
static __attribute__((constructor)) void dhcpmac_tg_ldr(void)
{
xtables_register_target(&dhcpmac_tg_reg);
}

View File

@@ -1,4 +1,4 @@
In conjunction with ebtables, DHCPADDR can be used to completely change all MAC In conjunction with ebtables, DHCPMAC can be used to completely change all MAC
addresses from and to a VMware-based virtual machine. This is needed because addresses from and to a VMware-based virtual machine. This is needed because
VMware does not allow to set a non-VMware MAC address before an operating VMware does not allow to set a non-VMware MAC address before an operating
system is booted (and the MAC be changed with `ip link set eth0 address system is booted (and the MAC be changed with `ip link set eth0 address
@@ -13,11 +13,11 @@ EXAMPLE, replacing all addresses from one of VMware's assigned vendor IDs
(00:50:56) addresses with something else: (00:50:56) addresses with something else:
.PP .PP
iptables -t mangle -A FORWARD -p udp --dport 67 -m physdev --physdev-in vmnet1 iptables -t mangle -A FORWARD -p udp --dport 67 -m physdev --physdev-in vmnet1
-m dhcpaddr --mac 00:50:56:00:00:00/24 -j DHCPADDR --set-mac -m dhcpmac --mac 00:50:56:00:00:00/24 -j DHCPMAC --set-mac
ab:cd:ef:00:00:00/24 ab:cd:ef:00:00:00/24
.PP .PP
iptables -t mangle -A FORWARD -p udp --dport 68 -m physdev --physdev-out vmnet1 iptables -t mangle -A FORWARD -p udp --dport 68 -m physdev --physdev-out vmnet1
-m dhcpaddr --mac ab:cd:ef:00:00:00/24 -j DHCPADDR --set-mac -m dhcpmac --mac ab:cd:ef:00:00:00/24 -j DHCPMAC --set-mac
00:50:56:00:00:00/24 00:50:56:00:00:00/24
.PP .PP
(This assumes there is a bridge interface that has vmnet1 as a port. You will (This assumes there is a bridge interface that has vmnet1 as a port. You will

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;

187
extensions/libxt_RAWDNAT.c Normal file
View File

@@ -0,0 +1,187 @@
/*
* "RAWNAT" target extension for iptables
* Copyright © Jan Engelhardt, 2008 - 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 <netinet/in.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <xtables.h>
#include <linux/netfilter.h>
#include "xt_RAWNAT.h"
enum {
FLAGS_TO = 1 << 0,
};
static const struct option rawdnat_tg_opts[] = {
{.name = "to-destination", .has_arg = true, .val = 't'},
{},
};
static void rawdnat_tg_help(void)
{
printf(
"RAWDNAT target options:\n"
" --to-destination addr[/mask] Address or network to map to\n"
);
}
static int
rawdnat_tg4_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
struct xt_rawnat_tginfo *info = (void *)(*target)->data;
struct in_addr *a;
unsigned int mask;
char *end;
switch (c) {
case 't':
info->mask = 32;
end = strchr(optarg, '/');
if (end != NULL) {
*end++ = '\0';
if (!xtables_strtoui(end, NULL, &mask, 0, 32))
xtables_param_act(XTF_BAD_VALUE, "RAWDNAT",
"--to-destination", optarg);
info->mask = mask;
}
a = xtables_numeric_to_ipaddr(optarg);
if (a == NULL)
xtables_param_act(XTF_BAD_VALUE, "RAWDNAT",
"--to-destination", optarg);
memcpy(&info->addr.in, a, sizeof(*a));
*flags |= FLAGS_TO;
return true;
}
return false;
}
static int
rawdnat_tg6_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
struct xt_rawnat_tginfo *info = (void *)(*target)->data;
struct in6_addr *a;
unsigned int mask;
char *end;
switch (c) {
case 't':
info->mask = 128;
end = strchr(optarg, '/');
if (end != NULL) {
*end++ = '\0';
if (!xtables_strtoui(end, NULL, &mask, 0, 32))
xtables_param_act(XTF_BAD_VALUE, "RAWDNAT",
"--to-destination", optarg);
info->mask = mask;
}
a = xtables_numeric_to_ip6addr(optarg);
if (a == NULL)
xtables_param_act(XTF_BAD_VALUE, "RAWDNAT",
"--to-destination", optarg);
memcpy(&info->addr.in6, a, sizeof(*a));
*flags |= FLAGS_TO;
return true;
}
return false;
}
static void rawdnat_tg_check(unsigned int flags)
{
if (!(flags & FLAGS_TO))
xtables_error(PARAMETER_PROBLEM, "RAWDNAT: "
"\"--to-destination\" is required.");
}
static void
rawdnat_tg4_print(const void *entry, const struct xt_entry_target *target,
int numeric)
{
const struct xt_rawnat_tginfo *info = (const void *)target->data;
if (!numeric && info->mask == 32)
printf("to-destination %s ",
xtables_ipaddr_to_anyname(&info->addr.in));
else
printf("to-destination %s/%u ",
xtables_ipaddr_to_numeric(&info->addr.in), info->mask);
}
static void
rawdnat_tg6_print(const void *entry, const struct xt_entry_target *target,
int numeric)
{
const struct xt_rawnat_tginfo *info = (const void *)target->data;
if (!numeric && info->mask == 128)
printf("to-destination %s ",
xtables_ip6addr_to_anyname(&info->addr.in6));
else
printf("to-destination %s/%u ",
xtables_ip6addr_to_numeric(&info->addr.in6), info->mask);
}
static void
rawdnat_tg4_save(const void *entry, const struct xt_entry_target *target)
{
const struct xt_rawnat_tginfo *info = (const void *)target->data;
printf("--to-destination %s/%u ",
xtables_ipaddr_to_numeric(&info->addr.in),
info->mask);
}
static void
rawdnat_tg6_save(const void *entry, const struct xt_entry_target *target)
{
const struct xt_rawnat_tginfo *info = (const void *)target->data;
printf("--to-destination %s/%u ",
xtables_ip6addr_to_numeric(&info->addr.in6),
info->mask);
}
static struct xtables_target rawdnat_tg4_reg = {
.version = XTABLES_VERSION,
.name = "RAWDNAT",
.revision = 0,
.family = PF_INET,
.size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.help = rawdnat_tg_help,
.parse = rawdnat_tg4_parse,
.final_check = rawdnat_tg_check,
.print = rawdnat_tg4_print,
.save = rawdnat_tg4_save,
.extra_opts = rawdnat_tg_opts,
};
static struct xtables_target rawdnat_tg6_reg = {
.version = XTABLES_VERSION,
.name = "RAWDNAT",
.revision = 0,
.family = PF_INET6,
.size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.help = rawdnat_tg_help,
.parse = rawdnat_tg6_parse,
.final_check = rawdnat_tg_check,
.print = rawdnat_tg6_print,
.save = rawdnat_tg6_save,
.extra_opts = rawdnat_tg_opts,
};
static void _init(void)
{
xtables_register_target(&rawdnat_tg4_reg);
xtables_register_target(&rawdnat_tg6_reg);
}

View File

@@ -0,0 +1,10 @@
The \fBRAWDNAT\fR target will rewrite the destination address in the IP header,
much like the \fBNETMAP\fR target.
.TP
\fB--to-destination\fR \fIaddr\fR[\fB/\fR\fImask\fR]
Network address to map to. The resulting address will be constructed the
following way: All 'one' bits in the \fImask\fR are filled in from the new
\fIaddress\fR. All bits that are zero in the mask are filled in from the
original address.
.PP
See the \fBRAWSNAT\fR help entry for examples and constraints.

187
extensions/libxt_RAWSNAT.c Normal file
View File

@@ -0,0 +1,187 @@
/*
* "RAWNAT" target extension for iptables
* Copyright © Jan Engelhardt, 2008 - 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 <netinet/in.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <xtables.h>
#include <linux/netfilter.h>
#include "xt_RAWNAT.h"
enum {
FLAGS_TO = 1 << 0,
};
static const struct option rawsnat_tg_opts[] = {
{.name = "to-source", .has_arg = true, .val = 't'},
{},
};
static void rawsnat_tg_help(void)
{
printf(
"RAWSNAT target options:\n"
" --to-source addr[/mask] Address or network to map to\n"
);
}
static int
rawsnat_tg4_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
struct xt_rawnat_tginfo *info = (void *)(*target)->data;
struct in_addr *a;
unsigned int mask;
char *end;
switch (c) {
case 't':
info->mask = 32;
end = strchr(optarg, '/');
if (end != NULL) {
*end++ = '\0';
if (!xtables_strtoui(end, NULL, &mask, 0, 32))
xtables_param_act(XTF_BAD_VALUE, "RAWSNAT",
"--to-source", optarg);
info->mask = mask;
}
a = xtables_numeric_to_ipaddr(optarg);
if (a == NULL)
xtables_param_act(XTF_BAD_VALUE, "RAWSNAT",
"--to-source", optarg);
memcpy(&info->addr.in, a, sizeof(*a));
*flags |= FLAGS_TO;
return true;
}
return false;
}
static int
rawsnat_tg6_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
struct xt_rawnat_tginfo *info = (void *)(*target)->data;
struct in6_addr *a;
unsigned int mask;
char *end;
switch (c) {
case 't':
info->mask = 128;
end = strchr(optarg, '/');
if (end != NULL) {
*end++ = '\0';
if (!xtables_strtoui(end, NULL, &mask, 0, 32))
xtables_param_act(XTF_BAD_VALUE, "RAWSNAT",
"--to-source", optarg);
info->mask = mask;
}
a = xtables_numeric_to_ip6addr(optarg);
if (a == NULL)
xtables_param_act(XTF_BAD_VALUE, "RAWSNAT",
"--to-source", optarg);
memcpy(&info->addr.in6, a, sizeof(*a));
*flags |= FLAGS_TO;
return true;
}
return false;
}
static void rawsnat_tg_check(unsigned int flags)
{
if (!(flags & FLAGS_TO))
xtables_error(PARAMETER_PROBLEM, "RAWSNAT: "
"\"--to-source\" is required.");
}
static void
rawsnat_tg4_print(const void *entry, const struct xt_entry_target *target,
int numeric)
{
const struct xt_rawnat_tginfo *info = (const void *)target->data;
if (!numeric && info->mask == 32)
printf("to-source %s ",
xtables_ipaddr_to_anyname(&info->addr.in));
else
printf("to-source %s/%u ",
xtables_ipaddr_to_numeric(&info->addr.in), info->mask);
}
static void
rawsnat_tg6_print(const void *entry, const struct xt_entry_target *target,
int numeric)
{
const struct xt_rawnat_tginfo *info = (const void *)target->data;
if (!numeric && info->mask == 128)
printf("to-source %s ",
xtables_ip6addr_to_anyname(&info->addr.in6));
else
printf("to-source %s/%u ",
xtables_ip6addr_to_numeric(&info->addr.in6), info->mask);
}
static void
rawsnat_tg4_save(const void *entry, const struct xt_entry_target *target)
{
const struct xt_rawnat_tginfo *info = (const void *)target->data;
printf("--to-source %s/%u ",
xtables_ipaddr_to_numeric(&info->addr.in),
info->mask);
}
static void
rawsnat_tg6_save(const void *entry, const struct xt_entry_target *target)
{
const struct xt_rawnat_tginfo *info = (const void *)target->data;
printf("--to-source %s/%u ",
xtables_ip6addr_to_numeric(&info->addr.in6),
info->mask);
}
static struct xtables_target rawsnat_tg4_reg = {
.version = XTABLES_VERSION,
.name = "RAWSNAT",
.revision = 0,
.family = PF_INET,
.size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.help = rawsnat_tg_help,
.parse = rawsnat_tg4_parse,
.final_check = rawsnat_tg_check,
.print = rawsnat_tg4_print,
.save = rawsnat_tg4_save,
.extra_opts = rawsnat_tg_opts,
};
static struct xtables_target rawsnat_tg6_reg = {
.version = XTABLES_VERSION,
.name = "RAWSNAT",
.revision = 0,
.family = PF_INET6,
.size = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_rawnat_tginfo)),
.help = rawsnat_tg_help,
.parse = rawsnat_tg6_parse,
.final_check = rawsnat_tg_check,
.print = rawsnat_tg6_print,
.save = rawsnat_tg6_save,
.extra_opts = rawsnat_tg_opts,
};
static void _init(void)
{
xtables_register_target(&rawsnat_tg4_reg);
xtables_register_target(&rawsnat_tg6_reg);
}

View File

@@ -0,0 +1,38 @@
The \fBRAWSNAT\fR and \fBRAWDNAT\fP targets provide stateless network address
translation.
.PP
The \fBRAWSNAT\fR target will rewrite the source address in the IP header, much
like the \fBNETMAP\fP target. \fBRAWSNAT\fP (and \fBRAWDNAT\fP) may only be
used in the \fBraw\fP or \fBrawpost\fP tables, but can be used in all chains,
which makes it possible to change the source address either when the packet
enters the machine or when it leaves it. The reason for this table constraint
is that RAWNAT must happen outside of connection tracking.
.TP
\fB--to-source\fR \fIaddr\fR[\fB/\fR\fImask\fR]
Network address to map to. The resulting address will be constructed the
following way: All 'one' bits in the \fImask\fR are filled in from the new
\fIaddress\fR. All bits that are zero in the mask are filled in from the
original address.
.PP
As an example, changing the destination for packets forwarded from an internal
LAN to the internet:
.IP
-t raw -A PREROUTING -i lan0 -d 212.201.100.135 -j RAWDNAT --to-destination 199.181.132.250
-t rawpost -A POSTROUTING -o lan0 -s 199.181.132.250 -j RAWSNAT --to-source 212.201.100.135
.PP
Note that changing addresses may influence the route selection! Specifically,
it statically NATs packets, not connections, like the normal DNAT/SNAT targets
would do. Also note that it can transform already-NATed connections -- as said,
it is completely external to Netfilter's connection tracking/NAT.
.PP
If the machine itself generates packets that are to be rawnat'ed, you need a
rule in the OUTPUT chain instead, just like you would with the stateful NAT
targets.
.PP
It may be necessary that in doing so, you also need an extra RAWSNAT rule, to
override the automatic source address selection that the routing code does
before passing packets to iptables. If the connecting socket has not been
explicitly bound to an address, as is the common mode of operation, the address
that will be chosen is the primary address of the device through which the
packet would be routed with its initial destination address - the address as
seen before any RAWNAT takes place.

33
extensions/libxt_STEAL.c Normal file
View File

@@ -0,0 +1,33 @@
#include <stdio.h>
#include <xtables.h>
static void steal_tg_help(void)
{
printf("STEAL takes no options\n\n");
}
static int steal_tg_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_target **target)
{
return 0;
}
static void steal_tg_check(unsigned int flags)
{
}
static struct xtables_target steal_tg_reg = {
.version = XTABLES_VERSION,
.name = "STEAL",
.family = AF_INET,
.size = XT_ALIGN(0),
.userspacesize = XT_ALIGN(0),
.help = steal_tg_help,
.parse = steal_tg_parse,
.final_check = steal_tg_check,
};
static void _init(void)
{
xtables_register_target(&steal_tg_reg);
}

View File

@@ -0,0 +1,2 @@
Like the DROP target, but does not throw an error like DROP when used in the
\fBOUTPUT\fP chain.

View File

@@ -25,7 +25,7 @@ ipsec --proto esp --tunnel-src 10.10.25.1 --tunnel-dst 10.10.25.7
You should also limit the rate at which connections can be received to limit You should also limit the rate at which connections can be received to limit
the CPU time taken by illegal requests, for example: the CPU time taken by illegal requests, for example:
.IP .IP
-A INPUT 0s 10.10.25.1 -m mac --mac-source aa:bb:cc:dd:ee:ff -d 10.10.25.7 -A INPUT -s 10.10.25.1 -m mac --mac-source aa:bb:cc:dd:ee:ff -d 10.10.25.7
-p udp --dport 9 -m limit --limit 5/minute -j SYSRQ -p udp --dport 9 -m limit --limit 5/minute -j SYSRQ
.PP .PP
This extension does not take any options. The \fB-p udp\fP options are This extension does not take any options. The \fB-p udp\fP options are

View File

@@ -50,12 +50,12 @@ 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");
ia = numeric_to_ipaddr(optarg); ia = xtables_numeric_to_ipaddr(optarg);
if (ia == NULL) if (ia == NULL)
exit_error(PARAMETER_PROBLEM, 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));
@@ -75,12 +75,12 @@ static int tee_tg6_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");
ia = numeric_to_ip6addr(optarg); ia = xtables_numeric_to_ip6addr(optarg);
if (ia == NULL) if (ia == NULL)
exit_error(PARAMETER_PROBLEM, 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));
@@ -94,7 +94,7 @@ static int tee_tg6_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");
} }
@@ -104,9 +104,9 @@ 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_numeric(&info->gw.in)); printf("TEE gw:%s ", xtables_ipaddr_to_numeric(&info->gw.in));
else else
printf("TEE gw:%s ", ipaddr_to_anyname(&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, static void tee_tg6_print(const void *ip, const struct xt_entry_target *target,
@@ -115,23 +115,23 @@ static void tee_tg6_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 ", ip6addr_to_numeric(&info->gw.in6)); printf("TEE gw:%s ", xtables_ip6addr_to_numeric(&info->gw.in6));
else else
printf("TEE gw:%s ", ip6addr_to_anyname(&info->gw.in6)); 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) static void tee_tg6_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 ", ip6addr_to_numeric(&info->gw.in6)); printf("--gateway %s ", xtables_ip6addr_to_numeric(&info->gw.in6));
} }
static struct xtables_target tee_tg_reg = { static struct xtables_target tee_tg_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");
} }
@@ -74,7 +74,7 @@ static void condition_save(const void *ip, const struct xt_entry_match *match)
{ {
const struct xt_condition_mtinfo *info = (const void *)match->data; const struct xt_condition_mtinfo *info = (const void *)match->data;
printf("--condition %s\"%s\" ", (info->invert) ? "! " : "", info->name); printf("%s--condition \"%s\" ", info->invert ? "! " : "", info->name);
} }
static struct xtables_match condition_mt_reg = { static struct xtables_match condition_mt_reg = {

View File

@@ -1,4 +0,0 @@
.TP
\fB--mac\fP \fIaa:bb:cc:dd:ee:ff\fP[\fB/\fP\fImask\fP]
Matches the DHCP Client Host address in a DHCP message. \fImask\fP specifies
the prefix length of the initial portion to match.

View File

@@ -1,5 +1,5 @@
/* /*
* "dhcpaddr" match extension for iptables * "dhcpmac" match extension for iptables
* Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008 * Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@@ -14,37 +14,37 @@
#include <netdb.h> #include <netdb.h>
#include <net/ethernet.h> #include <net/ethernet.h>
#include <xtables.h> #include <xtables.h>
#include "xt_DHCPADDR.h" #include "xt_DHCPMAC.h"
#include "mac.c" #include "mac.c"
enum { enum {
F_MAC = 1 << 0, F_MAC = 1 << 0,
}; };
static const struct option dhcpaddr_mt_opts[] = { static const struct option dhcpmac_mt_opts[] = {
{.name = "mac", .has_arg = true, .val = 'M'}, {.name = "mac", .has_arg = true, .val = 'M'},
{NULL}, {NULL},
}; };
static void dhcpaddr_mt_help(void) static void dhcpmac_mt_help(void)
{ {
printf( printf(
"dhcpaddr match options:\n" "dhcpmac match options:\n"
"[!] --mac lladdr[/mask] Match on MAC address in DHCP Client Host field\n" "[!] --mac lladdr[/mask] Match on MAC address in DHCP Client Host field\n"
); );
} }
static int dhcpaddr_mt_parse(int c, char **argv, int invert, static int dhcpmac_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 dhcpaddr_info *info = (void *)(*match)->data; struct dhcpmac_info *info = (void *)(*match)->data;
switch (c) { switch (c) {
case 'M': case 'M':
param_act(P_ONLY_ONCE, "dhcpaddr", "--mac", *flags & F_MAC); xtables_param_act(XTF_ONLY_ONCE, "dhcpmac", "--mac", *flags & F_MAC);
param_act(P_NO_INVERT, "dhcpaddr", "--mac", invert); xtables_param_act(XTF_NO_INVERT, "dhcpmac", "--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, "dhcpmac", "--mac", optarg);
if (invert) if (invert)
info->invert = true; info->invert = true;
*flags |= F_MAC; *flags |= F_MAC;
@@ -54,26 +54,26 @@ static int dhcpaddr_mt_parse(int c, char **argv, int invert,
return false; return false;
} }
static void dhcpaddr_mt_check(unsigned int flags) static void dhcpmac_mt_check(unsigned int flags)
{ {
if (flags == 0) if (flags == 0)
exit_error(PARAMETER_PROBLEM, "dhcpaddr match: " xtables_error(PARAMETER_PROBLEM, "dhcpmac match: "
"--mac parameter required"); "--mac parameter required");
} }
static void dhcpaddr_mt_print(const void *ip, static void dhcpmac_mt_print(const void *ip,
const struct xt_entry_match *match, int numeric) const struct xt_entry_match *match, int numeric)
{ {
const struct dhcpaddr_info *info = (void *)match->data; const struct dhcpmac_info *info = (void *)match->data;
printf("dhcpaddr %s" DH_MAC_FMT "/%u ", printf("dhcpmac %s" DH_MAC_FMT "/%u ",
info->invert ? "!" : "", DH_MAC_HEX(info->addr), info->mask); info->invert ? "!" : "", DH_MAC_HEX(info->addr), info->mask);
} }
static void dhcpaddr_mt_save(const void *ip, static void dhcpmac_mt_save(const void *ip,
const struct xt_entry_match *match) const struct xt_entry_match *match)
{ {
const struct dhcpaddr_info *info = (void *)match->data; const struct dhcpmac_info *info = (void *)match->data;
if (info->invert) if (info->invert)
printf("! "); printf("! ");
@@ -81,22 +81,22 @@ static void dhcpaddr_mt_save(const void *ip,
DH_MAC_HEX(info->addr), info->mask); DH_MAC_HEX(info->addr), info->mask);
} }
static struct xtables_match dhcpaddr_mt_reg = { static struct xtables_match dhcpmac_mt_reg = {
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.name = "dhcpaddr", .name = "dhcpmac",
.revision = 0, .revision = 0,
.family = PF_INET, .family = PF_INET,
.size = XT_ALIGN(sizeof(struct dhcpaddr_info)), .size = XT_ALIGN(sizeof(struct dhcpmac_info)),
.userspacesize = XT_ALIGN(sizeof(struct dhcpaddr_info)), .userspacesize = XT_ALIGN(sizeof(struct dhcpmac_info)),
.help = dhcpaddr_mt_help, .help = dhcpmac_mt_help,
.parse = dhcpaddr_mt_parse, .parse = dhcpmac_mt_parse,
.final_check = dhcpaddr_mt_check, .final_check = dhcpmac_mt_check,
.print = dhcpaddr_mt_print, .print = dhcpmac_mt_print,
.save = dhcpaddr_mt_save, .save = dhcpmac_mt_save,
.extra_opts = dhcpaddr_mt_opts, .extra_opts = dhcpmac_mt_opts,
}; };
static __attribute__((constructor)) void dhcpaddr_mt_ldr(void) static __attribute__((constructor)) void dhcpmac_mt_ldr(void)
{ {
xtables_register_match(&dhcpaddr_mt_reg); xtables_register_match(&dhcpmac_mt_reg);
} }

View File

@@ -0,0 +1,4 @@
.TP
\fB--mac\fP \fIaa:bb:cc:dd:ee:ff\fP[\fB/\fP\fImask\fP]
Matches the DHCP "Client Host" address (a MAC address) in a DHCP message.
\fImask\fP specifies the prefix length of the initial portion to match.

View File

@@ -9,6 +9,7 @@
*/ */
#include <getopt.h> #include <getopt.h>
#include <netdb.h> #include <netdb.h>
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -54,22 +55,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) || 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) || 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;
@@ -102,7 +103,7 @@ static struct xtables_match fuzzy_mt_reg = {
.name = "fuzzy", .name = "fuzzy",
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.size = XT_ALIGN(sizeof(struct xt_fuzzy_mtinfo)), .size = XT_ALIGN(sizeof(struct xt_fuzzy_mtinfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_fuzzy_mtinfo)), .userspacesize = offsetof(struct xt_fuzzy_mtinfo, packets_total),
.help = fuzzy_mt_help, .help = fuzzy_mt_help,
.init = fuzzy_mt_init, .init = fuzzy_mt_init,
.parse = fuzzy_mt_parse, .parse = fuzzy_mt_parse,

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");
} }
@@ -263,7 +263,7 @@ static struct xtables_match geoip_match = {
.name = "geoip", .name = "geoip",
.version = XTABLES_VERSION, .version = XTABLES_VERSION,
.size = XT_ALIGN(sizeof(struct xt_geoip_match_info)), .size = XT_ALIGN(sizeof(struct xt_geoip_match_info)),
.userspacesize = XT_ALIGN(offsetof(struct xt_geoip_match_info, mem)), .userspacesize = offsetof(struct xt_geoip_match_info, mem),
.help = geoip_help, .help = geoip_help,
.parse = geoip_parse, .parse = geoip_parse,
.final_check = geoip_final_check, .final_check = geoip_final_check,

233
extensions/libxt_iface.c Normal file
View File

@@ -0,0 +1,233 @@
/*
* Shared library add-on to iptables to add interface state matching
* support.
*
* (C) 2008 Gáspár Lajos <gaspar.lajos@glsys.eu>
*
* This program is released under the terms of GNU GPL version 2.
*/
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <xtables.h>
#include "xt_iface.h"
static const struct option iface_mt_opts[] = {
{.name = "iface", .has_arg = true, .val = 'i'},
{.name = "up", .has_arg = false, .val = 'u'},
{.name = "down", .has_arg = false, .val = 'U'}, /* not up */
{.name = "broadcast", .has_arg = false, .val = 'b'},
{.name = "loopback", .has_arg = false, .val = 'l'},
{.name = "pointopoint", .has_arg = false, .val = 'p'},
{.name = "pointtopoint", .has_arg = false, .val = 'p'}, /* eq pointopoint */
{.name = "running", .has_arg = false, .val = 'r'},
{.name = "noarp", .has_arg = false, .val = 'n'},
{.name = "arp", .has_arg = false, .val = 'N'}, /* not noarp */
{.name = "promisc", .has_arg = false, .val = 'o'},
{.name = "multicast", .has_arg = false, .val = 'm'},
{.name = "dynamic", .has_arg = false, .val = 'd'},
{.name = "lower-up", .has_arg = false, .val = 'w'},
{.name = "dormant", .has_arg = false, .val = 'a'},
{NULL},
};
static void iface_print_opt(const struct xt_iface_mtinfo *info,
const unsigned int option, const char *command)
{
if (info->flags & option)
printf(" %s", command);
if (info->invflags & option)
printf(" ! %s", command);
}
static void iface_setflag(struct xt_iface_mtinfo *info,
unsigned int *flags, int invert, u_int16_t flag, const char *command)
{
if (*flags & flag)
xtables_error(PARAMETER_PROBLEM,
"iface: \"--%s\" flag already specified", command);
if (invert)
info->invflags |= flag;
else
info->flags |= flag;
*flags |= flag;
}
static bool iface_valid_name(const char *name)
{
static const char invalid_chars[] = ".+!*";
return strlen(name) < IFNAMSIZ && strpbrk(name, invalid_chars) == NULL;
}
static void iface_mt_help(void)
{
printf(
"iface match options:\n"
" --iface interface Name of interface\n"
"[!] --up / --down match if UP flag (not) set\n"
"[!] --broadcast match if BROADCAST flag (not) set\n"
"[!] --loopback match if LOOPBACK flag (not) set\n"
"[!] --pointopoint\n"
"[!] --pointtopoint match if POINTOPOINT flag (not) set\n"
"[!] --running match if RUNNING flag (not) set\n"
"[!] --noarp / --arp match if NOARP flag (not) set\n"
"[!] --promisc match if PROMISC flag (not) set\n"
"[!] --multicast match if MULTICAST flag (not) set\n"
"[!] --dynamic match if DYNAMIC flag (not) set\n"
"[!] --lower-up match if LOWER_UP flag (not) set\n"
"[!] --dormant match if DORMANT flag (not) set\n");
}
static int iface_mt_parse(int c, char **argv, int invert, unsigned int *flags,
const void *entry, struct xt_entry_match **match)
{
struct xt_iface_mtinfo *info = (void *)(*match)->data;
switch (c) {
case 'U':
c = 'u';
invert = !invert;
break;
case 'N':
c = 'n';
invert = !invert;
break;
}
switch (c) {
case 'i': /* interface name */
if (*flags & XT_IFACE_IFACE)
xtables_error(PARAMETER_PROBLEM,
"iface: Interface name already specified");
if (!iface_valid_name(optarg))
xtables_error(PARAMETER_PROBLEM,
"iface: Invalid interface name!");
strcpy(info->ifname, optarg);
*flags |= XT_IFACE_IFACE;
return true;
case 'u': /* UP */
iface_setflag(info, flags, invert, XT_IFACE_UP, "up");
return true;
case 'b': /* BROADCAST */
iface_setflag(info, flags, invert, XT_IFACE_BROADCAST, "broadcast");
return true;
case 'l': /* LOOPBACK */
iface_setflag(info, flags, invert, XT_IFACE_LOOPBACK, "loopback");
return true;
case 'p': /* POINTOPOINT */
iface_setflag(info, flags, invert, XT_IFACE_POINTOPOINT, "pointopoint");
return true;
case 'r': /* RUNNING */
iface_setflag(info, flags, invert, XT_IFACE_RUNNING, "running");
return true;
case 'n': /* NOARP */
iface_setflag(info, flags, invert, XT_IFACE_NOARP, "noarp");
return true;
case 'o': /* PROMISC */
iface_setflag(info, flags, invert, XT_IFACE_PROMISC, "promisc");
return true;
case 'm': /* MULTICAST */
iface_setflag(info, flags, invert, XT_IFACE_MULTICAST, "multicast");
return true;
case 'd': /* DYNAMIC */
iface_setflag(info, flags, invert, XT_IFACE_DYNAMIC, "dynamic");
return true;
case 'w': /* LOWER_UP */
iface_setflag(info, flags, invert, XT_IFACE_LOWER_UP, "lower_up");
return true;
case 'a': /* DORMANT */
iface_setflag(info, flags, invert, XT_IFACE_DORMANT, "dormant");
return true;
}
return false;
}
static void iface_mt_check(unsigned int flags)
{
if (!(flags & XT_IFACE_IFACE))
xtables_error(PARAMETER_PROBLEM,
"iface: You must specify an interface");
if (flags == 0 || flags == XT_IFACE_IFACE)
xtables_error(PARAMETER_PROBLEM,
"iface: You must specify at least one option");
}
static void iface_mt_print(const void *ip, const struct xt_entry_match *match,
int numeric)
{
const struct xt_iface_mtinfo *info = (const void *)match->data;
printf("iface: \"%s\" [state:", info->ifname);
iface_print_opt(info, XT_IFACE_UP, "up");
iface_print_opt(info, XT_IFACE_BROADCAST, "broadcast");
iface_print_opt(info, XT_IFACE_LOOPBACK, "loopback");
iface_print_opt(info, XT_IFACE_POINTOPOINT, "pointopoint");
iface_print_opt(info, XT_IFACE_RUNNING, "running");
iface_print_opt(info, XT_IFACE_NOARP, "noarp");
iface_print_opt(info, XT_IFACE_PROMISC, "promisc");
iface_print_opt(info, XT_IFACE_MULTICAST, "multicast");
iface_print_opt(info, XT_IFACE_DYNAMIC, "dynamic");
iface_print_opt(info, XT_IFACE_LOWER_UP, "lower_up");
iface_print_opt(info, XT_IFACE_DORMANT, "dormant");
printf("] ");
}
static void iface_mt_save(const void *ip, const struct xt_entry_match *match)
{
const struct xt_iface_mtinfo *info = (const void *)match->data;
printf(" --iface %s", info->ifname);
iface_print_opt(info, XT_IFACE_UP, "--up");
iface_print_opt(info, XT_IFACE_BROADCAST, "--broadcast");
iface_print_opt(info, XT_IFACE_LOOPBACK, "--loopback");
iface_print_opt(info, XT_IFACE_POINTOPOINT, "--pointopoint");
iface_print_opt(info, XT_IFACE_RUNNING, "--running");
iface_print_opt(info, XT_IFACE_NOARP, "--noarp");
iface_print_opt(info, XT_IFACE_PROMISC, "--promisc");
iface_print_opt(info, XT_IFACE_MULTICAST, "--multicast");
iface_print_opt(info, XT_IFACE_DYNAMIC, "--dynamic");
iface_print_opt(info, XT_IFACE_LOWER_UP, "--lower_up");
iface_print_opt(info, XT_IFACE_DORMANT, "--dormant");
printf(" ");
}
static struct xtables_match iface_mt_reg = {
.version = XTABLES_VERSION,
.name = "iface",
.revision = 0,
.family = AF_INET,
.size = XT_ALIGN(sizeof(struct xt_iface_mtinfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_iface_mtinfo)),
.help = iface_mt_help,
.parse = iface_mt_parse,
.final_check = iface_mt_check,
.print = iface_mt_print,
.save = iface_mt_save,
.extra_opts = iface_mt_opts,
};
static struct xtables_match iface_mt6_reg = {
.version = XTABLES_VERSION,
.name = "iface",
.revision = 0,
.family = AF_INET6,
.size = XT_ALIGN(sizeof(struct xt_iface_mtinfo)),
.userspacesize = XT_ALIGN(sizeof(struct xt_iface_mtinfo)),
.help = iface_mt_help,
.parse = iface_mt_parse,
.final_check = iface_mt_check,
.print = iface_mt_print,
.save = iface_mt_save,
.extra_opts = iface_mt_opts,
};
static void _init(void)
{
xtables_register_match(&iface_mt_reg);
xtables_register_match(&iface_mt6_reg);
}

View File

@@ -0,0 +1,37 @@
Allows you to check interface states.
.TP
\fB\-\-iface\fP \fIname\fP
Check the states on the given interface. This option is required.
.TP
[\fB!\fP] \fB\-\-up\fP, [\fB!\fP] \fB\-\-down\fP
Check the UP flag.
.TP
[\fB!\fP] \fB\-\-broadcast\fP
Check the BROADCAST flag.
.TP
[\fB!\fP] \fB\-\-loopback\fP
Check the LOOPBACK flag.
.TP
[\fB!\fP] \fB\-\-pointtopoint\fP
Check the POINTTOPOINT flag.
.TP
[\fB!\fP] \fB\-\-running\fP
Check the RUNNING flag. Do NOT rely on it!
.TP
[\fB!\fP] \fB\-\-noarp\fP, [\fB!\fP] \fB\-\-arp\fP
Check the NOARP flag.
.TP
[\fB!\fP] \fB\-\-promisc\fP
Check the PROMISC flag.
.TP
[\fB!\fP] \fB\-\-multicast\fP
Check the MULTICAST flag.
.TP
[\fB!\fP] \fB\-\-dynamic\fP
Check the DYNAMIC flag.
.TP
[\fB!\fP] \fB\-\-lower-up\fP
Check the LOWER_UP flag.
.TP
[\fB!\fP] \fB\-\-dormant\fP
Check the DORMANT flag.

View File

@@ -1,7 +1,7 @@
/* /*
* "ipp2p" match extension for iptables * "ipp2p" match extension for iptables
* Eicke Friedrich/Klaus Degner <ipp2p@ipp2p.org>, 2005 - 2006 * Eicke Friedrich/Klaus Degner <ipp2p@ipp2p.org>, 2005 - 2006
* Jan Engelhardt <jengelh [at] medozas de>, 2008 * Jan Engelhardt <jengelh [at] medozas de>, 2008 - 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
@@ -17,7 +17,7 @@
#include <ctype.h> #include <ctype.h>
#include <xtables.h> #include <xtables.h>
#include "xt_ipp2p.h" #include "xt_ipp2p.h"
#define param_act(t, s, f) param_act((t), "ipp2p", (s), (f)) #define param_act(t, s, f) xtables_param_act((t), "ipp2p", (s), (f))
static void ipp2p_mt_help(void) static void ipp2p_mt_help(void)
{ {
@@ -63,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); param_act(XTF_ONLY_ONCE, "--edk", *flags & IPP2P_EDK);
param_act(P_NO_INVERT, "--edk", invert); 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); param_act(XTF_ONLY_ONCE, "--dc", *flags & IPP2P_DC);
param_act(P_NO_INVERT, "--dc", invert); 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); param_act(XTF_ONLY_ONCE, "--gnu", *flags & IPP2P_GNU);
param_act(P_NO_INVERT, "--gnu", invert); 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); param_act(XTF_ONLY_ONCE, "--kazaa", *flags & IPP2P_KAZAA);
param_act(P_NO_INVERT, "--kazaa", invert); 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); param_act(XTF_ONLY_ONCE, "--bit", *flags & IPP2P_BIT);
param_act(P_NO_INVERT, "--kazaa", invert); param_act(XTF_NO_INVERT, "--bit", 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); param_act(XTF_ONLY_ONCE, "--apple", *flags & IPP2P_APPLE);
param_act(P_NO_INVERT, "--apple", invert); 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); param_act(XTF_ONLY_ONCE, "--soul", *flags & IPP2P_SOUL);
param_act(P_NO_INVERT, "--soul", invert); 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); param_act(XTF_ONLY_ONCE, "--winmx", *flags & IPP2P_WINMX);
param_act(P_NO_INVERT, "--winmx", invert); 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); param_act(XTF_ONLY_ONCE, "--ares", *flags & IPP2P_ARES);
param_act(P_NO_INVERT, "--ares", invert); 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); param_act(XTF_ONLY_ONCE, "--mute", *flags & IPP2P_MUTE);
param_act(P_NO_INVERT, "--mute", invert); 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); param_act(XTF_ONLY_ONCE, "--waste", *flags & IPP2P_WASTE);
param_act(P_NO_INVERT, "--waste", invert); 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); param_act(XTF_ONLY_ONCE, "--xdcc", *flags & IPP2P_XDCC);
param_act(P_NO_INVERT, "--xdcc", invert); 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); param_act(XTF_ONLY_ONCE, "--debug", info->debug);
param_act(P_NO_INVERT, "--debug", invert); 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;
} }
@@ -175,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");
} }
@@ -199,7 +199,7 @@ static const char *const ipp2p_cmds[] = {
}; };
static void static void
ipp2p_mt_print(const void *entry, const struct xt_entry_match *match, ipp2p_mt_print1(const void *entry, const struct xt_entry_match *match,
int numeric) int numeric)
{ {
const struct ipt_p2p_info *info = (const void *)match->data; const struct ipt_p2p_info *info = (const void *)match->data;
@@ -213,9 +213,16 @@ ipp2p_mt_print(const void *entry, const struct xt_entry_match *match,
printf("--debug "); printf("--debug ");
} }
static void ipp2p_mt_print(const void *entry,
const struct xt_entry_match *match, int numeric)
{
printf("ipp2p ");
ipp2p_mt_print1(entry, match, true);
}
static void ipp2p_mt_save(const void *entry, const struct xt_entry_match *match) static void ipp2p_mt_save(const void *entry, const struct xt_entry_match *match)
{ {
ipp2p_mt_print(entry, match, true); ipp2p_mt_print1(entry, match, true);
} }
static struct xtables_match ipp2p_mt_reg = { static struct xtables_match ipp2p_mt_reg = {

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

@@ -52,42 +52,42 @@ static int length_mt_parse(int c, char **argv, int invert, unsigned int *flags,
switch (c) { switch (c) {
case '3': /* --layer3 */ case '3': /* --layer3 */
param_act(P_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER); xtables_param_act(XTF_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER);
info->flags &= ~XT_LENGTH_LAYER_MASK; info->flags &= ~XT_LENGTH_LAYER_MASK;
info->flags |= XT_LENGTH_LAYER3; info->flags |= XT_LENGTH_LAYER3;
*flags |= F_LAYER; *flags |= F_LAYER;
return true; return true;
case '4': /* --layer4 */ case '4': /* --layer4 */
param_act(P_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER); xtables_param_act(XTF_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER);
info->flags &= ~XT_LENGTH_LAYER_MASK; info->flags &= ~XT_LENGTH_LAYER_MASK;
info->flags |= XT_LENGTH_LAYER4; info->flags |= XT_LENGTH_LAYER4;
*flags |= F_LAYER; *flags |= F_LAYER;
return true; return true;
case '5': /* --layer5 */ case '5': /* --layer5 */
param_act(P_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER); xtables_param_act(XTF_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER);
info->flags &= ~XT_LENGTH_LAYER_MASK; info->flags &= ~XT_LENGTH_LAYER_MASK;
info->flags |= XT_LENGTH_LAYER5; info->flags |= XT_LENGTH_LAYER5;
*flags |= F_LAYER; *flags |= F_LAYER;
return true; return true;
case '7': /* --layer7 */ case '7': /* --layer7 */
param_act(P_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER); xtables_param_act(XTF_ONLY_ONCE, "length", "--layer*", *flags & F_LAYER);
info->flags &= ~XT_LENGTH_LAYER_MASK; info->flags &= ~XT_LENGTH_LAYER_MASK;
info->flags |= XT_LENGTH_LAYER7; info->flags |= XT_LENGTH_LAYER7;
*flags |= F_LAYER; *flags |= F_LAYER;
return true; return true;
case '=': /* --length */ case '=': /* --length */
param_act(P_ONLY_ONCE, "length", "--length", *flags & F_LENGTH); xtables_param_act(XTF_ONLY_ONCE, "length", "--length", *flags & F_LENGTH);
if (invert) if (invert)
info->flags |= XT_LENGTH_INVERT; info->flags |= XT_LENGTH_INVERT;
if (!strtonum(optarg, &end, &from, 0, ~0U)) if (!xtables_strtoui(optarg, &end, &from, 0, ~0U))
param_act(P_BAD_VALUE, "length", "--length", optarg); xtables_param_act(XTF_BAD_VALUE, "length", "--length", optarg);
to = from; to = from;
if (*end == ':') if (*end == ':')
if (!strtonum(end + 1, &end, &to, 0, ~0U)) if (!xtables_strtoui(end + 1, &end, &to, 0, ~0U))
param_act(P_BAD_VALUE, "length", xtables_param_act(XTF_BAD_VALUE, "length",
"--length", optarg); "--length", optarg);
if (*end != '\0') if (*end != '\0')
param_act(P_BAD_VALUE, "length", "--length", optarg); xtables_param_act(XTF_BAD_VALUE, "length", "--length", optarg);
info->min = from; info->min = from;
info->max = to; info->max = to;
*flags |= F_LENGTH; *flags |= F_LENGTH;
@@ -99,7 +99,7 @@ static int length_mt_parse(int c, char **argv, int invert, unsigned int *flags,
static void length_mt_check(unsigned int flags) static void length_mt_check(unsigned int flags)
{ {
if (!(flags & F_LENGTH)) if (!(flags & F_LENGTH))
exit_error(PARAMETER_PROBLEM, xtables_error(PARAMETER_PROBLEM,
"length: You must specify \"--length\""); "length: You must specify \"--length\"");
if (!(flags & F_LAYER)) if (!(flags & F_LAYER))
fprintf(stderr, "iptables: length match: Defaulting to " fprintf(stderr, "iptables: length match: Defaulting to "

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
@@ -27,5 +28,5 @@ ports where a protocol runs that is guaranteed to do a bidirectional exchange
of bytes. 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

@@ -234,7 +234,7 @@ static void __exit chaos_tg_exit(void)
module_init(chaos_tg_init); module_init(chaos_tg_init);
module_exit(chaos_tg_exit); module_exit(chaos_tg_exit);
MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>");
MODULE_DESCRIPTION("Xtables: Network scan slowdown with non-deterministic results"); MODULE_DESCRIPTION("Xtables: Network scan slowdown with non-deterministic results");
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_CHAOS"); MODULE_ALIAS("ipt_CHAOS");

View File

@@ -176,7 +176,7 @@ static void __exit delude_tg_exit(void)
module_init(delude_tg_init); module_init(delude_tg_init);
module_exit(delude_tg_exit); module_exit(delude_tg_exit);
MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>");
MODULE_DESCRIPTION("Xtables: Close TCP connections after handshake"); MODULE_DESCRIPTION("Xtables: Close TCP connections after handshake");
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_DELUDE"); MODULE_ALIAS("ipt_DELUDE");

View File

@@ -0,0 +1,8 @@
config NETFILTER_XT_DHCPMAC
tristate '"DHCPMAC" DHCP address matching and manipulation support'
depends on NETFILTER_XTABLES
depends on IP_NF_MANGLE || IP6_NF_MANGLE
---help---
The DHCPMAC extensions allows to match and change the MAC address in
a DHCP packet, so as to work around VMware's "inability" to use MAC
addresses from a vendor different than VMware at boot time.

View File

@@ -1,5 +1,5 @@
/* /*
* "DHCPADDR" extensions for Xtables * "DHCPMAC" extensions for Xtables
* Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008 * Copyright © Jan Engelhardt <jengelh [at] medozas de>, 2008
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@@ -14,7 +14,7 @@
#include <linux/udp.h> #include <linux/udp.h>
#include <net/ip.h> #include <net/ip.h>
#include <linux/netfilter/x_tables.h> #include <linux/netfilter/x_tables.h>
#include "xt_DHCPADDR.h" #include "xt_DHCPMAC.h"
#include "compat_xtables.h" #include "compat_xtables.h"
struct dhcp_message { struct dhcp_message {
@@ -69,9 +69,9 @@ static bool ether_cmp(const unsigned char *lh, const unsigned char *rh,
} }
static bool static bool
dhcpaddr_mt(const struct sk_buff *skb, const struct xt_match_param *par) dhcpmac_mt(const struct sk_buff *skb, const struct xt_match_param *par)
{ {
const struct dhcpaddr_info *info = par->matchinfo; const struct dhcpmac_info *info = par->matchinfo;
const struct dhcp_message *dh; const struct dhcp_message *dh;
struct dhcp_message dhcpbuf; struct dhcp_message dhcpbuf;
@@ -89,9 +89,9 @@ dhcpaddr_mt(const struct sk_buff *skb, const struct xt_match_param *par)
} }
static unsigned int static unsigned int
dhcpaddr_tg(struct sk_buff **pskb, const struct xt_target_param *par) dhcpmac_tg(struct sk_buff **pskb, const struct xt_target_param *par)
{ {
const struct dhcpaddr_info *info = par->targinfo; const struct dhcpmac_info *info = par->targinfo;
struct dhcp_message dhcpbuf, *dh; struct dhcp_message dhcpbuf, *dh;
struct udphdr udpbuf, *udph; struct udphdr udpbuf, *udph;
struct sk_buff *skb = *pskb; struct sk_buff *skb = *pskb;
@@ -122,52 +122,52 @@ dhcpaddr_tg(struct sk_buff **pskb, const struct xt_target_param *par)
return XT_CONTINUE; return XT_CONTINUE;
} }
static struct xt_target dhcpaddr_tg_reg __read_mostly = { static struct xt_target dhcpmac_tg_reg __read_mostly = {
.name = "DHCPADDR", .name = "DHCPMAC",
.revision = 0, .revision = 0,
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.proto = IPPROTO_UDP, .proto = IPPROTO_UDP,
.table = "mangle", .table = "mangle",
.target = dhcpaddr_tg, .target = dhcpmac_tg,
.targetsize = XT_ALIGN(sizeof(struct dhcpaddr_info)), .targetsize = XT_ALIGN(sizeof(struct dhcpmac_info)),
.me = THIS_MODULE, .me = THIS_MODULE,
}; };
static struct xt_match dhcpaddr_mt_reg __read_mostly = { static struct xt_match dhcpmac_mt_reg __read_mostly = {
.name = "dhcpaddr", .name = "dhcpmac",
.revision = 0, .revision = 0,
.family = NFPROTO_IPV4, .family = NFPROTO_IPV4,
.proto = IPPROTO_UDP, .proto = IPPROTO_UDP,
.match = dhcpaddr_mt, .match = dhcpmac_mt,
.matchsize = XT_ALIGN(sizeof(struct dhcpaddr_info)), .matchsize = XT_ALIGN(sizeof(struct dhcpmac_info)),
.me = THIS_MODULE, .me = THIS_MODULE,
}; };
static int __init dhcpaddr_init(void) static int __init dhcpmac_init(void)
{ {
int ret; int ret;
ret = xt_register_target(&dhcpaddr_tg_reg); ret = xt_register_target(&dhcpmac_tg_reg);
if (ret != 0) if (ret != 0)
return ret; return ret;
ret = xt_register_match(&dhcpaddr_mt_reg); ret = xt_register_match(&dhcpmac_mt_reg);
if (ret != 0) { if (ret != 0) {
xt_unregister_target(&dhcpaddr_tg_reg); xt_unregister_target(&dhcpmac_tg_reg);
return ret; return ret;
} }
return 0; return 0;
} }
static void __exit dhcpaddr_exit(void) static void __exit dhcpmac_exit(void)
{ {
xt_unregister_target(&dhcpaddr_tg_reg); xt_unregister_target(&dhcpmac_tg_reg);
xt_unregister_match(&dhcpaddr_mt_reg); xt_unregister_match(&dhcpmac_mt_reg);
} }
module_init(dhcpaddr_init); module_init(dhcpmac_init);
module_exit(dhcpaddr_exit); module_exit(dhcpmac_exit);
MODULE_DESCRIPTION("Xtables: Clamp DHCP MAC to packet MAC addresses"); MODULE_DESCRIPTION("Xtables: Clamp DHCP MAC to packet MAC addresses");
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>"); MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_DHCPADDR"); MODULE_ALIAS("ipt_DHCPMAC");
MODULE_ALIAS("ipt_dhcpaddr"); MODULE_ALIAS("ipt_dhcpmac");

View File

@@ -1,12 +1,12 @@
#ifndef _LINUX_NETFILTER_XT_DHCPADDR_H #ifndef _LINUX_NETFILTER_XT_DHCPMAC_H
#define _LINUX_NETFILTER_XT_DHCPADDR_H 1 #define _LINUX_NETFILTER_XT_DHCPMAC_H 1
#define DH_MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X" #define DH_MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X"
#define DH_MAC_HEX(z) z[0], z[1], z[2], z[3], z[4], z[5] #define DH_MAC_HEX(z) z[0], z[1], z[2], z[3], z[4], z[5]
struct dhcpaddr_info { struct dhcpmac_info {
unsigned char addr[ETH_ALEN]; unsigned char addr[ETH_ALEN];
uint8_t mask, invert; uint8_t mask, invert;
}; };
#endif /* _LINUX_NETFILTER_XT_DHCPADDR_H */ #endif /* _LINUX_NETFILTER_XT_DHCPMAC_H */

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);
@@ -127,7 +128,7 @@ static void __exit logmark_tg_exit(void)
module_init(logmark_tg_init); module_init(logmark_tg_init);
module_exit(logmark_tg_exit); module_exit(logmark_tg_exit);
MODULE_DESCRIPTION("Xtables: netfilter mark logging to syslog"); MODULE_DESCRIPTION("Xtables: netfilter mark logging to syslog");
MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>"); MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_LOGMARK"); MODULE_ALIAS("ipt_LOGMARK");
MODULE_ALIAS("ip6t_LOGMARK"); MODULE_ALIAS("ip6t_LOGMARK");

View File

@@ -0,0 +1,8 @@
config NETFILTER_XT_TARGET_RAWNAT
tristate '"RAWNAT" raw address translation w/o conntrack'
depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
depends on IP_NF_RAW || IP_NF6_RAW
---help---
This option adds the RAWSNAT and RAWDNAT targets which can do Network
Address Translation (no port translation) without requiring Netfilter
connection tracking.

346
extensions/xt_RAWNAT.c Normal file
View File

@@ -0,0 +1,346 @@
/*
* "RAWNAT" target extension for Xtables - untracked NAT
* Copyright © Jan Engelhardt, 2008 - 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/ipv6.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/netfilter.h>
#include <linux/netfilter/nf_conntrack_common.h>
#include <linux/netfilter/x_tables.h>
#include <linux/netfilter_ipv6/ip6_tables.h>
#include <net/ip.h>
#include <net/ipv6.h>
#include "compat_xtables.h"
#include "xt_RAWNAT.h"
static inline __be32
remask(__be32 addr, __be32 repl, unsigned int shift)
{
uint32_t mask = (shift == 32) ? 0 : (~(uint32_t)0 >> shift);
return htonl((ntohl(addr) & mask) | (ntohl(repl) & ~mask));
}
static void
rawnat_ipv6_mask(__be32 *addr, const __be32 *repl, unsigned int mask)
{
switch (mask) {
case 0:
break;
case 1 ... 31:
addr[0] = remask(addr[0], repl[0], mask);
break;
case 32:
addr[0] = repl[0];
break;
case 33 ... 63:
addr[0] = repl[0];
addr[1] = remask(addr[1], repl[1], mask - 64);
break;
case 64:
addr[0] = repl[0];
addr[1] = repl[1];
break;
case 65 ... 95:
addr[0] = repl[0];
addr[1] = repl[1];
addr[2] = remask(addr[2], repl[2], mask - 96);
case 96:
addr[0] = repl[0];
addr[1] = repl[1];
addr[2] = repl[2];
break;
case 97 ... 127:
addr[0] = repl[0];
addr[1] = repl[1];
addr[2] = repl[2];
addr[3] = remask(addr[3], repl[3], mask - 128);
break;
case 128:
addr[0] = repl[0];
addr[1] = repl[1];
addr[2] = repl[2];
addr[3] = repl[3];
break;
}
}
static void rawnat4_update_l4(struct sk_buff *skb, __be32 oldip, __be32 newip)
{
struct iphdr *iph = ip_hdr(skb);
void *transport_hdr = (void *)iph + ip_hdrlen(skb);
struct tcphdr *tcph;
struct udphdr *udph;
bool cond;
switch (iph->protocol) {
case IPPROTO_TCP:
tcph = transport_hdr;
inet_proto_csum_replace4(&tcph->check, skb, oldip, newip, true);
break;
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
udph = transport_hdr;
cond = udph->check != 0;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
cond |= skb->ip_summed == CHECKSUM_PARTIAL;
#endif
if (cond) {
inet_proto_csum_replace4(&udph->check, skb,
oldip, newip, true);
if (udph->check == 0)
udph->check = CSUM_MANGLED_0;
}
break;
}
}
static unsigned int rawnat4_writable_part(const struct iphdr *iph)
{
unsigned int wlen = sizeof(*iph);
switch (iph->protocol) {
case IPPROTO_TCP:
wlen += sizeof(struct tcphdr);
break;
case IPPROTO_UDP:
wlen += sizeof(struct udphdr);
break;
}
return wlen;
}
static unsigned int
rawsnat_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
{
const struct xt_rawnat_tginfo *info = par->targinfo;
struct iphdr *iph;
__be32 new_addr;
iph = ip_hdr(*pskb);
new_addr = remask(iph->saddr, info->addr.ip, info->mask);
if (iph->saddr == new_addr)
return XT_CONTINUE;
if (!skb_make_writable(pskb, rawnat4_writable_part(iph)))
return NF_DROP;
iph = ip_hdr(*pskb);
csum_replace4(&iph->check, iph->saddr, new_addr);
rawnat4_update_l4(*pskb, iph->saddr, new_addr);
iph->saddr = new_addr;
return XT_CONTINUE;
}
static unsigned int
rawdnat_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
{
const struct xt_rawnat_tginfo *info = par->targinfo;
struct iphdr *iph;
__be32 new_addr;
iph = ip_hdr(*pskb);
new_addr = remask(iph->daddr, info->addr.ip, info->mask);
if (iph->daddr == new_addr)
return XT_CONTINUE;
if (!skb_make_writable(pskb, rawnat4_writable_part(iph)))
return NF_DROP;
iph = ip_hdr(*pskb);
csum_replace4(&iph->check, iph->daddr, new_addr);
rawnat4_update_l4(*pskb, iph->daddr, new_addr);
iph->daddr = new_addr;
return XT_CONTINUE;
}
static bool rawnat6_prepare_l4(struct sk_buff **pskb, unsigned int *l4offset,
unsigned int *l4proto)
{
static const unsigned int types[] =
{IPPROTO_TCP, IPPROTO_UDP, IPPROTO_UDPLITE};
unsigned int i;
int err;
*l4proto = NEXTHDR_MAX;
for (i = 0; i < ARRAY_SIZE(types); ++i) {
err = ipv6_find_hdr(*pskb, l4offset, types[i], NULL);
if (err >= 0) {
*l4proto = types[i];
break;
}
if (err != -ENOENT)
return false;
}
switch (*l4proto) {
case IPPROTO_TCP:
if (!skb_make_writable(pskb, *l4offset + sizeof(struct tcphdr)))
return false;
break;
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
if (!skb_make_writable(pskb, *l4offset + sizeof(struct udphdr)))
return false;
break;
}
return true;
}
static void rawnat6_update_l4(struct sk_buff *skb, unsigned int l4proto,
unsigned int l4offset, const struct in6_addr *oldip,
const struct in6_addr *newip)
{
const struct ipv6hdr *iph = ipv6_hdr(skb);
struct tcphdr *tcph;
struct udphdr *udph;
unsigned int i;
bool cond;
switch (l4proto) {
case IPPROTO_TCP:
tcph = (void *)iph + l4offset;
for (i = 0; i < 4; ++i)
inet_proto_csum_replace4(&tcph->check, skb,
oldip->s6_addr32[i], newip->s6_addr32[i], true);
break;
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
udph = (void *)iph + l4offset;
cond = udph->check;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
cond |= skb->ip_summed == CHECKSUM_PARTIAL;
#endif
if (cond) {
for (i = 0; i < 4; ++i)
inet_proto_csum_replace4(&udph->check, skb,
oldip->s6_addr32[i],
newip->s6_addr32[i], true);
if (udph->check == 0)
udph->check = CSUM_MANGLED_0;
}
break;
}
}
static unsigned int
rawsnat_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
{
const struct xt_rawnat_tginfo *info = par->targinfo;
unsigned int l4offset, l4proto;
struct ipv6hdr *iph;
struct in6_addr new_addr;
iph = ipv6_hdr(*pskb);
memcpy(&new_addr, &iph->saddr, sizeof(new_addr));
rawnat_ipv6_mask(new_addr.s6_addr32, info->addr.ip6, info->mask);
if (ipv6_addr_cmp(&iph->saddr, &new_addr) == 0)
return XT_CONTINUE;
if (!rawnat6_prepare_l4(pskb, &l4offset, &l4proto))
return NF_DROP;
iph = ipv6_hdr(*pskb);
rawnat6_update_l4(*pskb, l4proto, l4offset, &iph->saddr, &new_addr);
memcpy(&iph->saddr, &new_addr, sizeof(new_addr));
return XT_CONTINUE;
}
static unsigned int
rawdnat_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
{
const struct xt_rawnat_tginfo *info = par->targinfo;
unsigned int l4offset, l4proto;
struct ipv6hdr *iph;
struct in6_addr new_addr;
iph = ipv6_hdr(*pskb);
memcpy(&new_addr, &iph->daddr, sizeof(new_addr));
rawnat_ipv6_mask(new_addr.s6_addr32, info->addr.ip6, info->mask);
if (ipv6_addr_cmp(&iph->daddr, &new_addr) == 0)
return XT_CONTINUE;
if (!rawnat6_prepare_l4(pskb, &l4offset, &l4proto))
return NF_DROP;
iph = ipv6_hdr(*pskb);
rawnat6_update_l4(*pskb, l4proto, l4offset, &iph->daddr, &new_addr);
memcpy(&iph->daddr, &new_addr, sizeof(new_addr));
return XT_CONTINUE;
}
static bool rawnat_tg_check(const struct xt_tgchk_param *par)
{
if (strcmp(par->table, "raw") == 0 ||
strcmp(par->table, "rawpost") == 0)
return true;
printk(KERN_ERR KBUILD_MODNAME " may only be used in the \"raw\" or "
"\"rawpost\" table.\n");
return false;
}
static struct xt_target rawnat_tg_reg[] __read_mostly = {
{
.name = "RAWSNAT",
.revision = 0,
.family = NFPROTO_IPV4,
.target = rawsnat_tg4,
.targetsize = sizeof(struct xt_rawnat_tginfo),
.checkentry = rawnat_tg_check,
.me = THIS_MODULE,
},
{
.name = "RAWSNAT",
.revision = 0,
.family = NFPROTO_IPV6,
.target = rawsnat_tg6,
.targetsize = sizeof(struct xt_rawnat_tginfo),
.checkentry = rawnat_tg_check,
.me = THIS_MODULE,
},
{
.name = "RAWDNAT",
.revision = 0,
.family = NFPROTO_IPV4,
.target = rawdnat_tg4,
.targetsize = sizeof(struct xt_rawnat_tginfo),
.checkentry = rawnat_tg_check,
.me = THIS_MODULE,
},
{
.name = "RAWDNAT",
.revision = 0,
.family = NFPROTO_IPV6,
.target = rawdnat_tg6,
.targetsize = sizeof(struct xt_rawnat_tginfo),
.checkentry = rawnat_tg_check,
.me = THIS_MODULE,
},
};
static int __init rawnat_tg_init(void)
{
return xt_register_targets(rawnat_tg_reg, ARRAY_SIZE(rawnat_tg_reg));
}
static void __exit rawnat_tg_exit(void)
{
xt_unregister_targets(rawnat_tg_reg, ARRAY_SIZE(rawnat_tg_reg));
}
module_init(rawnat_tg_init);
module_exit(rawnat_tg_exit);
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_DESCRIPTION("Xtables: conntrack-less raw NAT");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_RAWSNAT");
MODULE_ALIAS("ipt_RAWDNAT");
MODULE_ALIAS("ip6t_RAWSNAT");
MODULE_ALIAS("ip6t_RAWDNAT");

9
extensions/xt_RAWNAT.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef _LINUX_NETFILTER_XT_TARGET_RAWNAT
#define _LINUX_NETFILTER_XT_TARGET_RAWNAT 1
struct xt_rawnat_tginfo {
union nf_inet_addr addr;
__u8 mask;
};
#endif /* _LINUX_NETFILTER_XT_TARGET_RAWNAT */

66
extensions/xt_STEAL.c Normal file
View File

@@ -0,0 +1,66 @@
/*
* "STEAL" demo target extension for Xtables
* written by Jan Engelhardt <jengelh [at] medozas de>, 2008 - 2009
* placed in the Public Domain
*/
#include <linux/netfilter.h>
#include <linux/skbuff.h>
#include "compat_xtables.h"
static unsigned int
steal_tg(struct sk_buff **pskb, const struct xt_target_param *par)
{
kfree_skb(*pskb);
return NF_STOLEN;
}
static struct xt_target steal_tg_reg[] __read_mostly = {
{
.name = "STEAL",
.revision = 0,
.family = NFPROTO_UNSPEC,
.target = steal_tg,
.me = THIS_MODULE,
},
{
.name = "STEAL",
.revision = 0,
.family = NFPROTO_IPV6,
.target = steal_tg,
.me = THIS_MODULE,
},
{
.name = "STEAL",
.revision = 0,
.family = NFPROTO_ARP,
.target = steal_tg,
.me = THIS_MODULE,
},
{
.name = "STEAL",
.revision = 0,
.family = NFPROTO_BRIDGE,
.target = steal_tg,
.me = THIS_MODULE,
},
};
static int __init steal_tg_init(void)
{
return xt_register_targets(steal_tg_reg, ARRAY_SIZE(steal_tg_reg));
}
static void __exit steal_tg_exit(void)
{
xt_unregister_targets(steal_tg_reg, ARRAY_SIZE(steal_tg_reg));
}
module_init(steal_tg_init);
module_exit(steal_tg_exit);
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_DESCRIPTION("Xtables: Silently DROP packets on output chain");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_STEAL");
MODULE_ALIAS("ip6t_STEAL");
MODULE_ALIAS("arpt_STEAL");
MODULE_ALIAS("ebt_STEAL");

View File

@@ -200,7 +200,10 @@ sysrq_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
return NF_DROP; return NF_DROP;
iph = ip_hdr(skb); iph = ip_hdr(skb);
udph = (void *)iph + ip_hdrlen(skb); if (iph->protocol != IPPROTO_UDP)
return NF_ACCEPT; /* sink it */
udph = (const void *)iph + ip_hdrlen(skb);
len = ntohs(udph->len) - sizeof(struct udphdr); len = ntohs(udph->len) - sizeof(struct udphdr);
if (sysrq_debug) if (sysrq_debug)
@@ -217,13 +220,19 @@ sysrq_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
struct sk_buff *skb = *pskb; struct sk_buff *skb = *pskb;
const struct ipv6hdr *iph; const struct ipv6hdr *iph;
const struct udphdr *udph; const struct udphdr *udph;
unsigned short frag_off;
unsigned int th_off;
uint16_t len; uint16_t len;
if (skb_linearize(skb) < 0) if (skb_linearize(skb) < 0)
return NF_DROP; return NF_DROP;
iph = ipv6_hdr(skb); iph = ipv6_hdr(skb);
udph = udp_hdr(skb); if (ipv6_find_hdr(skb, &th_off, IPPROTO_UDP, &frag_off) < 0 ||
frag_off > 0)
return NF_ACCEPT; /* sink it */
udph = (const void *)iph + th_off;
len = ntohs(udph->len) - sizeof(struct udphdr); len = ntohs(udph->len) - sizeof(struct udphdr);
if (sysrq_debug) if (sysrq_debug)

View File

@@ -245,7 +245,7 @@ static void __exit tarpit_tg_exit(void)
module_init(tarpit_tg_init); module_init(tarpit_tg_init);
module_exit(tarpit_tg_exit); module_exit(tarpit_tg_exit);
MODULE_AUTHOR("Jan Engelhardt <jengelh@computergmbh.de>");
MODULE_DESCRIPTION("Xtables: \"TARPIT\", capture and hold TCP connections"); MODULE_DESCRIPTION("Xtables: \"TARPIT\", capture and hold TCP connections");
MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_TARPIT"); MODULE_ALIAS("ipt_TARPIT");

View File

@@ -26,6 +26,9 @@
# 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"
@@ -51,12 +54,20 @@ static const union nf_inet_addr tee_zero_address;
static bool static bool
tee_tg_route4(struct sk_buff *skb, 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 flowi fl; struct flowi fl;
memset(&fl, 0, sizeof(fl)); memset(&fl, 0, sizeof(fl));
fl.iif = skb_ifindex(skb);
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19)
fl.nl_u.ip4_u.fwmark = skb_nfmark(skb);
#else
fl.mark = skb_nfmark(skb);
#endif
fl.nl_u.ip4_u.daddr = info->gw.ip; 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; 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. */
@@ -210,14 +221,24 @@ tee_tg4(struct sk_buff **pskb, const struct xt_target_param *par)
return XT_CONTINUE; return XT_CONTINUE;
} }
#ifdef WITH_IPV6
static bool static bool
tee_tg_route6(struct sk_buff *skb, const struct xt_tee_tginfo *info) 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 dst_entry *dst;
struct flowi fl; struct flowi fl;
memset(&fl, 0, sizeof(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.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) #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 25)
dst = ip6_route_output(NULL, &fl); dst = ip6_route_output(NULL, &fl);
@@ -263,6 +284,7 @@ tee_tg6(struct sk_buff **pskb, const struct xt_target_param *par)
return XT_CONTINUE; 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)
{ {
@@ -284,6 +306,7 @@ static struct xt_target tee_tg_reg[] __read_mostly = {
.checkentry = tee_tg_check, .checkentry = tee_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
#ifdef WITH_IPV6
{ {
.name = "TEE", .name = "TEE",
.revision = 0, .revision = 0,
@@ -294,6 +317,7 @@ static struct xt_target tee_tg_reg[] __read_mostly = {
.checkentry = tee_tg_check, .checkentry = tee_tg_check,
.me = THIS_MODULE, .me = THIS_MODULE,
}, },
#endif
}; };
static int __init tee_tg_init(void) static int __init tee_tg_init(void)

View File

@@ -161,7 +161,9 @@ static bool condition_mt_check(const struct xt_mtchk_param *par)
var->refcount = 1; var->refcount = 1;
var->enabled = false; var->enabled = false;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 29)
var->status_proc->owner = THIS_MODULE; var->status_proc->owner = THIS_MODULE;
#endif
var->status_proc->data = var; var->status_proc->data = var;
wmb(); wmb();
var->status_proc->read_proc = condition_proc_read; var->status_proc->read_proc = condition_proc_read;

100
extensions/xt_iface.c Normal file
View File

@@ -0,0 +1,100 @@
/*
* xt_iface - kernel module to match interface state flags
*
* Original author: Gáspár Lajos <gaspar.lajos@glsys.eu>
*/
#include <linux/if.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/netfilter/x_tables.h>
#include "xt_iface.h"
#include "compat_xtables.h"
struct xt_iface_flag_pairs {
uint16_t iface_flag;
uint32_t iff_flag;
};
MODULE_AUTHOR("Gáspár Lajos <gaspar.lajos@glsys.eu>");
MODULE_DESCRIPTION("Xtables: iface match module");
MODULE_LICENSE("GPL");
MODULE_ALIAS("ipt_iface");
MODULE_ALIAS("ip6t_iface");
//MODULE_ALIAS("arpt_iface");
static const struct xt_iface_flag_pairs xt_iface_lookup[] =
{
{.iface_flag = XT_IFACE_UP, .iff_flag = IFF_UP},
{.iface_flag = XT_IFACE_BROADCAST, .iff_flag = IFF_BROADCAST},
{.iface_flag = XT_IFACE_LOOPBACK, .iff_flag = IFF_LOOPBACK},
{.iface_flag = XT_IFACE_POINTOPOINT, .iff_flag = IFF_POINTOPOINT},
{.iface_flag = XT_IFACE_RUNNING, .iff_flag = IFF_RUNNING},
{.iface_flag = XT_IFACE_NOARP, .iff_flag = IFF_NOARP},
{.iface_flag = XT_IFACE_PROMISC, .iff_flag = IFF_PROMISC},
{.iface_flag = XT_IFACE_MULTICAST, .iff_flag = IFF_MULTICAST},
{.iface_flag = XT_IFACE_DYNAMIC, .iff_flag = IFF_DYNAMIC},
{.iface_flag = XT_IFACE_LOWER_UP, .iff_flag = IFF_LOWER_UP},
{.iface_flag = XT_IFACE_DORMANT, .iff_flag = IFF_DORMANT},
};
static bool xt_iface_mt(const struct sk_buff *skb,
const struct xt_match_param *par)
{
const struct xt_iface_mtinfo *info = par->matchinfo;
struct net_device *dev;
bool retval;
int i;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
dev = dev_get_by_name(&init_net, info->ifname);
#else
dev = dev_get_by_name(info->ifname);
#endif
retval = dev != NULL;
if (retval) {
for (i = 0; i < ARRAY_SIZE(xt_iface_lookup) && retval; ++i) {
if (info->flags & xt_iface_lookup[i].iface_flag)
retval &= dev->flags & xt_iface_lookup[i].iff_flag;
if (info->invflags & xt_iface_lookup[i].iface_flag)
retval &= !(dev->flags & xt_iface_lookup[i].iff_flag);
}
dev_put(dev);
}
return retval;
}
static struct xt_match xt_iface_mt_reg[] __read_mostly = {
{
.name = "iface",
.revision = 0,
.family = NFPROTO_IPV4,
.matchsize = XT_ALIGN(sizeof(struct xt_iface_mtinfo)),
.match = xt_iface_mt,
.me = THIS_MODULE,
},
{
.name = "iface",
.revision = 0,
.family = NFPROTO_IPV6,
.matchsize = XT_ALIGN(sizeof(struct xt_iface_mtinfo)),
.match = xt_iface_mt,
.me = THIS_MODULE,
},
};
static int __init xt_iface_match_init(void)
{
return xt_register_matches(xt_iface_mt_reg,
ARRAY_SIZE(xt_iface_mt_reg));
}
static void __exit xt_iface_match_exit(void)
{
xt_unregister_matches(xt_iface_mt_reg, ARRAY_SIZE(xt_iface_mt_reg));
}
module_init(xt_iface_match_init);
module_exit(xt_iface_match_exit);

25
extensions/xt_iface.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef _LINUX_NETFILTER_XT_IFACE_H
#define _LINUX_NETFILTER_XT_IFACE_H 1
enum {
XT_IFACE_UP = 1 << 0,
XT_IFACE_BROADCAST = 1 << 1,
XT_IFACE_LOOPBACK = 1 << 2,
XT_IFACE_POINTOPOINT = 1 << 3,
XT_IFACE_RUNNING = 1 << 4,
XT_IFACE_NOARP = 1 << 5,
XT_IFACE_PROMISC = 1 << 6,
XT_IFACE_MULTICAST = 1 << 7,
XT_IFACE_DYNAMIC = 1 << 8,
XT_IFACE_LOWER_UP = 1 << 9,
XT_IFACE_DORMANT = 1 << 10,
XT_IFACE_IFACE = 1 << 15,
};
struct xt_iface_mtinfo {
char ifname[IFNAMSIZ];
__u16 flags;
__u16 invflags;
};
#endif

View File

@@ -0,0 +1,6 @@
config NETFILTER_XT_MATCH_IPV4OPTIONS
tristate '"ipv4options" IPv4 option match support'
depends on NETFILTER_XTABLES
---help---
The ipv4options match can be used to check on the presence or absence
of one or move IPv4 options.

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 */

View File

@@ -0,0 +1,7 @@
config NETFILTER_XT_MATCH_LENGTH2
tristate '"length2" match support'
depends on NETFILTER_XTABLES
---help---
This option adds the "length2" match which is an advanced form of
xt_length that allows unambiguous layer-4/-5/-7 length matching. It is
useful to detect empty packets or for aiding in packet scheduling.

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

@@ -0,0 +1,8 @@
config NETFILTER_XT_MATCH_QUOTA2
tristate '"quota2" match support'
depends on NETFILTER_XTABLES
---help---
This option adds the "quota2" match which is an advanced form of
xt_quota that also allows counting upwards, and where the counter can
be set through procfs. This allows for simple interfacing of
accounting information.

View File

@@ -2,18 +2,22 @@
# #
build_CHAOS=m build_CHAOS=m
build_DELUDE=m build_DELUDE=m
build_DHCPADDR=m build_DHCPMAC=m
build_ECHO= build_ECHO=
build_IPMARK=m build_IPMARK=m
build_LOGMARK=m build_LOGMARK=m
build_RAWNAT=m
build_STEAL=m
build_SYSRQ=m build_SYSRQ=m
build_TARPIT=m build_TARPIT=m
build_TEE=m build_TEE=m
build_condition=m build_condition=m
build_fuzzy=m build_fuzzy=m
build_geoip=m build_geoip=m
build_iface=m
build_ipp2p=m build_ipp2p=m
build_ipset=m build_ipset=m
build_ipv4options=m
build_length2=m build_length2=m
build_portscan=m build_lscan=m
build_quota2=m build_quota2=m

View File

@@ -1,4 +1,4 @@
.TH xtables\-addons 8 "v1.10 (2009\-02\-18)" "" "v1.10 (2009\-02\-18)" .TH xtables\-addons 8 "v1.15 (2009\-04\-30)" "" "v1.15 (2009\-04\-30)"
.SH Name .SH Name
Xtables\-addons - additional extensions for iptables, ip6tables, etc. Xtables\-addons - additional extensions for iptables, ip6tables, etc.
.SH Targets .SH Targets