2 +++ b/extensions/.IMQ-test
5 +# True if IMQ target patch is applied.
6 +[ -f $KERNEL_DIR/include/linux/netfilter_ipv4/ipt_IMQ.h ] && echo IMQ
8 +++ b/extensions/.IMQ-test6
11 +# True if IMQ target patch is applied.
12 +[ -f $KERNEL_DIR/include/linux/netfilter_ipv6/ip6t_IMQ.h ] && echo IMQ
14 +++ b/extensions/libip6t_IMQ.c
16 +/* Shared library add-on to iptables to add IMQ target support. */
23 +#include <ip6tables.h>
24 +#include <linux/netfilter_ipv6/ip6_tables.h>
25 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
27 +/* Function which prints out usage message. */
28 +static void IMQ_help(void)
31 +"IMQ target v%s options:\n"
32 +" --todev <N> enqueue to imq<N>, defaults to 0\n",
36 +static struct option IMQ_opts[] = {
37 + { "todev", 1, 0, '1' },
41 +/* Initialize the target. */
42 +static void IMQ_init(struct xt_entry_target *t)
44 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)t->data;
49 +/* Function which parses command options; returns true if it
51 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
53 + struct xt_entry_target **target)
55 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)(*target)->data;
59 + if (xtables_check_inverse(optarg, &invert, NULL, 0))
60 + xtables_error(PARAMETER_PROBLEM,
61 + "Unexpected `!' after --todev");
62 + mr->todev=atoi(optarg);
70 +/* Prints out the targinfo. */
71 +static void IMQ_print(const void *ip,
72 + const struct xt_entry_target *target,
75 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
77 + printf("IMQ: todev %u ", mr->todev);
80 +/* Saves the union ipt_targinfo in parsable form to stdout. */
81 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
83 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
85 + printf("--todev %u", mr->todev);
88 +static struct xtables_target imq = {
90 + .version = XTABLES_VERSION,
92 + .size = XT_ALIGN(sizeof(struct ip6t_imq_info)),
93 + .userspacesize = XT_ALIGN(sizeof(struct ip6t_imq_info)),
99 + .extra_opts = IMQ_opts,
104 + xtables_register_target(&imq);
107 +++ b/extensions/libipt_IMQ.c
109 +/* Shared library add-on to iptables to add IMQ target support. */
115 +#include <xtables.h>
116 +#include <iptables.h>
117 +#include <linux/netfilter_ipv4/ip_tables.h>
118 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
120 +/* Function which prints out usage message. */
121 +static void IMQ_help(void)
124 +"IMQ target v%s options:\n"
125 +" --todev <N> enqueue to imq<N>, defaults to 0\n",
129 +static struct option IMQ_opts[] = {
130 + { "todev", 1, 0, '1' },
134 +/* Initialize the target. */
135 +static void IMQ_init(struct xt_entry_target *t)
137 + struct ipt_imq_info *mr = (struct ipt_imq_info*)t->data;
142 +/* Function which parses command options; returns true if it
144 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
145 + const void *entry, struct xt_entry_target **target)
147 + struct ipt_imq_info *mr = (struct ipt_imq_info*)(*target)->data;
151 + if (xtables_check_inverse(optarg, &invert, NULL, 0))
152 + xtables_error(PARAMETER_PROBLEM,
153 + "Unexpected `!' after --todev");
154 + mr->todev=atoi(optarg);
162 +/* Prints out the targinfo. */
163 +static void IMQ_print(const void *ip,
164 + const struct xt_entry_target *target,
167 + struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
169 + printf("IMQ: todev %u ", mr->todev);
172 +/* Saves the union ipt_targinfo in parsable form to stdout. */
173 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
175 + struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
177 + printf("--todev %u", mr->todev);
180 +static struct xtables_target imq = {
182 + .version = XTABLES_VERSION,
184 + .size = XT_ALIGN(sizeof(struct ipt_imq_info)),
185 + .userspacesize = XT_ALIGN(sizeof(struct ipt_imq_info)),
188 + .parse = IMQ_parse,
189 + .print = IMQ_print,
191 + .extra_opts = IMQ_opts,
196 + xtables_register_target(&imq);