1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef _IP6_TABLES_H
17#define _IP6_TABLES_H
18
19#include <linux/types.h>
20
21#include <linux/if.h>
22#include <linux/netfilter_ipv6.h>
23
24#include <linux/netfilter/x_tables.h>
25
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
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
61
62struct ip6t_ip6 {
63
64 struct in6_addr src, dst;
65
66 struct in6_addr smsk, dmsk;
67 char iniface[IFNAMSIZ], outiface[IFNAMSIZ];
68 unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
69
70
71
72
73
74
75
76
77
78 __u16 proto;
79
80 __u8 tos;
81
82
83 __u8 flags;
84
85 __u8 invflags;
86};
87
88
89#define IP6T_F_PROTO 0x01
90
91#define IP6T_F_TOS 0x02
92#define IP6T_F_GOTO 0x04
93#define IP6T_F_MASK 0x07
94
95
96#define IP6T_INV_VIA_IN 0x01
97#define IP6T_INV_VIA_OUT 0x02
98#define IP6T_INV_TOS 0x04
99#define IP6T_INV_SRCIP 0x08
100#define IP6T_INV_DSTIP 0x10
101#define IP6T_INV_FRAG 0x20
102#define IP6T_INV_PROTO XT_INV_PROTO
103#define IP6T_INV_MASK 0x7F
104
105
106
107
108struct ip6t_entry {
109 struct ip6t_ip6 ipv6;
110
111
112 unsigned int nfcache;
113
114
115 __u16 target_offset;
116
117 __u16 next_offset;
118
119
120 unsigned int comefrom;
121
122
123 struct xt_counters counters;
124
125
126 unsigned char elems[0];
127};
128
129
130struct ip6t_standard {
131 struct ip6t_entry entry;
132 struct xt_standard_target target;
133};
134
135struct ip6t_error {
136 struct ip6t_entry entry;
137 struct xt_error_target target;
138};
139
140#define IP6T_ENTRY_INIT(__size) \
141{ \
142 .target_offset = sizeof(struct ip6t_entry), \
143 .next_offset = (__size), \
144}
145
146#define IP6T_STANDARD_INIT(__verdict) \
147{ \
148 .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \
149 .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \
150 sizeof(struct xt_standard_target)), \
151 .target.verdict = -(__verdict) - 1, \
152}
153
154#define IP6T_ERROR_INIT \
155{ \
156 .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \
157 .target = XT_TARGET_INIT(XT_ERROR_TARGET, \
158 sizeof(struct xt_error_target)), \
159 .target.errorname = "ERROR", \
160}
161
162
163
164
165
166
167
168
169#define IP6T_BASE_CTL 64
170
171#define IP6T_SO_SET_REPLACE (IP6T_BASE_CTL)
172#define IP6T_SO_SET_ADD_COUNTERS (IP6T_BASE_CTL + 1)
173#define IP6T_SO_SET_MAX IP6T_SO_SET_ADD_COUNTERS
174
175#define IP6T_SO_GET_INFO (IP6T_BASE_CTL)
176#define IP6T_SO_GET_ENTRIES (IP6T_BASE_CTL + 1)
177#define IP6T_SO_GET_REVISION_MATCH (IP6T_BASE_CTL + 4)
178#define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 5)
179#define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET
180
181
182#define IP6T_SO_ORIGINAL_DST 80
183
184
185struct ip6t_icmp {
186 __u8 type;
187 __u8 code[2];
188 __u8 invflags;
189};
190
191
192#define IP6T_ICMP_INV 0x01
193
194
195struct ip6t_getinfo {
196
197 char name[XT_TABLE_MAXNAMELEN];
198
199
200
201 unsigned int valid_hooks;
202
203
204 unsigned int hook_entry[NF_INET_NUMHOOKS];
205
206
207 unsigned int underflow[NF_INET_NUMHOOKS];
208
209
210 unsigned int num_entries;
211
212
213 unsigned int size;
214};
215
216
217struct ip6t_replace {
218
219 char name[XT_TABLE_MAXNAMELEN];
220
221
222
223 unsigned int valid_hooks;
224
225
226 unsigned int num_entries;
227
228
229 unsigned int size;
230
231
232 unsigned int hook_entry[NF_INET_NUMHOOKS];
233
234
235 unsigned int underflow[NF_INET_NUMHOOKS];
236
237
238
239 unsigned int num_counters;
240
241 struct xt_counters *counters;
242
243
244 struct ip6t_entry entries[0];
245};
246
247
248struct ip6t_get_entries {
249
250 char name[XT_TABLE_MAXNAMELEN];
251
252
253 unsigned int size;
254
255
256 struct ip6t_entry entrytable[0];
257};
258
259
260static __inline__ struct xt_entry_target *
261ip6t_get_target(struct ip6t_entry *e)
262{
263 return (struct xt_entry_target *)((char *)e + e->target_offset);
264}
265
266
267
268
269
270#endif
271