⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iptables.diff

📁 一个可以实现MPLS实验的linux源代码.你不仅可以实现单层标签的转发,还可以实现2个标签的实验,很好的.
💻 DIFF
📖 第 1 页 / 共 2 页
字号:
diff -uNr iptables/debugfiles.list iptables-mpls/debugfiles.list--- iptables/debugfiles.list	2005-10-14 23:37:33.000000000 -0500+++ iptables-mpls/debugfiles.list	2005-12-14 21:13:35.000000000 -0600@@ -16,6 +16,7 @@ /usr/lib/debug/lib/iptables/libipt_CONNMARK.so.debug /usr/lib/debug/lib/iptables/libipt_TCPMSS.so.debug /usr/lib/debug/lib/iptables/libipt_DNAT.so.debug+/usr/lib/debug/lib/iptables/libipt_mpls.so.debug /usr/lib/debug/lib/iptables/libip6t_limit.so.debug /usr/lib/debug/lib/iptables/libip6t_length.so.debug /usr/lib/debug/lib/iptables/libipt_standard.so.debug@@ -48,6 +49,7 @@ /usr/lib/debug/lib/iptables/libipt_hashlimit.so.debug /usr/lib/debug/lib/iptables/libipt_SNAT.so.debug /usr/lib/debug/lib/iptables/libipt_unclean.so.debug+/usr/lib/debug/lib/iptables/libip6t_mpls.so.debug /usr/lib/debug/lib/iptables/libipt_MASQUERADE.so.debug /usr/lib/debug/lib/iptables/libipt_ah.so.debug /usr/lib/debug/lib/iptables/libipt_addrtype.so.debugdiff -uNr iptables/extensions/libip6t_mpls.c iptables-mpls/extensions/libip6t_mpls.c--- iptables/extensions/libip6t_mpls.c	1969-12-31 18:00:00.000000000 -0600+++ iptables-mpls/extensions/libip6t_mpls.c	2005-12-14 21:11:22.000000000 -0600@@ -0,0 +1,114 @@+/* Shared library add-on to iptables to add mpls target support. */+#include <stdio.h>+#include <string.h>+#include <stdlib.h>+#include <getopt.h>++#include <ip6tables.h>+#include <linux/netfilter_ipv6/ip6_tables.h>+#include <linux/mpls.h>++/* Function which prints out usage message. */+static void+help(void)+{+	printf(+"mpls target v%s options:\n"+"  --nhlfe key		     Set an outgoing MPLS NHLFE\n"+"\n",+IPTABLES_VERSION);+}++static struct option opts[] = {+	{ .name = "nhlfe", .has_arg = 1, .flag = 0, .val = '1' },+	{ .name = 0 }+};++/* Initialize the target. */+static void+init(struct ip6t_entry_target *t, unsigned int *nfcache)+{+}++/* Function which parses command options; returns true if it+   ate an option */+static int+parse(int c, char **argv, int invert, unsigned int *flags,+      const struct ip6t_entry *entry,+      struct ip6t_entry_target **target)+{+	unsigned int temp;+	struct mpls_netfilter_target_info *mpls_info+		= (struct mpls_netfilter_target_info *)(*target)->data;++	switch (c) {+	case '1':+		if (*flags) {+			exit_error(PARAMETER_PROBLEM,+				   "mpls target: Can't specify --nhlfe twice");+		}++		if (string_to_number(optarg, 0,0xffff, (unsigned int *)&temp)) {+			exit_error(PARAMETER_PROBLEM, "Bad MPLS key `%s'",+				optarg);+		}++		mpls_info->key = temp;+		*flags = 1;+		break;+	default:+		return 0;+	}++	return 1;+}++static void+final_check(unsigned int flags)+{+	if (!flags)+		exit_error(PARAMETER_PROBLEM,+			   "mpls target: Parameter --nhlfe is required");+}++/* Prints out the targinfo. */+static void+print(const struct ip6t_ip6 *ip,+      const struct ip6t_entry_target *target,+      int numeric)+{+	const struct mpls_netfilter_target_info *mpls_info =+		(const struct mpls_netfilter_target_info *)target->data;++	printf("nhlfe 0x%x ",mpls_info->key);+}++/* Saves the union ipt_targinfo in parsable form to stdout. */+static void+save(const struct ip6t_ip6 *ip, const struct ip6t_entry_target *target)+{+	const struct mpls_netfilter_target_info *mpls_info =+		(const struct mpls_netfilter_target_info *)target->data;++	printf("--nhlfe 0x%x ",mpls_info->key);+}++static+struct ip6tables_target mpls = {+	.name	  = "mpls",+	.version  = IPTABLES_VERSION,+	.size	  = IP6T_ALIGN(sizeof(struct mpls_netfilter_target_info)),+	.userspacesize = IP6T_ALIGN(sizeof(struct mpls_netfilter_target_info)),+	.help	  = &help,+	.init	  = &init,+	.parse	  = &parse,+	.final_check   = &final_check,+	.print	  = &print,+	.save	  = &save,+	.extra_opts = opts+};++void _init(void)+{+	register_target6(&mpls);+}diff -uNr iptables/extensions/libipt_mpls.c iptables-mpls/extensions/libipt_mpls.c--- iptables/extensions/libipt_mpls.c	1969-12-31 18:00:00.000000000 -0600+++ iptables-mpls/extensions/libipt_mpls.c	2005-12-14 21:11:19.000000000 -0600@@ -0,0 +1,114 @@+/* Shared library add-on to iptables to add mpls target support. */+#include <stdio.h>+#include <string.h>+#include <stdlib.h>+#include <getopt.h>++#include <iptables.h>+#include <linux/netfilter_ipv4/ip_tables.h>+#include <linux/mpls.h>++/* Function which prints out usage message. */+static void+help(void)+{+	printf(+"mpls target v%s options:\n"+"  --nhlfe key		      Set an outgoing MPLS NHLFE\n"+"\n",+IPTABLES_VERSION);+}++static struct option opts[] = {+	{ .name = "nhlfe", .has_arg = 1, .flag = 0, .val = '1' },+	{ .name = 0 }+};++/* Initialize the target. */+static void+init(struct ipt_entry_target *t, unsigned int *nfcache)+{+}++/* Function which parses command options; returns true if it+   ate an option */+static int+parse(int c, char **argv, int invert, unsigned int *flags,+      const struct ipt_entry *entry,+      struct ipt_entry_target **target)+{+	unsigned int temp;+	struct mpls_netfilter_target_info *mpls_info+		= (struct mpls_netfilter_target_info *)(*target)->data;++	switch (c) {+	case '1':+		if (*flags) {+			exit_error(PARAMETER_PROBLEM,+				   "mpls target: Can't specify --nhlfe twice");+		}++		if (string_to_number(optarg, 0,0xffff,(unsigned int *)&temp)) {+			exit_error(PARAMETER_PROBLEM, "Bad MPLS key `%s'",+				optarg);+		}++		mpls_info->key = temp;+		*flags = 1;+		break;++	default:+		return 0;+	}++	return 1;+}++static void+final_check(unsigned int flags)+{+	if (!flags)+		exit_error(PARAMETER_PROBLEM,+			   "mpls target: Parameter --nhlfe is required");+}++/* Prints out the targinfo. */+static void+print(const struct ipt_ip *ip,+      const struct ipt_entry_target *target,+      int numeric)+{+	const struct mpls_netfilter_target_info *mpls_info =+		(const struct mpls_netfilter_target_info *)target->data;+	printf("nhlfe 0x%x ",mpls_info->key);+}++/* Saves the union ipt_targinfo in parsable form to stdout. */+static void+save(const struct ipt_ip *ip, const struct ipt_entry_target *target)+{+	const struct mpls_netfilter_target_info *mpls_info =+		(const struct mpls_netfilter_target_info *)target->data;++	printf("--nhlfe 0x%x ",mpls_info->key);+}++static+struct iptables_target mpls = {+	.name	  = "mpls",+	.version  = IPTABLES_VERSION,+	.size	  = IPT_ALIGN(sizeof(struct mpls_netfilter_target_info)),+	.userspacesize = IPT_ALIGN(sizeof(struct mpls_netfilter_target_info)),+	.help	  = &help,+	.init	  = &init,+	.parse	  = &parse,+	.final_check   = &final_check,+	.print	  = &print,+	.save	  = &save,+	.extra_opts = opts+};++void _init(void)+{+	register_target(&mpls);+}diff -uNr iptables/extensions/Makefile iptables-mpls/extensions/Makefile--- iptables/extensions/Makefile	2005-10-14 23:36:44.000000000 -0500+++ iptables-mpls/extensions/Makefile	2005-12-14 21:11:23.000000000 -0600@@ -5,8 +5,8 @@ # header files are present in the include/linux directory of this iptables # package (HW) #-PF_EXT_SLIB:=ah addrtype comment connlimit connmark conntrack dscp ecn esp hashlimit helper icmp iprange length limit mac mark multiport owner physdev pkttype realm rpc sctp standard state tcp tcpmss tos ttl udp unclean CLASSIFY CONNMARK DNAT DSCP ECN LOG MARK MASQUERADE MIRROR NETMAP NOTRACK REDIRECT REJECT SAME SNAT TARPIT TCPMSS TOS TRACE TTL ULOG-PF6_EXT_SLIB:=eui64 hl icmpv6 length limit mac mark multiport owner physdev standard tcp udp HL LOG MARK TRACE+PF_EXT_SLIB:=ah addrtype comment connlimit connmark conntrack dscp ecn esp hashlimit helper icmp iprange length limit mac mark multiport owner physdev pkttype realm rpc sctp standard state tcp tcpmss tos ttl udp unclean CLASSIFY CONNMARK DNAT DSCP ECN LOG MARK MASQUERADE MIRROR NETMAP NOTRACK REDIRECT REJECT SAME SNAT TARPIT TCPMSS TOS TRACE TTL ULOG mpls+PF6_EXT_SLIB:=eui64 hl icmpv6 length limit mac mark multiport owner physdev standard tcp udp HL LOG MARK TRACE mpls  # Optionals PF_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))diff -uNr iptables/include/linux/mpls.h iptables-mpls/include/linux/mpls.h--- iptables/include/linux/mpls.h	1969-12-31 18:00:00.000000000 -0600+++ iptables-mpls/include/linux/mpls.h	2005-12-14 21:11:31.000000000 -0600@@ -0,0 +1,255 @@+/*****************************************************************************+ * MPLS+ *      An implementation of the MPLS (MultiProtocol Label+ *      Switching Architecture) for Linux.+ *+ * Authors:+ *          James Leu        <jleu@mindspring.com>+ *          Ramon Casellas   <casellas@infres.enst.fr>+ *+ *   (c) 1999-2004   James Leu        <jleu@mindspring.com>+ *   (c) 2003-2004   Ramon Casellas   <casellas@infres.enst.fr>+ *+ * include/linux/mpls.h+ *      Data types and structs used by userspace programs to access MPLS+ *      forwarding. Most interface with the MPLS subsystem is IOCTL based+ *+ *      This program is free software; you can redistribute it and/or+ *      modify it under the terms of the GNU General Public License+ *      as published by the Free Software Foundation; either version+ *      2 of the License, or (at your option) any later version.+ ****************************************************************************/++#ifndef _LINUX_MPLS_H_+#define _LINUX_MPLS_H_++#ifdef __KERNEL__+#include <linux/socket.h>+#include <linux/if.h>+#else+#include <sys/socket.h>+#include <net/if.h>+#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -