]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/iptables-1.4.6-imq_test1.patch
finished core62.
[people/pmueller/ipfire-2.x.git] / src / patches / iptables-1.4.6-imq_test1.patch
1 diff -Naurw iptables-1.4.1/extensions/.IMQ-testx iptables-1.4.1.imq/extensions/.IMQ-testx
2 --- iptables-1.4.1/extensions/.IMQ-testx 1969-12-31 21:00:00.000000000 -0300
3 +++ iptables-1.4.1.imq/extensions/.IMQ-testx 2008-06-24 22:20:06.000000000 -0300
4 @@ -0,0 +1,3 @@
5 +#!/bin/sh
6 +# True if IMQ target patch is applied.
7 +[ -f $KERNEL_DIR/include/linux/netfilter/xt_IMQ.h ] && echo IMQ
8 diff -Naurw iptables-1.4.1/extensions/libxt_IMQ.c iptables-1.4.1.imq/extensions/libxt_IMQ.c
9 --- iptables-1.4.1/extensions/libxt_IMQ.c 1969-12-31 21:00:00.000000000 -0300
10 +++ iptables-1.4.1.imq/extensions/libxt_IMQ.c 2008-06-24 22:31:02.000000000 -0300
11 @@ -0,0 +1,103 @@
12 +/* Shared library add-on to iptables to add IMQ target support. */
13 +#include <stdio.h>
14 +#include <string.h>
15 +#include <stdlib.h>
16 +#include <getopt.h>
17 +
18 +#include <xtables.h>
19 +#include <linux/netfilter/x_tables.h>
20 +#include <linux/netfilter/xt_IMQ.h>
21 +
22 +/* Function which prints out usage message. */
23 +static void IMQ_help(void)
24 +{
25 + printf(
26 +"IMQ target options:\n"
27 +" --todev <N> enqueue to imq<N>, defaults to 0\n");
28 +
29 +}
30 +
31 +static struct option IMQ_opts[] = {
32 + { "todev", 1, 0, '1' },
33 + { 0 }
34 +};
35 +
36 +/* Initialize the target. */
37 +static void IMQ_init(struct xt_entry_target *t)
38 +{
39 + struct xt_imq_info *mr = (struct xt_imq_info*)t->data;
40 +
41 + mr->todev = 0;
42 +}
43 +
44 +/* Function which parses command options; returns true if it
45 + ate an option */
46 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
47 + const void *entry, struct xt_entry_target **target)
48 +{
49 + struct xt_imq_info *mr = (struct xt_imq_info*)(*target)->data;
50 +
51 + switch(c) {
52 + case '1':
53 + if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
54 + xtables_error(PARAMETER_PROBLEM,
55 + "Unexpected `!' for --todev");
56 + mr->todev=atoi(optarg);
57 + break;
58 + default:
59 + return 0;
60 + }
61 + return 1;
62 +}
63 +
64 +/* Prints out the targinfo. */
65 +static void IMQ_print(const void *ip,
66 + const struct xt_entry_target *target,
67 + int numeric)
68 +{
69 + struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
70 +
71 + printf("IMQ: todev %u ", mr->todev);
72 +}
73 +
74 +/* Saves the union ipt_targinfo in parsable form to stdout. */
75 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
76 +{
77 + struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
78 +
79 + printf("--todev %u", mr->todev);
80 +}
81 +
82 +static struct xtables_target imq_target = {
83 + .name = "IMQ",
84 + .version = XTABLES_VERSION,
85 + .family = NFPROTO_IPV4,
86 + .size = XT_ALIGN(sizeof(struct xt_imq_info)),
87 + .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)),
88 + .help = IMQ_help,
89 + .init = IMQ_init,
90 + .parse = IMQ_parse,
91 + .print = IMQ_print,
92 + .save = IMQ_save,
93 + .extra_opts = IMQ_opts,
94 +};
95 +
96 +static struct xtables_target imq_target6 = {
97 + .name = "IMQ",
98 + .version = XTABLES_VERSION,
99 + .family = NFPROTO_IPV6,
100 + .size = XT_ALIGN(sizeof(struct xt_imq_info)),
101 + .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)),
102 + .help = IMQ_help,
103 + .init = IMQ_init,
104 + .parse = IMQ_parse,
105 + .print = IMQ_print,
106 + .save = IMQ_save,
107 + .extra_opts = IMQ_opts,
108 +};
109 +
110 +// void __attribute((constructor)) nf_ext_init(void){
111 +void _init(void){
112 + xtables_register_target(&imq_target);
113 + xtables_register_target(&imq_target6);
114 +}
115 --- iptables-1.4.1.1/include/linux/netfilter/xt_IMQ.h 1970-01-01 02:00:00.000000000 +0200
116 +++ iptables-1.4.1.1.new/include/linux/netfilter/xt_IMQ.h 2008-08-05 00:41:28.000000000 +0300
117 @@ -0,0 +1,9 @@
118 +#ifndef _XT_IMQ_H
119 +#define _XT_IMQ_H
120 +
121 +struct xt_imq_info {
122 + unsigned int todev; /* target imq device */
123 +};
124 +
125 +#endif /* _XT_IMQ_H */
126 +