2 +++ b/extensions/.IMQ-testx
5 +# True if IMQ target patch is applied.
6 +[ -f $KERNEL_DIR/include/linux/netfilter/xt_IMQ.h ] && echo IMQ
8 +++ b/extensions/libxt_IMQ.c
10 +/* Shared library add-on to iptables to add IMQ target support. */
17 +#include <linux/netfilter/x_tables.h>
18 +#include <linux/netfilter/xt_IMQ.h>
20 +/* Function which prints out usage message. */
21 +static void IMQ_help(void)
24 +"IMQ target v%s options:\n"
25 +" --todev <N> enqueue to imq<N>, defaults to 0\n",
29 +static struct option IMQ_opts[] = {
30 + { "todev", 1, 0, '1' },
34 +/* Initialize the target. */
35 +static void IMQ_init(struct xt_entry_target *t)
37 + struct xt_imq_info *mr = (struct xt_imq_info*)t->data;
42 +/* Function which parses command options; returns true if it
44 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
45 + const void *entry, struct xt_entry_target **target)
47 + struct xt_imq_info *mr = (struct xt_imq_info*)(*target)->data;
51 + if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
52 + xtables_error(PARAMETER_PROBLEM,
53 + "Unexpected `!' after --todev");
54 + mr->todev=atoi(optarg);
62 +/* Prints out the targinfo. */
63 +static void IMQ_print(const void *ip,
64 + const struct xt_entry_target *target,
67 + struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
69 + printf("IMQ: todev %u ", mr->todev);
72 +/* Saves the union ipt_targinfo in parsable form to stdout. */
73 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
75 + struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
77 + printf("--todev %u", mr->todev);
80 +static struct xtables_target imq_target = {
82 + .version = XTABLES_VERSION,
83 + .family = NFPROTO_IPV4,
84 + .size = XT_ALIGN(sizeof(struct xt_imq_info)),
85 + .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)),
91 + .extra_opts = IMQ_opts,
94 +static struct xtables_target imq_target6 = {
96 + .version = XTABLES_VERSION,
97 + .family = NFPROTO_IPV6,
98 + .size = XT_ALIGN(sizeof(struct xt_imq_info)),
99 + .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)),
102 + .parse = IMQ_parse,
103 + .print = IMQ_print,
105 + .extra_opts = IMQ_opts,
110 + xtables_register_target(&imq_target);
111 + xtables_register_target(&imq_target6);
114 +++ b/include/linux/netfilter/xt_IMQ.h
119 +struct xt_imq_info {
120 + unsigned int todev; /* target imq device */
123 +#endif /* _XT_IMQ_H */