GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / include / linux / netfilter_arp / arp_tables.h
blobe9948c0560f6fb302d29b5be35c6fd083d8409a7
1 /*
2 * Format of an ARP firewall descriptor
4 * src, tgt, src_mask, tgt_mask, arpop, arpop_mask are always stored in
5 * network byte order.
6 * flags are stored in host byte order (of course).
7 */
9 #ifndef _ARPTABLES_H
10 #define _ARPTABLES_H
12 #ifdef __KERNEL__
13 #include <linux/if.h>
14 #include <linux/in.h>
15 #include <linux/if_arp.h>
16 #include <linux/skbuff.h>
17 #endif
18 #include <linux/types.h>
19 #include <linux/compiler.h>
20 #include <linux/netfilter_arp.h>
22 #include <linux/netfilter/x_tables.h>
24 #define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
25 #define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
27 #define ARPT_DEV_ADDR_LEN_MAX 16
29 struct arpt_devaddr_info {
30 char addr[ARPT_DEV_ADDR_LEN_MAX];
31 char mask[ARPT_DEV_ADDR_LEN_MAX];
34 /* Yes, Virginia, you have to zero the padding. */
35 struct arpt_arp {
36 /* Source and target IP addr */
37 struct in_addr src, tgt;
38 /* Mask for src and target IP addr */
39 struct in_addr smsk, tmsk;
41 /* Device hw address length, src+target device addresses */
42 u_int8_t arhln, arhln_mask;
43 struct arpt_devaddr_info src_devaddr;
44 struct arpt_devaddr_info tgt_devaddr;
46 /* ARP operation code. */
47 __be16 arpop, arpop_mask;
49 /* ARP hardware address and protocol address format. */
50 __be16 arhrd, arhrd_mask;
51 __be16 arpro, arpro_mask;
53 /* The protocol address length is only accepted if it is 4
54 * so there is no use in offering a way to do filtering on it.
57 char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
58 unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
60 /* Flags word */
61 u_int8_t flags;
62 /* Inverse flags */
63 u_int16_t invflags;
66 #define arpt_entry_target xt_entry_target
67 #define arpt_standard_target xt_standard_target
69 /* Values for "flag" field in struct arpt_ip (general arp structure).
70 * No flags defined yet.
72 #define ARPT_F_MASK 0x00 /* All possible flag bits mask. */
74 /* Values for "inv" field in struct arpt_arp. */
75 #define ARPT_INV_VIA_IN 0x0001 /* Invert the sense of IN IFACE. */
76 #define ARPT_INV_VIA_OUT 0x0002 /* Invert the sense of OUT IFACE */
77 #define ARPT_INV_SRCIP 0x0004 /* Invert the sense of SRC IP. */
78 #define ARPT_INV_TGTIP 0x0008 /* Invert the sense of TGT IP. */
79 #define ARPT_INV_SRCDEVADDR 0x0010 /* Invert the sense of SRC DEV ADDR. */
80 #define ARPT_INV_TGTDEVADDR 0x0020 /* Invert the sense of TGT DEV ADDR. */
81 #define ARPT_INV_ARPOP 0x0040 /* Invert the sense of ARP OP. */
82 #define ARPT_INV_ARPHRD 0x0080 /* Invert the sense of ARP HRD. */
83 #define ARPT_INV_ARPPRO 0x0100 /* Invert the sense of ARP PRO. */
84 #define ARPT_INV_ARPHLN 0x0200 /* Invert the sense of ARP HLN. */
85 #define ARPT_INV_MASK 0x03FF /* All possible flag bits mask. */
87 /* This structure defines each of the firewall rules. Consists of 3
88 parts which are 1) general ARP header stuff 2) match specific
89 stuff 3) the target to perform if the rule matches */
90 struct arpt_entry
92 struct arpt_arp arp;
94 /* Size of arpt_entry + matches */
95 u_int16_t target_offset;
96 /* Size of arpt_entry + matches + target */
97 u_int16_t next_offset;
99 /* Back pointer */
100 unsigned int comefrom;
102 /* Packet and byte counters. */
103 struct xt_counters counters;
105 /* The matches (if any), then the target. */
106 unsigned char elems[0];
110 * New IP firewall options for [gs]etsockopt at the RAW IP level.
111 * Unlike BSD Linux inherits IP options so you don't have to use a raw
112 * socket for this. Instead we check rights in the calls.
114 * ATTENTION: check linux/in.h before adding new number here.
116 #define ARPT_BASE_CTL 96
118 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL)
119 #define ARPT_SO_SET_ADD_COUNTERS (ARPT_BASE_CTL + 1)
120 #define ARPT_SO_SET_MAX ARPT_SO_SET_ADD_COUNTERS
122 #define ARPT_SO_GET_INFO (ARPT_BASE_CTL)
123 #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1)
124 /* #define ARPT_SO_GET_REVISION_MATCH (APRT_BASE_CTL + 2) */
125 #define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3)
126 #define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET)
128 /* CONTINUE verdict for targets */
129 #define ARPT_CONTINUE XT_CONTINUE
131 /* For standard target */
132 #define ARPT_RETURN XT_RETURN
134 /* The argument to ARPT_SO_GET_INFO */
135 struct arpt_getinfo {
136 /* Which table: caller fills this in. */
137 char name[ARPT_TABLE_MAXNAMELEN];
139 /* Kernel fills these in. */
140 /* Which hook entry points are valid: bitmask */
141 unsigned int valid_hooks;
143 /* Hook entry points: one per netfilter hook. */
144 unsigned int hook_entry[NF_ARP_NUMHOOKS];
146 /* Underflow points. */
147 unsigned int underflow[NF_ARP_NUMHOOKS];
149 /* Number of entries */
150 unsigned int num_entries;
152 /* Size of entries. */
153 unsigned int size;
156 /* The argument to ARPT_SO_SET_REPLACE. */
157 struct arpt_replace {
158 /* Which table. */
159 char name[ARPT_TABLE_MAXNAMELEN];
161 /* Which hook entry points are valid: bitmask. You can't
162 change this. */
163 unsigned int valid_hooks;
165 /* Number of entries */
166 unsigned int num_entries;
168 /* Total size of new entries */
169 unsigned int size;
171 /* Hook entry points. */
172 unsigned int hook_entry[NF_ARP_NUMHOOKS];
174 /* Underflow points. */
175 unsigned int underflow[NF_ARP_NUMHOOKS];
177 /* Information about old entries: */
178 /* Number of counters (must be equal to current number of entries). */
179 unsigned int num_counters;
180 /* The old entries' counters. */
181 struct xt_counters __user *counters;
183 /* The entries (hang off end: not really an array). */
184 struct arpt_entry entries[0];
187 /* The argument to ARPT_SO_ADD_COUNTERS. */
188 #define arpt_counters_info xt_counters_info
189 #define arpt_counters xt_counters
191 /* The argument to ARPT_SO_GET_ENTRIES. */
192 struct arpt_get_entries {
193 /* Which table: user fills this in. */
194 char name[ARPT_TABLE_MAXNAMELEN];
196 /* User fills this in: total entry size. */
197 unsigned int size;
199 /* The entries. */
200 struct arpt_entry entrytable[0];
203 /* Standard return verdict, or do jump. */
204 #define ARPT_STANDARD_TARGET XT_STANDARD_TARGET
205 /* Error verdict. */
206 #define ARPT_ERROR_TARGET XT_ERROR_TARGET
208 /* Helper functions */
209 static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e)
211 return (void *)e + e->target_offset;
214 #ifndef __KERNEL__
215 /* fn returns 0 to continue iteration */
216 #define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
217 XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args)
218 #endif
221 * Main firewall chains definitions and global var's definitions.
223 #ifdef __KERNEL__
225 /* Standard entry. */
226 struct arpt_standard {
227 struct arpt_entry entry;
228 struct arpt_standard_target target;
231 struct arpt_error_target {
232 struct arpt_entry_target target;
233 char errorname[ARPT_FUNCTION_MAXNAMELEN];
236 struct arpt_error {
237 struct arpt_entry entry;
238 struct arpt_error_target target;
241 #define ARPT_ENTRY_INIT(__size) \
243 .target_offset = sizeof(struct arpt_entry), \
244 .next_offset = (__size), \
247 #define ARPT_STANDARD_INIT(__verdict) \
249 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \
250 .target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \
251 sizeof(struct arpt_standard_target)), \
252 .target.verdict = -(__verdict) - 1, \
255 #define ARPT_ERROR_INIT \
257 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \
258 .target = XT_TARGET_INIT(ARPT_ERROR_TARGET, \
259 sizeof(struct arpt_error_target)), \
260 .target.errorname = "ERROR", \
263 extern void *arpt_alloc_initial_table(const struct xt_table *);
264 extern struct xt_table *arpt_register_table(struct net *net,
265 const struct xt_table *table,
266 const struct arpt_replace *repl);
267 extern void arpt_unregister_table(struct xt_table *table);
268 extern unsigned int arpt_do_table(struct sk_buff *skb,
269 unsigned int hook,
270 const struct net_device *in,
271 const struct net_device *out,
272 struct xt_table *table);
274 #define ARPT_ALIGN(s) XT_ALIGN(s)
276 #ifdef CONFIG_COMPAT
277 #include <net/compat.h>
279 struct compat_arpt_entry {
280 struct arpt_arp arp;
281 u_int16_t target_offset;
282 u_int16_t next_offset;
283 compat_uint_t comefrom;
284 struct compat_xt_counters counters;
285 unsigned char elems[0];
288 static inline struct arpt_entry_target *
289 compat_arpt_get_target(struct compat_arpt_entry *e)
291 return (void *)e + e->target_offset;
294 #define COMPAT_ARPT_ALIGN(s) COMPAT_XT_ALIGN(s)
296 #endif /* CONFIG_COMPAT */
297 #endif /*__KERNEL__*/
298 #endif /* _ARPTABLES_H */