1 diff -Naur iptables-1.4.12.1/extensions/libxt_IMQ.c iptables-1.4.12.1-imq/extensions/libxt_IMQ.c
2 --- iptables-1.4.12.1/extensions/libxt_IMQ.c 1970-01-01 02:00:00.000000000 +0200
3 +++ iptables-1.4.12.1-imq/extensions/libxt_IMQ.c 2011-09-30 13:53:21.000000000 +0300
5 +/* Shared library add-on to iptables to add IMQ target support. */
12 +#include <linux/netfilter/x_tables.h>
13 +#include <linux/netfilter/xt_IMQ.h>
15 +/* Function which prints out usage message. */
16 +static void IMQ_help(void)
19 +"IMQ target options:\n"
20 +" --todev <N> enqueue to imq<N>, defaults to 0\n");
24 +static struct option IMQ_opts[] = {
25 + { "todev", 1, 0, '1' },
29 +/* Initialize the target. */
30 +static void IMQ_init(struct xt_entry_target *t)
32 + struct xt_imq_info *mr = (struct xt_imq_info*)t->data;
37 +/* Function which parses command options; returns true if it
39 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
40 + const void *entry, struct xt_entry_target **target)
42 + struct xt_imq_info *mr = (struct xt_imq_info*)(*target)->data;
46 +/* if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
47 + xtables_error(PARAMETER_PROBLEM,
48 + "Unexpected `!' after --todev");
50 + mr->todev=atoi(optarg);
59 +/* Prints out the targinfo. */
60 +static void IMQ_print(const void *ip,
61 + const struct xt_entry_target *target,
64 + struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
66 + printf("IMQ: todev %u ", mr->todev);
69 +/* Saves the union ipt_targinfo in parsable form to stdout. */
70 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
72 + struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
74 + printf(" --todev %u", mr->todev);
77 +static struct xtables_target imq_target = {
79 + .version = XTABLES_VERSION,
80 + .family = NFPROTO_IPV4,
81 + .size = XT_ALIGN(sizeof(struct xt_imq_info)),
82 + .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)),
88 + .extra_opts = IMQ_opts,
91 +static struct xtables_target imq_target6 = {
93 + .version = XTABLES_VERSION,
94 + .family = NFPROTO_IPV6,
95 + .size = XT_ALIGN(sizeof(struct xt_imq_info)),
96 + .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)),
100 + .print = IMQ_print,
102 + .extra_opts = IMQ_opts,
105 +// void __attribute((constructor)) nf_ext_init(void){
107 + xtables_register_target(&imq_target);
108 + xtables_register_target(&imq_target6);
110 diff -Naur iptables-1.4.12.1/extensions/libxt_IMQ.man iptables-1.4.12.1-imq/extensions/libxt_IMQ.man
111 --- iptables-1.4.12.1/extensions/libxt_IMQ.man 1970-01-01 02:00:00.000000000 +0200
112 +++ iptables-1.4.12.1-imq/extensions/libxt_IMQ.man 2011-09-30 13:53:21.000000000 +0300
114 +This target is used to redirect the traffic to the IMQ driver and you can apply
115 +QoS rules like HTB or CBQ.
116 +For example you can select only traffic comming from a specific interface or
117 +is going out on a specific interface.
118 +Also it permits to capture the traffic BEFORE NAT in the case of outgoing traffic
119 +or AFTER NAT in the case of incomming traffic.
121 +\fB\-\-to\-dev\fP \fIvalue\fP
122 +Set the IMQ interface where to send this traffic
126 +Redirect incomming traffic from interface eth0 to imq0 and outgoing traffic to imq1:
127 +iptables \-t mangle \-A FORWARD \-i eth0 \-j IMQ \-\-to\-dev 0
128 +iptables \-t mangle \-A FORWARD \-o eth0 \-j IMQ \-\-to\-dev 1
129 diff -Naur iptables-1.4.12.1/include/linux/netfilter/xt_IMQ.h iptables-1.4.12.1-imq/include/linux/netfilter/xt_IMQ.h
130 --- iptables-1.4.12.1/include/linux/netfilter/xt_IMQ.h 1970-01-01 02:00:00.000000000 +0200
131 +++ iptables-1.4.12.1-imq/include/linux/netfilter/xt_IMQ.h 2011-09-30 13:53:21.000000000 +0300
136 +struct xt_imq_info {
137 + unsigned int todev; /* target imq device */
140 +#endif /* _XT_IMQ_H */