]>
Commit | Line | Data |
---|---|---|
50e2238a | 1 | Already applied: |
2 | CLASSIFY_more-hooks | |
3 | amanda_offset-fix | |
4 | conntrack-cacheline-opt | |
5 | expect-evict-order | |
6 | helper-locking_fix | |
7 | mangle-reroute | |
8 | owner-broken | |
9 | proc-no-internal-targets | |
10 | sctp | |
11 | HOPLIMIT | |
12 | IPV4OPTSSTRIP | |
13 | NETMAP | |
14 | SAME | |
15 | TTL | |
16 | connlimit | |
17 | dstlimit | |
18 | fuzzy | |
19 | hashlimit | |
20 | iprange | |
21 | ipv4options | |
22 | mport | |
23 | nth | |
24 | osf | |
25 | psd | |
26 | quota | |
27 | realm | |
28 | set | |
29 | time | |
30 | u32 | |
31 | ||
32 | CLASSIFY | |
33 | IPMARK | |
34 | ROUTE | |
35 | TARPIT | |
36 | XOR | |
37 | account | |
38 | addrtype | |
39 | comment | |
40 | goto | |
41 | ip_queue_vwmark | |
42 | ipp2p | |
43 | nf_conntrack | |
44 | ownercmd | |
45 | policy | |
46 | pptp-conntrack-nat | |
47 | ||
48 | ||
49 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/ipv4/nf_conntrack_icmp.h linux-2.6.10/include/linux/netfilter/ipv4/nf_conntrack_icmp.h | |
50 | --- linux-2.6.10.org/include/linux/netfilter/ipv4/nf_conntrack_icmp.h 1970-01-01 01:00:00.000000000 +0100 | |
51 | +++ linux-2.6.10/include/linux/netfilter/ipv4/nf_conntrack_icmp.h 2005-01-04 10:02:37.212444872 +0100 | |
52 | @@ -0,0 +1,17 @@ | |
53 | +/* | |
54 | + * ICMP tracking. | |
55 | + * | |
56 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_icmp.h | |
57 | + */ | |
58 | + | |
59 | +#ifndef _NF_CONNTRACK_ICMP_H | |
60 | +#define _NF_CONNTRACK_ICMP_H | |
61 | +#include <asm/atomic.h> | |
62 | + | |
63 | +struct nf_ct_icmp | |
64 | +{ | |
65 | + /* Optimization: when number in == number out, forget immediately. */ | |
66 | + atomic_t count; | |
67 | +}; | |
68 | + | |
69 | +#endif /* _NF_CONNTRACK_ICMP_H */ | |
70 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/ipv4/nf_conntrack_ipv4.h linux-2.6.10/include/linux/netfilter/ipv4/nf_conntrack_ipv4.h | |
71 | --- linux-2.6.10.org/include/linux/netfilter/ipv4/nf_conntrack_ipv4.h 1970-01-01 01:00:00.000000000 +0100 | |
72 | +++ linux-2.6.10/include/linux/netfilter/ipv4/nf_conntrack_ipv4.h 2005-01-04 10:02:37.213444720 +0100 | |
73 | @@ -0,0 +1,40 @@ | |
74 | +/* | |
75 | + * IPv4 support for nf_conntrack. | |
76 | + * | |
77 | + * 23 Mar 2004: Yasuyuki Kozakai @ USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
78 | + * - move L3 protocol dependent part from include/linux/netfilter_ipv4/ | |
79 | + * ip_conntarck.h | |
80 | + */ | |
81 | + | |
82 | +#ifndef _NF_CONNTRACK_IPV4_H | |
83 | +#define _NF_CONNTRACK_IPV4_H | |
84 | + | |
85 | +#ifdef CONFIG_IP_NF_NAT_NEEDED | |
86 | +#include <linux/netfilter_ipv4/ip_nat.h> | |
87 | + | |
88 | +/* per conntrack: nat application helper private data */ | |
89 | +union ip_conntrack_nat_help { | |
90 | + /* insert nat helper private data here */ | |
91 | +}; | |
92 | + | |
93 | +struct nf_conntrack_ipv4_nat { | |
94 | + struct ip_nat_info info; | |
95 | + union ip_conntrack_nat_help help; | |
96 | +#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ | |
97 | + defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) | |
98 | + int masq_index; | |
99 | +#endif | |
100 | +}; | |
101 | +#endif /* CONFIG_IP_NF_NAT_NEEDED */ | |
102 | + | |
103 | +struct nf_conntrack_ipv4 { | |
104 | +#ifdef CONFIG_IP_NF_NAT_NEEDED | |
105 | + struct nf_conntrack_ipv4_nat *nat; | |
106 | +#endif | |
107 | +}; | |
108 | + | |
109 | +/* Returns new sk_buff, or NULL */ | |
110 | +struct sk_buff * | |
111 | +nf_ct_ipv4_ct_gather_frags(struct sk_buff *skb); | |
112 | + | |
113 | +#endif /*_NF_CONNTRACK_IPV4_H*/ | |
114 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/ipv6/nf_conntrack_icmpv6.h linux-2.6.10/include/linux/netfilter/ipv6/nf_conntrack_icmpv6.h | |
115 | --- linux-2.6.10.org/include/linux/netfilter/ipv6/nf_conntrack_icmpv6.h 1970-01-01 01:00:00.000000000 +0100 | |
116 | +++ linux-2.6.10/include/linux/netfilter/ipv6/nf_conntrack_icmpv6.h 2005-01-04 10:02:37.214444568 +0100 | |
117 | @@ -0,0 +1,27 @@ | |
118 | +/* | |
119 | + * ICMPv6 tracking. | |
120 | + * | |
121 | + * 21 Apl 2004: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
122 | + * - separated from nf_conntrack_icmp.h | |
123 | + * | |
124 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_icmp.h | |
125 | + */ | |
126 | + | |
127 | +#ifndef _NF_CONNTRACK_ICMPV6_H | |
128 | +#define _NF_CONNTRACK_ICMPV6_H | |
129 | +#include <asm/atomic.h> | |
130 | + | |
131 | +#ifndef ICMPV6_NI_QUERY | |
132 | +#define ICMPV6_NI_QUERY 139 | |
133 | +#endif | |
134 | +#ifndef ICMPV6_NI_REPLY | |
135 | +#define ICMPV6_NI_REPLY 140 | |
136 | +#endif | |
137 | + | |
138 | +struct nf_ct_icmpv6 | |
139 | +{ | |
140 | + /* Optimization: when number in == number out, forget immediately. */ | |
141 | + atomic_t count; | |
142 | +}; | |
143 | + | |
144 | +#endif /* _NF_CONNTRACK_ICMPV6_H */ | |
145 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack.h linux-2.6.10/include/linux/netfilter/nf_conntrack.h | |
146 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack.h 1970-01-01 01:00:00.000000000 +0100 | |
147 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack.h 2005-01-04 10:02:37.215444416 +0100 | |
148 | @@ -0,0 +1,334 @@ | |
149 | +/* | |
150 | + * Connection state tracking for netfilter. This is separated from, | |
151 | + * but required by, the (future) NAT layer; it can also be used by an iptables | |
152 | + * extension. | |
153 | + * | |
154 | + * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
155 | + * - generalize L3 protocol dependent part. | |
156 | + * | |
157 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack.h | |
158 | + */ | |
159 | + | |
160 | +#ifndef _NF_CONNTRACK_H | |
161 | +#define _NF_CONNTRACK_H | |
162 | +#include <linux/config.h> | |
163 | +#include <linux/netfilter/nf_conntrack_tuple.h> | |
164 | +#include <linux/bitops.h> | |
165 | +#include <linux/compiler.h> | |
166 | +#include <asm/atomic.h> | |
167 | + | |
168 | +enum nf_conntrack_info | |
169 | +{ | |
170 | + /* Part of an established connection (either direction). */ | |
171 | + NF_CT_ESTABLISHED, | |
172 | + | |
173 | + /* Like NEW, but related to an existing connection, or ICMP error | |
174 | + (in either direction). */ | |
175 | + NF_CT_RELATED, | |
176 | + | |
177 | + /* Started a new connection to track (only | |
178 | + NF_CT_DIR_ORIGINAL); may be a retransmission. */ | |
179 | + NF_CT_NEW, | |
180 | + | |
181 | + /* >= this indicates reply direction */ | |
182 | + NF_CT_IS_REPLY, | |
183 | + | |
184 | + /* Number of distinct NF_CT types (no NEW in reply dirn). */ | |
185 | + NF_CT_NUMBER = NF_CT_IS_REPLY * 2 - 1 | |
186 | +}; | |
187 | + | |
188 | +/* Bitset representing status of connection. */ | |
189 | +enum nf_conntrack_status { | |
190 | + /* It's an expected connection: bit 0 set. This bit never changed */ | |
191 | + NF_S_EXPECTED_BIT = 0, | |
192 | + NF_S_EXPECTED = (1 << NF_S_EXPECTED_BIT), | |
193 | + | |
194 | + /* We've seen packets both ways: bit 1 set. Can be set, not unset. */ | |
195 | + NF_S_SEEN_REPLY_BIT = 1, | |
196 | + NF_S_SEEN_REPLY = (1 << NF_S_SEEN_REPLY_BIT), | |
197 | + | |
198 | + /* Conntrack should never be early-expired. */ | |
199 | + NF_S_ASSURED_BIT = 2, | |
200 | + NF_S_ASSURED = (1 << NF_S_ASSURED_BIT), | |
201 | + | |
202 | + /* Connection is confirmed: originating packet has left box */ | |
203 | + NF_S_CONFIRMED_BIT = 3, | |
204 | + NF_S_CONFIRMED = (1 << NF_S_CONFIRMED_BIT), | |
205 | +}; | |
206 | + | |
207 | +#include <linux/netfilter/nf_conntrack_tcp.h> | |
208 | +#include <linux/netfilter/ipv4/nf_conntrack_icmp.h> | |
209 | +#include <linux/netfilter/ipv6/nf_conntrack_icmpv6.h> | |
210 | +#include <linux/netfilter/nf_conntrack_sctp.h> | |
211 | + | |
212 | +/* per conntrack: protocol private data */ | |
213 | +union nf_conntrack_proto { | |
214 | + /* insert conntrack proto private data here */ | |
215 | + struct nf_ct_sctp sctp; | |
216 | + struct nf_ct_tcp tcp; | |
217 | + struct nf_ct_icmp icmp; | |
218 | + struct nf_ct_icmpv6 icmpv6; | |
219 | +}; | |
220 | + | |
221 | +union nf_conntrack_expect_proto { | |
222 | + /* insert expect proto private data here */ | |
223 | +}; | |
224 | + | |
225 | +/* Add protocol helper include file here */ | |
226 | +#include <linux/netfilter/nf_conntrack_ftp.h> | |
227 | + | |
228 | +/* per expectation: application helper private data */ | |
229 | +union nf_conntrack_expect_help { | |
230 | + /* insert conntrack helper private data (expect) here */ | |
231 | + struct nf_ct_ftp_expect exp_ftp_info; | |
232 | + | |
233 | +#ifdef CONFIG_IP_NF_NAT_NEEDED | |
234 | + union { | |
235 | + /* insert nat helper private data (expect) here */ | |
236 | + } nat; | |
237 | +#endif | |
238 | +}; | |
239 | + | |
240 | +/* per conntrack: application helper private data */ | |
241 | +union nf_conntrack_help { | |
242 | + /* insert conntrack helper private data (master) here */ | |
243 | + struct nf_ct_ftp_master ct_ftp_info; | |
244 | +}; | |
245 | + | |
246 | +#ifdef __KERNEL__ | |
247 | + | |
248 | +#include <linux/types.h> | |
249 | +#include <linux/skbuff.h> | |
250 | + | |
251 | +#ifdef CONFIG_NETFILTER_DEBUG | |
252 | +#define NF_CT_ASSERT(x) \ | |
253 | +do { \ | |
254 | + if (!(x)) \ | |
255 | + /* Wooah! I'm tripping my conntrack in a frenzy of \ | |
256 | + netplay... */ \ | |
257 | + printk("NF_CT_ASSERT: %s:%i(%s)\n", \ | |
258 | + __FILE__, __LINE__, __FUNCTION__); \ | |
259 | +} while(0) | |
260 | +#else | |
261 | +#define NF_CT_ASSERT(x) | |
262 | +#endif | |
263 | + | |
264 | +struct nf_conntrack_expect | |
265 | +{ | |
266 | + /* Internal linked list (global expectation list) */ | |
267 | + struct list_head list; | |
268 | + | |
269 | + /* reference count */ | |
270 | + atomic_t use; | |
271 | + | |
272 | + /* expectation list for this master */ | |
273 | + struct list_head expected_list; | |
274 | + | |
275 | + /* The conntrack of the master connection */ | |
276 | + struct nf_conn *expectant; | |
277 | + | |
278 | + /* The conntrack of the sibling connection, set after | |
279 | + * expectation arrived */ | |
280 | + struct nf_conn *sibling; | |
281 | + | |
282 | + /* Tuple saved for conntrack */ | |
283 | + struct nf_conntrack_tuple ct_tuple; | |
284 | + | |
285 | + /* Timer function; deletes the expectation. */ | |
286 | + struct timer_list timeout; | |
287 | + | |
288 | + /* Data filled out by the conntrack helpers follow: */ | |
289 | + | |
290 | + /* We expect this tuple, with the following mask */ | |
291 | + struct nf_conntrack_tuple tuple, mask; | |
292 | + | |
293 | + /* Function to call after setup and insertion */ | |
294 | + int (*expectfn)(struct nf_conn *new); | |
295 | + | |
296 | + /* At which sequence number did this expectation occur */ | |
297 | + u_int32_t seq; | |
298 | + | |
299 | + union nf_conntrack_expect_proto proto; | |
300 | + | |
301 | + union nf_conntrack_expect_help help; | |
302 | +}; | |
303 | + | |
304 | +struct nf_conntrack_counter | |
305 | +{ | |
306 | + u_int64_t packets; | |
307 | + u_int64_t bytes; | |
308 | +}; | |
309 | + | |
310 | +struct nf_conntrack_helper; | |
311 | + | |
312 | +#include <linux/netfilter/ipv4/nf_conntrack_ipv4.h> | |
313 | +struct nf_conn | |
314 | +{ | |
315 | + /* Usage count in here is 1 for hash table/destruct timer, 1 per skb, | |
316 | + plus 1 for any connection(s) we are `master' for */ | |
317 | + struct nf_conntrack ct_general; | |
318 | + | |
319 | + /* XXX should I move this to the tail ? - Y.K */ | |
320 | + /* These are my tuples; original and reply */ | |
321 | + struct nf_conntrack_tuple_hash tuplehash[NF_CT_DIR_MAX]; | |
322 | + | |
323 | + /* Have we seen traffic both ways yet? (bitset) */ | |
324 | + unsigned long status; | |
325 | + | |
326 | + /* Timer function; drops refcnt when it goes off. */ | |
327 | + struct timer_list timeout; | |
328 | + | |
329 | +#ifdef CONFIG_NF_CT_ACCT | |
330 | + /* Accounting Information (same cache line as other written members) */ | |
331 | + struct nf_conntrack_counter counters[NF_CT_DIR_MAX]; | |
332 | +#endif | |
333 | + | |
334 | + /* If we're expecting another related connection, this will be | |
335 | + in expected linked list */ | |
336 | + struct list_head sibling_list; | |
337 | + | |
338 | + /* Current number of expected connections */ | |
339 | + unsigned int expecting; | |
340 | + | |
341 | + /* If we were expected by an expectation, this will be it */ | |
342 | + struct nf_conntrack_expect *master; | |
343 | + | |
344 | + /* Helper. if any */ | |
345 | + struct nf_conntrack_helper *helper; | |
346 | + | |
347 | + /* features - nat, helper, ... used by allocating system */ | |
348 | + u_int32_t features; | |
349 | + | |
350 | + /* Storage reserved for other modules: */ | |
351 | + | |
352 | + union nf_conntrack_proto proto; | |
353 | + | |
354 | +#if defined(CONFIG_NF_CONNTRACK_MARK) | |
355 | + unsigned long mark; | |
356 | +#endif | |
357 | + | |
358 | + /* These members are dynamically allocated. */ | |
359 | + | |
360 | + union nf_conntrack_help *help; | |
361 | + | |
362 | + /* Layer 3 dependent members. (ex: NAT) */ | |
363 | + union { | |
364 | + struct nf_conntrack_ipv4 *ipv4; | |
365 | + } l3proto; | |
366 | + void *data[0]; | |
367 | +}; | |
368 | + | |
369 | +/* get master conntrack via master expectation */ | |
370 | +#define master_ct(conntr) (conntr->master ? conntr->master->expectant : NULL) | |
371 | + | |
372 | +/* Alter reply tuple (maybe alter helper). If it's already taken, | |
373 | + return 0 and don't do alteration. */ | |
374 | +extern int | |
375 | +nf_conntrack_alter_reply(struct nf_conn *conntrack, | |
376 | + const struct nf_conntrack_tuple *newreply); | |
377 | + | |
378 | +/* Is this tuple taken? (ignoring any belonging to the given | |
379 | + conntrack). */ | |
380 | +extern int | |
381 | +nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple, | |
382 | + const struct nf_conn *ignored_conntrack); | |
383 | + | |
384 | +/* Return conntrack_info and tuple hash for given skb. */ | |
385 | +static inline struct nf_conn * | |
386 | +nf_ct_get(struct sk_buff *skb, enum nf_conntrack_info *ctinfo) | |
387 | +{ | |
388 | + *ctinfo = skb->nfctinfo; | |
389 | + return (struct nf_conn *)skb->nfct; | |
390 | +} | |
391 | + | |
392 | +/* decrement reference count on a conntrack */ | |
393 | +extern inline void nf_ct_put(struct nf_conn *ct); | |
394 | + | |
395 | +/* find unconfirmed expectation based on tuple */ | |
396 | +struct nf_conntrack_expect * | |
397 | +nf_conntrack_expect_find_get(const struct nf_conntrack_tuple *tuple); | |
398 | + | |
399 | +/* decrement reference count on an expectation */ | |
400 | +void nf_conntrack_expect_put(struct nf_conntrack_expect *exp); | |
401 | + | |
402 | +/* call to create an explicit dependency on nf_conntrack. */ | |
403 | +extern void need_nf_conntrack(void); | |
404 | + | |
405 | +extern int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse, | |
406 | + const struct nf_conntrack_tuple *orig); | |
407 | + | |
408 | +/* Refresh conntrack for this many jiffies */ | |
409 | +extern void nf_ct_refresh_acct(struct nf_conn *ct, | |
410 | + enum nf_conntrack_info ctinfo, | |
411 | + const struct sk_buff *skb, | |
412 | + unsigned long extra_jiffies); | |
413 | + | |
414 | +/* These are for NAT. Icky. */ | |
415 | +/* Call me when a conntrack is destroyed. */ | |
416 | +extern void (*nf_conntrack_destroyed)(struct nf_conn *conntrack); | |
417 | + | |
418 | +/* Fake conntrack entry for untracked connections */ | |
419 | +extern struct nf_conn nf_conntrack_untracked; | |
420 | + | |
421 | +extern int nf_ct_no_defrag; | |
422 | + | |
423 | +/* Delete all conntracks which match. */ | |
424 | +extern void | |
425 | +nf_ct_selective_cleanup(int (*kill)(const struct nf_conn *i, void *data), | |
426 | + void *data); | |
427 | + | |
428 | +/* It's confirmed if it is, or has been in the hash table. */ | |
429 | +static inline int is_confirmed(struct nf_conn *ct) | |
430 | +{ | |
431 | + return test_bit(NF_S_CONFIRMED_BIT, &ct->status); | |
432 | +} | |
433 | + | |
434 | +extern unsigned int nf_conntrack_htable_size; | |
435 | + | |
436 | +struct nf_conntrack_stat | |
437 | +{ | |
438 | + unsigned int searched; | |
439 | + unsigned int found; | |
440 | + unsigned int new; | |
441 | + unsigned int invalid; | |
442 | + unsigned int ignore; | |
443 | + unsigned int delete; | |
444 | + unsigned int delete_list; | |
445 | + unsigned int insert; | |
446 | + unsigned int insert_failed; | |
447 | + unsigned int drop; | |
448 | + unsigned int early_drop; | |
449 | + unsigned int error; | |
450 | + unsigned int expect_new; | |
451 | + unsigned int expect_create; | |
452 | + unsigned int expect_delete; | |
453 | +}; | |
454 | + | |
455 | +#define NF_CT_STAT_INC(count) (__get_cpu_var(nf_conntrack_stat).count++) | |
456 | + | |
457 | +/* eg. PROVIDES_CONNTRACK(ftp); */ | |
458 | +#define PROVIDES_CONNTRACK(name) \ | |
459 | + int needs_nf_conntrack_##name; \ | |
460 | + EXPORT_SYMBOL(needs_nf_conntrack_##name) | |
461 | + | |
462 | +/*. eg. NEEDS_CONNTRACK(ftp); */ | |
463 | +#define NEEDS_CONNTRACK(name) \ | |
464 | + extern int needs_nf_conntrack_##name; \ | |
465 | + static int *need_nf_conntrack_##name __attribute_used__ = &needs_nf_conntrack_##name | |
466 | + | |
467 | +/* no helper, no nat */ | |
468 | +#define NF_CT_F_BASIC 0 | |
469 | +/* for helper */ | |
470 | +#define NF_CT_F_HELP 1 | |
471 | +/* for nat. */ | |
472 | +#define NF_CT_F_NAT 2 | |
473 | +#define NF_CT_F_NUM 4 | |
474 | + | |
475 | +extern int | |
476 | +nf_conntrack_register_cache(u_int32_t features, const char *name, size_t size, | |
477 | + int (*init_conntrack)(struct nf_conn *, u_int32_t)); | |
478 | +extern void | |
479 | +nf_conntrack_unregister_cache(u_int32_t features); | |
480 | + | |
481 | +#endif /* __KERNEL__ */ | |
482 | +#endif /* _NF_CONNTRACK_H */ | |
483 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack_core.h linux-2.6.10/include/linux/netfilter/nf_conntrack_core.h | |
484 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack_core.h 1970-01-01 01:00:00.000000000 +0100 | |
485 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack_core.h 2005-01-04 10:02:37.216444264 +0100 | |
486 | @@ -0,0 +1,71 @@ | |
487 | +/* | |
488 | + * This header is used to share core functionality between the | |
489 | + * standalone connection tracking module, and the compatibility layer's use | |
490 | + * of connection tracking. | |
491 | + * | |
492 | + * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
493 | + * - generalize L3 protocol dependent part. | |
494 | + * | |
495 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_core.h | |
496 | + */ | |
497 | + | |
498 | +#ifndef _NF_CONNTRACK_CORE_H | |
499 | +#define _NF_CONNTRACK_CORE_H | |
500 | + | |
501 | +#include <linux/netfilter.h> | |
502 | +#include <linux/netfilter_ipv4/lockhelp.h> | |
503 | + | |
504 | +extern unsigned int | |
505 | +nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb); | |
506 | + | |
507 | +extern int nf_conntrack_init(void); | |
508 | +extern void nf_conntrack_cleanup(void); | |
509 | + | |
510 | +extern struct list_head protocol_list; | |
511 | + | |
512 | +struct nf_conntrack_l3proto; | |
513 | +extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf); | |
514 | +/* Like above, but you already have conntrack read lock. */ | |
515 | +extern struct nf_conntrack_l3proto *__nf_ct_find_l3proto(u_int16_t l3proto); | |
516 | +extern struct list_head l3proto_list; | |
517 | + | |
518 | +struct nf_conntrack_protocol; | |
519 | + | |
520 | +extern int nf_ct_get_tuple(const struct sk_buff *skb, | |
521 | + unsigned int nhoff, | |
522 | + unsigned int dataoff, | |
523 | + u_int16_t l3num, | |
524 | + u_int8_t protonum, | |
525 | + struct nf_conntrack_tuple *tuple, | |
526 | + const struct nf_conntrack_l3proto *l3proto, | |
527 | + const struct nf_conntrack_protocol *protocol); | |
528 | + | |
529 | +extern int nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, | |
530 | + const struct nf_conntrack_tuple *orig, | |
531 | + const struct nf_conntrack_l3proto *l3proto, | |
532 | + const struct nf_conntrack_protocol *protocol); | |
533 | + | |
534 | +/* Find a connection corresponding to a tuple. */ | |
535 | +extern struct nf_conntrack_tuple_hash * | |
536 | +nf_conntrack_find_get(const struct nf_conntrack_tuple *tuple, | |
537 | + const struct nf_conn *ignored_conntrack); | |
538 | + | |
539 | +extern int __nf_conntrack_confirm(struct sk_buff *skb); | |
540 | + | |
541 | +/* Confirm a connection: returns NF_DROP if packet must be dropped. */ | |
542 | +static inline int nf_conntrack_confirm(struct sk_buff *skb) | |
543 | +{ | |
544 | + if (skb->nfct | |
545 | + && !is_confirmed((struct nf_conn *)skb->nfct)) | |
546 | + return __nf_conntrack_confirm(skb); | |
547 | + | |
548 | + return NF_ACCEPT; | |
549 | +} | |
550 | + | |
551 | +extern void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb); | |
552 | + | |
553 | +extern struct list_head *nf_conntrack_hash; | |
554 | +extern struct list_head nf_conntrack_expect_list; | |
555 | +DECLARE_RWLOCK_EXTERN(nf_conntrack_lock); | |
556 | +DECLARE_RWLOCK_EXTERN(nf_conntrack_expect_tuple_lock); | |
557 | +#endif /* _NF_CONNTRACK_CORE_H */ | |
558 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack_ftp.h linux-2.6.10/include/linux/netfilter/nf_conntrack_ftp.h | |
559 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack_ftp.h 1970-01-01 01:00:00.000000000 +0100 | |
560 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack_ftp.h 2005-01-04 10:02:37.216444264 +0100 | |
561 | @@ -0,0 +1,59 @@ | |
562 | +/* | |
563 | + * nf_conntrack_ftp.h | |
564 | + * | |
565 | + * Definitions and Declarations for FTP tracking. | |
566 | + * | |
567 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_ftp.h | |
568 | + * | |
569 | + * 16 Dec 2003: Yasuyuki Kozakai @ USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
570 | + * - IPv6 support. | |
571 | + */ | |
572 | + | |
573 | +#ifndef _NF_CONNTRACK_FTP_H | |
574 | +#define _NF_CONNTRACK_FTP_H | |
575 | +/* FTP tracking. */ | |
576 | + | |
577 | +#ifdef __KERNEL__ | |
578 | + | |
579 | +#include <linux/netfilter_ipv4/lockhelp.h> | |
580 | + | |
581 | +/* Protects ftp part of conntracks */ | |
582 | +DECLARE_LOCK_EXTERN(ip_ftp_lock); | |
583 | + | |
584 | +#define FTP_PORT 21 | |
585 | + | |
586 | +#endif /* __KERNEL__ */ | |
587 | + | |
588 | +enum nf_ct_ftp_type | |
589 | +{ | |
590 | + /* PORT command from client */ | |
591 | + NF_CT_FTP_PORT, | |
592 | + /* PASV response from server */ | |
593 | + NF_CT_FTP_PASV, | |
594 | + /* EPRT command from client */ | |
595 | + NF_CT_FTP_EPRT, | |
596 | + /* EPSV response from server */ | |
597 | + NF_CT_FTP_EPSV, | |
598 | +}; | |
599 | + | |
600 | +/* This structure is per expected connection */ | |
601 | +struct nf_ct_ftp_expect | |
602 | +{ | |
603 | + /* We record seq number and length of ftp ip/port text here: all in | |
604 | + * host order. */ | |
605 | + | |
606 | + /* sequence number of IP address in packet is in ip_conntrack_expect */ | |
607 | + u_int32_t len; /* length of IP address */ | |
608 | + enum nf_ct_ftp_type ftptype; /* PORT or PASV ? */ | |
609 | + u_int16_t port; /* TCP port that was to be used */ | |
610 | +}; | |
611 | + | |
612 | +/* This structure exists only once per master */ | |
613 | +struct nf_ct_ftp_master { | |
614 | + /* Next valid seq position for cmd matching after newline */ | |
615 | + u_int32_t seq_aft_nl[NF_CT_DIR_MAX]; | |
616 | + /* 0 means seq_match_aft_nl not set */ | |
617 | + int seq_aft_nl_set[NF_CT_DIR_MAX]; | |
618 | +}; | |
619 | + | |
620 | +#endif /* _NF_CONNTRACK_FTP_H */ | |
621 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack_helper.h linux-2.6.10/include/linux/netfilter/nf_conntrack_helper.h | |
622 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack_helper.h 1970-01-01 01:00:00.000000000 +0100 | |
623 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack_helper.h 2005-01-04 10:02:37.217444112 +0100 | |
624 | @@ -0,0 +1,57 @@ | |
625 | +/* | |
626 | + * connection tracking helpers. | |
627 | + * | |
628 | + * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
629 | + * - generalize L3 protocol dependent part. | |
630 | + * | |
631 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_helper.h | |
632 | + */ | |
633 | + | |
634 | +#ifndef _NF_CONNTRACK_HELPER_H | |
635 | +#define _NF_CONNTRACK_HELPER_H | |
636 | +#include <linux/netfilter/nf_conntrack.h> | |
637 | + | |
638 | +struct module; | |
639 | + | |
640 | +/* Reuse expectation when max_expected reached */ | |
641 | +#define NF_CT_HELPER_F_REUSE_EXPECT 0x01 | |
642 | + | |
643 | +struct nf_conntrack_helper | |
644 | +{ | |
645 | + struct list_head list; /* Internal use. */ | |
646 | + | |
647 | + const char *name; /* name of the module */ | |
648 | + unsigned char flags; /* Flags (see above) */ | |
649 | + struct module *me; /* pointer to self */ | |
650 | + unsigned int max_expected; /* Maximum number of concurrent | |
651 | + * expected connections */ | |
652 | + unsigned int timeout; /* timeout for expecteds */ | |
653 | + | |
654 | + /* Mask of things we will help (compared against server response) */ | |
655 | + struct nf_conntrack_tuple tuple; | |
656 | + struct nf_conntrack_tuple mask; | |
657 | + | |
658 | + /* Function to call when data passes; return verdict, or -1 to | |
659 | + invalidate. */ | |
660 | + int (*help)(const struct sk_buff *skb, | |
661 | + unsigned int dataoff, | |
662 | + struct nf_conn *ct, | |
663 | + enum nf_conntrack_info conntrackinfo); | |
664 | +}; | |
665 | + | |
666 | +extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); | |
667 | +extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *); | |
668 | + | |
669 | +extern struct nf_conntrack_helper *nf_ct_find_helper(const struct nf_conntrack_tuple *tuple); | |
670 | + | |
671 | +/* Allocate space for an expectation: this is mandatory before calling | |
672 | + ip_conntrack_expect_related. */ | |
673 | +extern struct nf_conntrack_expect *nf_conntrack_expect_alloc(void); | |
674 | +/* Add an expected connection: can have more than one per connection */ | |
675 | +extern int nf_conntrack_expect_related(struct nf_conntrack_expect *exp, | |
676 | + struct nf_conn *related_to); | |
677 | +extern int nf_conntrack_change_expect(struct nf_conntrack_expect *expect, | |
678 | + struct nf_conntrack_tuple *newtuple); | |
679 | +extern void nf_conntrack_unexpect_related(struct nf_conntrack_expect *exp); | |
680 | + | |
681 | +#endif /*_NF_CONNTRACK_HELPER_H*/ | |
682 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack_l3proto.h linux-2.6.10/include/linux/netfilter/nf_conntrack_l3proto.h | |
683 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack_l3proto.h 1970-01-01 01:00:00.000000000 +0100 | |
684 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack_l3proto.h 2005-01-04 10:02:37.218443960 +0100 | |
685 | @@ -0,0 +1,93 @@ | |
686 | +/* | |
687 | + * Copyright (C)2003,2004 USAGI/WIDE Project | |
688 | + * | |
689 | + * Header for use in defining a given L3 protocol for connection tracking. | |
690 | + * | |
691 | + * Author: | |
692 | + * Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
693 | + * | |
694 | + * Derived from include/netfilter_ipv4/ip_conntrack_protocol.h | |
695 | + */ | |
696 | + | |
697 | +#ifndef _NF_CONNTRACK_L3PROTO_H | |
698 | +#define _NF_CONNTRACK_L3PROTO_H | |
699 | +#include <linux/seq_file.h> | |
700 | +#include <linux/netfilter/nf_conntrack.h> | |
701 | + | |
702 | +struct nf_conntrack_l3proto | |
703 | +{ | |
704 | + /* Next pointer. */ | |
705 | + struct list_head list; | |
706 | + | |
707 | + /* L3 Protocol Family number. ex) PF_INET */ | |
708 | + u_int16_t l3proto; | |
709 | + | |
710 | + /* Protocol name */ | |
711 | + const char *name; | |
712 | + | |
713 | + /* | |
714 | + * Try to fill in the third arg: nhoff is offset of l3 proto | |
715 | + * hdr. Return true if possible. | |
716 | + */ | |
717 | + int (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff, | |
718 | + struct nf_conntrack_tuple *tuple); | |
719 | + | |
720 | + /* | |
721 | + * Invert the per-proto part of the tuple: ie. turn xmit into reply. | |
722 | + * Some packets can't be inverted: return 0 in that case. | |
723 | + */ | |
724 | + int (*invert_tuple)(struct nf_conntrack_tuple *inverse, | |
725 | + const struct nf_conntrack_tuple *orig); | |
726 | + | |
727 | + /* Print out the per-protocol part of the tuple. */ | |
728 | + int (*print_tuple)(struct seq_file *s, | |
729 | + const struct nf_conntrack_tuple *); | |
730 | + | |
731 | + /* Print out the private part of the conntrack. */ | |
732 | + int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); | |
733 | + | |
734 | + /* Returns verdict for packet, or -1 for invalid. */ | |
735 | + int (*packet)(struct nf_conn *conntrack, | |
736 | + const struct sk_buff *skb, | |
737 | + enum nf_conntrack_info ctinfo); | |
738 | + | |
739 | + /* | |
740 | + * Called when a new connection for this protocol found; | |
741 | + * returns TRUE if it's OK. If so, packet() called next. | |
742 | + */ | |
743 | + int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb); | |
744 | + | |
745 | + /* Called when a conntrack entry is destroyed */ | |
746 | + void (*destroy)(struct nf_conn *conntrack); | |
747 | + | |
748 | + /* | |
749 | + * Called before tracking. | |
750 | + * *dataoff: offset of protocol header (TCP, UDP,...) in *pskb | |
751 | + * *protonum: protocol number | |
752 | + */ | |
753 | + int (*prepare)(struct sk_buff **pskb, unsigned int hooknum, | |
754 | + unsigned int *dataoff, u_int8_t *protonum, int *ret); | |
755 | + | |
756 | + u_int32_t (*get_features)(const struct nf_conntrack_tuple *tuple); | |
757 | + | |
758 | + /* Module (if any) which this is connected to. */ | |
759 | + struct module *me; | |
760 | +}; | |
761 | + | |
762 | +extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX]; | |
763 | + | |
764 | +/* Protocol registration. */ | |
765 | +extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); | |
766 | +extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto); | |
767 | + | |
768 | +static inline struct nf_conntrack_l3proto * | |
769 | +nf_ct_find_l3proto(u_int16_t l3proto) | |
770 | +{ | |
771 | + return nf_ct_l3protos[l3proto]; | |
772 | +} | |
773 | + | |
774 | +/* Existing built-in protocols */ | |
775 | +extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4; | |
776 | +extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6; | |
777 | +extern struct nf_conntrack_l3proto nf_conntrack_generic_l3proto; | |
778 | +#endif /*_NF_CONNTRACK_L3PROTO_H*/ | |
779 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack_protocol.h linux-2.6.10/include/linux/netfilter/nf_conntrack_protocol.h | |
780 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack_protocol.h 1970-01-01 01:00:00.000000000 +0100 | |
781 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack_protocol.h 2005-01-04 10:02:37.219443808 +0100 | |
782 | @@ -0,0 +1,110 @@ | |
783 | +/* | |
784 | + * Header for use in defining a given protocol for connection tracking. | |
785 | + * | |
786 | + * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
787 | + * - generalized L3 protocol dependent part. | |
788 | + * | |
789 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_protcol.h | |
790 | + */ | |
791 | + | |
792 | +#ifndef _NF_CONNTRACK_PROTOCOL_H | |
793 | +#define _NF_CONNTRACK_PROTOCOL_H | |
794 | +#include <linux/netfilter/nf_conntrack.h> | |
795 | + | |
796 | +struct seq_file; | |
797 | + | |
798 | +struct nf_conntrack_protocol | |
799 | +{ | |
800 | + /* Next pointer. */ | |
801 | + struct list_head list; | |
802 | + | |
803 | + /* L3 Protocol number. */ | |
804 | + u_int16_t l3proto; | |
805 | + | |
806 | + /* Protocol number. */ | |
807 | + u_int8_t proto; | |
808 | + | |
809 | + /* Protocol name */ | |
810 | + const char *name; | |
811 | + | |
812 | + /* Try to fill in the third arg: dataoff is offset past NF | |
813 | + hdr. Return true if possible. */ | |
814 | + int (*pkt_to_tuple)(const struct sk_buff *skb, | |
815 | + unsigned int dataoff, | |
816 | + struct nf_conntrack_tuple *tuple); | |
817 | + | |
818 | + /* Invert the per-proto part of the tuple: ie. turn xmit into reply. | |
819 | + * Some packets can't be inverted: return 0 in that case. | |
820 | + */ | |
821 | + int (*invert_tuple)(struct nf_conntrack_tuple *inverse, | |
822 | + const struct nf_conntrack_tuple *orig); | |
823 | + | |
824 | + /* Print out the per-protocol part of the tuple. Return like seq_* */ | |
825 | + int (*print_tuple)(struct seq_file *s, | |
826 | + const struct nf_conntrack_tuple *); | |
827 | + | |
828 | + /* Print out the private part of the conntrack. */ | |
829 | + int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); | |
830 | + | |
831 | + /* Returns verdict for packet, or -1 for invalid. */ | |
832 | + int (*packet)(struct nf_conn *conntrack, | |
833 | + const struct sk_buff *skb, | |
834 | + unsigned int dataoff, | |
835 | + enum nf_conntrack_info ctinfo, | |
836 | + int pf, | |
837 | + unsigned int hooknum); | |
838 | + | |
839 | + /* Called when a new connection for this protocol found; | |
840 | + * returns TRUE if it's OK. If so, packet() called next. */ | |
841 | + int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb, | |
842 | + unsigned int dataoff); | |
843 | + | |
844 | + /* Called when a conntrack entry is destroyed */ | |
845 | + void (*destroy)(struct nf_conn *conntrack); | |
846 | + | |
847 | + /* Has to decide if a expectation matches one packet or not */ | |
848 | + int (*exp_matches_pkt)(struct nf_conntrack_expect *exp, | |
849 | + const struct sk_buff *skb, | |
850 | + unsigned int dataoff); | |
851 | + | |
852 | + int (*error)(struct sk_buff *skb, unsigned int dataoff, | |
853 | + enum nf_conntrack_info *ctinfo, | |
854 | + int pf, unsigned int hooknum); | |
855 | + | |
856 | + /* Module (if any) which this is connected to. */ | |
857 | + struct module *me; | |
858 | +}; | |
859 | + | |
860 | +/* Existing built-in protocols */ | |
861 | +extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp6; | |
862 | +extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4; | |
863 | +extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6; | |
864 | +extern struct nf_conntrack_protocol nf_conntrack_generic_protocol; | |
865 | + | |
866 | +#define MAX_NF_CT_PROTO 256 | |
867 | +extern struct nf_conntrack_protocol **nf_ct_protos[PF_MAX]; | |
868 | + | |
869 | +extern struct nf_conntrack_protocol * | |
870 | +nf_ct_find_proto(u_int16_t l3proto, u_int8_t protocol); | |
871 | + | |
872 | +/* Protocol registration. */ | |
873 | +extern int nf_conntrack_protocol_register(struct nf_conntrack_protocol *proto); | |
874 | +extern void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol *proto); | |
875 | + | |
876 | +/* Log invalid packets */ | |
877 | +extern unsigned int nf_ct_log_invalid; | |
878 | + | |
879 | +#ifdef CONFIG_SYSCTL | |
880 | +#ifdef DEBUG_INVALID_PACKETS | |
881 | +#define LOG_INVALID(proto) \ | |
882 | + (nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) | |
883 | +#else | |
884 | +#define LOG_INVALID(proto) \ | |
885 | + ((nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) \ | |
886 | + && net_ratelimit()) | |
887 | +#endif | |
888 | +#else | |
889 | +#define LOG_INVALID(proto) 0 | |
890 | +#endif /* CONFIG_SYSCTL */ | |
891 | + | |
892 | +#endif /*_NF_CONNTRACK_PROTOCOL_H*/ | |
893 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack_sctp.h linux-2.6.10/include/linux/netfilter/nf_conntrack_sctp.h | |
894 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack_sctp.h 1970-01-01 01:00:00.000000000 +0100 | |
895 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack_sctp.h 2005-01-04 10:02:37.219443808 +0100 | |
896 | @@ -0,0 +1,30 @@ | |
897 | +/* | |
898 | + * SCTP tracking. | |
899 | + * | |
900 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_tcp.h | |
901 | + */ | |
902 | + | |
903 | +#ifndef _NF_CONNTRACK_SCTP_H | |
904 | +#define _NF_CONNTRACK_SCTP_H | |
905 | + | |
906 | +enum sctp_conntrack { | |
907 | + SCTP_CONNTRACK_NONE, | |
908 | + SCTP_CONNTRACK_CLOSED, | |
909 | + SCTP_CONNTRACK_COOKIE_WAIT, | |
910 | + SCTP_CONNTRACK_COOKIE_ECHOED, | |
911 | + SCTP_CONNTRACK_ESTABLISHED, | |
912 | + SCTP_CONNTRACK_SHUTDOWN_SENT, | |
913 | + SCTP_CONNTRACK_SHUTDOWN_RECD, | |
914 | + SCTP_CONNTRACK_SHUTDOWN_ACK_SENT, | |
915 | + SCTP_CONNTRACK_MAX | |
916 | +}; | |
917 | + | |
918 | +struct nf_ct_sctp | |
919 | +{ | |
920 | + enum sctp_conntrack state; | |
921 | + | |
922 | + u_int32_t vtag[NF_CT_DIR_MAX]; | |
923 | + u_int32_t ttag[NF_CT_DIR_MAX]; | |
924 | +}; | |
925 | + | |
926 | +#endif /* _NF_CONNTRACK_SCTP_H */ | |
927 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack_tcp.h linux-2.6.10/include/linux/netfilter/nf_conntrack_tcp.h | |
928 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack_tcp.h 1970-01-01 01:00:00.000000000 +0100 | |
929 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack_tcp.h 2005-01-04 10:02:37.220443656 +0100 | |
930 | @@ -0,0 +1,58 @@ | |
931 | +/* | |
932 | + * TCP tracking. | |
933 | + * | |
934 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_tcp.h | |
935 | + */ | |
936 | + | |
937 | +#ifndef _NF_CONNTRACK_TCP_H | |
938 | +#define _NF_CONNTRACK_TCP_H | |
939 | + | |
940 | +enum tcp_conntrack { | |
941 | + TCP_CONNTRACK_NONE, | |
942 | + TCP_CONNTRACK_SYN_SENT, | |
943 | + TCP_CONNTRACK_SYN_RECV, | |
944 | + TCP_CONNTRACK_ESTABLISHED, | |
945 | + TCP_CONNTRACK_FIN_WAIT, | |
946 | + TCP_CONNTRACK_CLOSE_WAIT, | |
947 | + TCP_CONNTRACK_LAST_ACK, | |
948 | + TCP_CONNTRACK_TIME_WAIT, | |
949 | + TCP_CONNTRACK_CLOSE, | |
950 | + TCP_CONNTRACK_LISTEN, | |
951 | + TCP_CONNTRACK_MAX, | |
952 | + TCP_CONNTRACK_IGNORE | |
953 | +}; | |
954 | + | |
955 | +/* Window scaling is advertised by the sender */ | |
956 | +#define NF_CT_TCP_STATE_FLAG_WINDOW_SCALE 0x01 | |
957 | + | |
958 | +/* SACK is permitted by the sender */ | |
959 | +#define NF_CT_TCP_FLAG_SACK_PERM 0x02 | |
960 | + | |
961 | +struct nf_ct_tcp_state { | |
962 | + u_int32_t td_end; /* max of seq + len */ | |
963 | + u_int32_t td_maxend; /* max of ack + max(win, 1) */ | |
964 | + u_int32_t td_maxwin; /* max(win) */ | |
965 | + u_int8_t td_scale; /* window scale factor */ | |
966 | + u_int8_t loose; /* used when connection picked up from the middle */ | |
967 | + u_int8_t flags; /* per direction state flags */ | |
968 | + }; | |
969 | + | |
970 | +struct nf_ct_tcp | |
971 | +{ | |
972 | + struct nf_ct_tcp_state seen[2]; /* connection parameters per direction */ | |
973 | + u_int8_t state; /* state of the connection (enum tcp_conntrack) */ | |
974 | + /* For detecting stale connections */ | |
975 | + u_int8_t last_dir; /* Direction of the last packet (enum nf_conntrack_dir) */ | |
976 | + u_int8_t retrans; /* Number of retransmitted packets */ | |
977 | + u_int8_t last_index; /* Index of the last packet */ | |
978 | + u_int32_t last_seq; /* Last sequence number seen in dir */ | |
979 | + u_int32_t last_end; /* Last seq + len */ | |
980 | +}; | |
981 | + | |
982 | +/* Update TCP window tracking data when NAT mangles the packet */ | |
983 | +extern int nf_conntrack_tcp_update(struct sk_buff *skb, | |
984 | + unsigned int dataoff, | |
985 | + struct nf_conn *conntrack, | |
986 | + int dir); | |
987 | + | |
988 | +#endif /* _NF_CONNTRACK_TCP_H */ | |
989 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter/nf_conntrack_tuple.h linux-2.6.10/include/linux/netfilter/nf_conntrack_tuple.h | |
990 | --- linux-2.6.10.org/include/linux/netfilter/nf_conntrack_tuple.h 1970-01-01 01:00:00.000000000 +0100 | |
991 | +++ linux-2.6.10/include/linux/netfilter/nf_conntrack_tuple.h 2005-01-04 10:02:37.221443504 +0100 | |
992 | @@ -0,0 +1,195 @@ | |
993 | +/* | |
994 | + * Definitions and Declarations for tuple. | |
995 | + * | |
996 | + * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | |
997 | + * - generalize L3 protocol dependent part. | |
998 | + * | |
999 | + * Derived from include/linux/netfiter_ipv4/ip_conntrack_tuple.h | |
1000 | + */ | |
1001 | + | |
1002 | +#ifndef _NF_CONNTRACK_TUPLE_H | |
1003 | +#define _NF_CONNTRACK_TUPLE_H | |
1004 | + | |
1005 | +/* A `tuple' is a structure containing the information to uniquely | |
1006 | + identify a connection. ie. if two packets have the same tuple, they | |
1007 | + are in the same connection; if not, they are not. | |
1008 | + | |
1009 | + We divide the structure along "manipulatable" and | |
1010 | + "non-manipulatable" lines, for the benefit of the NAT code. | |
1011 | +*/ | |
1012 | + | |
1013 | +#define NF_CT_TUPLE_L3SIZE 4 | |
1014 | + | |
1015 | +/* The l3 protocol-specific manipulable parts of the tuple: always in | |
1016 | + network order! */ | |
1017 | +union nf_conntrack_man_l3proto { | |
1018 | + u_int32_t all[NF_CT_TUPLE_L3SIZE]; | |
1019 | + u_int32_t ip; | |
1020 | + u_int32_t ip6[4]; | |
1021 | +}; | |
1022 | + | |
1023 | +/* The protocol-specific manipulable parts of the tuple: always in | |
1024 | + network order! */ | |
1025 | +union nf_conntrack_man_proto | |
1026 | +{ | |
1027 | + /* Add other protocols here. */ | |
1028 | + u_int16_t all; | |
1029 | + | |
1030 | + struct { | |
1031 | + u_int16_t port; | |
1032 | + } tcp; | |
1033 | + struct { | |
1034 | + u_int16_t port; | |
1035 | + } udp; | |
1036 | + struct { | |
1037 | + u_int16_t id; | |
1038 | + } icmp; | |
1039 | + struct { | |
1040 | + u_int16_t port; | |
1041 | + } sctp; | |
1042 | +}; | |
1043 | + | |
1044 | +/* The manipulable part of the tuple. */ | |
1045 | +struct nf_conntrack_man | |
1046 | +{ | |
1047 | + union nf_conntrack_man_l3proto u3; | |
1048 | + union nf_conntrack_man_proto u; | |
1049 | + /* Layer 3 protocol */ | |
1050 | + u_int16_t l3num; | |
1051 | +}; | |
1052 | + | |
1053 | +/* This contains the information to distinguish a connection. */ | |
1054 | +struct nf_conntrack_tuple | |
1055 | +{ | |
1056 | + struct nf_conntrack_man src; | |
1057 | + | |
1058 | + /* These are the parts of the tuple which are fixed. */ | |
1059 | + struct { | |
1060 | + union { | |
1061 | + u_int32_t all[NF_CT_TUPLE_L3SIZE]; | |
1062 | + u_int32_t ip; | |
1063 | + u_int32_t ip6[4]; | |
1064 | + } u3; | |
1065 | + union { | |
1066 | + /* Add other protocols here. */ | |
1067 | + u_int16_t all; | |
1068 | + | |
1069 | + struct { | |
1070 | + u_int16_t port; | |
1071 | + } tcp; | |
1072 | + struct { | |
1073 | + u_int16_t port; | |
1074 | + } udp; | |
1075 | + struct { | |
1076 | + u_int8_t type, code; | |
1077 | + } icmp; | |
1078 | + struct { | |
1079 | + u_int16_t port; | |
1080 | + } sctp; | |
1081 | + } u; | |
1082 | + | |
1083 | + /* The protocol. */ | |
1084 | + u_int16_t protonum; | |
1085 | + } dst; | |
1086 | +}; | |
1087 | + | |
1088 | +/* This is optimized opposed to a memset of the whole structure. Everything we | |
1089 | + * really care about is the source/destination unions */ | |
1090 | +#define NF_CT_TUPLE_U_BLANK(tuple) \ | |
1091 | + do { \ | |
1092 | + (tuple)->src.u.all = 0; \ | |
1093 | + (tuple)->dst.u.all = 0; \ | |
1094 | + memset((tuple)->src.u3.all, 0, \ | |
1095 | + sizeof(u_int32_t)*NF_CT_TUPLE_L3SIZE); \ | |
1096 | + memset((tuple)->dst.u3.all, 0, \ | |
1097 | + sizeof(u_int32_t)*NF_CT_TUPLE_L3SIZE); \ | |
1098 | + } while (0) | |
1099 | + | |
1100 | +enum nf_conntrack_dir | |
1101 | +{ | |
1102 | + NF_CT_DIR_ORIGINAL, | |
1103 | + NF_CT_DIR_REPLY, | |
1104 | + NF_CT_DIR_MAX | |
1105 | +}; | |
1106 | + | |
1107 | +#ifdef __KERNEL__ | |
1108 | + | |
1109 | +#define NF_CT_DUMP_TUPLE(tp) \ | |
1110 | +DEBUGP("tuple %p: %u %u %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x %hu -> %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x %hu\n", \ | |
1111 | + (tp), (tp)->src.l3num, (tp)->dst.protonum, \ | |
1112 | + NIP6(*(struct in6_addr *)(tp)->src.u3.all), ntohs((tp)->src.u.all), \ | |
1113 | + NIP6(*(struct in6_addr *)(tp)->dst.u3.all), ntohs((tp)->dst.u.all)) | |
1114 | + | |
1115 | +#define NFCTINFO2DIR(ctinfo) ((ctinfo) >= NF_CT_IS_REPLY ? NF_CT_DIR_REPLY : NF_CT_DIR_ORIGINAL) | |
1116 | + | |
1117 | +/* If we're the first tuple, it's the original dir. */ | |
1118 | +#define NF_CT_DIRECTION(h) \ | |
1119 | + ((enum nf_conntrack_dir)(&(h)->ctrack->tuplehash[1] == (h))) | |
1120 | + | |
1121 | +/* Connections have two entries in the hash table: one for each way */ | |
1122 | +struct nf_conntrack_tuple_hash | |
1123 | +{ | |
1124 | + struct list_head list; | |
1125 | + | |
1126 | + struct nf_conntrack_tuple tuple; | |
1127 | + | |
1128 | + /* this == &ctrack->tuplehash[DIRECTION(this)]. */ | |
1129 | + struct nf_conn *ctrack; | |
1130 | +}; | |
1131 | + | |
1132 | +#endif /* __KERNEL__ */ | |
1133 | + | |
1134 | +static inline int nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, | |
1135 | + const struct nf_conntrack_tuple *t2) | |
1136 | +{ | |
1137 | + return (!memcmp(t1->src.u3.all, t2->src.u3.all, sizeof(t1->src.u3.all))) | |
1138 | + && (t1->src.u.all == t2->src.u.all) | |
1139 | + && (t1->src.l3num == t2->src.l3num) | |
1140 | + && (t1->dst.protonum == t2->dst.protonum); | |
1141 | +} | |
1142 | + | |
1143 | +static inline int nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1, | |
1144 | + const struct nf_conntrack_tuple *t2) | |
1145 | +{ | |
1146 | + return (!memcmp(t1->dst.u3.all, t2->dst.u3.all, sizeof(t1->dst.u3.all))) | |
1147 | + && (t1->dst.u.all == t2->dst.u.all) | |
1148 | + && (t1->src.l3num == t2->src.l3num) | |
1149 | + && (t1->dst.protonum == t2->dst.protonum); | |
1150 | +} | |
1151 | + | |
1152 | +static inline int nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1, | |
1153 | + const struct nf_conntrack_tuple *t2) | |
1154 | +{ | |
1155 | + return nf_ct_tuple_src_equal(t1, t2) && nf_ct_tuple_dst_equal(t1, t2); | |
1156 | +} | |
1157 | + | |
1158 | +static inline int nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t, | |
1159 | + const struct nf_conntrack_tuple *tuple, | |
1160 | + const struct nf_conntrack_tuple *mask) | |
1161 | +{ | |
1162 | + int count = 0; | |
1163 | + | |
1164 | + for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++){ | |
1165 | + if ((ntohs(t->src.u3.all[count]) ^ | |
1166 | + ntohs(tuple->src.u3.all[count])) & | |
1167 | + ntohs(mask->src.u3.all[count])) | |
1168 | + return 0; | |
1169 | + } | |
1170 | + | |
1171 | + for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++){ | |
1172 | + if ((ntohs(t->dst.u3.all[count]) ^ | |
1173 | + ntohs(tuple->dst.u3.all[count])) & | |
1174 | + ntohs(mask->dst.u3.all[count])) | |
1175 | + return 0; | |
1176 | + } | |
1177 | + | |
1178 | + if ((t->src.u.all ^ tuple->src.u.all) & mask->src.u.all || | |
1179 | + (t->dst.u.all ^ tuple->dst.u.all) & mask->dst.u.all || | |
1180 | + (t->src.l3num ^ tuple->src.l3num) & mask->src.l3num || | |
1181 | + (t->dst.protonum ^ tuple->dst.protonum) & mask->dst.protonum) | |
1182 | + return 0; | |
1183 | + | |
1184 | + return 1; | |
1185 | +} | |
1186 | + | |
1187 | +#endif /* _NF_CONNTRACK_TUPLE_H */ | |
1188 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_conntrack.h linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack.h | |
1189 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_conntrack.h 2004-12-24 22:35:28.000000000 +0100 | |
1190 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack.h 2005-01-04 10:02:37.221443504 +0100 | |
1191 | @@ -51,11 +51,13 @@ | |
1192 | ||
1193 | #include <linux/netfilter_ipv4/ip_conntrack_tcp.h> | |
1194 | #include <linux/netfilter_ipv4/ip_conntrack_icmp.h> | |
1195 | +#include <linux/netfilter_ipv4/ip_conntrack_proto_gre.h> | |
1196 | #include <linux/netfilter_ipv4/ip_conntrack_sctp.h> | |
1197 | ||
1198 | /* per conntrack: protocol private data */ | |
1199 | union ip_conntrack_proto { | |
1200 | /* insert conntrack proto private data here */ | |
1201 | + struct ip_ct_gre gre; | |
1202 | struct ip_ct_sctp sctp; | |
1203 | struct ip_ct_tcp tcp; | |
1204 | struct ip_ct_icmp icmp; | |
1205 | @@ -63,9 +65,11 @@ | |
1206 | ||
1207 | union ip_conntrack_expect_proto { | |
1208 | /* insert expect proto private data here */ | |
1209 | + struct ip_ct_gre_expect gre; | |
1210 | }; | |
1211 | ||
1212 | /* Add protocol helper include file here */ | |
1213 | +#include <linux/netfilter_ipv4/ip_conntrack_pptp.h> | |
1214 | #include <linux/netfilter_ipv4/ip_conntrack_amanda.h> | |
1215 | #include <linux/netfilter_ipv4/ip_conntrack_ftp.h> | |
1216 | #include <linux/netfilter_ipv4/ip_conntrack_irc.h> | |
1217 | @@ -73,6 +77,7 @@ | |
1218 | /* per expectation: application helper private data */ | |
1219 | union ip_conntrack_expect_help { | |
1220 | /* insert conntrack helper private data (expect) here */ | |
1221 | + struct ip_ct_pptp_expect exp_pptp_info; | |
1222 | struct ip_ct_amanda_expect exp_amanda_info; | |
1223 | struct ip_ct_ftp_expect exp_ftp_info; | |
1224 | struct ip_ct_irc_expect exp_irc_info; | |
1225 | @@ -87,16 +92,19 @@ | |
1226 | /* per conntrack: application helper private data */ | |
1227 | union ip_conntrack_help { | |
1228 | /* insert conntrack helper private data (master) here */ | |
1229 | + struct ip_ct_pptp_master ct_pptp_info; | |
1230 | struct ip_ct_ftp_master ct_ftp_info; | |
1231 | struct ip_ct_irc_master ct_irc_info; | |
1232 | }; | |
1233 | ||
1234 | #ifdef CONFIG_IP_NF_NAT_NEEDED | |
1235 | #include <linux/netfilter_ipv4/ip_nat.h> | |
1236 | +#include <linux/netfilter_ipv4/ip_nat_pptp.h> | |
1237 | ||
1238 | /* per conntrack: nat application helper private data */ | |
1239 | union ip_conntrack_nat_help { | |
1240 | /* insert nat helper private data here */ | |
1241 | + struct ip_nat_pptp nat_pptp_info; | |
1242 | }; | |
1243 | #endif | |
1244 | ||
1245 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_conntrack_pptp.h linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack_pptp.h | |
1246 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_conntrack_pptp.h 1970-01-01 01:00:00.000000000 +0100 | |
1247 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack_pptp.h 2005-01-04 10:02:37.223443200 +0100 | |
1248 | @@ -0,0 +1,310 @@ | |
1249 | +/* PPTP constants and structs */ | |
1250 | +#ifndef _CONNTRACK_PPTP_H | |
1251 | +#define _CONNTRACK_PPTP_H | |
1252 | + | |
1253 | +/* state of the control session */ | |
1254 | +enum pptp_ctrlsess_state { | |
1255 | + PPTP_SESSION_NONE, /* no session present */ | |
1256 | + PPTP_SESSION_ERROR, /* some session error */ | |
1257 | + PPTP_SESSION_STOPREQ, /* stop_sess request seen */ | |
1258 | + PPTP_SESSION_REQUESTED, /* start_sess request seen */ | |
1259 | + PPTP_SESSION_CONFIRMED, /* session established */ | |
1260 | +}; | |
1261 | + | |
1262 | +/* state of the call inside the control session */ | |
1263 | +enum pptp_ctrlcall_state { | |
1264 | + PPTP_CALL_NONE, | |
1265 | + PPTP_CALL_ERROR, | |
1266 | + PPTP_CALL_OUT_REQ, | |
1267 | + PPTP_CALL_OUT_CONF, | |
1268 | + PPTP_CALL_IN_REQ, | |
1269 | + PPTP_CALL_IN_REP, | |
1270 | + PPTP_CALL_IN_CONF, | |
1271 | + PPTP_CALL_CLEAR_REQ, | |
1272 | +}; | |
1273 | + | |
1274 | + | |
1275 | +/* conntrack private data */ | |
1276 | +struct ip_ct_pptp_master { | |
1277 | + enum pptp_ctrlsess_state sstate; /* session state */ | |
1278 | + | |
1279 | + /* everything below is going to be per-expectation in newnat, | |
1280 | + * since there could be more than one call within one session */ | |
1281 | + enum pptp_ctrlcall_state cstate; /* call state */ | |
1282 | + u_int16_t pac_call_id; /* call id of PAC, host byte order */ | |
1283 | + u_int16_t pns_call_id; /* call id of PNS, host byte order */ | |
1284 | +}; | |
1285 | + | |
1286 | +/* conntrack_expect private member */ | |
1287 | +struct ip_ct_pptp_expect { | |
1288 | + enum pptp_ctrlcall_state cstate; /* call state */ | |
1289 | + u_int16_t pac_call_id; /* call id of PAC */ | |
1290 | + u_int16_t pns_call_id; /* call id of PNS */ | |
1291 | +}; | |
1292 | + | |
1293 | + | |
1294 | +#ifdef __KERNEL__ | |
1295 | + | |
1296 | +#include <linux/netfilter_ipv4/lockhelp.h> | |
1297 | +DECLARE_LOCK_EXTERN(ip_pptp_lock); | |
1298 | + | |
1299 | +#define IP_CONNTR_PPTP PPTP_CONTROL_PORT | |
1300 | + | |
1301 | +#define PPTP_CONTROL_PORT 1723 | |
1302 | + | |
1303 | +#define PPTP_PACKET_CONTROL 1 | |
1304 | +#define PPTP_PACKET_MGMT 2 | |
1305 | + | |
1306 | +#define PPTP_MAGIC_COOKIE 0x1a2b3c4d | |
1307 | + | |
1308 | +struct pptp_pkt_hdr { | |
1309 | + __u16 packetLength; | |
1310 | + __u16 packetType; | |
1311 | + __u32 magicCookie; | |
1312 | +}; | |
1313 | + | |
1314 | +/* PptpControlMessageType values */ | |
1315 | +#define PPTP_START_SESSION_REQUEST 1 | |
1316 | +#define PPTP_START_SESSION_REPLY 2 | |
1317 | +#define PPTP_STOP_SESSION_REQUEST 3 | |
1318 | +#define PPTP_STOP_SESSION_REPLY 4 | |
1319 | +#define PPTP_ECHO_REQUEST 5 | |
1320 | +#define PPTP_ECHO_REPLY 6 | |
1321 | +#define PPTP_OUT_CALL_REQUEST 7 | |
1322 | +#define PPTP_OUT_CALL_REPLY 8 | |
1323 | +#define PPTP_IN_CALL_REQUEST 9 | |
1324 | +#define PPTP_IN_CALL_REPLY 10 | |
1325 | +#define PPTP_IN_CALL_CONNECT 11 | |
1326 | +#define PPTP_CALL_CLEAR_REQUEST 12 | |
1327 | +#define PPTP_CALL_DISCONNECT_NOTIFY 13 | |
1328 | +#define PPTP_WAN_ERROR_NOTIFY 14 | |
1329 | +#define PPTP_SET_LINK_INFO 15 | |
1330 | + | |
1331 | +#define PPTP_MSG_MAX 15 | |
1332 | + | |
1333 | +/* PptpGeneralError values */ | |
1334 | +#define PPTP_ERROR_CODE_NONE 0 | |
1335 | +#define PPTP_NOT_CONNECTED 1 | |
1336 | +#define PPTP_BAD_FORMAT 2 | |
1337 | +#define PPTP_BAD_VALUE 3 | |
1338 | +#define PPTP_NO_RESOURCE 4 | |
1339 | +#define PPTP_BAD_CALLID 5 | |
1340 | +#define PPTP_REMOVE_DEVICE_ERROR 6 | |
1341 | + | |
1342 | +struct PptpControlHeader { | |
1343 | + __u16 messageType; | |
1344 | + __u16 reserved; | |
1345 | +}; | |
1346 | + | |
1347 | +/* FramingCapability Bitmap Values */ | |
1348 | +#define PPTP_FRAME_CAP_ASYNC 0x1 | |
1349 | +#define PPTP_FRAME_CAP_SYNC 0x2 | |
1350 | + | |
1351 | +/* BearerCapability Bitmap Values */ | |
1352 | +#define PPTP_BEARER_CAP_ANALOG 0x1 | |
1353 | +#define PPTP_BEARER_CAP_DIGITAL 0x2 | |
1354 | + | |
1355 | +struct PptpStartSessionRequest { | |
1356 | + __u16 protocolVersion; | |
1357 | + __u8 reserved1; | |
1358 | + __u8 reserved2; | |
1359 | + __u32 framingCapability; | |
1360 | + __u32 bearerCapability; | |
1361 | + __u16 maxChannels; | |
1362 | + __u16 firmwareRevision; | |
1363 | + __u8 hostName[64]; | |
1364 | + __u8 vendorString[64]; | |
1365 | +}; | |
1366 | + | |
1367 | +/* PptpStartSessionResultCode Values */ | |
1368 | +#define PPTP_START_OK 1 | |
1369 | +#define PPTP_START_GENERAL_ERROR 2 | |
1370 | +#define PPTP_START_ALREADY_CONNECTED 3 | |
1371 | +#define PPTP_START_NOT_AUTHORIZED 4 | |
1372 | +#define PPTP_START_UNKNOWN_PROTOCOL 5 | |
1373 | + | |
1374 | +struct PptpStartSessionReply { | |
1375 | + __u16 protocolVersion; | |
1376 | + __u8 resultCode; | |
1377 | + __u8 generalErrorCode; | |
1378 | + __u32 framingCapability; | |
1379 | + __u32 bearerCapability; | |
1380 | + __u16 maxChannels; | |
1381 | + __u16 firmwareRevision; | |
1382 | + __u8 hostName[64]; | |
1383 | + __u8 vendorString[64]; | |
1384 | +}; | |
1385 | + | |
1386 | +/* PptpStopReasons */ | |
1387 | +#define PPTP_STOP_NONE 1 | |
1388 | +#define PPTP_STOP_PROTOCOL 2 | |
1389 | +#define PPTP_STOP_LOCAL_SHUTDOWN 3 | |
1390 | + | |
1391 | +struct PptpStopSessionRequest { | |
1392 | + __u8 reason; | |
1393 | +}; | |
1394 | + | |
1395 | +/* PptpStopSessionResultCode */ | |
1396 | +#define PPTP_STOP_OK 1 | |
1397 | +#define PPTP_STOP_GENERAL_ERROR 2 | |
1398 | + | |
1399 | +struct PptpStopSessionReply { | |
1400 | + __u8 resultCode; | |
1401 | + __u8 generalErrorCode; | |
1402 | +}; | |
1403 | + | |
1404 | +struct PptpEchoRequest { | |
1405 | + __u32 identNumber; | |
1406 | +}; | |
1407 | + | |
1408 | +/* PptpEchoReplyResultCode */ | |
1409 | +#define PPTP_ECHO_OK 1 | |
1410 | +#define PPTP_ECHO_GENERAL_ERROR 2 | |
1411 | + | |
1412 | +struct PptpEchoReply { | |
1413 | + __u32 identNumber; | |
1414 | + __u8 resultCode; | |
1415 | + __u8 generalErrorCode; | |
1416 | + __u16 reserved; | |
1417 | +}; | |
1418 | + | |
1419 | +/* PptpFramingType */ | |
1420 | +#define PPTP_ASYNC_FRAMING 1 | |
1421 | +#define PPTP_SYNC_FRAMING 2 | |
1422 | +#define PPTP_DONT_CARE_FRAMING 3 | |
1423 | + | |
1424 | +/* PptpCallBearerType */ | |
1425 | +#define PPTP_ANALOG_TYPE 1 | |
1426 | +#define PPTP_DIGITAL_TYPE 2 | |
1427 | +#define PPTP_DONT_CARE_BEARER_TYPE 3 | |
1428 | + | |
1429 | +struct PptpOutCallRequest { | |
1430 | + __u16 callID; | |
1431 | + __u16 callSerialNumber; | |
1432 | + __u32 minBPS; | |
1433 | + __u32 maxBPS; | |
1434 | + __u32 bearerType; | |
1435 | + __u32 framingType; | |
1436 | + __u16 packetWindow; | |
1437 | + __u16 packetProcDelay; | |
1438 | + __u16 reserved1; | |
1439 | + __u16 phoneNumberLength; | |
1440 | + __u16 reserved2; | |
1441 | + __u8 phoneNumber[64]; | |
1442 | + __u8 subAddress[64]; | |
1443 | +}; | |
1444 | + | |
1445 | +/* PptpCallResultCode */ | |
1446 | +#define PPTP_OUTCALL_CONNECT 1 | |
1447 | +#define PPTP_OUTCALL_GENERAL_ERROR 2 | |
1448 | +#define PPTP_OUTCALL_NO_CARRIER 3 | |
1449 | +#define PPTP_OUTCALL_BUSY 4 | |
1450 | +#define PPTP_OUTCALL_NO_DIAL_TONE 5 | |
1451 | +#define PPTP_OUTCALL_TIMEOUT 6 | |
1452 | +#define PPTP_OUTCALL_DONT_ACCEPT 7 | |
1453 | + | |
1454 | +struct PptpOutCallReply { | |
1455 | + __u16 callID; | |
1456 | + __u16 peersCallID; | |
1457 | + __u8 resultCode; | |
1458 | + __u8 generalErrorCode; | |
1459 | + __u16 causeCode; | |
1460 | + __u32 connectSpeed; | |
1461 | + __u16 packetWindow; | |
1462 | + __u16 packetProcDelay; | |
1463 | + __u32 physChannelID; | |
1464 | +}; | |
1465 | + | |
1466 | +struct PptpInCallRequest { | |
1467 | + __u16 callID; | |
1468 | + __u16 callSerialNumber; | |
1469 | + __u32 callBearerType; | |
1470 | + __u32 physChannelID; | |
1471 | + __u16 dialedNumberLength; | |
1472 | + __u16 dialingNumberLength; | |
1473 | + __u8 dialedNumber[64]; | |
1474 | + __u8 dialingNumber[64]; | |
1475 | + __u8 subAddress[64]; | |
1476 | +}; | |
1477 | + | |
1478 | +/* PptpInCallResultCode */ | |
1479 | +#define PPTP_INCALL_ACCEPT 1 | |
1480 | +#define PPTP_INCALL_GENERAL_ERROR 2 | |
1481 | +#define PPTP_INCALL_DONT_ACCEPT 3 | |
1482 | + | |
1483 | +struct PptpInCallReply { | |
1484 | + __u16 callID; | |
1485 | + __u16 peersCallID; | |
1486 | + __u8 resultCode; | |
1487 | + __u8 generalErrorCode; | |
1488 | + __u16 packetWindow; | |
1489 | + __u16 packetProcDelay; | |
1490 | + __u16 reserved; | |
1491 | +}; | |
1492 | + | |
1493 | +struct PptpInCallConnected { | |
1494 | + __u16 peersCallID; | |
1495 | + __u16 reserved; | |
1496 | + __u32 connectSpeed; | |
1497 | + __u16 packetWindow; | |
1498 | + __u16 packetProcDelay; | |
1499 | + __u32 callFramingType; | |
1500 | +}; | |
1501 | + | |
1502 | +struct PptpClearCallRequest { | |
1503 | + __u16 callID; | |
1504 | + __u16 reserved; | |
1505 | +}; | |
1506 | + | |
1507 | +struct PptpCallDisconnectNotify { | |
1508 | + __u16 callID; | |
1509 | + __u8 resultCode; | |
1510 | + __u8 generalErrorCode; | |
1511 | + __u16 causeCode; | |
1512 | + __u16 reserved; | |
1513 | + __u8 callStatistics[128]; | |
1514 | +}; | |
1515 | + | |
1516 | +struct PptpWanErrorNotify { | |
1517 | + __u16 peersCallID; | |
1518 | + __u16 reserved; | |
1519 | + __u32 crcErrors; | |
1520 | + __u32 framingErrors; | |
1521 | + __u32 hardwareOverRuns; | |
1522 | + __u32 bufferOverRuns; | |
1523 | + __u32 timeoutErrors; | |
1524 | + __u32 alignmentErrors; | |
1525 | +}; | |
1526 | + | |
1527 | +struct PptpSetLinkInfo { | |
1528 | + __u16 peersCallID; | |
1529 | + __u16 reserved; | |
1530 | + __u32 sendAccm; | |
1531 | + __u32 recvAccm; | |
1532 | +}; | |
1533 | + | |
1534 | + | |
1535 | +struct pptp_priv_data { | |
1536 | + __u16 call_id; | |
1537 | + __u16 mcall_id; | |
1538 | + __u16 pcall_id; | |
1539 | +}; | |
1540 | + | |
1541 | +union pptp_ctrl_union { | |
1542 | + struct PptpStartSessionRequest sreq; | |
1543 | + struct PptpStartSessionReply srep; | |
1544 | + struct PptpStopSessionRequest streq; | |
1545 | + struct PptpStopSessionReply strep; | |
1546 | + struct PptpOutCallRequest ocreq; | |
1547 | + struct PptpOutCallReply ocack; | |
1548 | + struct PptpInCallRequest icreq; | |
1549 | + struct PptpInCallReply icack; | |
1550 | + struct PptpInCallConnected iccon; | |
1551 | + struct PptpClearCallRequest clrreq; | |
1552 | + struct PptpCallDisconnectNotify disc; | |
1553 | + struct PptpWanErrorNotify wanerr; | |
1554 | + struct PptpSetLinkInfo setlink; | |
1555 | +}; | |
1556 | + | |
1557 | +#endif /* __KERNEL__ */ | |
1558 | +#endif /* _CONNTRACK_PPTP_H */ | |
1559 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h | |
1560 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h 1970-01-01 01:00:00.000000000 +0100 | |
1561 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h 2005-01-04 10:02:37.223443200 +0100 | |
1562 | @@ -0,0 +1,123 @@ | |
1563 | +#ifndef _CONNTRACK_PROTO_GRE_H | |
1564 | +#define _CONNTRACK_PROTO_GRE_H | |
1565 | +#include <asm/byteorder.h> | |
1566 | + | |
1567 | +/* GRE PROTOCOL HEADER */ | |
1568 | + | |
1569 | +/* GRE Version field */ | |
1570 | +#define GRE_VERSION_1701 0x0 | |
1571 | +#define GRE_VERSION_PPTP 0x1 | |
1572 | + | |
1573 | +/* GRE Protocol field */ | |
1574 | +#define GRE_PROTOCOL_PPTP 0x880B | |
1575 | + | |
1576 | +/* GRE Flags */ | |
1577 | +#define GRE_FLAG_C 0x80 | |
1578 | +#define GRE_FLAG_R 0x40 | |
1579 | +#define GRE_FLAG_K 0x20 | |
1580 | +#define GRE_FLAG_S 0x10 | |
1581 | +#define GRE_FLAG_A 0x80 | |
1582 | + | |
1583 | +#define GRE_IS_C(f) ((f)&GRE_FLAG_C) | |
1584 | +#define GRE_IS_R(f) ((f)&GRE_FLAG_R) | |
1585 | +#define GRE_IS_K(f) ((f)&GRE_FLAG_K) | |
1586 | +#define GRE_IS_S(f) ((f)&GRE_FLAG_S) | |
1587 | +#define GRE_IS_A(f) ((f)&GRE_FLAG_A) | |
1588 | + | |
1589 | +/* GRE is a mess: Four different standards */ | |
1590 | +struct gre_hdr { | |
1591 | +#if defined(__LITTLE_ENDIAN_BITFIELD) | |
1592 | + __u16 rec:3, | |
1593 | + srr:1, | |
1594 | + seq:1, | |
1595 | + key:1, | |
1596 | + routing:1, | |
1597 | + csum:1, | |
1598 | + version:3, | |
1599 | + reserved:4, | |
1600 | + ack:1; | |
1601 | +#elif defined(__BIG_ENDIAN_BITFIELD) | |
1602 | + __u16 csum:1, | |
1603 | + routing:1, | |
1604 | + key:1, | |
1605 | + seq:1, | |
1606 | + srr:1, | |
1607 | + rec:3, | |
1608 | + ack:1, | |
1609 | + reserved:4, | |
1610 | + version:3; | |
1611 | +#else | |
1612 | +#error "Adjust your <asm/byteorder.h> defines" | |
1613 | +#endif | |
1614 | + __u16 protocol; | |
1615 | +}; | |
1616 | + | |
1617 | +/* modified GRE header for PPTP */ | |
1618 | +struct gre_hdr_pptp { | |
1619 | + __u8 flags; /* bitfield */ | |
1620 | + __u8 version; /* should be GRE_VERSION_PPTP */ | |
1621 | + __u16 protocol; /* should be GRE_PROTOCOL_PPTP */ | |
1622 | + __u16 payload_len; /* size of ppp payload, not inc. gre header */ | |
1623 | + __u16 call_id; /* peer's call_id for this session */ | |
1624 | + __u32 seq; /* sequence number. Present if S==1 */ | |
1625 | + __u32 ack; /* seq number of highest packet recieved by */ | |
1626 | + /* sender in this session */ | |
1627 | +}; | |
1628 | + | |
1629 | + | |
1630 | +/* this is part of ip_conntrack */ | |
1631 | +struct ip_ct_gre { | |
1632 | + unsigned int stream_timeout; | |
1633 | + unsigned int timeout; | |
1634 | +}; | |
1635 | + | |
1636 | +/* this is part of ip_conntrack_expect */ | |
1637 | +struct ip_ct_gre_expect { | |
1638 | + struct ip_ct_gre_keymap *keymap_orig, *keymap_reply; | |
1639 | +}; | |
1640 | + | |
1641 | +#ifdef __KERNEL__ | |
1642 | +struct ip_conntrack_expect; | |
1643 | + | |
1644 | +/* structure for original <-> reply keymap */ | |
1645 | +struct ip_ct_gre_keymap { | |
1646 | + struct list_head list; | |
1647 | + | |
1648 | + struct ip_conntrack_tuple tuple; | |
1649 | +}; | |
1650 | + | |
1651 | + | |
1652 | +/* add new tuple->key_reply pair to keymap */ | |
1653 | +int ip_ct_gre_keymap_add(struct ip_conntrack_expect *exp, | |
1654 | + struct ip_conntrack_tuple *t, | |
1655 | + int reply); | |
1656 | + | |
1657 | +/* change an existing keymap entry */ | |
1658 | +void ip_ct_gre_keymap_change(struct ip_ct_gre_keymap *km, | |
1659 | + struct ip_conntrack_tuple *t); | |
1660 | + | |
1661 | +/* delete keymap entries */ | |
1662 | +void ip_ct_gre_keymap_destroy(struct ip_conntrack_expect *exp); | |
1663 | + | |
1664 | + | |
1665 | +/* get pointer to gre key, if present */ | |
1666 | +static inline u_int32_t *gre_key(struct gre_hdr *greh) | |
1667 | +{ | |
1668 | + if (!greh->key) | |
1669 | + return NULL; | |
1670 | + if (greh->csum || greh->routing) | |
1671 | + return (u_int32_t *) (greh+sizeof(*greh)+4); | |
1672 | + return (u_int32_t *) (greh+sizeof(*greh)); | |
1673 | +} | |
1674 | + | |
1675 | +/* get pointer ot gre csum, if present */ | |
1676 | +static inline u_int16_t *gre_csum(struct gre_hdr *greh) | |
1677 | +{ | |
1678 | + if (!greh->csum) | |
1679 | + return NULL; | |
1680 | + return (u_int16_t *) (greh+sizeof(*greh)); | |
1681 | +} | |
1682 | + | |
1683 | +#endif /* __KERNEL__ */ | |
1684 | + | |
1685 | +#endif /* _CONNTRACK_PROTO_GRE_H */ | |
1686 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_conntrack_tuple.h linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack_tuple.h | |
1687 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_conntrack_tuple.h 2004-12-24 22:35:23.000000000 +0100 | |
1688 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_conntrack_tuple.h 2005-01-04 10:02:37.224443048 +0100 | |
1689 | @@ -14,7 +14,7 @@ | |
1690 | union ip_conntrack_manip_proto | |
1691 | { | |
1692 | /* Add other protocols here. */ | |
1693 | - u_int16_t all; | |
1694 | + u_int32_t all; | |
1695 | ||
1696 | struct { | |
1697 | u_int16_t port; | |
1698 | @@ -28,6 +28,9 @@ | |
1699 | struct { | |
1700 | u_int16_t port; | |
1701 | } sctp; | |
1702 | + struct { | |
1703 | + u_int32_t key; | |
1704 | + } gre; | |
1705 | }; | |
1706 | ||
1707 | /* The manipulable part of the tuple. */ | |
1708 | @@ -47,7 +50,7 @@ | |
1709 | u_int32_t ip; | |
1710 | union { | |
1711 | /* Add other protocols here. */ | |
1712 | - u_int16_t all; | |
1713 | + u_int32_t all; | |
1714 | ||
1715 | struct { | |
1716 | u_int16_t port; | |
1717 | @@ -61,6 +64,9 @@ | |
1718 | struct { | |
1719 | u_int16_t port; | |
1720 | } sctp; | |
1721 | + struct { | |
1722 | + u_int32_t key; | |
1723 | + } gre; | |
1724 | } u; | |
1725 | ||
1726 | /* The protocol. */ | |
1727 | @@ -86,10 +92,16 @@ | |
1728 | #ifdef __KERNEL__ | |
1729 | ||
1730 | #define DUMP_TUPLE(tp) \ | |
1731 | -DEBUGP("tuple %p: %u %u.%u.%u.%u:%hu -> %u.%u.%u.%u:%hu\n", \ | |
1732 | +DEBUGP("tuple %p: %u %u.%u.%u.%u:%u -> %u.%u.%u.%u:%u\n", \ | |
1733 | (tp), (tp)->dst.protonum, \ | |
1734 | - NIPQUAD((tp)->src.ip), ntohs((tp)->src.u.all), \ | |
1735 | - NIPQUAD((tp)->dst.ip), ntohs((tp)->dst.u.all)) | |
1736 | + NIPQUAD((tp)->src.ip), ntohl((tp)->src.u.all), \ | |
1737 | + NIPQUAD((tp)->dst.ip), ntohl((tp)->dst.u.all)) | |
1738 | + | |
1739 | +#define DUMP_TUPLE_RAW(x) \ | |
1740 | + DEBUGP("tuple %p: %u %u.%u.%u.%u:0x%08x -> %u.%u.%u.%u:0x%08x\n",\ | |
1741 | + (x), (x)->dst.protonum, \ | |
1742 | + NIPQUAD((x)->src.ip), ntohl((x)->src.u.all), \ | |
1743 | + NIPQUAD((x)->dst.ip), ntohl((x)->dst.u.all)) | |
1744 | ||
1745 | #define CTINFO2DIR(ctinfo) ((ctinfo) >= IP_CT_IS_REPLY ? IP_CT_DIR_REPLY : IP_CT_DIR_ORIGINAL) | |
1746 | ||
1747 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_nat_pptp.h linux-2.6.10/include/linux/netfilter_ipv4/ip_nat_pptp.h | |
1748 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_nat_pptp.h 1970-01-01 01:00:00.000000000 +0100 | |
1749 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_nat_pptp.h 2005-01-04 10:02:37.225442896 +0100 | |
1750 | @@ -0,0 +1,11 @@ | |
1751 | +/* PPTP constants and structs */ | |
1752 | +#ifndef _NAT_PPTP_H | |
1753 | +#define _NAT_PPTP_H | |
1754 | + | |
1755 | +/* conntrack private data */ | |
1756 | +struct ip_nat_pptp { | |
1757 | + u_int16_t pns_call_id; /* NAT'ed PNS call id */ | |
1758 | + u_int16_t pac_call_id; /* NAT'ed PAC call id */ | |
1759 | +}; | |
1760 | + | |
1761 | +#endif /* _NAT_PPTP_H */ | |
1762 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_queue.h linux-2.6.10/include/linux/netfilter_ipv4/ip_queue.h | |
1763 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_queue.h 2004-12-24 22:35:28.000000000 +0100 | |
1764 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_queue.h 2005-01-04 10:02:37.225442896 +0100 | |
1765 | @@ -47,10 +47,20 @@ | |
1766 | unsigned char payload[0]; /* Optional replacement packet */ | |
1767 | } ipq_verdict_msg_t; | |
1768 | ||
1769 | +typedef struct ipq_vwmark_msg { | |
1770 | + unsigned int value; /* Verdict to hand to netfilter */ | |
1771 | + unsigned long id; /* Packet ID for this verdict */ | |
1772 | + size_t data_len; /* Length of replacement data */ | |
1773 | + unsigned char payload[0]; /* Optional replacement packet */ | |
1774 | + unsigned long nfmark; /* Mark for the Packet */ | |
1775 | +} ipq_vwmark_msg_t; | |
1776 | + | |
1777 | + | |
1778 | typedef struct ipq_peer_msg { | |
1779 | union { | |
1780 | ipq_verdict_msg_t verdict; | |
1781 | ipq_mode_msg_t mode; | |
1782 | + ipq_vwmark_msg_t vwmark; | |
1783 | } msg; | |
1784 | } ipq_peer_msg_t; | |
1785 | ||
1786 | @@ -67,6 +77,7 @@ | |
1787 | #define IPQM_MODE (IPQM_BASE + 1) /* Mode request from peer */ | |
1788 | #define IPQM_VERDICT (IPQM_BASE + 2) /* Verdict from peer */ | |
1789 | #define IPQM_PACKET (IPQM_BASE + 3) /* Packet from kernel */ | |
1790 | -#define IPQM_MAX (IPQM_BASE + 4) | |
1791 | +#define IPQM_VWMARK (IPQM_BASE + 4) /* Verdict and mark from peer */ | |
1792 | +#define IPQM_MAX (IPQM_BASE + 5) | |
1793 | ||
1794 | #endif /*_IP_QUEUE_H*/ | |
1795 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set.h linux-2.6.10/include/linux/netfilter_ipv4/ip_set.h | |
1796 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set.h 1970-01-01 01:00:00.000000000 +0100 | |
1797 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_set.h 2005-01-04 10:02:37.227442592 +0100 | |
1798 | @@ -0,0 +1,489 @@ | |
1799 | +#ifndef _IP_SET_H | |
1800 | +#define _IP_SET_H | |
1801 | + | |
1802 | +/* Copyright (C) 2000-2002 Joakim Axelsson <gozem@linux.nu> | |
1803 | + * Patrick Schaaf <bof@bof.de> | |
1804 | + * Martin Josefsson <gandalf@wlug.westbo.se> | |
1805 | + * Copyright (C) 2003-2004 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | |
1806 | + * | |
1807 | + * This program is free software; you can redistribute it and/or modify | |
1808 | + * it under the terms of the GNU General Public License version 2 as | |
1809 | + * published by the Free Software Foundation. | |
1810 | + */ | |
1811 | + | |
1812 | +/* | |
1813 | + * A sockopt of such quality has hardly ever been seen before on the open | |
1814 | + * market! This little beauty, hardly ever used: above 64, so it's | |
1815 | + * traditionally used for firewalling, not touched (even once!) by the | |
1816 | + * 2.0, 2.2 and 2.4 kernels! | |
1817 | + * | |
1818 | + * Comes with its own certificate of authenticity, valid anywhere in the | |
1819 | + * Free world! | |
1820 | + * | |
1821 | + * Rusty, 19.4.2000 | |
1822 | + */ | |
1823 | +#define SO_IP_SET 83 | |
1824 | + | |
1825 | +/* | |
1826 | + * Heavily modify by Joakim Axelsson 08.03.2002 | |
1827 | + * - Made it more modulebased | |
1828 | + * | |
1829 | + * Additional heavy modifications by Jozsef Kadlecsik 22.02.2004 | |
1830 | + * - bindings added | |
1831 | + * - in order to "deal with" backward compatibility, renamed to ipset | |
1832 | + */ | |
1833 | + | |
1834 | +/* | |
1835 | + * Used so that the kernel module and ipset-binary can match their versions | |
1836 | + */ | |
1837 | +#define IP_SET_PROTOCOL_VERSION 2 | |
1838 | + | |
1839 | +#define IP_SET_MAXNAMELEN 32 /* set names and set typenames */ | |
1840 | + | |
1841 | +/* Lets work with our own typedef for representing an IP address. | |
1842 | + * We hope to make the code more portable, possibly to IPv6... | |
1843 | + * | |
1844 | + * The representation works in HOST byte order, because most set types | |
1845 | + * will perform arithmetic operations and compare operations. | |
1846 | + * | |
1847 | + * For now the type is an uint32_t. | |
1848 | + * | |
1849 | + * Make sure to ONLY use the functions when translating and parsing | |
1850 | + * in order to keep the host byte order and make it more portable: | |
1851 | + * parse_ip() | |
1852 | + * parse_mask() | |
1853 | + * parse_ipandmask() | |
1854 | + * ip_tostring() | |
1855 | + * (Joakim: where are they???) | |
1856 | + */ | |
1857 | + | |
1858 | +typedef uint32_t ip_set_ip_t; | |
1859 | + | |
1860 | +/* Sets are identified by an id in kernel space. Tweak with ip_set_id_t | |
1861 | + * and IP_SET_INVALID_ID if you want to increase the max number of sets. | |
1862 | + */ | |
1863 | +typedef uint16_t ip_set_id_t; | |
1864 | + | |
1865 | +#define IP_SET_INVALID_ID 65535 | |
1866 | + | |
1867 | +/* How deep we follow bindings */ | |
1868 | +#define IP_SET_MAX_BINDINGS 6 | |
1869 | + | |
1870 | +/* | |
1871 | + * Option flags for kernel operations (ipt_set_info) | |
1872 | + */ | |
1873 | +#define IPSET_SRC 0x01 /* Source match/add */ | |
1874 | +#define IPSET_DST 0x02 /* Destination match/add */ | |
1875 | +#define IPSET_MATCH_INV 0x04 /* Inverse matching */ | |
1876 | + | |
1877 | +/* | |
1878 | + * Set types (flavours) | |
1879 | + */ | |
1880 | +#define IPSET_TYPE_IP 0 /* IP address type of set */ | |
1881 | +#define IPSET_TYPE_PORT 1 /* Port type of set */ | |
1882 | + | |
1883 | +/* Reserved keywords */ | |
1884 | +#define IPSET_TOKEN_DEFAULT ":default:" | |
1885 | +#define IPSET_TOKEN_ALL ":all:" | |
1886 | + | |
1887 | +/* SO_IP_SET operation constants, and their request struct types. | |
1888 | + * | |
1889 | + * Operation ids: | |
1890 | + * 0-99: commands with version checking | |
1891 | + * 100-199: add/del/test/bind/unbind | |
1892 | + * 200-299: list, save, restore | |
1893 | + */ | |
1894 | + | |
1895 | +/* Single shot operations: | |
1896 | + * version, create, destroy, flush, rename and swap | |
1897 | + * | |
1898 | + * Sets are identified by name. | |
1899 | + */ | |
1900 | + | |
1901 | +#define IP_SET_REQ_STD \ | |
1902 | + unsigned op; \ | |
1903 | + unsigned version; \ | |
1904 | + char name[IP_SET_MAXNAMELEN] | |
1905 | + | |
1906 | +#define IP_SET_OP_CREATE 0x00000001 /* Create a new (empty) set */ | |
1907 | +struct ip_set_req_create { | |
1908 | + IP_SET_REQ_STD; | |
1909 | + char typename[IP_SET_MAXNAMELEN]; | |
1910 | +}; | |
1911 | + | |
1912 | +#define IP_SET_OP_DESTROY 0x00000002 /* Remove a (empty) set */ | |
1913 | +struct ip_set_req_std { | |
1914 | + IP_SET_REQ_STD; | |
1915 | +}; | |
1916 | + | |
1917 | +#define IP_SET_OP_FLUSH 0x00000003 /* Remove all IPs in a set */ | |
1918 | +/* Uses ip_set_req_std */ | |
1919 | + | |
1920 | +#define IP_SET_OP_RENAME 0x00000004 /* Rename a set */ | |
1921 | +/* Uses ip_set_req_create */ | |
1922 | + | |
1923 | +#define IP_SET_OP_SWAP 0x00000005 /* Swap two sets */ | |
1924 | +/* Uses ip_set_req_create */ | |
1925 | + | |
1926 | +union ip_set_name_index { | |
1927 | + char name[IP_SET_MAXNAMELEN]; | |
1928 | + ip_set_id_t index; | |
1929 | +}; | |
1930 | + | |
1931 | +#define IP_SET_OP_GET_BYNAME 0x00000006 /* Get set index by name */ | |
1932 | +struct ip_set_req_get_set { | |
1933 | + unsigned op; | |
1934 | + unsigned version; | |
1935 | + union ip_set_name_index set; | |
1936 | +}; | |
1937 | + | |
1938 | +#define IP_SET_OP_GET_BYINDEX 0x00000007 /* Get set name by index */ | |
1939 | +/* Uses ip_set_req_get_set */ | |
1940 | + | |
1941 | +#define IP_SET_OP_VERSION 0x00000100 /* Ask kernel version */ | |
1942 | +struct ip_set_req_version { | |
1943 | + unsigned op; | |
1944 | + unsigned version; | |
1945 | +}; | |
1946 | + | |
1947 | +/* Double shots operations: | |
1948 | + * add, del, test, bind and unbind. | |
1949 | + * | |
1950 | + * First we query the kernel to get the index and type of the target set, | |
1951 | + * then issue the command. Validity of IP is checked in kernel in order | |
1952 | + * to minimalize sockopt operations. | |
1953 | + */ | |
1954 | + | |
1955 | +/* Get minimal set data for add/del/test/bind/unbind IP */ | |
1956 | +#define IP_SET_OP_ADT_GET 0x00000010 /* Get set and type */ | |
1957 | +struct ip_set_req_adt_get { | |
1958 | + unsigned op; | |
1959 | + unsigned version; | |
1960 | + union ip_set_name_index set; | |
1961 | + char typename[IP_SET_MAXNAMELEN]; | |
1962 | +}; | |
1963 | + | |
1964 | +#define IP_SET_REQ_BYINDEX \ | |
1965 | + unsigned op; \ | |
1966 | + ip_set_id_t index; | |
1967 | + | |
1968 | +struct ip_set_req_adt { | |
1969 | + IP_SET_REQ_BYINDEX; | |
1970 | +}; | |
1971 | + | |
1972 | +#define IP_SET_OP_ADD_IP 0x00000101 /* Add an IP to a set */ | |
1973 | +/* Uses ip_set_req_adt, with type specific addage */ | |
1974 | + | |
1975 | +#define IP_SET_OP_DEL_IP 0x00000102 /* Remove an IP from a set */ | |
1976 | +/* Uses ip_set_req_adt, with type specific addage */ | |
1977 | + | |
1978 | +#define IP_SET_OP_TEST_IP 0x00000103 /* Test an IP in a set */ | |
1979 | +/* Uses ip_set_req_adt, with type specific addage */ | |
1980 | + | |
1981 | +#define IP_SET_OP_BIND_SET 0x00000104 /* Bind an IP to a set */ | |
1982 | +/* Uses ip_set_req_bind, with type specific addage */ | |
1983 | +struct ip_set_req_bind { | |
1984 | + IP_SET_REQ_BYINDEX; | |
1985 | + char binding[IP_SET_MAXNAMELEN]; | |
1986 | +}; | |
1987 | + | |
1988 | +#define IP_SET_OP_UNBIND_SET 0x00000105 /* Unbind an IP from a set */ | |
1989 | +/* Uses ip_set_req_bind, with type speficic addage | |
1990 | + * index = 0 means unbinding for all sets */ | |
1991 | + | |
1992 | +#define IP_SET_OP_TEST_BIND_SET 0x00000106 /* Test binding an IP to a set */ | |
1993 | +/* Uses ip_set_req_bind, with type specific addage */ | |
1994 | + | |
1995 | +/* Multiple shots operations: list, save, restore. | |
1996 | + * | |
1997 | + * - check kernel version and query the max number of sets | |
1998 | + * - get the basic information on all sets | |
1999 | + * and size required for the next step | |
2000 | + * - get actual set data: header, data, bindings | |
2001 | + */ | |
2002 | + | |
2003 | +/* Get max_sets and the index of a queried set | |
2004 | + */ | |
2005 | +#define IP_SET_OP_MAX_SETS 0x00000020 | |
2006 | +struct ip_set_req_max_sets { | |
2007 | + unsigned op; | |
2008 | + unsigned version; | |
2009 | + ip_set_id_t max_sets; /* max_sets */ | |
2010 | + ip_set_id_t sets; /* real number of sets */ | |
2011 | + union ip_set_name_index set; /* index of set if name used */ | |
2012 | +}; | |
2013 | + | |
2014 | +/* Get the id and name of the sets plus size for next step */ | |
2015 | +#define IP_SET_OP_LIST_SIZE 0x00000201 | |
2016 | +#define IP_SET_OP_SAVE_SIZE 0x00000202 | |
2017 | +struct ip_set_req_setnames { | |
2018 | + unsigned op; | |
2019 | + ip_set_id_t index; /* set to list/save */ | |
2020 | + size_t size; /* size to get setdata/bindings */ | |
2021 | + /* followed by sets number of struct ip_set_name_list */ | |
2022 | +}; | |
2023 | + | |
2024 | +struct ip_set_name_list { | |
2025 | + char name[IP_SET_MAXNAMELEN]; | |
2026 | + char typename[IP_SET_MAXNAMELEN]; | |
2027 | + ip_set_id_t index; | |
2028 | + ip_set_id_t id; | |
2029 | +}; | |
2030 | + | |
2031 | +/* The actual list operation */ | |
2032 | +#define IP_SET_OP_LIST 0x00000203 | |
2033 | +struct ip_set_req_list { | |
2034 | + IP_SET_REQ_BYINDEX; | |
2035 | + /* sets number of struct ip_set_list in reply */ | |
2036 | +}; | |
2037 | + | |
2038 | +struct ip_set_list { | |
2039 | + ip_set_id_t index; | |
2040 | + ip_set_id_t binding; | |
2041 | + u_int32_t ref; | |
2042 | + size_t header_size; /* Set header data of header_size */ | |
2043 | + size_t members_size; /* Set members data of members_size */ | |
2044 | + size_t bindings_size; /* Set bindings data of bindings_size */ | |
2045 | +}; | |
2046 | + | |
2047 | +struct ip_set_hash_list { | |
2048 | + ip_set_ip_t ip; | |
2049 | + ip_set_id_t binding; | |
2050 | +}; | |
2051 | + | |
2052 | +/* The save operation */ | |
2053 | +#define IP_SET_OP_SAVE 0x00000204 | |
2054 | +/* Uses ip_set_req_list, in the reply replaced by | |
2055 | + * sets number of struct ip_set_save plus a marker | |
2056 | + * ip_set_save followed by ip_set_hash_save structures. | |
2057 | + */ | |
2058 | +struct ip_set_save { | |
2059 | + ip_set_id_t index; | |
2060 | + ip_set_id_t binding; | |
2061 | + size_t header_size; /* Set header data of header_size */ | |
2062 | + size_t members_size; /* Set members data of members_size */ | |
2063 | +}; | |
2064 | + | |
2065 | +/* At restoring, ip == 0 means default binding for the given set: */ | |
2066 | +struct ip_set_hash_save { | |
2067 | + ip_set_ip_t ip; | |
2068 | + ip_set_id_t id; | |
2069 | + ip_set_id_t binding; | |
2070 | +}; | |
2071 | + | |
2072 | +/* The restore operation */ | |
2073 | +#define IP_SET_OP_RESTORE 0x00000205 | |
2074 | +/* Uses ip_set_req_setnames followed by ip_set_restore structures | |
2075 | + * plus a marker ip_set_restore, followed by ip_set_hash_save | |
2076 | + * structures. | |
2077 | + */ | |
2078 | +struct ip_set_restore { | |
2079 | + char name[IP_SET_MAXNAMELEN]; | |
2080 | + char typename[IP_SET_MAXNAMELEN]; | |
2081 | + ip_set_id_t index; | |
2082 | + size_t header_size; /* Create data of header_size */ | |
2083 | + size_t members_size; /* Set members data of members_size */ | |
2084 | +}; | |
2085 | + | |
2086 | +static inline int bitmap_bytes(ip_set_ip_t a, ip_set_ip_t b) | |
2087 | +{ | |
2088 | + return 4 * ((((b - a + 8) / 8) + 3) / 4); | |
2089 | +} | |
2090 | + | |
2091 | +#ifdef __KERNEL__ | |
2092 | + | |
2093 | +#define ip_set_printk(format, args...) \ | |
2094 | + do { \ | |
2095 | + printk("%s: %s: ", __FILE__, __FUNCTION__); \ | |
2096 | + printk(format "\n" , ## args); \ | |
2097 | + } while (0) | |
2098 | + | |
2099 | +#if defined(IP_SET_DEBUG) | |
2100 | +#define DP(format, args...) \ | |
2101 | + do { \ | |
2102 | + printk("%s: %s (DBG): ", __FILE__, __FUNCTION__);\ | |
2103 | + printk(format "\n" , ## args); \ | |
2104 | + } while (0) | |
2105 | +#define IP_SET_ASSERT(x) \ | |
2106 | + do { \ | |
2107 | + if (!(x)) \ | |
2108 | + printk("IP_SET_ASSERT: %s:%i(%s)\n", \ | |
2109 | + __FILE__, __LINE__, __FUNCTION__); \ | |
2110 | + } while (0) | |
2111 | +#else | |
2112 | +#define DP(format, args...) | |
2113 | +#define IP_SET_ASSERT(x) | |
2114 | +#endif | |
2115 | + | |
2116 | +struct ip_set; | |
2117 | + | |
2118 | +/* | |
2119 | + * The ip_set_type definition - one per set type, e.g. "ipmap". | |
2120 | + * | |
2121 | + * Each individual set has a pointer, set->type, going to one | |
2122 | + * of these structures. Function pointers inside the structure implement | |
2123 | + * the real behaviour of the sets. | |
2124 | + * | |
2125 | + * If not mentioned differently, the implementation behind the function | |
2126 | + * pointers of a set_type, is expected to return 0 if ok, and a negative | |
2127 | + * errno (e.g. -EINVAL) on error. | |
2128 | + */ | |
2129 | +struct ip_set_type { | |
2130 | + struct list_head list; /* next in list of set types */ | |
2131 | + | |
2132 | + /* test for IP in set (kernel: iptables -m set src|dst) | |
2133 | + * return 0 if not in set, 1 if in set. | |
2134 | + */ | |
2135 | + int (*testip_kernel) (struct ip_set *set, | |
2136 | + const struct sk_buff * skb, | |
2137 | + u_int32_t flags, | |
2138 | + ip_set_ip_t *ip); | |
2139 | + | |
2140 | + /* test for IP in set (userspace: ipset -T set IP) | |
2141 | + * return 0 if not in set, 1 if in set. | |
2142 | + */ | |
2143 | + int (*testip) (struct ip_set *set, | |
2144 | + const void *data, size_t size, | |
2145 | + ip_set_ip_t *ip); | |
2146 | + | |
2147 | + /* | |
2148 | + * Size of the data structure passed by when | |
2149 | + * adding/deletin/testing an entry. | |
2150 | + */ | |
2151 | + size_t reqsize; | |
2152 | + | |
2153 | + /* Add IP into set (userspace: ipset -A set IP) | |
2154 | + * Return -EEXIST if the address is already in the set, | |
2155 | + * and -ERANGE if the address lies outside the set bounds. | |
2156 | + * If the address was not already in the set, 0 is returned. | |
2157 | + */ | |
2158 | + int (*addip) (struct ip_set *set, | |
2159 | + const void *data, size_t size, | |
2160 | + ip_set_ip_t *ip); | |
2161 | + | |
2162 | + /* Add IP into set (kernel: iptables ... -j SET set src|dst) | |
2163 | + * Return -EEXIST if the address is already in the set, | |
2164 | + * and -ERANGE if the address lies outside the set bounds. | |
2165 | + * If the address was not already in the set, 0 is returned. | |
2166 | + */ | |
2167 | + int (*addip_kernel) (struct ip_set *set, | |
2168 | + const struct sk_buff * skb, | |
2169 | + u_int32_t flags, | |
2170 | + ip_set_ip_t *ip); | |
2171 | + | |
2172 | + /* remove IP from set (userspace: ipset -D set --entry x) | |
2173 | + * Return -EEXIST if the address is NOT in the set, | |
2174 | + * and -ERANGE if the address lies outside the set bounds. | |
2175 | + * If the address really was in the set, 0 is returned. | |
2176 | + */ | |
2177 | + int (*delip) (struct ip_set *set, | |
2178 | + const void *data, size_t size, | |
2179 | + ip_set_ip_t *ip); | |
2180 | + | |
2181 | + /* remove IP from set (kernel: iptables ... -j SET --entry x) | |
2182 | + * Return -EEXIST if the address is NOT in the set, | |
2183 | + * and -ERANGE if the address lies outside the set bounds. | |
2184 | + * If the address really was in the set, 0 is returned. | |
2185 | + */ | |
2186 | + int (*delip_kernel) (struct ip_set *set, | |
2187 | + const struct sk_buff * skb, | |
2188 | + u_int32_t flags, | |
2189 | + ip_set_ip_t *ip); | |
2190 | + | |
2191 | + /* new set creation - allocated type specific items | |
2192 | + */ | |
2193 | + int (*create) (struct ip_set *set, | |
2194 | + const void *data, size_t size); | |
2195 | + | |
2196 | + /* retry the operation after successfully tweaking the set | |
2197 | + */ | |
2198 | + int (*retry) (struct ip_set *set); | |
2199 | + | |
2200 | + /* set destruction - free type specific items | |
2201 | + * There is no return value. | |
2202 | + * Can be called only when child sets are destroyed. | |
2203 | + */ | |
2204 | + void (*destroy) (struct ip_set *set); | |
2205 | + | |
2206 | + /* set flushing - reset all bits in the set, or something similar. | |
2207 | + * There is no return value. | |
2208 | + */ | |
2209 | + void (*flush) (struct ip_set *set); | |
2210 | + | |
2211 | + /* Listing: Get size needed for header | |
2212 | + */ | |
2213 | + int (*list_header_size) (const struct ip_set *set); | |
2214 | + | |
2215 | + /* Listing: Get the header | |
2216 | + * | |
2217 | + * Fill in the information in "data". | |
2218 | + * This function is always run after list_header_size() under a | |
2219 | + * writelock on the set. Therefor is the length of "data" always | |
2220 | + * correct. | |
2221 | + */ | |
2222 | + void (*list_header) (const struct ip_set *set, | |
2223 | + void *data); | |
2224 | + | |
2225 | + /* Listing: Get the size for the set members | |
2226 | + */ | |
2227 | + int (*list_members_size) (const struct ip_set *set); | |
2228 | + | |
2229 | + /* Listing: Get the set members | |
2230 | + * | |
2231 | + * Fill in the information in "data". | |
2232 | + * This function is always run after list_member_size() under a | |
2233 | + * writelock on the set. Therefor is the length of "data" always | |
2234 | + * correct. | |
2235 | + */ | |
2236 | + void (*list_members) (const struct ip_set *set, | |
2237 | + void *data); | |
2238 | + | |
2239 | + char typename[IP_SET_MAXNAMELEN]; | |
2240 | + char typecode; | |
2241 | + int protocol_version; | |
2242 | + | |
2243 | + /* Set this to THIS_MODULE if you are a module, otherwise NULL */ | |
2244 | + struct module *me; | |
2245 | +}; | |
2246 | + | |
2247 | +extern int ip_set_register_set_type(struct ip_set_type *set_type); | |
2248 | +extern void ip_set_unregister_set_type(struct ip_set_type *set_type); | |
2249 | + | |
2250 | +/* A generic ipset */ | |
2251 | +struct ip_set { | |
2252 | + char name[IP_SET_MAXNAMELEN]; /* the name of the set */ | |
2253 | + rwlock_t lock; /* lock for concurrency control */ | |
2254 | + ip_set_id_t id; /* set id for swapping */ | |
2255 | + ip_set_id_t binding; /* default binding for the set */ | |
2256 | + atomic_t ref; /* in kernel and in hash references */ | |
2257 | + struct ip_set_type *type; /* the set types */ | |
2258 | + void *data; /* pooltype specific data */ | |
2259 | +}; | |
2260 | + | |
2261 | +/* Structure to bind set elements to sets */ | |
2262 | +struct ip_set_hash { | |
2263 | + struct list_head list; /* list of clashing entries in hash */ | |
2264 | + ip_set_ip_t ip; /* ip from set */ | |
2265 | + ip_set_id_t id; /* set id */ | |
2266 | + ip_set_id_t binding; /* set we bind the element to */ | |
2267 | +}; | |
2268 | + | |
2269 | +/* register and unregister set references */ | |
2270 | +extern ip_set_id_t ip_set_get_byname(const char name[IP_SET_MAXNAMELEN]); | |
2271 | +extern ip_set_id_t ip_set_get_byindex(ip_set_id_t id); | |
2272 | +extern void ip_set_put(ip_set_id_t id); | |
2273 | + | |
2274 | +/* API for iptables set match, and SET target */ | |
2275 | +extern void ip_set_addip_kernel(ip_set_id_t id, | |
2276 | + const struct sk_buff *skb, | |
2277 | + const u_int32_t *flags); | |
2278 | +extern void ip_set_delip_kernel(ip_set_id_t id, | |
2279 | + const struct sk_buff *skb, | |
2280 | + const u_int32_t *flags); | |
2281 | +extern int ip_set_testip_kernel(ip_set_id_t id, | |
2282 | + const struct sk_buff *skb, | |
2283 | + const u_int32_t *flags); | |
2284 | + | |
2285 | +#endif /* __KERNEL__ */ | |
2286 | + | |
2287 | +#endif /*_IP_SET_H*/ | |
2288 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_iphash.h linux-2.6.10/include/linux/netfilter_ipv4/ip_set_iphash.h | |
2289 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_iphash.h 1970-01-01 01:00:00.000000000 +0100 | |
2290 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_set_iphash.h 2005-01-04 10:02:37.228442440 +0100 | |
2291 | @@ -0,0 +1,30 @@ | |
2292 | +#ifndef __IP_SET_IPHASH_H | |
2293 | +#define __IP_SET_IPHASH_H | |
2294 | + | |
2295 | +#include <linux/netfilter_ipv4/ip_set.h> | |
2296 | + | |
2297 | +#define SETTYPE_NAME "iphash" | |
2298 | +#define MAX_RANGE 0x0000FFFF | |
2299 | + | |
2300 | +struct ip_set_iphash { | |
2301 | + ip_set_ip_t *members; /* the iphash proper */ | |
2302 | + uint32_t initval; /* initval for jhash_1word */ | |
2303 | + uint32_t prime; /* prime for double hashing */ | |
2304 | + uint32_t hashsize; /* hash size */ | |
2305 | + uint16_t probes; /* max number of probes */ | |
2306 | + uint16_t resize; /* resize factor in percent */ | |
2307 | + ip_set_ip_t netmask; /* netmask */ | |
2308 | +}; | |
2309 | + | |
2310 | +struct ip_set_req_iphash_create { | |
2311 | + uint32_t hashsize; | |
2312 | + uint16_t probes; | |
2313 | + uint16_t resize; | |
2314 | + ip_set_ip_t netmask; | |
2315 | +}; | |
2316 | + | |
2317 | +struct ip_set_req_iphash { | |
2318 | + ip_set_ip_t ip; | |
2319 | +}; | |
2320 | + | |
2321 | +#endif /* __IP_SET_IPHASH_H */ | |
2322 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_ipmap.h linux-2.6.10/include/linux/netfilter_ipv4/ip_set_ipmap.h | |
2323 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_ipmap.h 1970-01-01 01:00:00.000000000 +0100 | |
2324 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_set_ipmap.h 2005-01-04 10:02:37.228442440 +0100 | |
2325 | @@ -0,0 +1,56 @@ | |
2326 | +#ifndef __IP_SET_IPMAP_H | |
2327 | +#define __IP_SET_IPMAP_H | |
2328 | + | |
2329 | +#include <linux/netfilter_ipv4/ip_set.h> | |
2330 | + | |
2331 | +#define SETTYPE_NAME "ipmap" | |
2332 | +#define MAX_RANGE 0x0000FFFF | |
2333 | + | |
2334 | +struct ip_set_ipmap { | |
2335 | + void *members; /* the ipmap proper */ | |
2336 | + ip_set_ip_t first_ip; /* host byte order, included in range */ | |
2337 | + ip_set_ip_t last_ip; /* host byte order, included in range */ | |
2338 | + ip_set_ip_t netmask; /* subnet netmask */ | |
2339 | + ip_set_ip_t sizeid; /* size of set in IPs */ | |
2340 | + u_int16_t hosts; /* number of hosts in a subnet */ | |
2341 | +}; | |
2342 | + | |
2343 | +struct ip_set_req_ipmap_create { | |
2344 | + ip_set_ip_t from; | |
2345 | + ip_set_ip_t to; | |
2346 | + ip_set_ip_t netmask; | |
2347 | +}; | |
2348 | + | |
2349 | +struct ip_set_req_ipmap { | |
2350 | + ip_set_ip_t ip; | |
2351 | +}; | |
2352 | + | |
2353 | +unsigned int | |
2354 | +mask_to_bits(ip_set_ip_t mask) | |
2355 | +{ | |
2356 | + unsigned int bits = 32; | |
2357 | + ip_set_ip_t maskaddr; | |
2358 | + | |
2359 | + if (mask == 0xFFFFFFFF) | |
2360 | + return bits; | |
2361 | + | |
2362 | + maskaddr = 0xFFFFFFFE; | |
2363 | + while (--bits >= 0 && maskaddr != mask) | |
2364 | + maskaddr <<= 1; | |
2365 | + | |
2366 | + return bits; | |
2367 | +} | |
2368 | + | |
2369 | +ip_set_ip_t | |
2370 | +range_to_mask(ip_set_ip_t from, ip_set_ip_t to, unsigned int *bits) | |
2371 | +{ | |
2372 | + ip_set_ip_t mask = 0xFFFFFFFE; | |
2373 | + | |
2374 | + *bits = 32; | |
2375 | + while (--(*bits) >= 0 && mask && (to & mask) != from) | |
2376 | + mask <<= 1; | |
2377 | + | |
2378 | + return mask; | |
2379 | +} | |
2380 | + | |
2381 | +#endif /* __IP_SET_IPMAP_H */ | |
2382 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_jhash.h linux-2.6.10/include/linux/netfilter_ipv4/ip_set_jhash.h | |
2383 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_jhash.h 1970-01-01 01:00:00.000000000 +0100 | |
2384 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_set_jhash.h 2005-01-04 10:02:37.229442288 +0100 | |
2385 | @@ -0,0 +1,148 @@ | |
2386 | +#ifndef _LINUX_IPSET_JHASH_H | |
2387 | +#define _LINUX_IPSET_JHASH_H | |
2388 | + | |
2389 | +/* This is a copy of linux/jhash.h but the types u32/u8 are changed | |
2390 | + * to __u32/__u8 so that the header file can be included into | |
2391 | + * userspace code as well. Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) | |
2392 | + */ | |
2393 | + | |
2394 | +/* jhash.h: Jenkins hash support. | |
2395 | + * | |
2396 | + * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net) | |
2397 | + * | |
2398 | + * http://burtleburtle.net/bob/hash/ | |
2399 | + * | |
2400 | + * These are the credits from Bob's sources: | |
2401 | + * | |
2402 | + * lookup2.c, by Bob Jenkins, December 1996, Public Domain. | |
2403 | + * hash(), hash2(), hash3, and mix() are externally useful functions. | |
2404 | + * Routines to test the hash are included if SELF_TEST is defined. | |
2405 | + * You can use this free for any purpose. It has no warranty. | |
2406 | + * | |
2407 | + * Copyright (C) 2003 David S. Miller (davem@redhat.com) | |
2408 | + * | |
2409 | + * I've modified Bob's hash to be useful in the Linux kernel, and | |
2410 | + * any bugs present are surely my fault. -DaveM | |
2411 | + */ | |
2412 | + | |
2413 | +/* NOTE: Arguments are modified. */ | |
2414 | +#define __jhash_mix(a, b, c) \ | |
2415 | +{ \ | |
2416 | + a -= b; a -= c; a ^= (c>>13); \ | |
2417 | + b -= c; b -= a; b ^= (a<<8); \ | |
2418 | + c -= a; c -= b; c ^= (b>>13); \ | |
2419 | + a -= b; a -= c; a ^= (c>>12); \ | |
2420 | + b -= c; b -= a; b ^= (a<<16); \ | |
2421 | + c -= a; c -= b; c ^= (b>>5); \ | |
2422 | + a -= b; a -= c; a ^= (c>>3); \ | |
2423 | + b -= c; b -= a; b ^= (a<<10); \ | |
2424 | + c -= a; c -= b; c ^= (b>>15); \ | |
2425 | +} | |
2426 | + | |
2427 | +/* The golden ration: an arbitrary value */ | |
2428 | +#define JHASH_GOLDEN_RATIO 0x9e3779b9 | |
2429 | + | |
2430 | +/* The most generic version, hashes an arbitrary sequence | |
2431 | + * of bytes. No alignment or length assumptions are made about | |
2432 | + * the input key. | |
2433 | + */ | |
2434 | +static inline __u32 jhash(void *key, __u32 length, __u32 initval) | |
2435 | +{ | |
2436 | + __u32 a, b, c, len; | |
2437 | + __u8 *k = key; | |
2438 | + | |
2439 | + len = length; | |
2440 | + a = b = JHASH_GOLDEN_RATIO; | |
2441 | + c = initval; | |
2442 | + | |
2443 | + while (len >= 12) { | |
2444 | + a += (k[0] +((__u32)k[1]<<8) +((__u32)k[2]<<16) +((__u32)k[3]<<24)); | |
2445 | + b += (k[4] +((__u32)k[5]<<8) +((__u32)k[6]<<16) +((__u32)k[7]<<24)); | |
2446 | + c += (k[8] +((__u32)k[9]<<8) +((__u32)k[10]<<16)+((__u32)k[11]<<24)); | |
2447 | + | |
2448 | + __jhash_mix(a,b,c); | |
2449 | + | |
2450 | + k += 12; | |
2451 | + len -= 12; | |
2452 | + } | |
2453 | + | |
2454 | + c += length; | |
2455 | + switch (len) { | |
2456 | + case 11: c += ((__u32)k[10]<<24); | |
2457 | + case 10: c += ((__u32)k[9]<<16); | |
2458 | + case 9 : c += ((__u32)k[8]<<8); | |
2459 | + case 8 : b += ((__u32)k[7]<<24); | |
2460 | + case 7 : b += ((__u32)k[6]<<16); | |
2461 | + case 6 : b += ((__u32)k[5]<<8); | |
2462 | + case 5 : b += k[4]; | |
2463 | + case 4 : a += ((__u32)k[3]<<24); | |
2464 | + case 3 : a += ((__u32)k[2]<<16); | |
2465 | + case 2 : a += ((__u32)k[1]<<8); | |
2466 | + case 1 : a += k[0]; | |
2467 | + }; | |
2468 | + | |
2469 | + __jhash_mix(a,b,c); | |
2470 | + | |
2471 | + return c; | |
2472 | +} | |
2473 | + | |
2474 | +/* A special optimized version that handles 1 or more of __u32s. | |
2475 | + * The length parameter here is the number of __u32s in the key. | |
2476 | + */ | |
2477 | +static inline __u32 jhash2(__u32 *k, __u32 length, __u32 initval) | |
2478 | +{ | |
2479 | + __u32 a, b, c, len; | |
2480 | + | |
2481 | + a = b = JHASH_GOLDEN_RATIO; | |
2482 | + c = initval; | |
2483 | + len = length; | |
2484 | + | |
2485 | + while (len >= 3) { | |
2486 | + a += k[0]; | |
2487 | + b += k[1]; | |
2488 | + c += k[2]; | |
2489 | + __jhash_mix(a, b, c); | |
2490 | + k += 3; len -= 3; | |
2491 | + } | |
2492 | + | |
2493 | + c += length * 4; | |
2494 | + | |
2495 | + switch (len) { | |
2496 | + case 2 : b += k[1]; | |
2497 | + case 1 : a += k[0]; | |
2498 | + }; | |
2499 | + | |
2500 | + __jhash_mix(a,b,c); | |
2501 | + | |
2502 | + return c; | |
2503 | +} | |
2504 | + | |
2505 | + | |
2506 | +/* A special ultra-optimized versions that knows they are hashing exactly | |
2507 | + * 3, 2 or 1 word(s). | |
2508 | + * | |
2509 | + * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally | |
2510 | + * done at the end is not done here. | |
2511 | + */ | |
2512 | +static inline __u32 jhash_3words(__u32 a, __u32 b, __u32 c, __u32 initval) | |
2513 | +{ | |
2514 | + a += JHASH_GOLDEN_RATIO; | |
2515 | + b += JHASH_GOLDEN_RATIO; | |
2516 | + c += initval; | |
2517 | + | |
2518 | + __jhash_mix(a, b, c); | |
2519 | + | |
2520 | + return c; | |
2521 | +} | |
2522 | + | |
2523 | +static inline __u32 jhash_2words(__u32 a, __u32 b, __u32 initval) | |
2524 | +{ | |
2525 | + return jhash_3words(a, b, 0, initval); | |
2526 | +} | |
2527 | + | |
2528 | +static inline __u32 jhash_1word(__u32 a, __u32 initval) | |
2529 | +{ | |
2530 | + return jhash_3words(a, 0, 0, initval); | |
2531 | +} | |
2532 | + | |
2533 | +#endif /* _LINUX_IPSET_JHASH_H */ | |
2534 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_macipmap.h linux-2.6.10/include/linux/netfilter_ipv4/ip_set_macipmap.h | |
2535 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_macipmap.h 1970-01-01 01:00:00.000000000 +0100 | |
2536 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_set_macipmap.h 2005-01-04 10:02:37.230442136 +0100 | |
2537 | @@ -0,0 +1,38 @@ | |
2538 | +#ifndef __IP_SET_MACIPMAP_H | |
2539 | +#define __IP_SET_MACIPMAP_H | |
2540 | + | |
2541 | +#include <linux/netfilter_ipv4/ip_set.h> | |
2542 | + | |
2543 | +#define SETTYPE_NAME "macipmap" | |
2544 | +#define MAX_RANGE 0x0000FFFF | |
2545 | + | |
2546 | +/* general flags */ | |
2547 | +#define IPSET_MACIP_MATCHUNSET 1 | |
2548 | + | |
2549 | +/* per ip flags */ | |
2550 | +#define IPSET_MACIP_ISSET 1 | |
2551 | + | |
2552 | +struct ip_set_macipmap { | |
2553 | + void *members; /* the macipmap proper */ | |
2554 | + ip_set_ip_t first_ip; /* host byte order, included in range */ | |
2555 | + ip_set_ip_t last_ip; /* host byte order, included in range */ | |
2556 | + u_int32_t flags; | |
2557 | +}; | |
2558 | + | |
2559 | +struct ip_set_req_macipmap_create { | |
2560 | + ip_set_ip_t from; | |
2561 | + ip_set_ip_t to; | |
2562 | + u_int32_t flags; | |
2563 | +}; | |
2564 | + | |
2565 | +struct ip_set_req_macipmap { | |
2566 | + ip_set_ip_t ip; | |
2567 | + unsigned char ethernet[ETH_ALEN]; | |
2568 | +}; | |
2569 | + | |
2570 | +struct ip_set_macip { | |
2571 | + unsigned short flags; | |
2572 | + unsigned char ethernet[ETH_ALEN]; | |
2573 | +}; | |
2574 | + | |
2575 | +#endif /* __IP_SET_MACIPMAP_H */ | |
2576 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_malloc.h linux-2.6.10/include/linux/netfilter_ipv4/ip_set_malloc.h | |
2577 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_malloc.h 1970-01-01 01:00:00.000000000 +0100 | |
2578 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_set_malloc.h 2005-01-04 10:02:37.230442136 +0100 | |
2579 | @@ -0,0 +1,34 @@ | |
2580 | +#ifndef _IP_SET_MALLOC_H | |
2581 | +#define _IP_SET_MALLOC_H | |
2582 | + | |
2583 | +#ifdef __KERNEL__ | |
2584 | + | |
2585 | +/* Memory allocation and deallocation */ | |
2586 | +static size_t max_malloc_size = 0; | |
2587 | + | |
2588 | +static inline void init_max_malloc_size(void) | |
2589 | +{ | |
2590 | +#define CACHE(x) max_malloc_size = x; | |
2591 | +#include <linux/kmalloc_sizes.h> | |
2592 | +#undef CACHE | |
2593 | +} | |
2594 | + | |
2595 | +static inline void * ip_set_malloc(size_t bytes) | |
2596 | +{ | |
2597 | + if (bytes > max_malloc_size) | |
2598 | + return vmalloc(bytes); | |
2599 | + else | |
2600 | + return kmalloc(bytes, GFP_KERNEL); | |
2601 | +} | |
2602 | + | |
2603 | +static inline void ip_set_free(void * data, size_t bytes) | |
2604 | +{ | |
2605 | + if (bytes > max_malloc_size) | |
2606 | + vfree(data); | |
2607 | + else | |
2608 | + kfree(data); | |
2609 | +} | |
2610 | + | |
2611 | +#endif /* __KERNEL__ */ | |
2612 | + | |
2613 | +#endif /*_IP_SET_MALLOC_H*/ | |
2614 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_portmap.h linux-2.6.10/include/linux/netfilter_ipv4/ip_set_portmap.h | |
2615 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_portmap.h 1970-01-01 01:00:00.000000000 +0100 | |
2616 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_set_portmap.h 2005-01-04 10:02:37.231441984 +0100 | |
2617 | @@ -0,0 +1,25 @@ | |
2618 | +#ifndef __IP_SET_PORTMAP_H | |
2619 | +#define __IP_SET_PORTMAP_H | |
2620 | + | |
2621 | +#include <linux/netfilter_ipv4/ip_set.h> | |
2622 | + | |
2623 | +#define SETTYPE_NAME "portmap" | |
2624 | +#define MAX_RANGE 0x0000FFFF | |
2625 | +#define INVALID_PORT (MAX_RANGE + 1) | |
2626 | + | |
2627 | +struct ip_set_portmap { | |
2628 | + void *members; /* the portmap proper */ | |
2629 | + ip_set_ip_t first_port; /* host byte order, included in range */ | |
2630 | + ip_set_ip_t last_port; /* host byte order, included in range */ | |
2631 | +}; | |
2632 | + | |
2633 | +struct ip_set_req_portmap_create { | |
2634 | + ip_set_ip_t from; | |
2635 | + ip_set_ip_t to; | |
2636 | +}; | |
2637 | + | |
2638 | +struct ip_set_req_portmap { | |
2639 | + ip_set_ip_t port; | |
2640 | +}; | |
2641 | + | |
2642 | +#endif /* __IP_SET_PORTMAP_H */ | |
2643 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_prime.h linux-2.6.10/include/linux/netfilter_ipv4/ip_set_prime.h | |
2644 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_set_prime.h 1970-01-01 01:00:00.000000000 +0100 | |
2645 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_set_prime.h 2005-01-04 10:02:37.231441984 +0100 | |
2646 | @@ -0,0 +1,34 @@ | |
2647 | +#ifndef __IP_SET_PRIME_H | |
2648 | +#define __IP_SET_PRIME_H | |
2649 | + | |
2650 | +static inline unsigned make_prime_bound(unsigned nr) | |
2651 | +{ | |
2652 | + unsigned long long nr64 = nr; | |
2653 | + unsigned long long x = 1; | |
2654 | + nr = 1; | |
2655 | + while (x <= nr64) { x <<= 2; nr <<= 1; } | |
2656 | + return nr; | |
2657 | +} | |
2658 | + | |
2659 | +static inline int make_prime_check(unsigned nr) | |
2660 | +{ | |
2661 | + unsigned x = 3; | |
2662 | + unsigned b = make_prime_bound(nr); | |
2663 | + while (x <= b) { | |
2664 | + if (0 == (nr % x)) return 0; | |
2665 | + x += 2; | |
2666 | + } | |
2667 | + return 1; | |
2668 | +} | |
2669 | + | |
2670 | +static unsigned make_prime(unsigned nr) | |
2671 | +{ | |
2672 | + if (0 == (nr & 1)) nr--; | |
2673 | + while (nr > 1) { | |
2674 | + if (make_prime_check(nr)) return nr; | |
2675 | + nr -= 2; | |
2676 | + } | |
2677 | + return 2; | |
2678 | +} | |
2679 | + | |
2680 | +#endif /* __IP_SET_PRIME_H */ | |
2681 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ip_tables.h linux-2.6.10/include/linux/netfilter_ipv4/ip_tables.h | |
2682 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ip_tables.h 2004-12-24 22:34:57.000000000 +0100 | |
2683 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ip_tables.h 2005-01-04 10:02:37.232441832 +0100 | |
2684 | @@ -105,7 +105,8 @@ | |
2685 | ||
2686 | /* Values for "flag" field in struct ipt_ip (general ip structure). */ | |
2687 | #define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */ | |
2688 | -#define IPT_F_MASK 0x01 /* All possible flag bits mask. */ | |
2689 | +#define IPT_F_GOTO 0x02 /* Set if jump is a goto */ | |
2690 | +#define IPT_F_MASK 0x03 /* All possible flag bits mask. */ | |
2691 | ||
2692 | /* Values for "inv" field in struct ipt_ip. */ | |
2693 | #define IPT_INV_VIA_IN 0x01 /* Invert the sense of IN IFACE. */ | |
2694 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ipt_IPMARK.h linux-2.6.10/include/linux/netfilter_ipv4/ipt_IPMARK.h | |
2695 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ipt_IPMARK.h 1970-01-01 01:00:00.000000000 +0100 | |
2696 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ipt_IPMARK.h 2005-01-04 10:02:37.233441680 +0100 | |
2697 | @@ -0,0 +1,13 @@ | |
2698 | +#ifndef _IPT_IPMARK_H_target | |
2699 | +#define _IPT_IPMARK_H_target | |
2700 | + | |
2701 | +struct ipt_ipmark_target_info { | |
2702 | + unsigned long andmask; | |
2703 | + unsigned long ormask; | |
2704 | + unsigned int addr; | |
2705 | +}; | |
2706 | + | |
2707 | +#define IPT_IPMARK_SRC 0 | |
2708 | +#define IPT_IPMARK_DST 1 | |
2709 | + | |
2710 | +#endif /*_IPT_IPMARK_H_target*/ | |
2711 | diff -Nur --exclude '*.orig' linux-2.6.10.org/include/linux/netfilter_ipv4/ipt_ROUTE.h linux-2.6.10/include/linux/netfilter_ipv4/ipt_ROUTE.h | |
2712 | --- linux-2.6.10.org/include/linux/netfilter_ipv4/ipt_ROUTE.h 1970-01-01 01:00:00.000000000 +0100 | |
2713 | +++ linux-2.6.10/include/linux/netfilter_ipv4/ipt_ROUTE.h 2005-01-04 10:02:37.233441680 +0100 | |
2714 | @@ -0,0 +1,23 @@ | |
2715 | +/* Header file for iptables ipt_ROUTE target | |
2716 | + * | |
2717 |