Input: wm97xx: add new AC97 bus support
[sfrench/cifs-2.6.git] / include / uapi / linux / netfilter_ipv6 / ip6_tables.h
1 /*
2  * 25-Jul-1998 Major changes to allow for ip chain table
3  *
4  * 3-Jan-2000 Named tables to allow packet selection for different uses.
5  */
6
7 /*
8  *      Format of an IP6 firewall descriptor
9  *
10  *      src, dst, src_mask, dst_mask are always stored in network byte order.
11  *      flags are stored in host byte order (of course).
12  *      Port numbers are stored in HOST byte order.
13  */
14
15 #ifndef _UAPI_IP6_TABLES_H
16 #define _UAPI_IP6_TABLES_H
17
18 #include <linux/types.h>
19 #include <linux/compiler.h>
20 #include <linux/if.h>
21 #include <linux/netfilter_ipv6.h>
22
23 #include <linux/netfilter/x_tables.h>
24
25 #ifndef __KERNEL__
26 #define IP6T_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
27 #define IP6T_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
28 #define ip6t_match xt_match
29 #define ip6t_target xt_target
30 #define ip6t_table xt_table
31 #define ip6t_get_revision xt_get_revision
32 #define ip6t_entry_match xt_entry_match
33 #define ip6t_entry_target xt_entry_target
34 #define ip6t_standard_target xt_standard_target
35 #define ip6t_error_target xt_error_target
36 #define ip6t_counters xt_counters
37 #define IP6T_CONTINUE XT_CONTINUE
38 #define IP6T_RETURN XT_RETURN
39
40 /* Pre-iptables-1.4.0 */
41 #include <linux/netfilter/xt_tcpudp.h>
42 #define ip6t_tcp xt_tcp
43 #define ip6t_udp xt_udp
44 #define IP6T_TCP_INV_SRCPT      XT_TCP_INV_SRCPT
45 #define IP6T_TCP_INV_DSTPT      XT_TCP_INV_DSTPT
46 #define IP6T_TCP_INV_FLAGS      XT_TCP_INV_FLAGS
47 #define IP6T_TCP_INV_OPTION     XT_TCP_INV_OPTION
48 #define IP6T_TCP_INV_MASK       XT_TCP_INV_MASK
49 #define IP6T_UDP_INV_SRCPT      XT_UDP_INV_SRCPT
50 #define IP6T_UDP_INV_DSTPT      XT_UDP_INV_DSTPT
51 #define IP6T_UDP_INV_MASK       XT_UDP_INV_MASK
52
53 #define ip6t_counters_info xt_counters_info
54 #define IP6T_STANDARD_TARGET XT_STANDARD_TARGET
55 #define IP6T_ERROR_TARGET XT_ERROR_TARGET
56 #define IP6T_MATCH_ITERATE(e, fn, args...) \
57         XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args)
58 #define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \
59         XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args)
60 #endif
61
62 /* Yes, Virginia, you have to zero the padding. */
63 struct ip6t_ip6 {
64         /* Source and destination IP6 addr */
65         struct in6_addr src, dst;               
66         /* Mask for src and dest IP6 addr */
67         struct in6_addr smsk, dmsk;
68         char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
69         unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
70
71         /* Upper protocol number
72          * - The allowed value is 0 (any) or protocol number of last parsable
73          *   header, which is 50 (ESP), 59 (No Next Header), 135 (MH), or
74          *   the non IPv6 extension headers.
75          * - The protocol numbers of IPv6 extension headers except of ESP and
76          *   MH do not match any packets.
77          * - You also need to set IP6T_FLAGS_PROTO to "flags" to check protocol.
78          */
79         __u16 proto;
80         /* TOS to match iff flags & IP6T_F_TOS */
81         __u8 tos;
82
83         /* Flags word */
84         __u8 flags;
85         /* Inverse flags */
86         __u8 invflags;
87 };
88
89 /* Values for "flag" field in struct ip6t_ip6 (general ip6 structure). */
90 #define IP6T_F_PROTO            0x01    /* Set if rule cares about upper 
91                                            protocols */
92 #define IP6T_F_TOS              0x02    /* Match the TOS. */
93 #define IP6T_F_GOTO             0x04    /* Set if jump is a goto */
94 #define IP6T_F_MASK             0x07    /* All possible flag bits mask. */
95
96 /* Values for "inv" field in struct ip6t_ip6. */
97 #define IP6T_INV_VIA_IN         0x01    /* Invert the sense of IN IFACE. */
98 #define IP6T_INV_VIA_OUT                0x02    /* Invert the sense of OUT IFACE */
99 #define IP6T_INV_TOS            0x04    /* Invert the sense of TOS. */
100 #define IP6T_INV_SRCIP          0x08    /* Invert the sense of SRC IP. */
101 #define IP6T_INV_DSTIP          0x10    /* Invert the sense of DST OP. */
102 #define IP6T_INV_FRAG           0x20    /* Invert the sense of FRAG. */
103 #define IP6T_INV_PROTO          XT_INV_PROTO
104 #define IP6T_INV_MASK           0x7F    /* All possible flag bits mask. */
105
106 /* This structure defines each of the firewall rules.  Consists of 3
107    parts which are 1) general IP header stuff 2) match specific
108    stuff 3) the target to perform if the rule matches */
109 struct ip6t_entry {
110         struct ip6t_ip6 ipv6;
111
112         /* Mark with fields that we care about. */
113         unsigned int nfcache;
114
115         /* Size of ipt_entry + matches */
116         __u16 target_offset;
117         /* Size of ipt_entry + matches + target */
118         __u16 next_offset;
119
120         /* Back pointer */
121         unsigned int comefrom;
122
123         /* Packet and byte counters. */
124         struct xt_counters counters;
125
126         /* The matches (if any), then the target. */
127         unsigned char elems[0];
128 };
129
130 /* Standard entry */
131 struct ip6t_standard {
132         struct ip6t_entry entry;
133         struct xt_standard_target target;
134 };
135
136 struct ip6t_error {
137         struct ip6t_entry entry;
138         struct xt_error_target target;
139 };
140
141 #define IP6T_ENTRY_INIT(__size)                                                \
142 {                                                                              \
143         .target_offset  = sizeof(struct ip6t_entry),                           \
144         .next_offset    = (__size),                                            \
145 }
146
147 #define IP6T_STANDARD_INIT(__verdict)                                          \
148 {                                                                              \
149         .entry          = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)),       \
150         .target         = XT_TARGET_INIT(XT_STANDARD_TARGET,                   \
151                                          sizeof(struct xt_standard_target)),   \
152         .target.verdict = -(__verdict) - 1,                                    \
153 }
154
155 #define IP6T_ERROR_INIT                                                        \
156 {                                                                              \
157         .entry          = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)),          \
158         .target         = XT_TARGET_INIT(XT_ERROR_TARGET,                      \
159                                          sizeof(struct xt_error_target)),      \
160         .target.errorname = "ERROR",                                           \
161 }
162
163 /*
164  * New IP firewall options for [gs]etsockopt at the RAW IP level.
165  * Unlike BSD Linux inherits IP options so you don't have to use
166  * a raw socket for this. Instead we check rights in the calls.
167  *
168  * ATTENTION: check linux/in6.h before adding new number here.
169  */
170 #define IP6T_BASE_CTL                   64
171
172 #define IP6T_SO_SET_REPLACE             (IP6T_BASE_CTL)
173 #define IP6T_SO_SET_ADD_COUNTERS        (IP6T_BASE_CTL + 1)
174 #define IP6T_SO_SET_MAX                 IP6T_SO_SET_ADD_COUNTERS
175
176 #define IP6T_SO_GET_INFO                (IP6T_BASE_CTL)
177 #define IP6T_SO_GET_ENTRIES             (IP6T_BASE_CTL + 1)
178 #define IP6T_SO_GET_REVISION_MATCH      (IP6T_BASE_CTL + 4)
179 #define IP6T_SO_GET_REVISION_TARGET     (IP6T_BASE_CTL + 5)
180 #define IP6T_SO_GET_MAX                 IP6T_SO_GET_REVISION_TARGET
181
182 /* obtain original address if REDIRECT'd connection */
183 #define IP6T_SO_ORIGINAL_DST            80
184
185 /* ICMP matching stuff */
186 struct ip6t_icmp {
187         __u8 type;                              /* type to match */
188         __u8 code[2];                           /* range of code */
189         __u8 invflags;                          /* Inverse flags */
190 };
191
192 /* Values for "inv" field for struct ipt_icmp. */
193 #define IP6T_ICMP_INV   0x01    /* Invert the sense of type/code test */
194
195 /* The argument to IP6T_SO_GET_INFO */
196 struct ip6t_getinfo {
197         /* Which table: caller fills this in. */
198         char name[XT_TABLE_MAXNAMELEN];
199
200         /* Kernel fills these in. */
201         /* Which hook entry points are valid: bitmask */
202         unsigned int valid_hooks;
203
204         /* Hook entry points: one per netfilter hook. */
205         unsigned int hook_entry[NF_INET_NUMHOOKS];
206
207         /* Underflow points. */
208         unsigned int underflow[NF_INET_NUMHOOKS];
209
210         /* Number of entries */
211         unsigned int num_entries;
212
213         /* Size of entries. */
214         unsigned int size;
215 };
216
217 /* The argument to IP6T_SO_SET_REPLACE. */
218 struct ip6t_replace {
219         /* Which table. */
220         char name[XT_TABLE_MAXNAMELEN];
221
222         /* Which hook entry points are valid: bitmask.  You can't
223            change this. */
224         unsigned int valid_hooks;
225
226         /* Number of entries */
227         unsigned int num_entries;
228
229         /* Total size of new entries */
230         unsigned int size;
231
232         /* Hook entry points. */
233         unsigned int hook_entry[NF_INET_NUMHOOKS];
234
235         /* Underflow points. */
236         unsigned int underflow[NF_INET_NUMHOOKS];
237
238         /* Information about old entries: */
239         /* Number of counters (must be equal to current number of entries). */
240         unsigned int num_counters;
241         /* The old entries' counters. */
242         struct xt_counters __user *counters;
243
244         /* The entries (hang off end: not really an array). */
245         struct ip6t_entry entries[0];
246 };
247
248 /* The argument to IP6T_SO_GET_ENTRIES. */
249 struct ip6t_get_entries {
250         /* Which table: user fills this in. */
251         char name[XT_TABLE_MAXNAMELEN];
252
253         /* User fills this in: total entry size. */
254         unsigned int size;
255
256         /* The entries. */
257         struct ip6t_entry entrytable[0];
258 };
259
260 /* Helper functions */
261 static __inline__ struct xt_entry_target *
262 ip6t_get_target(struct ip6t_entry *e)
263 {
264         return (void *)e + e->target_offset;
265 }
266
267 /*
268  *      Main firewall chains definitions and global var's definitions.
269  */
270
271 #endif /* _UAPI_IP6_TABLES_H */