63617076bd48d23b17e9b6d18a888c053deb62ea
[openwrt/svn-archive/archive.git] / package / iptables / patches / 1.4.0 / 005-imq1.patch
1 --- iptables-1.4.0.orig/extensions.orig/.IMQ-test6 Thu Jan 1 01:00:00 1970
2 +++ iptables-1.4.0/extensions/.IMQ-test6 Mon Jun 16 10:12:47 2003
3 @@ -0,0 +1,3 @@
4 +#!/bin/sh
5 +# True if IMQ target patch is applied.
6 +[ -f $KERNEL_DIR/include/linux/netfilter_ipv6/ip6t_IMQ.h ] && echo IMQ
7 --- iptables-1.4.0.orig/extensions.orig/libip6t_IMQ.c Thu Jan 1 01:00:00 1970
8 +++ iptables-1.4.0/extensions/libip6t_IMQ.c Mon Jun 16 10:12:47 2003
9 @@ -0,0 +1,100 @@
10 +/* Shared library add-on to iptables to add IMQ target support. */
11 +#include <stdio.h>
12 +#include <string.h>
13 +#include <stdlib.h>
14 +#include <getopt.h>
15 +
16 +#include <ip6tables.h>
17 +#include <linux/netfilter_ipv6/ip6_tables.h>
18 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
19 +
20 +/* Function which prints out usage message. */
21 +static void
22 +help(void)
23 +{
24 + printf(
25 +"IMQ target v%s options:\n"
26 +" --todev <N> enqueue to imq<N>, defaults to 0\n",
27 +IPTABLES_VERSION);
28 +}
29 +
30 +static struct option opts[] = {
31 + { "todev", 1, 0, '1' },
32 + { 0 }
33 +};
34 +
35 +/* Initialize the target. */
36 +static void
37 +init(struct xt_entry_target *t)
38 +{
39 + struct ip6t_imq_info *mr = (struct ip6t_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
47 +parse(int c, char **argv, int invert, unsigned int *flags,
48 + const void *entry,
49 + struct xt_entry_target **target)
50 +{
51 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)(*target)->data;
52 +
53 + switch(c) {
54 + case '1':
55 + if (check_inverse(optarg, &invert, NULL, 0))
56 + exit_error(PARAMETER_PROBLEM,
57 + "Unexpected `!' after --todev");
58 + mr->todev=atoi(optarg);
59 + break;
60 + default:
61 + return 0;
62 + }
63 + return 1;
64 +}
65 +
66 +static void
67 +final_check(unsigned int flags)
68 +{
69 +}
70 +
71 +/* Prints out the targinfo. */
72 +static void
73 +print(const void *ip,
74 + const struct xt_entry_target *target,
75 + int numeric)
76 +{
77 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
78 +
79 + printf("IMQ: todev %u ", mr->todev);
80 +}
81 +
82 +/* Saves the union ipt_targinfo in parsable form to stdout. */
83 +static void
84 +save(const void *ip, const struct xt_entry_target *target)
85 +{
86 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
87 +
88 + printf("--todev %u", mr->todev);
89 +}
90 +
91 +static struct ip6tables_target imq = {
92 + .next = NULL,
93 + .name = "IMQ",
94 + .version = IPTABLES_VERSION,
95 + .size = IP6T_ALIGN(sizeof(struct ip6t_imq_info)),
96 + .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_imq_info)),
97 + .help = &help,
98 + .init = &init,
99 + .parse = &parse,
100 + .final_check = &final_check,
101 + .print = &print,
102 + .save = &save,
103 + .extra_opts = opts
104 +};
105 +
106 +static __attribute__((constructor)) void _init(void)
107 +{
108 + register_target6(&imq);
109 +}
110 --- iptables-1.4.0.orig/extensions.orig/.IMQ-test Thu Jan 1 01:00:00 1970
111 +++ iptables-1.4.0/extensions/.IMQ-test Mon Jun 16 10:12:47 2003
112 @@ -0,0 +1,3 @@
113 +#!/bin/sh
114 +# True if IMQ target patch is applied.
115 +[ -f $KERNEL_DIR/include/linux/netfilter_ipv4/ipt_IMQ.h ] && echo IMQ
116 --- iptables-1.4.0.orig/extensions.orig/libipt_IMQ.c Thu Jan 1 01:00:00 1970
117 +++ iptables-1.4.0/extensions/libipt_IMQ.c Mon Jun 16 10:12:47 2003
118 @@ -0,0 +1,100 @@
119 +/* Shared library add-on to iptables to add IMQ target support. */
120 +#include <stdio.h>
121 +#include <string.h>
122 +#include <stdlib.h>
123 +#include <getopt.h>
124 +
125 +#include <iptables.h>
126 +#include <linux/netfilter_ipv4/ip_tables.h>
127 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
128 +
129 +/* Function which prints out usage message. */
130 +static void
131 +help(void)
132 +{
133 + printf(
134 +"IMQ target v%s options:\n"
135 +" --todev <N> enqueue to imq<N>, defaults to 0\n",
136 +IPTABLES_VERSION);
137 +}
138 +
139 +static struct option opts[] = {
140 + { "todev", 1, 0, '1' },
141 + { 0 }
142 +};
143 +
144 +/* Initialize the target. */
145 +static void
146 +init(struct xt_entry_target *t)
147 +{
148 + struct ipt_imq_info *mr = (struct ipt_imq_info*)t->data;
149 +
150 + mr->todev = 0;
151 +}
152 +
153 +/* Function which parses command options; returns true if it
154 + ate an option */
155 +static int
156 +parse(int c, char **argv, int invert, unsigned int *flags,
157 + const void *entry,
158 + struct xt_entry_target **target)
159 +{
160 + struct ipt_imq_info *mr = (struct ipt_imq_info*)(*target)->data;
161 +
162 + switch(c) {
163 + case '1':
164 + if (check_inverse(optarg, &invert, NULL, 0))
165 + exit_error(PARAMETER_PROBLEM,
166 + "Unexpected `!' after --todev");
167 + mr->todev=atoi(optarg);
168 + break;
169 + default:
170 + return 0;
171 + }
172 + return 1;
173 +}
174 +
175 +static void
176 +final_check(unsigned int flags)
177 +{
178 +}
179 +
180 +/* Prints out the targinfo. */
181 +static void
182 +print(const void *ip,
183 + const struct xt_entry_target *target,
184 + int numeric)
185 +{
186 + struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
187 +
188 + printf("IMQ: todev %u ", mr->todev);
189 +}
190 +
191 +/* Saves the union ipt_targinfo in parsable form to stdout. */
192 +static void
193 +save(const void *ip, const struct xt_entry_target *target)
194 +{
195 + struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
196 +
197 + printf("--todev %u", mr->todev);
198 +}
199 +
200 +static struct iptables_target imq = {
201 + .next = NULL,
202 + .name = "IMQ",
203 + .version = IPTABLES_VERSION,
204 + .size = IPT_ALIGN(sizeof(struct ipt_imq_info)),
205 + .userspacesize = IPT_ALIGN(sizeof(struct ipt_imq_info)),
206 + .help = &help,
207 + .init = &init,
208 + .parse = &parse,
209 + .final_check = &final_check,
210 + .print = &print,
211 + .save = &save,
212 + .extra_opts = opts
213 +};
214 +
215 +static __attribute__((constructor)) void _init(void)
216 +{
217 + register_target(&imq);
218 +}
219