3 #include <linux/kernel.h>
4 #include <linux/types.h>
6 #define XT_FUNCTION_MAXNAMELEN 30
7 #define XT_EXTENSION_MAXNAMELEN 29
8 #define XT_TABLE_MAXNAMELEN 32
10 struct xt_entry_match
{
15 /* Used by userspace */
16 char name
[XT_EXTENSION_MAXNAMELEN
];
22 /* Used inside the kernel */
23 struct xt_match
*match
;
30 unsigned char data
[0];
33 struct xt_entry_target
{
38 /* Used by userspace */
39 char name
[XT_EXTENSION_MAXNAMELEN
];
45 /* Used inside the kernel */
46 struct xt_target
*target
;
53 unsigned char data
[0];
56 #define XT_TARGET_INIT(__name, __size) \
59 .target_size = XT_ALIGN(__size), \
64 struct xt_standard_target
{
65 struct xt_entry_target target
;
69 /* The argument to IPT_SO_GET_REVISION_*. Returns highest revision
70 * kernel supports, if >= revision. */
71 struct xt_get_revision
{
72 char name
[XT_EXTENSION_MAXNAMELEN
];
76 /* CONTINUE verdict for targets */
77 #define XT_CONTINUE 0xFFFFFFFF
79 /* For standard target */
80 #define XT_RETURN (-NF_REPEAT - 1)
82 /* this is a dummy structure to find out the alignment requirement for a struct
83 * containing all the fundamental data types that are used in ipt_entry,
84 * ip6t_entry and arpt_entry. This sucks, and it is a hack. It will be my
85 * personal pleasure to remove it -HW
94 #define XT_ALIGN(s) __ALIGN_KERNEL((s), __alignof__(struct _xt_align))
96 /* Standard return verdict, or do jump. */
97 #define XT_STANDARD_TARGET ""
99 #define XT_ERROR_TARGET "ERROR"
101 #define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0)
102 #define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0)
105 __u64 pcnt
, bcnt
; /* Packet and byte counters */
108 /* The argument to IPT_SO_ADD_COUNTERS. */
109 struct xt_counters_info
{
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 /* fn returns 0 to continue iteration */
122 #define XT_MATCH_ITERATE(type, e, fn, args...) \
126 struct xt_entry_match *__m; \
128 for (__i = sizeof(type); \
129 __i < (e)->target_offset; \
130 __i += __m->u.match_size) { \
131 __m = (void *)e + __i; \
133 __ret = fn(__m , ## args); \
140 /* fn returns 0 to continue iteration */
141 #define XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \
143 unsigned int __i, __n; \
147 for (__i = 0, __n = 0; __i < (size); \
148 __i += __entry->next_offset, __n++) { \
149 __entry = (void *)(entries) + __i; \
153 __ret = fn(__entry , ## args); \
160 /* fn returns 0 to continue iteration */
161 #define XT_ENTRY_ITERATE(type, entries, size, fn, args...) \
162 XT_ENTRY_ITERATE_CONTINUE(type, entries, size, 0, fn, args)
165 /* pos is normally a struct ipt_entry/ip6t_entry/etc. */
166 #define xt_entry_foreach(pos, ehead, esize) \
167 for ((pos) = (typeof(pos))(ehead); \
168 (pos) < (typeof(pos))((char *)(ehead) + (esize)); \
169 (pos) = (typeof(pos))((char *)(pos) + (pos)->next_offset))
171 /* can only be xt_entry_match, so no use of typeof here */
172 #define xt_ematch_foreach(pos, entry) \
173 for ((pos) = (struct xt_entry_match *)entry->elems; \
174 (pos) < (struct xt_entry_match *)((char *)(entry) + \
175 (entry)->target_offset); \
176 (pos) = (struct xt_entry_match *)((char *)(pos) + \
177 (pos)->u.match_size))
180 #endif /* _X_TABLES_H */