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