MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / linux / netfilter / x_tables.h
blob022edfa97ed977dfe6fd8f74b28472804067d5a8
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"
99 #define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0)
100 #define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0)
102 struct xt_counters
104 u_int64_t pcnt, bcnt; /* Packet and byte counters */
107 /* The argument to IPT_SO_ADD_COUNTERS. */
108 struct xt_counters_info
110 /* Which table. */
111 char name[XT_TABLE_MAXNAMELEN];
113 unsigned int num_counters;
115 /* The counters (actually `number' of these). */
116 struct xt_counters counters[0];
119 #define XT_INV_PROTO 0x40 /* Invert the sense of PROTO. */
121 #ifdef __KERNEL__
123 #include <linux/netdevice.h>
125 struct xt_match
127 struct list_head list;
129 const char name[XT_FUNCTION_MAXNAMELEN-1];
131 /* Return true or false: return FALSE and set *hotdrop = 1 to
132 force immediate packet drop. */
133 /* Arguments changed since 2.6.9, as this must now handle
134 non-linear skb, using skb_header_pointer and
135 skb_ip_make_writable. */
136 int (*match)(const struct sk_buff *skb,
137 const struct net_device *in,
138 const struct net_device *out,
139 const struct xt_match *match,
140 const void *matchinfo,
141 int offset,
142 unsigned int protoff,
143 int *hotdrop);
145 /* Called when user tries to insert an entry of this type. */
146 /* Should return true or false. */
147 int (*checkentry)(const char *tablename,
148 const void *ip,
149 const struct xt_match *match,
150 void *matchinfo,
151 unsigned int hook_mask);
153 /* Called when entry of this type deleted. */
154 void (*destroy)(const struct xt_match *match, void *matchinfo);
156 /* Called when userspace align differs from kernel space one */
157 void (*compat_from_user)(void *dst, void *src);
158 int (*compat_to_user)(void __user *dst, void *src);
160 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
161 struct module *me;
163 /* Free to use by each match */
164 unsigned long data;
166 char *table;
167 unsigned int matchsize;
168 unsigned int compatsize;
169 unsigned int hooks;
170 unsigned short proto;
172 unsigned short family;
173 u_int8_t revision;
176 /* Registration hooks for targets. */
177 struct xt_target
179 struct list_head list;
181 const char name[XT_FUNCTION_MAXNAMELEN-1];
183 /* Returns verdict. Argument order changed since 2.6.9, as this
184 must now handle non-linear skbs, using skb_copy_bits and
185 skb_ip_make_writable. */
186 unsigned int (*target)(struct sk_buff **pskb,
187 const struct net_device *in,
188 const struct net_device *out,
189 unsigned int hooknum,
190 const struct xt_target *target,
191 const void *targinfo);
193 /* Called when user tries to insert an entry of this type:
194 hook_mask is a bitmask of hooks from which it can be
195 called. */
196 /* Should return true or false. */
197 int (*checkentry)(const char *tablename,
198 const void *entry,
199 const struct xt_target *target,
200 void *targinfo,
201 unsigned int hook_mask);
203 /* Called when entry of this type deleted. */
204 void (*destroy)(const struct xt_target *target, void *targinfo);
206 /* Called when userspace align differs from kernel space one */
207 void (*compat_from_user)(void *dst, void *src);
208 int (*compat_to_user)(void __user *dst, void *src);
210 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
211 struct module *me;
213 char *table;
214 unsigned int targetsize;
215 unsigned int compatsize;
216 unsigned int hooks;
217 unsigned short proto;
219 unsigned short family;
220 u_int8_t revision;
223 /* Furniture shopping... */
224 struct xt_table
226 struct list_head list;
228 /* A unique name... */
229 char name[XT_TABLE_MAXNAMELEN];
231 /* What hooks you will enter on */
232 unsigned int valid_hooks;
234 /* Lock for the curtain */
235 rwlock_t lock;
237 /* Man behind the curtain... */
238 //struct ip6t_table_info *private;
239 void *private;
241 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
242 struct module *me;
244 int af; /* address/protocol family */
247 #include <linux/netfilter_ipv4.h>
249 /* The table itself */
250 struct xt_table_info
252 /* Size per table */
253 unsigned int size;
254 /* Number of entries: FIXME. --RR */
255 unsigned int number;
256 /* Initial number of entries. Needed for module usage count */
257 unsigned int initial_entries;
259 /* Entry points and underflows */
260 unsigned int hook_entry[NF_IP_NUMHOOKS];
261 unsigned int underflow[NF_IP_NUMHOOKS];
263 /* ipt_entry tables: one per CPU */
264 char *entries[NR_CPUS];
267 extern int xt_register_target(struct xt_target *target);
268 extern void xt_unregister_target(struct xt_target *target);
269 extern int xt_register_targets(struct xt_target *target, unsigned int n);
270 extern void xt_unregister_targets(struct xt_target *target, unsigned int n);
272 extern int xt_register_match(struct xt_match *target);
273 extern void xt_unregister_match(struct xt_match *target);
274 extern int xt_register_matches(struct xt_match *match, unsigned int n);
275 extern void xt_unregister_matches(struct xt_match *match, unsigned int n);
277 extern int xt_check_match(const struct xt_match *match, unsigned short family,
278 unsigned int size, const char *table, unsigned int hook,
279 unsigned short proto, int inv_proto);
280 extern int xt_check_target(const struct xt_target *target, unsigned short family,
281 unsigned int size, const char *table, unsigned int hook,
282 unsigned short proto, int inv_proto);
284 extern int xt_register_table(struct xt_table *table,
285 struct xt_table_info *bootstrap,
286 struct xt_table_info *newinfo);
287 extern void *xt_unregister_table(struct xt_table *table);
289 extern struct xt_table_info *xt_replace_table(struct xt_table *table,
290 unsigned int num_counters,
291 struct xt_table_info *newinfo,
292 int *error);
294 extern struct xt_match *xt_find_match(int af, const char *name, u8 revision);
295 extern struct xt_target *xt_find_target(int af, const char *name, u8 revision);
296 extern struct xt_target *xt_request_find_target(int af, const char *name,
297 u8 revision);
298 extern int xt_find_revision(int af, const char *name, u8 revision, int target,
299 int *err);
301 extern struct xt_table *xt_find_table_lock(int af, const char *name);
302 extern void xt_table_unlock(struct xt_table *t);
304 extern int xt_proto_init(int af);
305 extern void xt_proto_fini(int af);
307 extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
308 extern void xt_free_table_info(struct xt_table_info *info);
310 #ifdef CONFIG_COMPAT
311 #include <net/compat.h>
313 struct compat_xt_entry_match
315 union {
316 struct {
317 u_int16_t match_size;
318 char name[XT_FUNCTION_MAXNAMELEN - 1];
319 u_int8_t revision;
320 } user;
321 struct {
322 u_int16_t match_size;
323 compat_uptr_t match;
324 } kernel;
325 u_int16_t match_size;
326 } u;
327 unsigned char data[0];
330 struct compat_xt_entry_target
332 union {
333 struct {
334 u_int16_t target_size;
335 char name[XT_FUNCTION_MAXNAMELEN - 1];
336 u_int8_t revision;
337 } user;
338 struct {
339 u_int16_t target_size;
340 compat_uptr_t target;
341 } kernel;
342 u_int16_t target_size;
343 } u;
344 unsigned char data[0];
347 /* FIXME: this works only on 32 bit tasks
348 * need to change whole approach in order to calculate align as function of
349 * current task alignment */
351 struct compat_xt_counters
353 #if defined(CONFIG_X86_64) || defined(CONFIG_IA64)
354 u_int32_t cnt[4];
355 #else
356 u_int64_t cnt[2];
357 #endif
360 struct compat_xt_counters_info
362 char name[XT_TABLE_MAXNAMELEN];
363 compat_uint_t num_counters;
364 struct compat_xt_counters counters[0];
367 #define COMPAT_XT_ALIGN(s) (((s) + (__alignof__(struct compat_xt_counters)-1)) \
368 & ~(__alignof__(struct compat_xt_counters)-1))
370 extern void xt_compat_lock(int af);
371 extern void xt_compat_unlock(int af);
373 extern int xt_compat_match_offset(struct xt_match *match);
374 extern void xt_compat_match_from_user(struct xt_entry_match *m,
375 void **dstptr, int *size);
376 extern int xt_compat_match_to_user(struct xt_entry_match *m,
377 void __user **dstptr, int *size);
379 extern int xt_compat_target_offset(struct xt_target *target);
380 extern void xt_compat_target_from_user(struct xt_entry_target *t,
381 void **dstptr, int *size);
382 extern int xt_compat_target_to_user(struct xt_entry_target *t,
383 void __user **dstptr, int *size);
385 #endif /* CONFIG_COMPAT */
386 #endif /* __KERNEL__ */
388 #endif /* _X_TABLES_H */