All of lore.kernel.org
 help / color / mirror / Atom feed
* iptables: libxt_TEE
@ 2010-04-19 12:48 Jan Engelhardt
  2010-04-19 12:48 ` [PATCH] extensions: add support for xt_TEE Jan Engelhardt
  2010-05-13 13:48 ` iptables: libxt_TEE Patrick McHardy
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Engelhardt @ 2010-04-19 12:48 UTC (permalink / raw)
  To: kaber; +Cc: netfilter-devel


The following changes since commit db6d027bb9626129617ea3a3f2fe4b87ab307bf6:
  Jan Engelhardt (1):
        libxt_osf: import nfnl_osf program

are available in the git repository at:

  git://dev.medozas.de/iptables master

Jan Engelhardt (1):
      extensions: add support for xt_TEE

 extensions/libxt_TEE.c           |  202 ++++++++++++++++++++++++++++++++++++++
 extensions/libxt_TEE.man         |   12 +++
 include/linux/netfilter/xt_TEE.h |    9 ++
 3 files changed, 223 insertions(+), 0 deletions(-)
 create mode 100644 extensions/libxt_TEE.c
 create mode 100644 extensions/libxt_TEE.man
 create mode 100644 include/linux/netfilter/xt_TEE.h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] extensions: add support for xt_TEE
  2010-04-19 12:48 iptables: libxt_TEE Jan Engelhardt
@ 2010-04-19 12:48 ` Jan Engelhardt
  2010-05-13 13:48 ` iptables: libxt_TEE Patrick McHardy
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Engelhardt @ 2010-04-19 12:48 UTC (permalink / raw)
  To: kaber; +Cc: netfilter-devel

xt_TEE is firstly included in Linux 2.6.35.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
 extensions/libxt_TEE.c           |  202 ++++++++++++++++++++++++++++++++++++++
 extensions/libxt_TEE.man         |   12 +++
 include/linux/netfilter/xt_TEE.h |    9 ++
 3 files changed, 223 insertions(+), 0 deletions(-)
 create mode 100644 extensions/libxt_TEE.c
 create mode 100644 extensions/libxt_TEE.man
 create mode 100644 include/linux/netfilter/xt_TEE.h

