diff options
author | Patrick McHardy <kaber@trash.net> | 2007-05-10 17:14:16 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-05-11 02:47:43 -0400 |
commit | 3c2ad469c317147fc1de19579f8173ddb68a9e91 (patch) | |
tree | ce2e5499e113d4fd5f5a4c158340549da1ce572b /include/linux | |
parent | 41a23b0788610b27ecb4c4ee857f3fe7168f1070 (diff) |
[NETFILTER]: Clean up table initialization
- move arp_tables initial table structure definitions to arp_tables.h
similar to ip_tables and ip6_tables
- use C99 initializers
- use initializer macros where possible
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/netfilter/x_tables.h | 8 | ||||
-rw-r--r-- | include/linux/netfilter_arp/arp_tables.h | 41 | ||||
-rw-r--r-- | include/linux/netfilter_ipv4/ip_tables.h | 22 | ||||
-rw-r--r-- | include/linux/netfilter_ipv6/ip6_tables.h | 22 |
4 files changed, 93 insertions, 0 deletions
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 022edfa97ed9..7e733a6ba4f6 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h | |||
@@ -54,6 +54,14 @@ struct xt_entry_target | |||
54 | unsigned char data[0]; | 54 | unsigned char data[0]; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | #define XT_TARGET_INIT(__name, __size) \ | ||
58 | { \ | ||
59 | .target.u.user = { \ | ||
60 | .target_size = XT_ALIGN(__size), \ | ||
61 | .name = __name, \ | ||
62 | }, \ | ||
63 | } | ||
64 | |||
57 | struct xt_standard_target | 65 | struct xt_standard_target |
58 | { | 66 | { |
59 | struct xt_entry_target target; | 67 | struct xt_entry_target target; |
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h index 24c8786d12e9..584cd1b18f12 100644 --- a/include/linux/netfilter_arp/arp_tables.h +++ b/include/linux/netfilter_arp/arp_tables.h | |||
@@ -238,6 +238,47 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e | |||
238 | */ | 238 | */ |
239 | #ifdef __KERNEL__ | 239 | #ifdef __KERNEL__ |
240 | 240 | ||
241 | /* Standard entry. */ | ||
242 | struct arpt_standard | ||
243 | { | ||
244 | struct arpt_entry entry; | ||
245 | struct arpt_standard_target target; | ||
246 | }; | ||
247 | |||
248 | struct arpt_error_target | ||
249 | { | ||
250 | struct arpt_entry_target target; | ||
251 | char errorname[ARPT_FUNCTION_MAXNAMELEN]; | ||
252 | }; | ||
253 | |||
254 | struct arpt_error | ||
255 | { | ||
256 | struct arpt_entry entry; | ||
257 | struct arpt_error_target target; | ||
258 | }; | ||
259 | |||
260 | #define ARPT_ENTRY_INIT(__size) \ | ||
261 | { \ | ||
262 | .target_offset = sizeof(struct arpt_entry), \ | ||
263 | .next_offset = (__size), \ | ||
264 | } | ||
265 | |||
266 | #define ARPT_STANDARD_INIT(__verdict) \ | ||
267 | { \ | ||
268 | .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \ | ||
269 | .target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \ | ||
270 | sizeof(struct arpt_standard_target)), \ | ||
271 | .target.verdict = -(__verdict) - 1, \ | ||
272 | } | ||
273 | |||
274 | #define ARPT_ERROR_INIT \ | ||
275 | { \ | ||
276 | .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \ | ||
277 | .target = XT_TARGET_INIT(ARPT_ERROR_TARGET, \ | ||
278 | sizeof(struct arpt_error_target)), \ | ||
279 | .target.errorname = "ERROR", \ | ||
280 | } | ||
281 | |||
241 | #define arpt_register_target(tgt) \ | 282 | #define arpt_register_target(tgt) \ |
242 | ({ (tgt)->family = NF_ARP; \ | 283 | ({ (tgt)->family = NF_ARP; \ |
243 | xt_register_target(tgt); }) | 284 | xt_register_target(tgt); }) |
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h index 9527296595cd..2f46dd728ee1 100644 --- a/include/linux/netfilter_ipv4/ip_tables.h +++ b/include/linux/netfilter_ipv4/ip_tables.h | |||
@@ -295,6 +295,28 @@ struct ipt_error | |||
295 | struct ipt_error_target target; | 295 | struct ipt_error_target target; |
296 | }; | 296 | }; |
297 | 297 | ||
298 | #define IPT_ENTRY_INIT(__size) \ | ||
299 | { \ | ||
300 | .target_offset = sizeof(struct ipt_entry), \ | ||
301 | .next_offset = (__size), \ | ||
302 | } | ||
303 | |||
304 | #define IPT_STANDARD_INIT(__verdict) \ | ||
305 | { \ | ||
306 | .entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \ | ||
307 | .target = XT_TARGET_INIT(IPT_STANDARD_TARGET, \ | ||
308 | sizeof(struct xt_standard_target)), \ | ||
309 | .target.verdict = -(__verdict) - 1, \ | ||
310 | } | ||
311 | |||
312 | #define IPT_ERROR_INIT \ | ||
313 | { \ | ||
314 | .entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \ | ||
315 | .target = XT_TARGET_INIT(IPT_ERROR_TARGET, \ | ||
316 | sizeof(struct ipt_error_target)), \ | ||
317 | .target.errorname = "ERROR", \ | ||
318 | } | ||
319 | |||
298 | extern unsigned int ipt_do_table(struct sk_buff **pskb, | 320 | extern unsigned int ipt_do_table(struct sk_buff **pskb, |
299 | unsigned int hook, | 321 | unsigned int hook, |
300 | const struct net_device *in, | 322 | const struct net_device *in, |
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h index 61aa10412fc8..4686f8342cbd 100644 --- a/include/linux/netfilter_ipv6/ip6_tables.h +++ b/include/linux/netfilter_ipv6/ip6_tables.h | |||
@@ -123,6 +123,28 @@ struct ip6t_error | |||
123 | struct ip6t_error_target target; | 123 | struct ip6t_error_target target; |
124 | }; | 124 | }; |
125 | 125 | ||
126 | #define IP6T_ENTRY_INIT(__size) \ | ||
127 | { \ | ||
128 | .target_offset = sizeof(struct ip6t_entry), \ | ||
129 | .next_offset = (__size), \ | ||
130 | } | ||
131 | |||
132 | #define IP6T_STANDARD_INIT(__verdict) \ | ||
133 | { \ | ||
134 | .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \ | ||
135 | .target = XT_TARGET_INIT(IP6T_STANDARD_TARGET, \ | ||
136 | sizeof(struct ip6t_standard_target)), \ | ||
137 | .target.verdict = -(__verdict) - 1, \ | ||
138 | } | ||
139 | |||
140 | #define IP6T_ERROR_INIT \ | ||
141 | { \ | ||
142 | .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \ | ||
143 | .target = XT_TARGET_INIT(IP6T_ERROR_TARGET, \ | ||
144 | sizeof(struct ip6t_error_target)), \ | ||
145 | .target.errorname = "ERROR", \ | ||
146 | } | ||
147 | |||
126 | /* | 148 | /* |
127 | * New IP firewall options for [gs]etsockopt at the RAW IP level. | 149 | * New IP firewall options for [gs]etsockopt at the RAW IP level. |
128 | * Unlike BSD Linux inherits IP options so you don't have to use | 150 | * Unlike BSD Linux inherits IP options so you don't have to use |