4 #define XT_FUNCTION_MAXNAMELEN 30
5 #define XT_TABLE_MAXNAMELEN 32
13 /* Used by userspace */
14 char name
[XT_FUNCTION_MAXNAMELEN
-1];
21 /* Used inside the kernel */
22 struct xt_match
*match
;
29 unsigned char data
[0];
32 struct xt_entry_target
36 u_int16_t target_size
;
38 /* Used by userspace */
39 char name
[XT_FUNCTION_MAXNAMELEN
-1];
44 u_int16_t target_size
;
46 /* Used inside the kernel */
47 struct xt_target
*target
;
51 u_int16_t target_size
;
54 unsigned char data
[0];
57 struct xt_standard_target
59 struct xt_entry_target target
;
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];
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
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 ""
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)
120 u_int64_t pcnt
, bcnt
; /* Packet and byte counters */
123 /* The argument to IPT_SO_ADD_COUNTERS. */
124 struct xt_counters_info
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. */
139 #include <linux/netdevice.h>
143 struct list_head list
;
145 const char name
[XT_FUNCTION_MAXNAMELEN
-1];
147 /* Return true or false: return FALSE and set *hotdrop = 1 to
148 force immediate packet drop. */
149 /* Arguments changed since 2.6.9, as this must now handle
150 non-linear skb, using skb_header_pointer and
151 skb_ip_make_writable. */
152 int (*match
)(const struct sk_buff
*skb
,
153 const struct net_device
*in
,
154 const struct net_device
*out
,
155 const struct xt_match
*match
,
156 const void *matchinfo
,
158 unsigned int protoff
,
161 /* Called when user tries to insert an entry of this type. */
162 /* Should return true or false. */
163 int (*checkentry
)(const char *tablename
,
165 const struct xt_match
*match
,
167 unsigned int hook_mask
);
169 /* Called when entry of this type deleted. */
170 void (*destroy
)(const struct xt_match
*match
, void *matchinfo
);
172 /* Called when userspace align differs from kernel space one */
173 void (*compat_from_user
)(void *dst
, void *src
);
174 int (*compat_to_user
)(void __user
*dst
, void *src
);
176 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
179 /* Free to use by each match */
183 unsigned int matchsize
;
184 unsigned int compatsize
;
186 unsigned short proto
;
188 unsigned short family
;
192 /* Registration hooks for targets. */
195 struct list_head list
;
197 const char name
[XT_FUNCTION_MAXNAMELEN
-1];
199 /* Returns verdict. Argument order changed since 2.6.9, as this
200 must now handle non-linear skbs, using skb_copy_bits and
201 skb_ip_make_writable. */
202 unsigned int (*target
)(struct sk_buff
**pskb
,
203 const struct net_device
*in
,
204 const struct net_device
*out
,
205 unsigned int hooknum
,
206 const struct xt_target
*target
,
207 const void *targinfo
);
209 /* Called when user tries to insert an entry of this type:
210 hook_mask is a bitmask of hooks from which it can be
212 /* Should return true or false. */
213 int (*checkentry
)(const char *tablename
,
215 const struct xt_target
*target
,
217 unsigned int hook_mask
);
219 /* Called when entry of this type deleted. */
220 void (*destroy
)(const struct xt_target
*target
, void *targinfo
);
222 /* Called when userspace align differs from kernel space one */
223 void (*compat_from_user
)(void *dst
, void *src
);
224 int (*compat_to_user
)(void __user
*dst
, void *src
);
226 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
230 unsigned int targetsize
;
231 unsigned int compatsize
;
233 unsigned short proto
;
235 unsigned short family
;
239 /* Furniture shopping... */
242 struct list_head list
;
244 /* A unique name... */
245 char name
[XT_TABLE_MAXNAMELEN
];
247 /* What hooks you will enter on */
248 unsigned int valid_hooks
;
250 /* Lock for the curtain */
253 /* Man behind the curtain... */
254 //struct ip6t_table_info *private;
257 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
260 int af
; /* address/protocol family */
263 #include <linux/netfilter_ipv4.h>
265 /* The table itself */
270 /* Number of entries: FIXME. --RR */
272 /* Initial number of entries. Needed for module usage count */
273 unsigned int initial_entries
;
275 /* Entry points and underflows */
276 unsigned int hook_entry
[NF_IP_NUMHOOKS
];
277 unsigned int underflow
[NF_IP_NUMHOOKS
];
279 /* ipt_entry tables: one per CPU */
280 char *entries
[NR_CPUS
];
283 extern int xt_register_target(struct xt_target
*target
);
284 extern void xt_unregister_target(struct xt_target
*target
);
285 extern int xt_register_targets(struct xt_target
*target
, unsigned int n
);
286 extern void xt_unregister_targets(struct xt_target
*target
, unsigned int n
);
288 extern int xt_register_match(struct xt_match
*target
);
289 extern void xt_unregister_match(struct xt_match
*target
);
290 extern int xt_register_matches(struct xt_match
*match
, unsigned int n
);
291 extern void xt_unregister_matches(struct xt_match
*match
, unsigned int n
);
293 extern int xt_check_match(const struct xt_match
*match
, unsigned short family
,
294 unsigned int size
, const char *table
, unsigned int hook
,
295 unsigned short proto
, int inv_proto
);
296 extern int xt_check_target(const struct xt_target
*target
, unsigned short family
,
297 unsigned int size
, const char *table
, unsigned int hook
,
298 unsigned short proto
, int inv_proto
);
300 extern int xt_register_table(struct xt_table
*table
,
301 struct xt_table_info
*bootstrap
,
302 struct xt_table_info
*newinfo
);
303 extern void *xt_unregister_table(struct xt_table
*table
);
305 extern struct xt_table_info
*xt_replace_table(struct xt_table
*table
,
306 unsigned int num_counters
,
307 struct xt_table_info
*newinfo
,
310 extern struct xt_match
*xt_find_match(int af
, const char *name
, u8 revision
);
311 extern struct xt_target
*xt_find_target(int af
, const char *name
, u8 revision
);
312 extern struct xt_target
*xt_request_find_target(int af
, const char *name
,
314 extern int xt_find_revision(int af
, const char *name
, u8 revision
, int target
,
317 extern struct xt_table
*xt_find_table_lock(int af
, const char *name
);
318 extern void xt_table_unlock(struct xt_table
*t
);
320 extern int xt_proto_init(int af
);
321 extern void xt_proto_fini(int af
);
323 extern struct xt_table_info
*xt_alloc_table_info(unsigned int size
);
324 extern void xt_free_table_info(struct xt_table_info
*info
);
327 #include <net/compat.h>
329 struct compat_xt_entry_match
333 u_int16_t match_size
;
334 char name
[XT_FUNCTION_MAXNAMELEN
- 1];
338 u_int16_t match_size
;
341 u_int16_t match_size
;
343 unsigned char data
[0];
346 struct compat_xt_entry_target
350 u_int16_t target_size
;
351 char name
[XT_FUNCTION_MAXNAMELEN
- 1];
355 u_int16_t target_size
;
356 compat_uptr_t target
;
358 u_int16_t target_size
;
360 unsigned char data
[0];
363 /* FIXME: this works only on 32 bit tasks
364 * need to change whole approach in order to calculate align as function of
365 * current task alignment */
367 struct compat_xt_counters
369 #if defined(CONFIG_X86_64) || defined(CONFIG_IA64)
376 struct compat_xt_counters_info
378 char name
[XT_TABLE_MAXNAMELEN
];
379 compat_uint_t num_counters
;
380 struct compat_xt_counters counters
[0];
383 #define COMPAT_XT_ALIGN(s) (((s) + (__alignof__(struct compat_xt_counters)-1)) \
384 & ~(__alignof__(struct compat_xt_counters)-1))
386 extern void xt_compat_lock(int af
);
387 extern void xt_compat_unlock(int af
);
389 extern int xt_compat_match_offset(struct xt_match
*match
);
390 extern void xt_compat_match_from_user(struct xt_entry_match
*m
,
391 void **dstptr
, int *size
);
392 extern int xt_compat_match_to_user(struct xt_entry_match
*m
,
393 void __user
**dstptr
, int *size
);
395 extern int xt_compat_target_offset(struct xt_target
*target
);
396 extern void xt_compat_target_from_user(struct xt_entry_target
*t
,
397 void **dstptr
, int *size
);
398 extern int xt_compat_target_to_user(struct xt_entry_target
*t
,
399 void __user
**dstptr
, int *size
);
401 #endif /* CONFIG_COMPAT */
402 #endif /* __KERNEL__ */
404 #endif /* _X_TABLES_H */