4 #define XT_FUNCTION_MAXNAMELEN 30
5 #define XT_TABLE_MAXNAMELEN 32
7 /* The argument to IPT_SO_GET_REVISION_*. Returns highest revision
8 * kernel supports, if >= revision. */
11 char name[XT_FUNCTION_MAXNAMELEN-1];
16 /* CONTINUE verdict for targets */
17 #define XT_CONTINUE 0xFFFFFFFF
19 /* For standard target */
20 #define XT_RETURN (-NF_REPEAT - 1)
22 /* this is a dummy structure to find out the alignment requirement for a struct
23 * containing all the fundamental data types that are used in ipt_entry,
24 * ip6t_entry and arpt_entry. This sucks, and it is a hack. It will be my
25 * personal pleasure to remove it -HW
35 #define XT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) \
36 & ~(__alignof__(struct _xt_align)-1))
38 /* Standard return verdict, or do jump. */
39 #define XT_STANDARD_TARGET ""
41 #define XT_ERROR_TARGET "ERROR"
44 * New IP firewall options for [gs]etsockopt at the RAW IP level.
45 * Unlike BSD Linux inherits IP options so you don't have to use a raw
46 * socket for this. Instead we check rights in the calls. */
47 #define XT_BASE_CTL 64 /* base for firewall socket options */
49 #define XT_SO_SET_REPLACE (XT_BASE_CTL)
50 #define XT_SO_SET_ADD_COUNTERS (XT_BASE_CTL + 1)
51 #define XT_SO_SET_MAX XT_SO_SET_ADD_COUNTERS
53 #define XT_SO_GET_INFO (XT_BASE_CTL)
54 #define XT_SO_GET_ENTRIES (XT_BASE_CTL + 1)
55 #define XT_SO_GET_REVISION_MATCH (XT_BASE_CTL + 2)
56 #define XT_SO_GET_REVISION_TARGET (XT_BASE_CTL + 3)
57 #define XT_SO_GET_MAX XT_SO_GET_REVISION_TARGET
59 #define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0)
60 #define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0)
64 u_int64_t pcnt, bcnt; /* Packet and byte counters */
67 /* The argument to IPT_SO_ADD_COUNTERS. */
68 struct xt_counters_info
71 char name[XT_TABLE_MAXNAMELEN];
73 unsigned int num_counters;
75 /* The counters (actually `number' of these). */
76 struct xt_counters counters[0];
79 #define XT_INV_PROTO 0x40 /* Invert the sense of PROTO. */
83 #include <linux/netdevice.h>
85 #define ASSERT_READ_LOCK(x)
86 #define ASSERT_WRITE_LOCK(x)
87 #include <linux/netfilter_ipv4/listhelp.h>
91 struct list_head list;
93 const char name[XT_FUNCTION_MAXNAMELEN-1];
97 /* Return true or false: return FALSE and set *hotdrop = 1 to
98 force immediate packet drop. */
99 /* Arguments changed since 2.6.9, as this must now handle
100 non-linear skb, using skb_header_pointer and
101 skb_ip_make_writable. */
102 int (*match)(const struct sk_buff *skb,
103 const struct net_device *in,
104 const struct net_device *out,
105 const void *matchinfo,
107 unsigned int protoff,
110 /* Called when user tries to insert an entry of this type. */
111 /* Should return true or false. */
112 int (*checkentry)(const char *tablename,
115 unsigned int matchinfosize,
116 unsigned int hook_mask);
118 /* Called when entry of this type deleted. */
119 void (*destroy)(void *matchinfo, unsigned int matchinfosize);
121 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
125 /* Registration hooks for targets. */
128 struct list_head list;
130 const char name[XT_FUNCTION_MAXNAMELEN-1];
134 /* Returns verdict. Argument order changed since 2.6.9, as this
135 must now handle non-linear skbs, using skb_copy_bits and
136 skb_ip_make_writable. */
137 unsigned int (*target)(struct sk_buff **pskb,
138 const struct net_device *in,
139 const struct net_device *out,
140 unsigned int hooknum,
141 const void *targinfo,
144 /* Called when user tries to insert an entry of this type:
145 hook_mask is a bitmask of hooks from which it can be
147 /* Should return true or false. */
148 int (*checkentry)(const char *tablename,
151 unsigned int targinfosize,
152 unsigned int hook_mask);
154 /* Called when entry of this type deleted. */
155 void (*destroy)(void *targinfo, unsigned int targinfosize);
157 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
161 /* Furniture shopping... */
164 struct list_head list;
166 /* A unique name... */
167 char name[XT_TABLE_MAXNAMELEN];
169 /* What hooks you will enter on */
170 unsigned int valid_hooks;
172 /* Lock for the curtain */
175 /* Man behind the curtain... */
176 //struct ip6t_table_info *private;
179 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
182 int af; /* address/protocol family */
185 #include <linux/netfilter_ipv4.h>
187 /* The table itself */
192 /* Number of entries: FIXME. --RR */
194 /* Initial number of entries. Needed for module usage count */
195 unsigned int initial_entries;
197 /* Entry points and underflows */
198 unsigned int hook_entry[NF_IP_NUMHOOKS];
199 unsigned int underflow[NF_IP_NUMHOOKS];
201 /* ipt_entry tables: one per CPU */
202 char *entries[NR_CPUS];
205 extern int xt_register_target(int af, struct xt_target *target);
206 extern void xt_unregister_target(int af, struct xt_target *target);
207 extern int xt_register_match(int af, struct xt_match *target);
208 extern void xt_unregister_match(int af, struct xt_match *target);
210 extern int xt_register_table(struct xt_table *table,
211 struct xt_table_info *bootstrap,
212 struct xt_table_info *newinfo);
213 extern void *xt_unregister_table(struct xt_table *table);
215 extern struct xt_table_info *xt_replace_table(struct xt_table *table,
216 unsigned int num_counters,
217 struct xt_table_info *newinfo,
220 extern struct xt_match *xt_find_match(int af, const char *name, u8 revision);
221 extern struct xt_target *xt_find_target(int af, const char *name, u8 revision);
222 extern struct xt_target *xt_request_find_target(int af, const char *name,
224 extern int xt_find_revision(int af, const char *name, u8 revision, int target,
227 extern struct xt_table *xt_find_table_lock(int af, const char *name);
228 extern void xt_table_unlock(struct xt_table *t);
230 extern int xt_proto_init(int af);
231 extern void xt_proto_fini(int af);
233 extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
234 extern void xt_free_table_info(struct xt_table_info *info);
236 #endif /* __KERNEL__ */
238 #endif /* _X_TABLES_H */