diff --git a/extensions/libxt_TEE.c b/extensions/libxt_TEE.c
new file mode 100644
index 0000000..f8e7fd1
--- /dev/null
+++ b/extensions/libxt_TEE.c
@@ -0,0 +1,202 @@
+/*
+ *	"TEE" target extension for iptables
+ *	Copyright © Sebastian Claßen <sebastian.classen [at] freenet.ag>, 2007
+ *	Jan Engelhardt <jengelh [at] medozas de>, 2007 - 2010
+ *
+ *	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 <sys/socket.h>
+#include <getopt.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <arpa/inet.h>
+#include <net/if.h>
+#include <netinet/in.h>
+
+#include <xtables.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_TEE.h>
+
+enum {
+	FLAG_GATEWAY = 1 << 0,
+	FLAG_OIF     = 1 << 1,
+};
+
+static const struct option tee_tg_opts[] = {
+	{.name = "gateway", .has_arg = true, .val = 'g'},
+	{.name = "oif",     .has_arg = true, .val = 'o'},
+	{NULL},
+};
+
+static void tee_tg_help(void)
+{
+	printf(
+"TEE target options:\n"
+"  --gateway IPADDR    Route packet via the gateway given by address\n"
+"  --oif NAME          Include oif in route calculation\n"
+"\n");
+}
+
+static int tee_tg_parse(int c, char **argv, int invert, unsigned int *flags,
+                        const void *entry, struct xt_entry_target **target)
+{
+	struct xt_tee_tginfo *info = (void *)(*target)->data;
+	const struct in_addr *ia;
+
+	switch (c) {
+	case 'g':
+		if (*flags & FLAG_GATEWAY)
+			xtables_error(PARAMETER_PROBLEM,
+			           "Cannot specify --gateway more than once");
+
+		ia = xtables_numeric_to_ipaddr(optarg);
+		if (ia == NULL)
+			xtables_error(PARAMETER_PROBLEM,
+			           "Invalid IP address %s", optarg);
+
+		memcpy(&info->gw, ia, sizeof(*ia));
+		*flags |= FLAG_GATEWAY;
+		return true;
+	case 'o':
+		if (*flags & FLAG_OIF)
+			xtables_error(PARAMETER_PROBLEM,
+				"Cannot specify --oif more than once");
+		if (strlen(optarg) >= sizeof(info->oif))
+			xtables_error(PARAMETER_PROBLEM,
+				"oif name too long");
+		strcpy(info->oif, optarg);
+		*flags |= FLAG_OIF;
+		return true;
+	}
+
+	return false;
+}
+
+static int tee_tg6_parse(int c, char **argv, int invert, unsigned int *flags,
+                         const void *entry, struct xt_entry_target **target)
+{
+	struct xt_tee_tginfo *info = (void *)(*target)->data;
+	const struct in6_addr *ia;
+
+	switch (c) {
+	case 'g':
+		if (*flags & FLAG_GATEWAY)
+			xtables_error(PARAMETER_PROBLEM,
+			           "Cannot specify --gateway more than once");
+
+		ia = xtables_numeric_to_ip6addr(optarg);
+		if (ia == NULL)
+			xtables_error(PARAMETER_PROBLEM,
+			           "Invalid IP address %s", optarg);
+
+		memcpy(&info->gw, ia, sizeof(*ia));
+		*flags |= FLAG_GATEWAY;
+		return true;
+	case 'o':
+		if (*flags & FLAG_OIF)
+			xtables_error(PARAMETER_PROBLEM,
+				"Cannot specify --oif more than once");
+		if (strlen(optarg) >= sizeof(info->oif))
+			xtables_error(PARAMETER_PROBLEM,
+				"oif name too long");
+		strcpy(info->oif, optarg);
+		*flags |= FLAG_OIF;
+		return true;
+	}
+
+	return false;
+}
+
+static void tee_tg_check(unsigned int flags)
+{
+	if (flags == 0)
+		xtables_error(PARAMETER_PROBLEM, "TEE target: "
+		           "--gateway parameter required");
+}
+
+static void tee_tg_print(const void *ip, const struct xt_entry_target *target,
+                         int numeric)
+{
+	const struct xt_tee_tginfo *info = (const void *)target->data;
+
+	if (numeric)
+		printf("TEE gw:%s ", xtables_ipaddr_to_numeric(&info->gw.in));
+	else
+		printf("TEE gw:%s ", xtables_ipaddr_to_anyname(&info->gw.in));
+	if (*info->oif != '\0')
+		printf("oif=%s ", info->oif);
+}
+
+static void tee_tg6_print(const void *ip, const struct xt_entry_target *target,
+                          int numeric)
+{
+	const struct xt_tee_tginfo *info = (const void *)target->data;
+
+	if (numeric)
+		printf("TEE gw:%s ", xtables_ip6addr_to_numeric(&info->gw.in6));
+	else
+		printf("TEE gw:%s ", xtables_ip6addr_to_anyname(&info->gw.in6));
+	if (*info->oif != '\0')
+		printf("oif=%s ", info->oif);
+}
+
+static void tee_tg_save(const void *ip, const struct xt_entry_target *target)
+{
+	const struct xt_tee_tginfo *info = (const void *)target->data;
+
+	printf("--gateway %s ", xtables_ipaddr_to_numeric(&info->gw.in));
+	if (*info->oif != '\0')
+		printf("--oif %s ", info->oif);
+}
+
+static void tee_tg6_save(const void *ip, const struct xt_entry_target *target)
+{
+	const struct xt_tee_tginfo *info = (const void *)target->data;
+
+	printf("--gateway %s ", xtables_ip6addr_to_numeric(&info->gw.in6));
+	if (*info->oif != '\0')
+		printf("--oif %s ", info->oif);
+}
+
+static struct xtables_target tee_tg_reg = {
+	.name          = "TEE",
+	.version       = XTABLES_VERSION,
+	.revision      = 1,
+	.family        = NFPROTO_IPV4,
+	.size          = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
+	.userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
+	.help          = tee_tg_help,
+	.parse         = tee_tg_parse,
+	.final_check   = tee_tg_check,
+	.print         = tee_tg_print,
+	.save          = tee_tg_save,
+	.extra_opts    = tee_tg_opts,
+};
+
+static struct xtables_target tee_tg6_reg = {
+	.name          = "TEE",
+	.version       = XTABLES_VERSION,
+	.revision      = 1,
+	.family        = NFPROTO_IPV6,
+	.size          = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
+	.userspacesize = XT_ALIGN(sizeof(struct xt_tee_tginfo)),
+	.help          = tee_tg_help,
+	.parse         = tee_tg6_parse,
+	.final_check   = tee_tg_check,
+	.print         = tee_tg6_print,
+	.save          = tee_tg6_save,
+	.extra_opts    = tee_tg_opts,
+};
+
+static __attribute__((constructor)) void tee_tg_ldr(void)
+{
+	xtables_register_target(&tee_tg_reg);
+	xtables_register_target(&tee_tg6_reg);
+}
diff --git a/extensions/libxt_TEE.man b/extensions/libxt_TEE.man
new file mode 100644
index 0000000..456d150
--- /dev/null
+++ b/extensions/libxt_TEE.man
@@ -0,0 +1,12 @@
+The \fBTEE\fP target will clone a packet and redirect this clone to another
+machine on the \fBlocal\fP network segment. In other words, the nexthop
+must be the target, or you will have to configure the nexthop to forward it
+further if so desired.
+.TP
+\fB\-\-gateway\fP \fIipaddr\fP
+Send the cloned packet to the host reachable at the given IP address.
+Use of 0.0.0.0 (for IPv4 packets) or :: (IPv6) is invalid.
+.PP
+To forward all incoming traffic on eth0 to an Network Layer logging box:
+.PP
+\-t mangle \-A PREROUTING \-i eth0 \-j TEE \-\-gateway 2001:db8::1
diff --git a/include/linux/netfilter/xt_TEE.h b/include/linux/netfilter/xt_TEE.h
new file mode 100644
index 0000000..55d4a50
--- /dev/null
+++ b/include/linux/netfilter/xt_TEE.h
@@ -0,0 +1,9 @@
+#ifndef _XT_TEE_TARGET_H
+#define _XT_TEE_TARGET_H
+
+struct xt_tee_tginfo {
+	union nf_inet_addr gw;
+	char oif[16];
+};
+
+#endif /* _XT_TEE_TARGET_H */
-- 
1.7.0.5

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: iptables: libxt_TEE
  2010-04-19 12:48 iptables: libxt_TEE Jan Engelhardt
  2010-04-19 12:48 ` [PATCH] extensions: add support for xt_TEE Jan Engelhardt
@ 2010-05-13 13:48 ` Patrick McHardy
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick McHardy @ 2010-05-13 13:48 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: netfilter-devel

Jan Engelhardt wrote:
> The following changes since commit db6d027bb9626129617ea3a3f2fe4b87ab307bf6:
>   Jan Engelhardt (1):
>         libxt_osf: import nfnl_osf program
> 
> are available in the git repository at:
> 
>   git://dev.medozas.de/iptables master
> 
> Jan Engelhardt (1):
>       extensions: add support for xt_TEE

I've created a new branch "iptables-next" and pulled this in so
people can already test the new features in net-next.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-05-13 13:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19 12:48 iptables: libxt_TEE Jan Engelhardt
2010-04-19 12:48 ` [PATCH] extensions: add support for xt_TEE Jan Engelhardt
2010-05-13 13:48 ` iptables: libxt_TEE Patrick McHardy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.