2009-04-29 23:31:23 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/extensions/.IMQ-test
|
2008-12-01 20:27:46 +00:00
|
|
|
@@ -0,0 +1,3 @@
|
|
|
|
+#!/bin/sh
|
|
|
|
+# True if IMQ target patch is applied.
|
|
|
|
+[ -f $KERNEL_DIR/include/linux/netfilter_ipv4/ipt_IMQ.h ] && echo IMQ
|
2009-04-29 23:31:23 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/extensions/.IMQ-test6
|
2006-03-23 09:59:33 +00:00
|
|
|
@@ -0,0 +1,3 @@
|
|
|
|
+#!/bin/sh
|
|
|
|
+# True if IMQ target patch is applied.
|
2008-04-15 06:11:23 +00:00
|
|
|
+[ -f $KERNEL_DIR/include/linux/netfilter_ipv6/ip6t_IMQ.h ] && echo IMQ
|
2009-04-29 23:31:23 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/extensions/libip6t_IMQ.c
|
|
|
|
@@ -0,0 +1,90 @@
|
2006-03-23 09:59:33 +00:00
|
|
|
+/* Shared library add-on to iptables to add IMQ target support. */
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <string.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <getopt.h>
|
|
|
|
+
|
2009-04-29 23:31:23 +00:00
|
|
|
+#include <xtables.h>
|
2006-03-23 09:59:33 +00:00
|
|
|
+#include <ip6tables.h>
|
|
|
|
+#include <linux/netfilter_ipv6/ip6_tables.h>
|
|
|
|
+#include <linux/netfilter_ipv6/ip6t_IMQ.h>
|
|
|
|
+
|
|
|
|
+/* Function which prints out usage message. */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static void IMQ_help(void)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
|
|
|
+ printf(
|
|
|
|
+"IMQ target v%s options:\n"
|
|
|
|
+" --todev <N> enqueue to imq<N>, defaults to 0\n",
|
2008-12-01 20:27:46 +00:00
|
|
|
+XTABLES_VERSION);
|
2006-03-23 09:59:33 +00:00
|
|
|
+}
|
|
|
|
+
|
2008-12-01 20:27:46 +00:00
|
|
|
+static struct option IMQ_opts[] = {
|
2006-03-23 09:59:33 +00:00
|
|
|
+ { "todev", 1, 0, '1' },
|
|
|
|
+ { 0 }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/* Initialize the target. */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static void IMQ_init(struct xt_entry_target *t)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
|
|
|
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)t->data;
|
|
|
|
+
|
|
|
|
+ mr->todev = 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Function which parses command options; returns true if it
|
|
|
|
+ ate an option */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
|
2008-04-15 06:11:23 +00:00
|
|
|
+ const void *entry,
|
|
|
|
+ struct xt_entry_target **target)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
|
|
|
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)(*target)->data;
|
|
|
|
+
|
|
|
|
+ switch(c) {
|
|
|
|
+ case '1':
|
2009-04-29 23:31:23 +00:00
|
|
|
+ if (xtables_check_inverse(optarg, &invert, NULL, 0))
|
|
|
|
+ xtables_error(PARAMETER_PROBLEM,
|
2006-03-23 09:59:33 +00:00
|
|
|
+ "Unexpected `!' after --todev");
|
|
|
|
+ mr->todev=atoi(optarg);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Prints out the targinfo. */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static void IMQ_print(const void *ip,
|
2008-04-15 06:11:23 +00:00
|
|
|
+ const struct xt_entry_target *target,
|
2006-03-23 09:59:33 +00:00
|
|
|
+ int numeric)
|
|
|
|
+{
|
|
|
|
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
|
|
|
|
+
|
|
|
|
+ printf("IMQ: todev %u ", mr->todev);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Saves the union ipt_targinfo in parsable form to stdout. */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static void IMQ_save(const void *ip, const struct xt_entry_target *target)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
|
|
|
+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
|
|
|
|
+
|
|
|
|
+ printf("--todev %u", mr->todev);
|
|
|
|
+}
|
|
|
|
+
|
2008-12-01 20:27:46 +00:00
|
|
|
+static struct xtables_target imq = {
|
2006-03-23 09:59:33 +00:00
|
|
|
+ .name = "IMQ",
|
2008-12-01 20:27:46 +00:00
|
|
|
+ .version = XTABLES_VERSION,
|
|
|
|
+ .family = PF_INET6,
|
|
|
|
+ .size = XT_ALIGN(sizeof(struct ip6t_imq_info)),
|
|
|
|
+ .userspacesize = XT_ALIGN(sizeof(struct ip6t_imq_info)),
|
|
|
|
+ .help = IMQ_help,
|
|
|
|
+ .init = IMQ_init,
|
|
|
|
+ .parse = IMQ_parse,
|
|
|
|
+ .print = IMQ_print,
|
|
|
|
+ .save = IMQ_save,
|
|
|
|
+ .extra_opts = IMQ_opts,
|
2006-03-23 09:59:33 +00:00
|
|
|
+};
|
|
|
|
+
|
2008-12-01 20:27:46 +00:00
|
|
|
+void _init(void)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
2008-12-01 20:27:46 +00:00
|
|
|
+ xtables_register_target(&imq);
|
2006-03-23 09:59:33 +00:00
|
|
|
+}
|
2009-04-29 23:31:23 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/extensions/libipt_IMQ.c
|
|
|
|
@@ -0,0 +1,89 @@
|
2006-03-23 09:59:33 +00:00
|
|
|
+/* Shared library add-on to iptables to add IMQ target support. */
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <string.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <getopt.h>
|
|
|
|
+
|
2009-04-29 23:31:23 +00:00
|
|
|
+#include <xtables.h>
|
2006-03-23 09:59:33 +00:00
|
|
|
+#include <iptables.h>
|
|
|
|
+#include <linux/netfilter_ipv4/ip_tables.h>
|
|
|
|
+#include <linux/netfilter_ipv4/ipt_IMQ.h>
|
|
|
|
+
|
|
|
|
+/* Function which prints out usage message. */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static void IMQ_help(void)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
|
|
|
+ printf(
|
|
|
|
+"IMQ target v%s options:\n"
|
|
|
|
+" --todev <N> enqueue to imq<N>, defaults to 0\n",
|
2008-12-01 20:27:46 +00:00
|
|
|
+XTABLES_VERSION);
|
2006-03-23 09:59:33 +00:00
|
|
|
+}
|
|
|
|
+
|
2008-12-01 20:27:46 +00:00
|
|
|
+static struct option IMQ_opts[] = {
|
2006-03-23 09:59:33 +00:00
|
|
|
+ { "todev", 1, 0, '1' },
|
|
|
|
+ { 0 }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+/* Initialize the target. */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static void IMQ_init(struct xt_entry_target *t)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
|
|
|
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)t->data;
|
|
|
|
+
|
|
|
|
+ mr->todev = 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Function which parses command options; returns true if it
|
|
|
|
+ ate an option */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
|
|
|
|
+ const void *entry, struct xt_entry_target **target)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
|
|
|
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)(*target)->data;
|
|
|
|
+
|
|
|
|
+ switch(c) {
|
|
|
|
+ case '1':
|
2009-04-29 23:31:23 +00:00
|
|
|
+ if (xtables_check_inverse(optarg, &invert, NULL, 0))
|
|
|
|
+ xtables_error(PARAMETER_PROBLEM,
|
2006-03-23 09:59:33 +00:00
|
|
|
+ "Unexpected `!' after --todev");
|
|
|
|
+ mr->todev=atoi(optarg);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Prints out the targinfo. */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static void IMQ_print(const void *ip,
|
2008-04-15 06:11:23 +00:00
|
|
|
+ const struct xt_entry_target *target,
|
2006-03-23 09:59:33 +00:00
|
|
|
+ int numeric)
|
|
|
|
+{
|
|
|
|
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
|
|
|
|
+
|
|
|
|
+ printf("IMQ: todev %u ", mr->todev);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Saves the union ipt_targinfo in parsable form to stdout. */
|
2008-12-01 20:27:46 +00:00
|
|
|
+static void IMQ_save(const void *ip, const struct xt_entry_target *target)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
|
|
|
+ struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
|
|
|
|
+
|
|
|
|
+ printf("--todev %u", mr->todev);
|
|
|
|
+}
|
|
|
|
+
|
2008-12-01 20:27:46 +00:00
|
|
|
+static struct xtables_target imq = {
|
2006-03-23 09:59:33 +00:00
|
|
|
+ .name = "IMQ",
|
2008-12-01 20:27:46 +00:00
|
|
|
+ .version = XTABLES_VERSION,
|
|
|
|
+ .family = PF_INET,
|
|
|
|
+ .size = XT_ALIGN(sizeof(struct ipt_imq_info)),
|
|
|
|
+ .userspacesize = XT_ALIGN(sizeof(struct ipt_imq_info)),
|
|
|
|
+ .help = IMQ_help,
|
|
|
|
+ .init = IMQ_init,
|
|
|
|
+ .parse = IMQ_parse,
|
|
|
|
+ .print = IMQ_print,
|
|
|
|
+ .save = IMQ_save,
|
|
|
|
+ .extra_opts = IMQ_opts,
|
2006-03-23 09:59:33 +00:00
|
|
|
+};
|
|
|
|
+
|
2008-12-01 20:27:46 +00:00
|
|
|
+void _init(void)
|
2006-03-23 09:59:33 +00:00
|
|
|
+{
|
2008-12-01 20:27:46 +00:00
|
|
|
+ xtables_register_target(&imq);
|
2006-03-23 09:59:33 +00:00
|
|
|
+}
|