[NETFILTER]: x_tables: remove unused argument to target functions
[linux-2.6.22.y-op.git] / include / linux / netfilter / x_tables.h
blob9cef0e91542b870e0b0a2e455573c37946b2fe60
1 #ifndef _X_TABLES_H
2 #define _X_TABLES_H
4 #define XT_FUNCTION_MAXNAMELEN 30
5 #define XT_TABLE_MAXNAMELEN 32
7 struct xt_entry_match
9 union {
10 struct {
11 u_int16_t match_size;
13 /* Used by userspace */
14 char name[XT_FUNCTION_MAXNAMELEN-1];
16 u_int8_t revision;
17 } user;
18 struct {
19 u_int16_t match_size;
21 /* Used inside the kernel */
22 struct xt_match *match;
23 } kernel;
25 /* Total length */
26 u_int16_t match_size;
27 } u;
29 unsigned char data[0];
32 struct xt_entry_target
34 union {
35 struct {
36 u_int16_t target_size;
38 /* Used by userspace */
39 char name[XT_FUNCTION_MAXNAMELEN-1];
41 u_int8_t revision;
42 } user;
43 struct {
44 u_int16_t target_size;
46 /* Used inside the kernel */
47 struct xt_target *target;
48 } kernel;
50 /* Total length */
51 u_int16_t target_size;
52 } u;
54 unsigned char data[0];
57 struct xt_standard_target
59 struct xt_entry_target target;
60 int verdict;
63 /* The argument to IPT_SO_GET_REVISION_*. Returns highest revision
64 * kernel supports, if >= revision. */
65 struct xt_get_revision
67 char name[XT_FUNCTION_MAXNAMELEN-1];
69 u_int8_t revision;
72 /* CONTINUE verdict for targets */
73 #define XT_CONTINUE 0xFFFFFFFF
75 /* For standard target */
76 #define XT_RETURN (-NF_REPEAT - 1)
78 /* this is a dummy structure to find out the alignment requirement for a struct
79 * containing all the fundamental data types that are used in ipt_entry,
80 * ip6t_entry and arpt_entry. This sucks, and it is a hack. It will be my
81 * personal pleasure to remove it -HW
83 struct _xt_align
85 u_int8_t u8;
86 u_int16_t u16;
87 u_int32_t u32;
88 u_int64_t u64;
91 #define XT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) \
92 & ~(__alignof__(struct _xt_align)-1))
94 /* Standard return verdict, or do jump. */
95 #define XT_STANDARD_TARGET ""
96 /* Error verdict. */
97 #define XT_ERROR_TARGET "ERROR"
100 * New IP firewall options for [gs]etsockopt at the RAW IP level.
101 * Unlike BSD Linux inherits IP options so you don't have to use a raw
102 * socket for this. Instead we check rights in the calls. */
103 #define XT_BASE_CTL 64 /* base for firewall socket options */
105 #define XT_SO_SET_REPLACE (XT_BASE_CTL)
106 #define XT_SO_SET_ADD_COUNTERS (XT_BASE_CTL + 1)
107 #define XT_SO_SET_MAX XT_SO_SET_ADD_COUNTERS
109 #define XT_SO_GET_INFO (XT_BASE_CTL)
110 #define XT_SO_GET_ENTRIES (XT_BASE_CTL + 1)
111 #define XT_SO_GET_REVISION_MATCH (XT_BASE_CTL + 2)
112 #define XT_SO_GET_REVISION_TARGET (XT_BASE_CTL + 3)
113 #define XT_SO_GET_MAX XT_SO_GET_REVISION_TARGET
115 #define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0)
116 #define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0)
118 struct xt_counters
120 u_int64_t pcnt, bcnt; /* Packet and byte counters */
123 /* The argument to IPT_SO_ADD_COUNTERS. */
124 struct xt_counters_info
126 /* Which table. */
127 char name[XT_TABLE_MAXNAMELEN];
129 unsigned int num_counters;
131 /* The counters (actually `number' of these). */
132 struct xt_counters counters[0];
135 #define XT_INV_PROTO 0x40 /* Invert the sense of PROTO. */
137 #ifdef __KERNEL__
139 #include <linux/netdevice.h>
141 #define ASSERT_READ_LOCK(x)
142 #define ASSERT_WRITE_LOCK(x)
143 #include <linux/netfilter_ipv4/listhelp.h>
145 #ifdef CONFIG_COMPAT
146 #define COMPAT_TO_USER 1
147 #define COMPAT_FROM_USER -1
148 #define COMPAT_CALC_SIZE 0
149 #endif
151 struct xt_match
153 struct list_head list;
155 const char name[XT_FUNCTION_MAXNAMELEN-1];
157 /* Return true or false: return FALSE and set *hotdrop = 1 to
158 force immediate packet drop. */
159 /* Arguments changed since 2.6.9, as this must now handle
160 non-linear skb, using skb_header_pointer and
161 skb_ip_make_writable. */
162 int (*match)(const struct sk_buff *skb,
163 const struct net_device *in,
164 const struct net_device *out,
165 const struct xt_match *match,
166 const void *matchinfo,
167 int offset,
168 unsigned int protoff,
169 int *hotdrop);
171 /* Called when user tries to insert an entry of this type. */
172 /* Should return true or false. */
173 int (*checkentry)(const char *tablename,
174 const void *ip,
175 const struct xt_match *match,
176 void *matchinfo,
177 unsigned int matchinfosize,
178 unsigned int hook_mask);
180 /* Called when entry of this type deleted. */
181 void (*destroy)(const struct xt_match *match, void *matchinfo,
182 unsigned int matchinfosize);
184 /* Called when userspace align differs from kernel space one */
185 int (*compat)(void *match, void **dstptr, int *size, int convert);
187 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
188 struct module *me;
190 char *table;
191 unsigned int matchsize;
192 unsigned int hooks;
193 unsigned short proto;
195 unsigned short family;
196 u_int8_t revision;
199 /* Registration hooks for targets. */
200 struct xt_target
202 struct list_head list;
204 const char name[XT_FUNCTION_MAXNAMELEN-1];
206 /* Returns verdict. Argument order changed since 2.6.9, as this
207 must now handle non-linear skbs, using skb_copy_bits and
208 skb_ip_make_writable. */
209 unsigned int (*target)(struct sk_buff **pskb,
210 const struct net_device *in,
211 const struct net_device *out,
212 unsigned int hooknum,
213 const struct xt_target *target,
214 const void *targinfo);
216 /* Called when user tries to insert an entry of this type:
217 hook_mask is a bitmask of hooks from which it can be
218 called. */
219 /* Should return true or false. */
220 int (*checkentry)(const char *tablename,
221 const void *entry,
222 const struct xt_target *target,
223 void *targinfo,
224 unsigned int targinfosize,
225 unsigned int hook_mask);
227 /* Called when entry of this type deleted. */
228 void (*destroy)(const struct xt_target *target, void *targinfo,
229 unsigned int targinfosize);
231 /* Called when userspace align differs from kernel space one */
232 int (*compat)(void *target, void **dstptr, int *size, int convert);
234 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
235 struct module *me;
237 char *table;
238 unsigned int targetsize;
239 unsigned int hooks;
240 unsigned short proto;
242 unsigned short family;
243 u_int8_t revision;
246 /* Furniture shopping... */
247 struct xt_table
249 struct list_head list;
251 /* A unique name... */
252 char name[XT_TABLE_MAXNAMELEN];
254 /* What hooks you will enter on */
255 unsigned int valid_hooks;
257 /* Lock for the curtain */
258 rwlock_t lock;
260 /* Man behind the curtain... */
261 //struct ip6t_table_info *private;
262 void *private;
264 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
265 struct module *me;
267 int af; /* address/protocol family */
270 #include <linux/netfilter_ipv4.h>
272 /* The table itself */
273 struct xt_table_info
275 /* Size per table */
276 unsigned int size;
277 /* Number of entries: FIXME. --RR */
278 unsigned int number;
279 /* Initial number of entries. Needed for module usage count */
280 unsigned int initial_entries;
282 /* Entry points and underflows */
283 unsigned int hook_entry[NF_IP_NUMHOOKS];
284 unsigned int underflow[NF_IP_NUMHOOKS];
286 /* ipt_entry tables: one per CPU */
287 char *entries[NR_CPUS];
290 extern int xt_register_target(struct xt_target *target);
291 extern void xt_unregister_target(struct xt_target *target);
292 extern int xt_register_targets(struct xt_target *target, unsigned int n);
293 extern void xt_unregister_targets(struct xt_target *target, unsigned int n);
295 extern int xt_register_match(struct xt_match *target);
296 extern void xt_unregister_match(struct xt_match *target);
297 extern int xt_register_matches(struct xt_match *match, unsigned int n);
298 extern void xt_unregister_matches(struct xt_match *match, unsigned int n);
300 extern int xt_check_match(const struct xt_match *match, unsigned short family,
301 unsigned int size, const char *table, unsigned int hook,
302 unsigned short proto, int inv_proto);
303 extern int xt_check_target(const struct xt_target *target, unsigned short family,
304 unsigned int size, const char *table, unsigned int hook,
305 unsigned short proto, int inv_proto);
307 extern int xt_register_table(struct xt_table *table,
308 struct xt_table_info *bootstrap,
309 struct xt_table_info *newinfo);
310 extern void *xt_unregister_table(struct xt_table *table);
312 extern struct xt_table_info *xt_replace_table(struct xt_table *table,
313 unsigned int num_counters,
314 struct xt_table_info *newinfo,
315 int *error);
317 extern struct xt_match *xt_find_match(int af, const char *name, u8 revision);
318 extern struct xt_target *xt_find_target(int af, const char *name, u8 revision);
319 extern struct xt_target *xt_request_find_target(int af, const char *name,
320 u8 revision);
321 extern int xt_find_revision(int af, const char *name, u8 revision, int target,
322 int *err);
324 extern struct xt_table *xt_find_table_lock(int af, const char *name);
325 extern void xt_table_unlock(struct xt_table *t);
327 extern int xt_proto_init(int af);
328 extern void xt_proto_fini(int af);
330 extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
331 extern void xt_free_table_info(struct xt_table_info *info);
333 #ifdef CONFIG_COMPAT
334 #include <net/compat.h>
336 struct compat_xt_entry_match
338 union {
339 struct {
340 u_int16_t match_size;
341 char name[XT_FUNCTION_MAXNAMELEN - 1];
342 u_int8_t revision;
343 } user;
344 struct {
345 u_int16_t match_size;
346 compat_uptr_t match;
347 } kernel;
348 u_int16_t match_size;
349 } u;
350 unsigned char data[0];
353 struct compat_xt_entry_target
355 union {
356 struct {
357 u_int16_t target_size;
358 char name[XT_FUNCTION_MAXNAMELEN - 1];
359 u_int8_t revision;
360 } user;
361 struct {
362 u_int16_t target_size;
363 compat_uptr_t target;
364 } kernel;
365 u_int16_t target_size;
366 } u;
367 unsigned char data[0];
370 /* FIXME: this works only on 32 bit tasks
371 * need to change whole approach in order to calculate align as function of
372 * current task alignment */
374 struct compat_xt_counters
376 #if defined(CONFIG_X86_64) || defined(CONFIG_IA64)
377 u_int32_t cnt[4];
378 #else
379 u_int64_t cnt[2];
380 #endif
383 struct compat_xt_counters_info
385 char name[XT_TABLE_MAXNAMELEN];
386 compat_uint_t num_counters;
387 struct compat_xt_counters counters[0];
390 #define COMPAT_XT_ALIGN(s) (((s) + (__alignof__(struct compat_xt_counters)-1)) \
391 & ~(__alignof__(struct compat_xt_counters)-1))
393 extern void xt_compat_lock(int af);
394 extern void xt_compat_unlock(int af);
395 extern int xt_compat_match(void *match, void **dstptr, int *size, int convert);
396 extern int xt_compat_target(void *target, void **dstptr, int *size,
397 int convert);
399 #endif /* CONFIG_COMPAT */
400 #endif /* __KERNEL__ */
402 #endif /* _X_TABLES_H */