M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
@@ -0,0 +1,130 @@
diff -ruN iptables-1.4.7-old/extensions/libipt_NATTYPE.c iptables-1.4.7-new/extensions/libipt_NATTYPE.c
--- iptables-1.4.7-old/extensions/libipt_NATTYPE.c 1970-01-01 02:00:00.000000000 +0200
+++ iptables-1.4.7-new/extensions/libipt_NATTYPE.c 2010-04-22 11:14:47.000000000 +0300
@@ -0,0 +1,126 @@
+/* Shared library add-on to iptables to add masquerade support. */
+#include <stdio.h>
+#include <netdb.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <xtables.h>
+#include <linux/netfilter_ipv4/ip_tables.h>
+//#include <linux/netfilter_ipv4/ip_nat_rule.h>
+#include <ipt_NATTYPE.h>
+
+/* Function which prints out usage message. */
+static void
+help(void)
+{
+ printf(
+ "NATTYPE target options:\n"
+ " --mode \n"
+ " dnat (PREROUTING)\n"
+ " forward_in (FORWARD)\n"
+ " forward_out (FORWARD)\n"
+ " --type \n"
+ " %d -- Endpoint Independent\n"
+ " %d -- Address Restricted\n",
+ TYPE_ENDPOINT_INDEPENDENT, TYPE_ADDRESS_RESTRICTED);
+}
+
+static struct option opts[] = {
+ {"mode", 1, 0, '1'},
+ { "type", 1, 0, '2' },
+ { 0 }
+};
+
+/* Initialize the target. */
+static void
+init(struct xt_entry_target *t)
+{
+}
+
+
+/* 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 void *entry,
+ struct xt_entry_target **target)
+{
+ struct ipt_nattype_info *info = (struct ipt_nattype_info *)(*target)->data;
+
+ switch (c) {
+
+ case '1':
+ if (!strcasecmp(optarg, "dnat")) {
+ printf("dnat\n");
+ info->mode= MODE_DNAT;
+ } else if (!strcasecmp(optarg, "forward_in")){
+ printf("forward in\n");
+ info->mode= MODE_FORWARD_IN;
+ } else if (!strcasecmp(optarg, "forward_out")){
+ printf("forward out\n");
+ info->mode= MODE_FORWARD_OUT;
+ }
+ return 1;
+
+ case '2':
+ info->type = atoi(optarg);
+ printf("nat type: %d\n", info->type);
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
+void print_mode(u_int16_t mode)
+{
+
+ printf("--mode:");
+ if( mode == MODE_DNAT)
+ printf("dnat ");
+ else if( mode == MODE_FORWARD_IN)
+ printf("forward_in ");
+ else if( mode == MODE_FORWARD_OUT)
+ printf("forward_out ");
+}
+
+/* Prints out the targinfo. */
+static void
+print(const void *ip,
+ const struct xt_entry_target *target,
+ int numeric)
+{
+ struct ipt_nattype_info *info = (struct ipt_nattype_info *)(target)->data;
+ print_mode(info->mode);
+ if( info->type !=0)
+ printf("--type: %d", info->type);
+}
+
+/* Saves the union ipt_targinfo in parsable form to stdout. */
+static void
+save(const void *ip, const struct xt_entry_target *target)
+{
+ struct ipt_nattype_info *info = (struct ipt_nattype_info *)(target)->data;
+ print_mode(info->mode);
+ if( info->type !=0)
+ printf("--type: %d", info->type);
+}
+
+static struct xtables_target nattype = { NULL,
+ .name = "NATTYPE",
+ .version = XTABLES_VERSION,
+ .family = NFPROTO_IPV4,
+ .size = XT_ALIGN(sizeof(struct ipt_nattype_info)),
+ .userspacesize = XT_ALIGN(sizeof(struct ipt_nattype_info)),
+ .help = &help,
+ .init = &init,
+ .parse = &parse,
+ .print = &print,
+ .save = &save,
+ .extra_opts = opts
+};
+
+void _init(void)
+{
+ xtables_register_target(&nattype);
+}