V4L/DVB (7166): [v4l] Add new user class controls and deprecate others
[linux-2.6.git] / include / linux / netfilter_arp / arp_tables.h
blob590ac3d6d5d67e349b28a146be534d14cefa29c3
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
137 /* Which table: caller fills this in. */
138 char name[ARPT_TABLE_MAXNAMELEN];
140 /* Kernel fills these in. */
141 /* Which hook entry points are valid: bitmask */
142 unsigned int valid_hooks;
144 /* Hook entry points: one per netfilter hook. */
145 unsigned int hook_entry[NF_ARP_NUMHOOKS];
147 /* Underflow points. */
148 unsigned int underflow[NF_ARP_NUMHOOKS];
150 /* Number of entries */
151 unsigned int num_entries;
153 /* Size of entries. */
154 unsigned int size;
157 /* The argument to ARPT_SO_SET_REPLACE. */
158 struct arpt_replace
160 /* Which table. */
161 char name[ARPT_TABLE_MAXNAMELEN];
163 /* Which hook entry points are valid: bitmask. You can't
164 change this. */
165 unsigned int valid_hooks;
167 /* Number of entries */
168 unsigned int num_entries;
170 /* Total size of new entries */
171 unsigned int size;
173 /* Hook entry points. */
174 unsigned int hook_entry[NF_ARP_NUMHOOKS];
176 /* Underflow points. */
177 unsigned int underflow[NF_ARP_NUMHOOKS];
179 /* Information about old entries: */
180 /* Number of counters (must be equal to current number of entries). */
181 unsigned int num_counters;
182 /* The old entries' counters. */
183 struct xt_counters __user *counters;
185 /* The entries (hang off end: not really an array). */
186 struct arpt_entry entries[0];
189 /* The argument to ARPT_SO_ADD_COUNTERS. */
190 #define arpt_counters_info xt_counters_info
191 #define arpt_counters xt_counters
193 /* The argument to ARPT_SO_GET_ENTRIES. */
194 struct arpt_get_entries
196 /* Which table: user fills this in. */
197 char name[ARPT_TABLE_MAXNAMELEN];
199 /* User fills this in: total entry size. */
200 unsigned int size;
202 /* The entries. */
203 struct arpt_entry entrytable[0];
206 /* Standard return verdict, or do jump. */
207 #define ARPT_STANDARD_TARGET XT_STANDARD_TARGET
208 /* Error verdict. */
209 #define ARPT_ERROR_TARGET XT_ERROR_TARGET
211 /* Helper functions */
212 static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e)
214 return (void *)e + e->target_offset;
217 /* fn returns 0 to continue iteration */
218 #define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
219 XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args)
222 * Main firewall chains definitions and global var's definitions.
224 #ifdef __KERNEL__
226 /* Standard entry. */
227 struct arpt_standard
229 struct arpt_entry entry;
230 struct arpt_standard_target target;
233 struct arpt_error_target
235 struct arpt_entry_target target;
236 char errorname[ARPT_FUNCTION_MAXNAMELEN];
239 struct arpt_error
241 struct arpt_entry entry;
242 struct arpt_error_target target;
245 #define ARPT_ENTRY_INIT(__size) \
247 .target_offset = sizeof(struct arpt_entry), \
248 .next_offset = (__size), \
251 #define ARPT_STANDARD_INIT(__verdict) \
253 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \
254 .target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \
255 sizeof(struct arpt_standard_target)), \
256 .target.verdict = -(__verdict) - 1, \
259 #define ARPT_ERROR_INIT \
261 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \
262 .target = XT_TARGET_INIT(ARPT_ERROR_TARGET, \
263 sizeof(struct arpt_error_target)), \
264 .target.errorname = "ERROR", \
267 extern struct xt_table *arpt_register_table(struct net *net,
268 struct xt_table *table,
269 const struct arpt_replace *repl);
270 extern void arpt_unregister_table(struct xt_table *table);
271 extern unsigned int arpt_do_table(struct sk_buff *skb,
272 unsigned int hook,
273 const struct net_device *in,
274 const struct net_device *out,
275 struct xt_table *table);
277 #define ARPT_ALIGN(s) XT_ALIGN(s)
279 #ifdef CONFIG_COMPAT
280 #include <net/compat.h>
282 struct compat_arpt_entry
284 struct arpt_arp arp;
285 u_int16_t target_offset;
286 u_int16_t next_offset;
287 compat_uint_t comefrom;
288 struct compat_xt_counters counters;
289 unsigned char elems[0];
292 static inline struct arpt_entry_target *
293 compat_arpt_get_target(struct compat_arpt_entry *e)
295 return (void *)e + e->target_offset;
298 #define COMPAT_ARPT_ALIGN(s) COMPAT_XT_ALIGN(s)
300 /* fn returns 0 to continue iteration */
301 #define COMPAT_ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
302 XT_ENTRY_ITERATE(struct compat_arpt_entry, entries, size, fn, ## args)
304 #define COMPAT_ARPT_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \
305 XT_ENTRY_ITERATE_CONTINUE(struct compat_arpt_entry, entries, size, n, \
306 fn, ## args)
308 #endif /* CONFIG_COMPAT */
309 #endif /*__KERNEL__*/
310 #endif /* _ARPTABLES_H */