fix a crash in ip175c attribute enumeration
[openwrt.git] / package / iptables / patches / 1.4.3.2 / 005-imq1.patch
1 --- /dev/null
2 +++ b/extensions/.IMQ-test
3 @@ -0,0 +1,3 @@
4 +#!/bin/sh
5 +# True if IMQ target patch is applied.
6 +[ -f $KERNEL_DIR/include/linux/netfilter_ipv4/ipt_IMQ.h ] && echo IMQ
7 --- /dev/null
8 +++ b/extensions/.IMQ-test6
9 @@ -0,0 +1,3 @@
10 +#!/bin/sh
11 +# True if IMQ target patch is applied.
12 +[ -f $KERNEL_DIR/include/linux/netfilter_ipv6/ip6t_IMQ.h ] && echo IMQ
13 --- /dev/null
14 +++ b/extensions/libip6t_IMQ.c
15 @@ -0,0 +1,90 @@
16 +/* Shared library add-on to iptables to add IMQ target support. */
17 +#include <stdio.h>
18 +#include <string.h>
19 +#include <stdlib.h>
20 +#include <getopt.h>
21 +
22 +#include <xtables.h>
23 +#include <ip6tables.h>
24 +#include <linux/netfilter_ipv6/ip6_tables.h>
25 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
26 +
27 +/* Function which prints out usage message. */
28 +static void IMQ_help(void)
29 +{
30 + printf(
31 +"IMQ target v%s options:\n"
32 +" --todev <N> enqueue to imq<N>, defaults to 0\n",
33 +XTABLES_VERSION);
34 +}
35 +
36 +static struct option IMQ_opts[] = {
37 + { "todev", 1, 0, '1' },
38 + { 0 }
39 +};
40 +
41 +/* Initialize the target. */
42 +static void IMQ_init(struct xt_entry_target *t)
43 +{
44 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)t->data;
45 +
46 + mr->todev = 0;
47 +}
48 +
49 +/* Function which parses command options; returns true if it
50 + ate an option */
51 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
52 + const void *entry,
53 + struct xt_entry_target **target)
54 +{
55 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)(*target)->data;
56 +
57 + switch(c) {
58 + case '1':
59 + if (xtables_check_inverse(optarg, &invert, NULL, 0))
60 + xtables_error(PARAMETER_PROBLEM,
61 + "Unexpected `!' after --todev");
62 + mr->todev=atoi(optarg);
63 + break;
64 + default:
65 + return 0;
66 + }
67 + return 1;
68 +}
69 +
70 +/* Prints out the targinfo. */
71 +static void IMQ_print(const void *ip,
72 + const struct xt_entry_target *target,
73 + int numeric)
74 +{
75 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
76 +
77 + printf("IMQ: todev %u ", mr->todev);
78 +}
79 +
80 +/* Saves the union ipt_targinfo in parsable form to stdout. */
81 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
82 +{
83 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data;
84 +
85 + printf("--todev %u", mr->todev);
86 +}
87 +
88 +static struct xtables_target imq = {
89 + .name = "IMQ",
90 + .version = XTABLES_VERSION,
91 + .family = PF_INET6,
92 + .size = XT_ALIGN(sizeof(struct ip6t_imq_info)),
93 + .userspacesize = XT_ALIGN(sizeof(struct ip6t_imq_info)),
94 + .help = IMQ_help,
95 + .init = IMQ_init,
96 + .parse = IMQ_parse,
97 + .print = IMQ_print,
98 + .save = IMQ_save,
99 + .extra_opts = IMQ_opts,
100 +};
101 +
102 +void _init(void)
103 +{
104 + xtables_register_target(&imq);
105 +}
106 --- /dev/null
107 +++ b/extensions/libipt_IMQ.c
108 @@ -0,0 +1,89 @@
109 +/* Shared library add-on to iptables to add IMQ target support. */
110 +#include <stdio.h>
111 +#include <string.h>
112 +#include <stdlib.h>
113 +#include <getopt.h>
114 +
115 +#include <xtables.h>
116 +#include <iptables.h>
117 +#include <linux/netfilter_ipv4/ip_tables.h>
118 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
119 +
120 +/* Function which prints out usage message. */
121 +static void IMQ_help(void)
122 +{
123 + printf(
124 +"IMQ target v%s options:\n"
125 +" --todev <N> enqueue to imq<N>, defaults to 0\n",
126 +XTABLES_VERSION);
127 +}
128 +
129 +static struct option IMQ_opts[] = {
130 + { "todev", 1, 0, '1' },
131 + { 0 }
132 +};
133 +
134 +/* Initialize the target. */
135 +static void IMQ_init(struct xt_entry_target *t)
136 +{
137 + struct ipt_imq_info *mr = (struct ipt_imq_info*)t->data;
138 +
139 + mr->todev = 0;
140 +}
141 +
142 +/* Function which parses command options; returns true if it
143 + ate an option */
144 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
145 + const void *entry, struct xt_entry_target **target)
146 +{
147 + struct ipt_imq_info *mr = (struct ipt_imq_info*)(*target)->data;
148 +
149 + switch(c) {
150 + case '1':
151 + if (xtables_check_inverse(optarg, &invert, NULL, 0))
152 + xtables_error(PARAMETER_PROBLEM,
153 + "Unexpected `!' after --todev");
154 + mr->todev=atoi(optarg);
155 + break;
156 + default:
157 + return 0;
158 + }
159 + return 1;
160 +}
161 +
162 +/* Prints out the targinfo. */
163 +static void IMQ_print(const void *ip,
164 + const struct xt_entry_target *target,
165 + int numeric)
166 +{
167 + struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
168 +
169 + printf("IMQ: todev %u ", mr->todev);
170 +}
171 +
172 +/* Saves the union ipt_targinfo in parsable form to stdout. */
173 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
174 +{
175 + struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data;
176 +
177 + printf("--todev %u", mr->todev);
178 +}
179 +
180 +static struct xtables_target imq = {
181 + .name = "IMQ",
182 + .version = XTABLES_VERSION,
183 + .family = PF_INET,
184 + .size = XT_ALIGN(sizeof(struct ipt_imq_info)),
185 + .userspacesize = XT_ALIGN(sizeof(struct ipt_imq_info)),
186 + .help = IMQ_help,
187 + .init = IMQ_init,
188 + .parse = IMQ_parse,
189 + .print = IMQ_print,
190 + .save = IMQ_save,
191 + .extra_opts = IMQ_opts,
192 +};
193 +
194 +void _init(void)
195 +{
196 + xtables_register_target(&imq);
197 +}
This page took 0.048482 seconds and 5 git commands to generate.