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