?? iptables.diff
字號:
diff -uNr iptables/extensions/libip6t_spec_nh.c iptables-mpls/extensions/libip6t_spec_nh.c--- iptables/extensions/libip6t_spec_nh.c 1969-12-31 18:00:00.000000000 -0600+++ iptables-mpls/extensions/libip6t_spec_nh.c 2004-10-10 20:51:16.000000000 -0500@@ -0,0 +1,130 @@+/* Shared library add-on to iptables to add spec_nh 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/netfilter_ipv6/ip6t_spec_nh.h>++/* Function which prints out usage message. */+static void+help(void)+{+ printf(+"spec_nh target v%s options:\n"+" --spec_nh proto:value Set a special nexthop\n"+"\n",+IPTABLES_VERSION);+}++static struct option opts[] = {+ { .name = "spec_nh", .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)+{+ char *prot;+ char *value;+ unsigned int temp;+ struct ip6t_spec_nh_target_info *spec_nh_info+ = (struct ip6t_spec_nh_target_info *)(*target)->data;++ switch (c) {+ case '1':+ if (*flags) {+ exit_error(PARAMETER_PROBLEM,+ "spec_nh target: Can't specify --spec_nh twice");+ }++ prot = strtok(optarg,":");+ value = strtok(NULL,":");++ if ((!prot) || string_to_number(prot, 0, 0xffff,+ (unsigned int *)&temp)) {+ exit_error(PARAMETER_PROBLEM,+ "Bad spec_nh proto `%s'", prot);+ }++ spec_nh_info->proto = htons((unsigned short)temp);++ if ((!value) || string_to_number(value, 0, 0xffffffff,+ (unsigned int *)&temp)) {+ exit_error(PARAMETER_PROBLEM,+ "Bad spec_nh value `%s'", optarg);+ }++ spec_nh_info->data = (unsigned int)temp;+ *flags = 1;+ break;+ default:+ return 0;+ }++ return 1;+}++static void+final_check(unsigned int flags)+{+ if (!flags)+ exit_error(PARAMETER_PROBLEM,+ "spec_nh target: Parameter --spec_nh is required");+}++/* Prints out the targinfo. */+static void+print(const struct ip6t_ip6 *ip,+ const struct ip6t_entry_target *target,+ int numeric)+{+ const struct ip6t_spec_nh_target_info *spec_nh_info =+ (const struct ip6t_spec_nh_target_info *)target->data;++ printf("spec_nh set 0x%04x:0x%08x ",spec_nh_info->proto,+ spec_nh_info->data);+}++/* 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 ip6t_spec_nh_target_info *spec_nh_info =+ (const struct ip6t_spec_nh_target_info *)target->data;++ printf("--spec_nh 0x%04x:0x%08x ",spec_nh_info->proto,+ spec_nh_info->data);+}++static+struct ip6tables_target spec_nh = {+ .name = "spec_nh",+ .version = IPTABLES_VERSION,+ .size = IP6T_ALIGN(sizeof(struct ip6t_spec_nh_target_info)),+ .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_spec_nh_target_info)),+ .help = &help,+ .init = &init,+ .parse = &parse,+ .final_check = &final_check,+ .print = &print,+ .save = &save,+ .extra_opts = opts+};++void _init(void)+{+ register_target6(&spec_nh);+}diff -uNr iptables/extensions/libipt_spec_nh.c iptables-mpls/extensions/libipt_spec_nh.c--- iptables/extensions/libipt_spec_nh.c 1969-12-31 18:00:00.000000000 -0600+++ iptables-mpls/extensions/libipt_spec_nh.c 2004-10-10 20:50:20.000000000 -0500@@ -0,0 +1,136 @@+/* Shared library add-on to iptables to add spec_nh 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/netfilter_ipv4/ipt_spec_nh.h>++struct spec_nh_info {+ struct ipt_entry_target t;+ struct ipt_spec_nh_target_info spec_nh;+};++/* Function which prints out usage message. */+static void+help(void)+{+ printf(+"spec_nh target v%s options:\n"+" --spec_nh proto:value Set a special next hop\n"+"\n",+IPTABLES_VERSION);+}++static struct option opts[] = {+ { "spec_nh", 1, 0, '1' },+ { 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)+{+ char *prot;+ char *value;+ unsigned int temp;+ struct ipt_spec_nh_target_info *spec_nh_info+ = (struct ipt_spec_nh_target_info *)(*target)->data;++ switch (c) {+ case '1':+ if (*flags) {+ exit_error(PARAMETER_PROBLEM,+ "spec_nh target: Can't specify --spec_nh twice");+ }++ prot = strtok(optarg,":");+ value = strtok(NULL,":");++ if ((!prot) || string_to_number(prot, 0, 0xffff,+ (unsigned int *)&temp)) {+ exit_error(PARAMETER_PROBLEM,+ "Bad spec_nh proto `%s'", prot);+ }++ spec_nh_info->proto = htons((unsigned short)temp);++ if ((!value) || string_to_number(value, 0, 0xffffffff, + (unsigned int *)&temp)) {+ exit_error(PARAMETER_PROBLEM,+ "Bad spec_nh value `%s'", optarg);+ }++ spec_nh_info->data = (unsigned int)temp;+ *flags = 1;+ break;++ default:+ return 0;+ }++ return 1;+}++static void+final_check(unsigned int flags)+{+ if (!flags)+ exit_error(PARAMETER_PROBLEM,+ "spec_nh target: Parameter --spec_nh is required");+}++/* Prints out the targinfo. */+static void+print(const struct ipt_ip *ip,+ const struct ipt_entry_target *target,+ int numeric)+{+ const struct ipt_spec_nh_target_info *spec_nh_info =+ (const struct ipt_spec_nh_target_info *)target->data;+ printf("set spec_nh 0x%04x:0x%08x ",spec_nh_info->proto,+ spec_nh_info->data);+}++/* 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 ipt_spec_nh_target_info *spec_nh_info =+ (const struct ipt_spec_nh_target_info *)target->data;++ printf("--spec_nh 0x%04x:%0x08x ",spec_nh_info->proto,+ spec_nh_info->data);+}++static+struct iptables_target spec_nh+= { NULL,+ "spec_nh",+ IPTABLES_VERSION,+ IPT_ALIGN(sizeof(struct ipt_spec_nh_target_info)),+ IPT_ALIGN(sizeof(struct ipt_spec_nh_target_info)),+ &help,+ &init,+ &parse,+ &final_check,+ &print,+ &save,+ opts+};++void _init(void)+{+ register_target(&spec_nh);+}diff -uNr iptables/extensions/Makefile iptables-mpls/extensions/Makefile--- iptables/extensions/Makefile 2005-01-02 21:00:07.000000000 -0600+++ iptables-mpls/extensions/Makefile 2005-01-02 21:41:26.000000000 -0600@@ -5,8 +5,8 @@ # header files are present in the include/linux directory of this iptables # package (HW) #-PF_EXT_SLIB:=ah connlimit connmark conntrack dscp ecn esp 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 standard tcp udp HL LOG MARK TRACE+PF_EXT_SLIB:=ah connlimit connmark conntrack dscp ecn esp 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 spec_nh+PF6_EXT_SLIB:=eui64 hl icmpv6 length limit mac mark multiport owner standard tcp udp HL LOG MARK TRACE spec_nh # Optionals PF_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))diff -uNr iptables/iptables.c iptables-mpls/iptables.c--- iptables/iptables.c 2005-01-02 21:00:07.000000000 -0600+++ iptables-mpls/iptables.c 2005-01-22 11:52:59.172060704 -0600@@ -39,6 +39,7 @@ #include <iptables.h> #include <fcntl.h> #include <sys/wait.h>+#include <linux/mpls.h> #ifndef TRUE #define TRUE 1@@ -2007,10 +2008,19 @@ case 'V': if (invert)- printf("Not %s ;-)\n", program_version);+ printf("Not %s mpls-linux %d.%d%d%d ;-)\n",+ program_version,+ (MPLS_LINUX_VERSION >> 24) & 0xFF,+ (MPLS_LINUX_VERSION >> 16) & 0xFF,+ (MPLS_LINUX_VERSION >> 8) & 0xFF,+ (MPLS_LINUX_VERSION) & 0xFF); else- printf("%s v%s\n",- program_name, program_version);+ printf("%s v%s mpls-linux %d.%d%d%d\n",+ program_name, program_version,+ (MPLS_LINUX_VERSION >> 24) & 0xFF,+ (MPLS_LINUX_VERSION >> 16) & 0xFF,+ (MPLS_LINUX_VERSION >> 8) & 0xFF,+ (MPLS_LINUX_VERSION) & 0xFF); exit(0); case '0':
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -