]>
Commit | Line | Data |
---|---|---|
70b033d6 | 1 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ip_pool.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ip_pool.h |
2 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ip_pool.h 1970-01-01 01:00:00.000000000 +0100 | |
3 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ip_pool.h 2004-02-16 11:07:21.518803072 +0100 | |
4 | @@ -0,0 +1,64 @@ | |
5 | +#ifndef _IP_POOL_H | |
6 | +#define _IP_POOL_H | |
7 | + | |
8 | +/***************************************************************************/ | |
9 | +/* This program is free software; you can redistribute it and/or modify */ | |
10 | +/* it under the terms of the GNU General Public License as published by */ | |
11 | +/* the Free Software Foundation; either version 2 of the License, or */ | |
12 | +/* (at your option) any later version. */ | |
13 | +/* */ | |
14 | +/* This program is distributed in the hope that it will be useful, */ | |
15 | +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | |
16 | +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | |
17 | +/* GNU General Public License for more details. */ | |
18 | +/* */ | |
19 | +/* You should have received a copy of the GNU General Public License */ | |
20 | +/* along with this program; if not, write to the Free Software */ | |
21 | +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/ | |
22 | +/***************************************************************************/ | |
23 | + | |
24 | +/* A sockopt of such quality has hardly ever been seen before on the open | |
25 | + * market! This little beauty, hardly ever used: above 64, so it's | |
26 | + * traditionally used for firewalling, not touched (even once!) by the | |
27 | + * 2.0, 2.2 and 2.4 kernels! | |
28 | + * | |
29 | + * Comes with its own certificate of authenticity, valid anywhere in the | |
30 | + * Free world! | |
31 | + * | |
32 | + * Rusty, 19.4.2000 | |
33 | + */ | |
34 | +#define SO_IP_POOL 81 | |
35 | + | |
36 | +typedef int ip_pool_t; /* pool index */ | |
37 | +#define IP_POOL_NONE ((ip_pool_t)-1) | |
38 | + | |
39 | +struct ip_pool_request { | |
40 | + int op; | |
41 | + ip_pool_t index; | |
42 | + u_int32_t addr; | |
43 | + u_int32_t addr2; | |
44 | +}; | |
45 | + | |
46 | +/* NOTE: I deliberately break the first cut ippool utility. Nobody uses it. */ | |
47 | + | |
48 | +#define IP_POOL_BAD001 0x00000010 | |
49 | + | |
50 | +#define IP_POOL_FLUSH 0x00000011 /* req.index, no arguments */ | |
51 | +#define IP_POOL_INIT 0x00000012 /* from addr to addr2 incl. */ | |
52 | +#define IP_POOL_DESTROY 0x00000013 /* req.index, no arguments */ | |
53 | +#define IP_POOL_ADD_ADDR 0x00000014 /* add addr to pool */ | |
54 | +#define IP_POOL_DEL_ADDR 0x00000015 /* del addr from pool */ | |
55 | +#define IP_POOL_HIGH_NR 0x00000016 /* result in req.index */ | |
56 | +#define IP_POOL_LOOKUP 0x00000017 /* result in addr and addr2 */ | |
57 | +#define IP_POOL_USAGE 0x00000018 /* result in addr */ | |
58 | +#define IP_POOL_TEST_ADDR 0x00000019 /* result (0/1) returned */ | |
59 | + | |
60 | +#ifdef __KERNEL__ | |
61 | + | |
62 | +/* NOTE: ip_pool_match() and ip_pool_mod() expect ADDR to be host byte order */ | |
63 | +extern int ip_pool_match(ip_pool_t pool, u_int32_t addr); | |
64 | +extern int ip_pool_mod(ip_pool_t pool, u_int32_t addr, int isdel); | |
65 | + | |
66 | +#endif | |
67 | + | |
68 | +#endif /*_IP_POOL_H*/ | |
69 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_NETLINK.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_NETLINK.h | |
70 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_NETLINK.h 1970-01-01 01:00:00.000000000 +0100 | |
71 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_NETLINK.h 2004-02-16 11:07:05.880548139 +0100 | |
72 | @@ -0,0 +1,27 @@ | |
73 | +#ifndef _IPT_FWMON_H | |
74 | +#define _IPT_FWMON_H | |
75 | + | |
76 | +/* Bitmask macros */ | |
77 | +#define MASK(x,y) (x & y) | |
78 | +#define MASK_SET(x,y) x |= y | |
79 | +#define MASK_UNSET(x,y) x &= ~y | |
80 | + | |
81 | +#define USE_MARK 0x00000001 | |
82 | +#define USE_DROP 0x00000002 | |
83 | +#define USE_SIZE 0x00000004 | |
84 | + | |
85 | +struct ipt_nldata | |
86 | +{ | |
87 | + unsigned int flags; | |
88 | + unsigned int mark; | |
89 | + unsigned int size; | |
90 | +}; | |
91 | + | |
92 | +/* Old header */ | |
93 | +struct netlink_t { | |
94 | + unsigned int len; | |
95 | + unsigned int mark; | |
96 | + char iface[IFNAMSIZ]; | |
97 | +}; | |
98 | + | |
99 | +#endif /*_IPT_FWMON_H*/ | |
100 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_TTL.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_TTL.h | |
101 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_TTL.h 1970-01-01 01:00:00.000000000 +0100 | |
102 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_TTL.h 2004-02-16 11:07:09.253740328 +0100 | |
103 | @@ -0,0 +1,21 @@ | |
104 | +/* TTL modification module for IP tables | |
105 | + * (C) 2000 by Harald Welte <laforge@gnumonks.org> */ | |
106 | + | |
107 | +#ifndef _IPT_TTL_H | |
108 | +#define _IPT_TTL_H | |
109 | + | |
110 | +enum { | |
111 | + IPT_TTL_SET = 0, | |
112 | + IPT_TTL_INC, | |
113 | + IPT_TTL_DEC | |
114 | +}; | |
115 | + | |
116 | +#define IPT_TTL_MAXMODE IPT_TTL_DEC | |
117 | + | |
118 | +struct ipt_TTL_info { | |
119 | + u_int8_t mode; | |
120 | + u_int8_t ttl; | |
121 | +}; | |
122 | + | |
123 | + | |
124 | +#endif | |
125 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_connlimit.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_connlimit.h | |
126 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_connlimit.h 1970-01-01 01:00:00.000000000 +0100 | |
127 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_connlimit.h 2004-02-16 11:07:11.549190614 +0100 | |
128 | @@ -0,0 +1,12 @@ | |
129 | +#ifndef _IPT_CONNLIMIT_H | |
130 | +#define _IPT_CONNLIMIT_H | |
131 | + | |
132 | +struct ipt_connlimit_data; | |
133 | + | |
134 | +struct ipt_connlimit_info { | |
135 | + int limit; | |
136 | + int inverse; | |
137 | + u_int32_t mask; | |
138 | + struct ipt_connlimit_data *data; | |
139 | +}; | |
140 | +#endif /* _IPT_CONNLIMIT_H */ | |
141 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_dstlimit.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_dstlimit.h | |
142 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_dstlimit.h 1970-01-01 01:00:00.000000000 +0100 | |
143 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_dstlimit.h 2004-02-16 11:07:13.230787904 +0100 | |
144 | @@ -0,0 +1,36 @@ | |
145 | +#ifndef _IPT_DSTLIMIT_H | |
146 | +#define _IPT_DSTLIMIT_H | |
147 | + | |
148 | +/* timings are in milliseconds. */ | |
149 | +#define IPT_DSTLIMIT_SCALE 10000 | |
150 | +/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 | |
151 | + seconds, or one every 59 hours. */ | |
152 | + | |
153 | +/* details of this structure hidden by the implementation */ | |
154 | +struct ipt_dstlimit_htable; | |
155 | + | |
156 | +#define IPT_DSTLIMIT_HASH_DIP 0x0001 | |
157 | +#define IPT_DSTLIMIT_HASH_DPT 0x0002 | |
158 | +#define IPT_DSTLIMIT_HASH_SIP 0x0004 | |
159 | + | |
160 | +struct ipt_dstlimit_info { | |
161 | + u_int32_t mode; /* bitmask of IPT_DSTLIMIT_HASH_* */ | |
162 | + u_int32_t avg; /* Average secs between packets * scale */ | |
163 | + u_int32_t burst; /* Period multiplier for upper limit. */ | |
164 | + | |
165 | + /* user specified */ | |
166 | + unsigned int size; /* how many buckets */ | |
167 | + unsigned int max; /* max number of entries */ | |
168 | + unsigned int gc_interval; /* gc interval */ | |
169 | + unsigned int expire; /* when do entries expire? */ | |
170 | + char name [IFNAMSIZ]; /* name */ | |
171 | + | |
172 | + struct ipt_dstlimit_htable *hinfo; | |
173 | + | |
174 | + /* Used internally by the kernel */ | |
175 | + union { | |
176 | + void *ptr; | |
177 | + struct ipt_dstlimit_info *master; | |
178 | + } u; | |
179 | +}; | |
180 | +#endif /*_IPT_DSTLIMIT_H*/ | |
181 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_fuzzy.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_fuzzy.h | |
182 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_fuzzy.h 1970-01-01 01:00:00.000000000 +0100 | |
183 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_fuzzy.h 2004-02-16 11:07:14.925382080 +0100 | |
184 | @@ -0,0 +1,21 @@ | |
185 | +#ifndef _IPT_FUZZY_H | |
186 | +#define _IPT_FUZZY_H | |
187 | + | |
188 | +#include <linux/param.h> | |
189 | +#include <linux/types.h> | |
190 | + | |
191 | +#define MAXFUZZYRATE 10000000 | |
192 | +#define MINFUZZYRATE 3 | |
193 | + | |
194 | +struct ipt_fuzzy_info { | |
195 | + u_int32_t minimum_rate; | |
196 | + u_int32_t maximum_rate; | |
197 | + u_int32_t packets_total; | |
198 | + u_int32_t bytes_total; | |
199 | + u_int32_t previous_time; | |
200 | + u_int32_t present_time; | |
201 | + u_int32_t mean_rate; | |
202 | + u_int8_t acceptance_rate; | |
203 | +}; | |
204 | + | |
205 | +#endif /*_IPT_FUZZY_H*/ | |
206 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_ipv4options.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_ipv4options.h | |
207 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_ipv4options.h 1970-01-01 01:00:00.000000000 +0100 | |
208 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_ipv4options.h 2004-02-16 11:07:16.164085433 +0100 | |
209 | @@ -0,0 +1,21 @@ | |
210 | +#ifndef __ipt_ipv4options_h_included__ | |
211 | +#define __ipt_ipv4options_h_included__ | |
212 | + | |
213 | +#define IPT_IPV4OPTION_MATCH_SSRR 0x01 /* For strict source routing */ | |
214 | +#define IPT_IPV4OPTION_MATCH_LSRR 0x02 /* For loose source routing */ | |
215 | +#define IPT_IPV4OPTION_DONT_MATCH_SRR 0x04 /* any source routing */ | |
216 | +#define IPT_IPV4OPTION_MATCH_RR 0x08 /* For Record route */ | |
217 | +#define IPT_IPV4OPTION_DONT_MATCH_RR 0x10 | |
218 | +#define IPT_IPV4OPTION_MATCH_TIMESTAMP 0x20 /* For timestamp request */ | |
219 | +#define IPT_IPV4OPTION_DONT_MATCH_TIMESTAMP 0x40 | |
220 | +#define IPT_IPV4OPTION_MATCH_ROUTER_ALERT 0x80 /* For router-alert */ | |
221 | +#define IPT_IPV4OPTION_DONT_MATCH_ROUTER_ALERT 0x100 | |
222 | +#define IPT_IPV4OPTION_MATCH_ANY_OPT 0x200 /* match packet with any option */ | |
223 | +#define IPT_IPV4OPTION_DONT_MATCH_ANY_OPT 0x400 /* match packet with no option */ | |
224 | + | |
225 | +struct ipt_ipv4options_info { | |
226 | + u_int16_t options; | |
227 | +}; | |
228 | + | |
229 | + | |
230 | +#endif /* __ipt_ipv4options_h_included__ */ | |
231 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_mport.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_mport.h | |
232 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_mport.h 1970-01-01 01:00:00.000000000 +0100 | |
233 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_mport.h 2004-02-16 11:07:17.665725817 +0100 | |
234 | @@ -0,0 +1,24 @@ | |
235 | +#ifndef _IPT_MPORT_H | |
236 | +#define _IPT_MPORT_H | |
237 | +#include <linux/netfilter_ipv4/ip_tables.h> | |
238 | + | |
239 | +#define IPT_MPORT_SOURCE (1<<0) | |
240 | +#define IPT_MPORT_DESTINATION (1<<1) | |
241 | +#define IPT_MPORT_EITHER (IPT_MPORT_SOURCE|IPT_MPORT_DESTINATION) | |
242 | + | |
243 | +#define IPT_MULTI_PORTS 15 | |
244 | + | |
245 | +/* Must fit inside union ipt_matchinfo: 32 bytes */ | |
246 | +/* every entry in ports[] except for the last one has one bit in pflags | |
247 | + * associated with it. If this bit is set, the port is the first port of | |
248 | + * a portrange, with the next entry being the last. | |
249 | + * End of list is marked with pflags bit set and port=65535. | |
250 | + * If 14 ports are used (last one does not have a pflag), the last port | |
251 | + * is repeated to fill the last entry in ports[] */ | |
252 | +struct ipt_mport | |
253 | +{ | |
254 | + u_int8_t flags:2; /* Type of comparison */ | |
255 | + u_int16_t pflags:14; /* Port flags */ | |
256 | + u_int16_t ports[IPT_MULTI_PORTS]; /* Ports */ | |
257 | +}; | |
258 | +#endif /*_IPT_MPORT_H*/ | |
259 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_nth.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_nth.h | |
260 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_nth.h 1970-01-01 01:00:00.000000000 +0100 | |
261 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_nth.h 2004-02-16 11:07:18.796455028 +0100 | |
262 | @@ -0,0 +1,19 @@ | |
263 | +#ifndef _IPT_NTH_H | |
264 | +#define _IPT_NTH_H | |
265 | + | |
266 | +#include <linux/param.h> | |
267 | +#include <linux/types.h> | |
268 | + | |
269 | +#ifndef IPT_NTH_NUM_COUNTERS | |
270 | +#define IPT_NTH_NUM_COUNTERS 16 | |
271 | +#endif | |
272 | + | |
273 | +struct ipt_nth_info { | |
274 | + u_int8_t every; | |
275 | + u_int8_t not; | |
276 | + u_int8_t startat; | |
277 | + u_int8_t counter; | |
278 | + u_int8_t packet; | |
279 | +}; | |
280 | + | |
281 | +#endif /*_IPT_NTH_H*/ | |
282 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_osf.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_osf.h | |
283 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_osf.h 1970-01-01 01:00:00.000000000 +0100 | |
284 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_osf.h 2004-02-16 11:07:19.917186632 +0100 | |
285 | @@ -0,0 +1,130 @@ | |
286 | +/* | |
287 | + * ipt_osf.h | |
288 | + * | |
289 | + * Copyright (c) 2003 Evgeniy Polyakov <johnpol@2ka.mipt.ru> | |
290 | + * | |
291 | + * | |
292 | + * This program is free software; you can redistribute it and/or modify | |
293 | + * it under the terms of the GNU General Public License as published by | |
294 | + * the Free Software Foundation; either version 2 of the License, or | |
295 | + * (at your option) any later version. | |
296 | + * | |
297 | + * This program is distributed in the hope that it will be useful, | |
298 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
299 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
300 | + * GNU General Public License for more details. | |
301 | + * | |
302 | + * You should have received a copy of the GNU General Public License | |
303 | + * along with this program; if not, write to the Free Software | |
304 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
305 | + */ | |
306 | + | |
307 | +#ifndef _IPT_OSF_H | |
308 | +#define _IPT_OSF_H | |
309 | + | |
310 | +#define MAXGENRELEN 32 | |
311 | +#define MAXDETLEN 64 | |
312 | + | |
313 | +#define IPT_OSF_GENRE 1 | |
314 | +#define IPT_OSF_SMART 2 | |
315 | +#define IPT_OSF_LOG 4 | |
316 | + | |
317 | +#define IPT_OSF_LOGLEVEL_ALL 0 | |
318 | +#define IPT_OSF_LOGLEVEL_FIRST 1 | |
319 | + | |
320 | +#include <linux/list.h> | |
321 | + | |
322 | +struct ipt_osf_info | |
323 | +{ | |
324 | + char genre[MAXGENRELEN]; | |
325 | + int len; | |
326 | + unsigned long flags; | |
327 | + int loglevel; | |
328 | + int invert; /* UNSUPPORTED */ | |
329 | +}; | |
330 | + | |
331 | +struct osf_wc | |
332 | +{ | |
333 | + char wc; | |
334 | + unsigned long val; | |
335 | +}; | |
336 | + | |
337 | +/* This struct represents IANA options | |
338 | + * http://www.iana.org/assignments/tcp-parameters | |
339 | + */ | |
340 | +struct osf_opt | |
341 | +{ | |
342 | + unsigned char kind; | |
343 | + unsigned char length; | |
344 | + struct osf_wc wc; | |
345 | +}; | |
346 | + | |
347 | +#ifdef __KERNEL__ | |
348 | + | |
349 | +struct osf_finger | |
350 | +{ | |
351 | + struct list_head flist; | |
352 | + struct osf_wc wss; | |
353 | + unsigned char ttl; | |
354 | + unsigned char df; | |
355 | + unsigned long ss; | |
356 | + char genre[MAXGENRELEN]; | |
357 | + char version[MAXGENRELEN], subtype[MAXGENRELEN]; | |
358 | + | |
359 | + /* Not needed, but for consistency with original table from Michal Zalewski */ | |
360 | + char details[MAXDETLEN]; | |
361 | + | |
362 | + int opt_num; | |
363 | + struct osf_opt opt[MAX_IPOPTLEN]; /* In case it is all NOP or EOL */ | |
364 | + | |
365 | +}; | |
366 | + | |
367 | +/* Defines for IANA option kinds */ | |
368 | + | |
369 | +#define OSFOPT_EOL 0 /* End of options */ | |
370 | +#define OSFOPT_NOP 1 /* NOP */ | |
371 | +#define OSFOPT_MSS 2 /* Maximum segment size */ | |
372 | +#define OSFOPT_WSO 3 /* Window scale option */ | |
373 | +#define OSFOPT_SACKP 4 /* SACK permitted */ | |
374 | +#define OSFOPT_SACK 5 /* SACK */ | |
375 | +#define OSFOPT_ECHO 6 | |
376 | +#define OSFOPT_ECHOREPLY 7 | |
377 | +#define OSFOPT_TS 8 /* Timestamp option */ | |
378 | +#define OSFOPT_POCP 9 /* Partial Order Connection Permitted */ | |
379 | +#define OSFOPT_POSP 10 /* Partial Order Service Profile */ | |
380 | +/* Others are not used in current OSF */ | |
381 | + | |
382 | +static struct osf_opt IANA_opts[] = | |
383 | +{ | |
384 | + {0, 1,}, | |
385 | + {1, 1,}, | |
386 | + {2, 4,}, | |
387 | + {3, 3,}, | |
388 | + {4, 2,}, | |
389 | + {5, 1 ,}, /* SACK length is not defined */ | |
390 | + {6, 6,}, | |
391 | + {7, 6,}, | |
392 | + {8, 10,}, | |
393 | + {9, 2,}, | |
394 | + {10, 3,}, | |
395 | + {11, 1,}, /* CC: Suppose 1 */ | |
396 | + {12, 1,}, /* the same */ | |
397 | + {13, 1,}, /* and here too */ | |
398 | + {14, 3,}, | |
399 | + {15, 1,}, /* TCP Alternate Checksum Data. Length is not defined */ | |
400 | + {16, 1,}, | |
401 | + {17, 1,}, | |
402 | + {18, 3,}, | |
403 | + {19, 18,}, | |
404 | + {20, 1,}, | |
405 | + {21, 1,}, | |
406 | + {22, 1,}, | |
407 | + {23, 1,}, | |
408 | + {24, 1,}, | |
409 | + {25, 1,}, | |
410 | + {26, 1,}, | |
411 | +}; | |
412 | + | |
413 | +#endif /* __KERNEL__ */ | |
414 | + | |
415 | +#endif /* _IPT_OSF_H */ | |
416 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_pool.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_pool.h | |
417 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_pool.h 1970-01-01 01:00:00.000000000 +0100 | |
418 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_pool.h 2004-02-16 11:07:21.518803072 +0100 | |
419 | @@ -0,0 +1,25 @@ | |
420 | +#ifndef _IPT_POOL_H | |
421 | +#define _IPT_POOL_H | |
422 | + | |
423 | +#include <linux/netfilter_ipv4/ip_pool.h> | |
424 | + | |
425 | +#define IPT_POOL_INV_SRC 0x00000001 | |
426 | +#define IPT_POOL_INV_DST 0x00000002 | |
427 | +#define IPT_POOL_DEL_SRC 0x00000004 | |
428 | +#define IPT_POOL_DEL_DST 0x00000008 | |
429 | +#define IPT_POOL_INV_MOD_SRC 0x00000010 | |
430 | +#define IPT_POOL_INV_MOD_DST 0x00000020 | |
431 | +#define IPT_POOL_MOD_SRC_ACCEPT 0x00000040 | |
432 | +#define IPT_POOL_MOD_DST_ACCEPT 0x00000080 | |
433 | +#define IPT_POOL_MOD_SRC_DROP 0x00000100 | |
434 | +#define IPT_POOL_MOD_DST_DROP 0x00000200 | |
435 | + | |
436 | +/* match info */ | |
437 | +struct ipt_pool_info | |
438 | +{ | |
439 | + ip_pool_t src; | |
440 | + ip_pool_t dst; | |
441 | + unsigned flags; | |
442 | +}; | |
443 | + | |
444 | +#endif /*_IPT_POOL_H*/ | |
445 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_psd.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_psd.h | |
446 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_psd.h 1970-01-01 01:00:00.000000000 +0100 | |
447 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_psd.h 2004-02-16 11:07:22.387595011 +0100 | |
448 | @@ -0,0 +1,40 @@ | |
449 | +#ifndef _IPT_PSD_H | |
450 | +#define _IPT_PSD_H | |
451 | + | |
452 | +#include <linux/param.h> | |
453 | +#include <linux/types.h> | |
454 | + | |
455 | +/* | |
456 | + * High port numbers have a lower weight to reduce the frequency of false | |
457 | + * positives, such as from passive mode FTP transfers. | |
458 | + */ | |
459 | +#define PORT_WEIGHT_PRIV 3 | |
460 | +#define PORT_WEIGHT_HIGH 1 | |
461 | + | |
462 | +/* | |
463 | + * Port scan detection thresholds: at least COUNT ports need to be scanned | |
464 | + * from the same source, with no longer than DELAY ticks between ports. | |
465 | + */ | |
466 | +#define SCAN_MIN_COUNT 7 | |
467 | +#define SCAN_MAX_COUNT (SCAN_MIN_COUNT * PORT_WEIGHT_PRIV) | |
468 | +#define SCAN_WEIGHT_THRESHOLD SCAN_MAX_COUNT | |
469 | +#define SCAN_DELAY_THRESHOLD (HZ * 3) | |
470 | + | |
471 | +/* | |
472 | + * Keep track of up to LIST_SIZE source addresses, using a hash table of | |
473 | + * HASH_SIZE entries for faster lookups, but limiting hash collisions to | |
474 | + * HASH_MAX source addresses per the same hash value. | |
475 | + */ | |
476 | +#define LIST_SIZE 0x100 | |
477 | +#define HASH_LOG 9 | |
478 | +#define HASH_SIZE (1 << HASH_LOG) | |
479 | +#define HASH_MAX 0x10 | |
480 | + | |
481 | +struct ipt_psd_info { | |
482 | + unsigned int weight_threshold; | |
483 | + unsigned int delay_threshold; | |
484 | + unsigned short lo_ports_weight; | |
485 | + unsigned short hi_ports_weight; | |
486 | +}; | |
487 | + | |
488 | +#endif /*_IPT_PSD_H*/ | |
489 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_quota.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_quota.h | |
490 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_quota.h 1970-01-01 01:00:00.000000000 +0100 | |
491 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_quota.h 2004-02-16 11:07:23.219395809 +0100 | |
492 | @@ -0,0 +1,11 @@ | |
493 | +#ifndef _IPT_QUOTA_H | |
494 | +#define _IPT_QUOTA_H | |
495 | + | |
496 | +/* print debug info in both kernel/netfilter module & iptable library */ | |
497 | +//#define DEBUG_IPT_QUOTA | |
498 | + | |
499 | +struct ipt_quota_info { | |
500 | + u_int64_t quota; | |
501 | +}; | |
502 | + | |
503 | +#endif /*_IPT_QUOTA_H*/ | |
504 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_random.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_random.h | |
505 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_random.h 1970-01-01 01:00:00.000000000 +0100 | |
506 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_random.h 2004-02-16 11:07:24.378118313 +0100 | |
507 | @@ -0,0 +1,11 @@ | |
508 | +#ifndef _IPT_RAND_H | |
509 | +#define _IPT_RAND_H | |
510 | + | |
511 | +#include <linux/param.h> | |
512 | +#include <linux/types.h> | |
513 | + | |
514 | +struct ipt_rand_info { | |
515 | + u_int8_t average; | |
516 | +}; | |
517 | + | |
518 | +#endif /*_IPT_RAND_H*/ | |
519 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_realm.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_realm.h | |
520 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_realm.h 1970-01-01 01:00:00.000000000 +0100 | |
521 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_realm.h 2004-02-16 11:07:26.369641375 +0100 | |
522 | @@ -0,0 +1,9 @@ | |
523 | +#ifndef _IPT_REALM_H | |
524 | +#define _IPT_REALM_H | |
525 | + | |
526 | +struct ipt_realm_info { | |
527 | + u_int32_t id; | |
528 | + u_int32_t mask; | |
529 | + u_int8_t invert; | |
530 | +}; | |
531 | +#endif /*_IPT_REALM_H*/ | |
532 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_time.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_time.h | |
533 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_time.h 1970-01-01 01:00:00.000000000 +0100 | |
534 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_time.h 2004-02-16 11:07:27.150454383 +0100 | |
535 | @@ -0,0 +1,13 @@ | |
536 | +#ifndef __ipt_time_h_included__ | |
537 | +#define __ipt_time_h_included__ | |
538 | + | |
539 | + | |
540 | +struct ipt_time_info { | |
541 | + u_int8_t days_match; /* 1 bit per day. -SMTWTFS */ | |
542 | + u_int16_t time_start; /* 0 < time_start < 23*60+59 = 1439 */ | |
543 | + u_int16_t time_stop; /* 0:0 < time_stat < 23:59 */ | |
544 | + u_int8_t kerneltime; /* ignore skb time (and use kerneltime) or not. */ | |
545 | +}; | |
546 | + | |
547 | + | |
548 | +#endif /* __ipt_time_h_included__ */ | |
549 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_u32.h linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_u32.h | |
550 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv4/ipt_u32.h 1970-01-01 01:00:00.000000000 +0100 | |
551 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv4/ipt_u32.h 2004-02-16 11:07:28.175208970 +0100 | |
552 | @@ -0,0 +1,40 @@ | |
553 | +#ifndef _IPT_U32_H | |
554 | +#define _IPT_U32_H | |
555 | +#include <linux/netfilter_ipv4/ip_tables.h> | |
556 | + | |
557 | +enum ipt_u32_ops | |
558 | +{ | |
559 | + IPT_U32_AND, | |
560 | + IPT_U32_LEFTSH, | |
561 | + IPT_U32_RIGHTSH, | |
562 | + IPT_U32_AT | |
563 | +}; | |
564 | + | |
565 | +struct ipt_u32_location_element | |
566 | +{ | |
567 | + u_int32_t number; | |
568 | + u_int8_t nextop; | |
569 | +}; | |
570 | +struct ipt_u32_value_element | |
571 | +{ | |
572 | + u_int32_t min; | |
573 | + u_int32_t max; | |
574 | +}; | |
575 | +/* *** any way to allow for an arbitrary number of elements? | |
576 | + for now I settle for a limit of 10 of each */ | |
577 | +#define U32MAXSIZE 10 | |
578 | +struct ipt_u32_test | |
579 | +{ | |
580 | + u_int8_t nnums; | |
581 | + struct ipt_u32_location_element location[U32MAXSIZE+1]; | |
582 | + u_int8_t nvalues; | |
583 | + struct ipt_u32_value_element value[U32MAXSIZE+1]; | |
584 | +}; | |
585 | + | |
586 | +struct ipt_u32 | |
587 | +{ | |
588 | + u_int8_t ntests; | |
589 | + struct ipt_u32_test tests[U32MAXSIZE+1]; | |
590 | +}; | |
591 | + | |
592 | +#endif /*_IPT_U32_H*/ | |
593 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_HL.h linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_HL.h | |
594 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_HL.h 1970-01-01 01:00:00.000000000 +0100 | |
595 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_HL.h 2004-02-16 11:06:53.521507853 +0100 | |
596 | @@ -0,0 +1,22 @@ | |
597 | +/* Hop Limit modification module for ip6tables | |
598 | + * Maciej Soltysiak <solt@dns.toxicfilms.tv> | |
599 | + * Based on HW's TTL module */ | |
600 | + | |
9a8ef503 | 601 | +#ifndef _IP6T_HL_H |
602 | +#define _IP6T_HL_H | |
70b033d6 | 603 | + |
604 | +enum { | |
9a8ef503 | 605 | + IP6T_HL_SET = 0, |
606 | + IP6T_HL_INC, | |
607 | + IP6T_HL_DEC | |
70b033d6 | 608 | +}; |
609 | + | |
9a8ef503 | 610 | +#define IP6T_HL_MAXMODE IP6T_HL_DEC |
70b033d6 | 611 | + |
9a8ef503 | 612 | +struct ip6t_HL_info { |
70b033d6 | 613 | + u_int8_t mode; |
614 | + u_int8_t hop_limit; | |
615 | +}; | |
616 | + | |
617 | + | |
618 | +#endif | |
619 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_REJECT.h linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_REJECT.h | |
620 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_REJECT.h 2004-02-15 03:44:09.000000000 +0100 | |
621 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_REJECT.h 2004-02-16 11:07:07.812085576 +0100 | |
622 | @@ -2,15 +2,17 @@ | |
623 | #define _IP6T_REJECT_H | |
624 | ||
625 | enum ip6t_reject_with { | |
626 | - IP6T_ICMP_NET_UNREACHABLE, | |
627 | - IP6T_ICMP_HOST_UNREACHABLE, | |
628 | - IP6T_ICMP_PROT_UNREACHABLE, | |
629 | - IP6T_ICMP_PORT_UNREACHABLE, | |
630 | - IP6T_ICMP_ECHOREPLY | |
631 | + IP6T_ICMP6_NO_ROUTE, | |
632 | + IP6T_ICMP6_ADM_PROHIBITED, | |
633 | + IP6T_ICMP6_NOT_NEIGHBOUR, | |
634 | + IP6T_ICMP6_ADDR_UNREACH, | |
635 | + IP6T_ICMP6_PORT_UNREACH, | |
636 | + IP6T_ICMP6_ECHOREPLY, | |
637 | + IP6T_TCP_RESET | |
638 | }; | |
639 | ||
640 | struct ip6t_reject_info { | |
641 | enum ip6t_reject_with with; /* reject type */ | |
642 | }; | |
643 | ||
644 | -#endif /*_IPT_REJECT_H*/ | |
645 | +#endif /*_IP6T_REJECT_H*/ | |
646 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_fuzzy.h linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_fuzzy.h | |
647 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_fuzzy.h 1970-01-01 01:00:00.000000000 +0100 | |
648 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_fuzzy.h 2004-02-16 11:07:14.925382080 +0100 | |
649 | @@ -0,0 +1,21 @@ | |
650 | +#ifndef _IP6T_FUZZY_H | |
651 | +#define _IP6T_FUZZY_H | |
652 | + | |
653 | +#include <linux/param.h> | |
654 | +#include <linux/types.h> | |
655 | + | |
656 | +#define MAXFUZZYRATE 10000000 | |
657 | +#define MINFUZZYRATE 3 | |
658 | + | |
659 | +struct ip6t_fuzzy_info { | |
660 | + u_int32_t minimum_rate; | |
661 | + u_int32_t maximum_rate; | |
662 | + u_int32_t packets_total; | |
663 | + u_int32_t bytes_total; | |
664 | + u_int32_t previous_time; | |
665 | + u_int32_t present_time; | |
666 | + u_int32_t mean_rate; | |
667 | + u_int8_t acceptance_rate; | |
668 | +}; | |
669 | + | |
670 | +#endif /*_IP6T_FUZZY_H*/ | |
671 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_nth.h linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_nth.h | |
672 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_nth.h 1970-01-01 01:00:00.000000000 +0100 | |
673 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_nth.h 2004-02-16 11:07:18.796455028 +0100 | |
674 | @@ -0,0 +1,19 @@ | |
675 | +#ifndef _IP6T_NTH_H | |
676 | +#define _IP6T_NTH_H | |
677 | + | |
678 | +#include <linux/param.h> | |
679 | +#include <linux/types.h> | |
680 | + | |
681 | +#ifndef IP6T_NTH_NUM_COUNTERS | |
682 | +#define IP6T_NTH_NUM_COUNTERS 16 | |
683 | +#endif | |
684 | + | |
685 | +struct ip6t_nth_info { | |
686 | + u_int8_t every; | |
687 | + u_int8_t not; | |
688 | + u_int8_t startat; | |
689 | + u_int8_t counter; | |
690 | + u_int8_t packet; | |
691 | +}; | |
692 | + | |
693 | +#endif /*_IP6T_NTH_H*/ | |
694 | diff -Nur linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_random.h linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_random.h | |
695 | --- linux-2.6.3-rc3.org/include/linux/netfilter_ipv6/ip6t_random.h 1970-01-01 01:00:00.000000000 +0100 | |
696 | +++ linux-2.6.3-rc3/include/linux/netfilter_ipv6/ip6t_random.h 2004-02-16 11:07:24.378118313 +0100 | |
697 | @@ -0,0 +1,11 @@ | |
698 | +#ifndef _IP6T_RAND_H | |
699 | +#define _IP6T_RAND_H | |
700 | + | |
701 | +#include <linux/param.h> | |
702 | +#include <linux/types.h> | |
703 | + | |
704 | +struct ip6t_rand_info { | |
705 | + u_int8_t average; | |
706 | +}; | |
707 | + | |
708 | +#endif /*_IP6T_RAND_H*/ | |
709 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/Kconfig linux-2.6.3-rc3/net/ipv4/netfilter/Kconfig | |
710 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/Kconfig 2004-02-16 10:08:59.000000000 +0100 | |
711 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/Kconfig 2004-02-16 11:07:28.178208252 +0100 | |
712 | @@ -588,5 +588,384 @@ | |
713 | ||
714 | To compile it as a module, choose M here. If unsure, say N. | |
715 | ||
716 | +config IP_NF_TARGET_IPV4OPTSSTRIP | |
717 | + tristate 'IPV4OPTSSTRIP target support' | |
718 | + depends on IP_NF_MANGLE | |
719 | + help | |
720 | + This option adds CONFIG_IP_NF_TARGET_IPV4OPTSSTRIP, which supplies a target | |
721 | + module that will allow you to strip all the IP options from a packet. | |
722 | + | |
723 | + The target doesn't take any option, and therefore is extremly easy to use : | |
724 | + | |
725 | + # iptables -t mangle -A PREROUTING -j IPV4OPTSSTRIP | |
726 | + # iptables -t mangle --list -n | |
727 | + Chain PREROUTING (policy ACCEPT) | |
728 | + target prot opt source destination | |
729 | + IPV4OPTSSTRIP all -- 0.0.0.0/0 0.0.0.0/0 | |
730 | + | |
731 | + Chain OUTPUT (policy ACCEPT) | |
732 | + target prot opt source destination | |
733 | + | |
734 | +config IP_NF_TARGET_NETLINK | |
735 | + tristate 'NETLINK target support' | |
736 | + depends on IP_NF_FILTER | |
737 | + help | |
738 | + CONFIG_IP_NF_TARGET_NETLINK adds a NETLINK target that sends dropped packets to | |
739 | + userspace via a netlink socket. Apps such as fwmon | |
740 | + (http://firestorm.geek-ware.co.uk) can then recieve and dislpay these packets. | |
741 | + This option is basically a re-implementation of the ipchains -o option. | |
742 | + | |
743 | +config IP_NF_TARGET_TTL | |
744 | + tristate 'TTL target support' | |
745 | + depends on IP_NF_MANGLE | |
746 | + help | |
747 | + This adds an iptables TTL manipulation target, which enables the user | |
748 | + to set the TTL value of an IP packet or to increment / decrement it | |
749 | + by a given value. | |
750 | + | |
751 | +config IP_NF_MATCH_CONNLIMIT | |
752 | + tristate 'Connections/IP limit match support' | |
753 | + depends on IP_NF_IPTABLES | |
754 | + help | |
755 | + This adds an iptables match which allows you to restrict the | |
756 | + number of parallel TCP connections to a server per client IP address | |
757 | + (or address block). | |
758 | + | |
759 | + Examples: | |
760 | + | |
761 | + # allow 2 telnet connections per client host | |
762 | + iptables -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT | |
763 | + | |
764 | + # you can also match the other way around: | |
765 | + iptables -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT | |
766 | + | |
767 | + # limit the nr of parallel http requests to 16 per class C sized | |
768 | + # network (24 bit netmask) | |
769 | + iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16 \ | |
770 | + --connlimit-mask 24 -j REJECT | |
771 | + | |
772 | +config IP_NF_MATCH_DSTLIMIT | |
773 | + tristate 'dstlimit match support' | |
774 | + depends on IP_NF_IPTABLES | |
775 | + help | |
776 | + | |
777 | + This patch adds a new match called 'dstlimit'. | |
778 | + The idea is to have something like 'limit', but either per | |
779 | + destination-ip or per (destip,destport) tuple. | |
780 | + | |
781 | + It gives you the ability to say | |
782 | + '1000 packets per second for every host in 192.168.0.0/16' | |
783 | + '100 packets per second for every service of 192.168.1.1' | |
784 | + | |
785 | + Parameters are: | |
786 | + --dstlimit <rate> | |
787 | + A rate just like the limit match | |
788 | + --dstlimit-burst <num> | |
789 | + Burst value, just like limit match | |
790 | + --dstlimit-mode destip | destip-destport | |
791 | + Limit per IP or per port | |
792 | + --dstlimit-name foo | |
793 | + The name for the /proc/net/ipt_dstlimit/foo entry | |
794 | + --dstlimit-htable-size <num> | |
795 | + The number of buckets of the hash table | |
796 | + --dstlimit-htable-max <num> | |
797 | + Maximum entries in the hash | |
798 | + --dstlimit-htable-expire <num> | |
799 | + After how many miliseconds do hash entries expire | |
800 | + --dstlimit-htable-gcinterval <num> | |
801 | + How many miliseconds between garbage collection intervals | |
802 | + | |
803 | + | |
804 | +config IP_NF_MATCH_FUZZY | |
805 | + tristate 'fuzzy match support' | |
806 | + depends on IP_NF_IPTABLES | |
807 | + help | |
808 | + This option adds a `fuzzy' match which allows you to match packets according to | |
809 | + a dynamic profile implemented by means of a simple Fuzzy Logic Controller (FLC) | |
810 | + | |
811 | +config IP_NF_MATCH_IPV4OPTIONS | |
812 | + tristate 'IPV4OPTIONS match support' | |
813 | + depends on IP_NF_IPTABLES | |
814 | + help | |
815 | + This option adds an iptables 'ipv4options' match, which allows you to | |
816 | + match on IPv4 header options like source routing, record route, timestamp and | |
817 | + router-alert. | |
818 | + | |
819 | + Suppported options are: | |
820 | + --ssrr | |
821 | + To match packets with the flag strict source routing. | |
822 | + --lsrr | |
823 | + To match packets with the flag loose source routing. | |
824 | + --no-srr | |
825 | + To match packets with no flag for source routing. | |
826 | + [!] --rr | |
827 | + To match packets with the RR flag. | |
828 | + [!] --ts | |
829 | + To match packets with the TS flag. | |
830 | + [!] --ra | |
831 | + To match packets with the router-alert option. | |
832 | + [!] --any-opt | |
833 | + To match a packet with at least one IP option, or no IP option | |
834 | + at all if ! is chosen. | |
835 | + | |
836 | + Example: | |
837 | + $ iptables -A input -m ipv4options --rr -j DROP | |
838 | + will drop packets with the record-route flag. | |
839 | + | |
840 | + $ iptables -A input -m ipv4options --ts -j DROP | |
841 | + will drop packets with the timestamp flag. | |
842 | + | |
843 | +config IP_NF_MATCH_MPORT | |
844 | + tristate 'Multiple port with ranges match support' | |
845 | + depends on IP_NF_IPTABLES | |
846 | + help | |
847 | + This module is an enhanced multiport match. It has support for byte | |
848 | + ranges as well as for single ports. | |
849 | + Up to 15 ports are allowed. Note that a portrange uses up 2 port values. | |
850 | + | |
851 | + Examples: | |
852 | + # iptables -A FORWARD -p tcp -m mport --ports 23:42,65 | |
853 | + | |
854 | +config IP_NF_MATCH_NTH | |
855 | + tristate 'Nth match support' | |
856 | + depends on IP_NF_IPTABLES | |
857 | + help | |
858 | + This option adds an iptables `Nth' match, which allows you to match every Nth | |
859 | + packet encountered. By default there are 16 different counters that can be | |
860 | + used. | |
861 | + | |
862 | + This match functions in one of two ways | |
863 | + 1) Match ever Nth packet, and only the Nth packet. | |
864 | + example: | |
865 | + iptables -t mangle -A PREROUTING -m nth --every 10 -j DROP | |
866 | + This rule will drop every 10th packet. | |
867 | + 2) Unique rule for every packet. This is an easy and quick | |
868 | + method to produce load-balancing for both inbound and outbound. | |
869 | + example: | |
870 | + iptables -t nat -A POSTROUTING -o eth0 -m nth --counter 7 \ | |
871 | + --every 3 --packet 0 -j SNAT --to-source 10.0.0.5 | |
872 | + iptables -t nat -A POSTROUTING -o eth0 -m nth --counter 7 \ | |
873 | + --every 3 --packet 1 -j SNAT --to-source 10.0.0.6 | |
874 | + iptables -t nat -A POSTROUTING -o eth0 -m nth --counter 7 \ | |
875 | + --every 3 --packet 2 -j SNAT --to-source 10.0.0.7 | |
876 | + This example evenly splits connections between the three SNAT | |
877 | + addresses. | |
878 | + | |
879 | + By using the mangle table and iproute2, you can setup complex | |
880 | + load-balanced routing. There's lot of other uses. Be creative! | |
881 | + | |
882 | + Suppported options are: | |
883 | + --every Nth Match every Nth packet | |
884 | + [--counter] num Use counter 0-15 (default:0) | |
885 | + [--start] num Initialize the counter at the number 'num' | |
886 | + instead of 0. Must be between 0 and Nth-1 | |
887 | + [--packet] num Match on 'num' packet. Must be between 0 | |
888 | + and Nth-1. | |
889 | + If --packet is used for a counter than | |
890 | + there must be Nth number of --packet | |
891 | + rules, covering all values between 0 and | |
892 | + Nth-1 inclusively. | |
893 | + | |
894 | +config IP_NF_MATCH_OSF | |
895 | + tristate 'OSF match support' | |
896 | + depends on IP_NF_IPTABLES | |
897 | + help | |
898 | + The idea of passive OS fingerprint matching exists for quite a long time, | |
899 | + but was created as extension fo OpenBSD pf only some weeks ago. | |
900 | + Original idea was lurked in some OpenBSD mailing list (thanks | |
901 | + grange@open...) and than adopted for Linux netfilter in form of this code. | |
902 | + | |
903 | + Original table was created by Michal Zalewski <lcamtuf@coredump.cx> for | |
904 | + his excellent p0f and than changed a bit for more convenience. | |
905 | + | |
906 | + This module compares some data(WS, MSS, options and it's order, ttl, | |
907 | + df and others) from first SYN packet (actually from packets with SYN | |
908 | + bit set) with hardcoded in fingers[] table ones. | |
909 | + | |
910 | + Example: (Of course this only an example, do not get inspired by this) | |
911 | + | |
912 | + # iptables -N LINUX | |
913 | + # iptables -A LINUX -j LOG --log-prefix "Linux" | |
914 | + | |
915 | + # iptables -A INPUT -p tcp -m osf --genre Linux -j LINUX | |
916 | + # iptables -A INPUT -p tcp -m osf --genre FreeBSD -j REJECT | |
917 | + | |
918 | + NOTE: -p tcp is obviously required as it is a TCP match. | |
919 | + | |
920 | + OSF also has: | |
921 | + --log 1/0. | |
922 | + If present, OSF will log determined genres even if they don't match | |
923 | + desired one. | |
924 | + 0 - log all determined entries, | |
925 | + 1 - only first one. | |
926 | + | |
927 | + Example: | |
928 | + #iptables -I INPUT -j ACCEPT -p tcp -m osf --genre Linux --log 1 --smart | |
929 | + | |
930 | + In syslog you find something like this: | |
931 | + ipt_osf: Windows [Windows XP Pro SP1, 2000 SP3]: 11.22.33.55:4024 -> 11.22.33.44:139 | |
932 | + ipt_osf: Unknown: 16384:106:1:48:020405B401010402 44.33.22.11:1239 -> 11.22.33.44:80 | |
933 | + | |
934 | + --smart | |
935 | + if present, OSF will use some smartness to determine remote OS. | |
936 | + Now only not use TTL( with it far remote machines can be determined). | |
937 | + | |
938 | + Fingerprints can be loaded through /proc/sys/net/ipv4/osf file. | |
939 | + Only one fingerprint per open/close. | |
940 | + | |
941 | + Fingerprints can be downloaded from http://www.openbsd.org/cgi-bin/cvsweb/src/etc/pf.os | |
942 | + | |
943 | +config IP_POOL_STATISTICS | |
944 | + bool 'enable statistics on pool usage' | |
945 | + depends on IP_NF_POOL!=n | |
946 | + | |
947 | +config IP_NF_POOL | |
948 | + tristate 'IP address pool support' | |
949 | + depends on IP_NF_IPTABLES | |
950 | + help | |
951 | + CONFIG_IP_NF_POOL provides a match which lets you use bitmaps with one bit per | |
952 | + address from some range of IP addresses; the match depends on whether a checked | |
953 | + source or destination address has its bit set in the pool. It also provides a | |
954 | + POOL target, which can be used to add or remove the addresses of a packet | |
955 | + to/from a pool. | |
956 | + | |
957 | + There is also a POOL netfilter target, which can be used to set or remove the | |
958 | + addresses of a packet from a pool. | |
959 | + | |
960 | + To define and use pools, you need userlevel utilities: a patched iptables, and | |
961 | + the program ippool(8), which defines the pools and their bounds. The current | |
962 | + release of pool matching is ippool-0.0.2, and can be found in the archives of | |
963 | + the netfilter mailing list at http://lists.netfilter.org/. | |
964 | + | |
965 | +config IP_NF_MATCH_PSD | |
966 | + tristate 'psd match support' | |
967 | + depends on IP_NF_IPTABLES | |
968 | + help | |
969 | + This option adds a `psd' match, which supplies portscan | |
970 | + detection match (psd). This match will attempt to detect TCP and UDP | |
971 | + port scans. This match was derived from Solar Designer's scanlogd. | |
972 | + | |
973 | + Suppported options are: | |
974 | + | |
975 | + --psd-weight-threshold <threshold> | |
976 | + | |
977 | + Total weight of the latest TCP/UDP packets with different | |
978 | + destination ports coming from the same host to be treated as port | |
979 | + scan sequence. | |
980 | + | |
981 | + --psd-delay-threshold <delay> | |
982 | + | |
983 | + Delay (in hundredths of second) for the packets with different | |
984 | + destination ports coming from the same host to be treated as | |
985 | + possible port scan subsequence. | |
986 | + | |
987 | + --psd-lo-ports-weight <weight> | |
988 | + | |
989 | + Weight of the packet with privileged (<=1024) destination port. | |
990 | + | |
991 | + --psd-hi-ports-weight <weight> | |
992 | + | |
993 | + Weight of the packet with non-priviliged destination port. | |
994 | + | |
995 | +config IP_NF_MATCH_QUOTA | |
996 | + tristate 'quota match support' | |
997 | + depends on IP_NF_IPTABLES | |
998 | + help | |
999 | + This option adds CONFIG_IP_NF_MATCH_QUOTA, which implements network | |
1000 | + quotas by decrementing a byte counter with each packet. | |
1001 | + | |
1002 | + Supported options are: | |
1003 | + --quota <bytes> | |
1004 | + The quota in bytes. | |
1005 | + | |
1006 | + KNOWN BUGS: this does not work on SMP systems. | |
1007 | + | |
1008 | + | |
1009 | +config IP_NF_MATCH_RANDOM | |
1010 | + tristate 'random match support' | |
1011 | + depends on IP_NF_IPTABLES | |
1012 | + help | |
1013 | + This option adds a `random' match, | |
1014 | + which allow you to match packets randomly | |
1015 | + following a given probability. | |
1016 | + | |
1017 | + Suppported options are: | |
1018 | + | |
1019 | + [--average] percent will match randomly packets with a probability of | |
1020 | + 'percent'. default is 50% | |
1021 | + | |
1022 | +config IP_NF_MATCH_REALM | |
1023 | + tristate 'realm match support' | |
1024 | + depends on IP_NF_IPTABLES | |
1025 | + help | |
1026 | + realm match: uses realm key from routing as match criteria similiar to | |
1027 | + one in packet classifier | |
1028 | + | |
1029 | + /** snip from packet classifier documentation */ | |
1030 | + Routing tables based classifier | |
1031 | + CONFIG_NET_CLS_ROUTE4 | |
1032 | + If you say Y here, you will be able to classify outgoing packets | |
1033 | + according to the route table entry they matched. If unsure, say Y. | |
1034 | + /** end snip **/ | |
1035 | + | |
1036 | + | |
1037 | + # Example | |
1038 | + # add route | |
1039 | + /sbin/ip route add 194.29.194.0/24 via 194.29.192.1 realm 10 | |
1040 | + | |
1041 | + # source realm is in realm with mask 0xFFFF0000, | |
1042 | + # destination is in realm with mask 0x0000FFFF | |
1043 | + | |
1044 | + # match destination realm | |
1045 | + /usr/local/sbin/iptables -A OUTPUT -m realm --realm 10 -j LOG | |
1046 | + | |
1047 | + # match realm of source, this is also determinated by routing, | |
1048 | + /usr/local/sbin/iptables -A INPUT -m realm --realm 655360 -j LOG | |
1049 | + | |
1050 | + THIS PATCH REQUIRES CONFIG_NET_CLS_ROUTE TO BE SET | |
1051 | + | |
1052 | +config IP_NF_MATCH_TIME | |
1053 | + tristate 'TIME match support' | |
1054 | + depends on IP_NF_IPTABLES | |
1055 | + help | |
1056 | + | |
1057 | + This option adds CONFIG_IP_NF_MATCH_TIME, which supplies a time match module. | |
1058 | + This match allows you to filter based on the packet arrival time | |
1059 | + (arrival time at the machine which the netfilter is running on) or | |
1060 | + departure time (for locally generated packets). | |
1061 | + | |
1062 | + Supported options are: | |
1063 | + --timestart HH:MM | |
1064 | + The starting point of the time match frame. | |
1065 | + | |
1066 | + --timestop HH:MM | |
1067 | + The stopping point of the time match frame | |
1068 | + | |
1069 | + --days Tue,Mon... | |
1070 | + Days of the week to match separated by a coma, no space | |
1071 | + (one of Sun,Mon,Tue,Wed,Thu,Fri,Sat) | |
1072 | + | |
1073 | + Example: | |
1074 | + -A INPUT -m time --timestart 8:00 --timestop 18:00 --days Mon,Tue,Wed,Thu,Fri | |
1075 | + will match packets that have an arrival timestamp in the range 8:00->18:00 from Monday | |
1076 | + to Friday. | |
1077 | + | |
1078 | + -A OUTPUT -m time --timestart 8:00 --timestop 18:00 --Days Mon | |
1079 | + will match the packets (locally generated) that have a departure timestamp | |
1080 | + in the range 8:00->18:00 on Monday only. | |
1081 | + | |
1082 | +config IP_NF_MATCH_U32 | |
1083 | + tristate 'U32 match support' | |
1084 | + depends on IP_NF_IPTABLES | |
1085 | + help | |
1086 | + | |
1087 | + U32 allows you to extract quantities of up to 4 bytes from a packet, | |
1088 | + AND them with specified masks, shift them by specified amounts and | |
1089 | + test whether the results are in any of a set of specified ranges. | |
1090 | + The specification of what to extract is general enough to skip over | |
1091 | + headers with lengths stored in the packet, as in IP or TCP header | |
1092 | + lengths. | |
1093 | + Details and examples are in the kernel module source. | |
1094 | + | |
1095 | endmenu | |
1096 | ||
1097 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/Makefile linux-2.6.3-rc3/net/ipv4/netfilter/Makefile | |
1098 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/Makefile 2004-02-16 10:08:59.000000000 +0100 | |
1099 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/Makefile 2004-02-16 11:07:28.178208252 +0100 | |
1100 | @@ -42,15 +42,38 @@ | |
1101 | # matches | |
1102 | obj-$(CONFIG_IP_NF_MATCH_HELPER) += ipt_helper.o | |
1103 | obj-$(CONFIG_IP_NF_MATCH_LIMIT) += ipt_limit.o | |
1104 | +obj-$(CONFIG_IP_NF_MATCH_QUOTA) += ipt_quota.o | |
1105 | +obj-$(CONFIG_IP_NF_MATCH_DSTLIMIT) += ipt_dstlimit.o | |
1106 | obj-$(CONFIG_IP_NF_MATCH_MARK) += ipt_mark.o | |
1107 | +obj-$(CONFIG_IP_NF_POOL) += ipt_pool.o ipt_POOL.o ip_pool.o | |
1108 | obj-$(CONFIG_IP_NF_MATCH_MAC) += ipt_mac.o | |
1109 | obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o | |
1110 | ||
1111 | obj-$(CONFIG_IP_NF_MATCH_PKTTYPE) += ipt_pkttype.o | |
1112 | obj-$(CONFIG_IP_NF_MATCH_MULTIPORT) += ipt_multiport.o | |
1113 | + | |
1114 | +obj-$(CONFIG_IP_NF_MATCH_MPORT) += ipt_mport.o | |
1115 | + | |
1116 | obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o | |
1117 | obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o | |
1118 | ||
1119 | +obj-$(CONFIG_IP_NF_MATCH_TIME) += ipt_time.o | |
1120 | + | |
1121 | + | |
1122 | +obj-$(CONFIG_IP_NF_MATCH_RANDOM) += ipt_random.o | |
1123 | + | |
1124 | +obj-$(CONFIG_IP_NF_MATCH_PSD) += ipt_psd.o | |
1125 | + | |
1126 | +obj-$(CONFIG_IP_NF_MATCH_OSF) += ipt_osf.o | |
1127 | + | |
1128 | + | |
1129 | +obj-$(CONFIG_IP_NF_MATCH_NTH) += ipt_nth.o | |
1130 | + | |
1131 | +obj-$(CONFIG_IP_NF_MATCH_IPV4OPTIONS) += ipt_ipv4options.o | |
1132 | + | |
1133 | + | |
1134 | +obj-$(CONFIG_IP_NF_MATCH_FUZZY) += ipt_fuzzy.o | |
1135 | + | |
1136 | obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o | |
1137 | ||
1138 | obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o | |
1139 | @@ -59,10 +82,15 @@ | |
1140 | ||
1141 | obj-$(CONFIG_IP_NF_MATCH_LENGTH) += ipt_length.o | |
1142 | ||
1143 | +obj-$(CONFIG_IP_NF_MATCH_U32) += ipt_u32.o | |
1144 | + | |
1145 | + | |
1146 | obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o | |
1147 | obj-$(CONFIG_IP_NF_MATCH_STATE) += ipt_state.o | |
1148 | +obj-$(CONFIG_IP_NF_MATCH_CONNLIMIT) += ipt_connlimit.o | |
1149 | obj-$(CONFIG_IP_NF_MATCH_CONNTRACK) += ipt_conntrack.o | |
1150 | obj-$(CONFIG_IP_NF_MATCH_TCPMSS) += ipt_tcpmss.o | |
1151 | +obj-$(CONFIG_IP_NF_MATCH_REALM) += ipt_realm.o | |
1152 | ||
1153 | obj-$(CONFIG_IP_NF_MATCH_PHYSDEV) += ipt_physdev.o | |
1154 | ||
1155 | @@ -80,6 +108,9 @@ | |
1156 | obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o | |
1157 | obj-$(CONFIG_IP_NF_NAT_SNMP_BASIC) += ip_nat_snmp_basic.o | |
1158 | obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o | |
1159 | +obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o | |
1160 | +obj-$(CONFIG_IP_NF_TARGET_NETLINK) += ipt_NETLINK.o | |
1161 | +obj-$(CONFIG_IP_NF_TARGET_IPV4OPTSSTRIP) += ipt_IPV4OPTSSTRIP.o | |
1162 | obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o | |
1163 | obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o | |
1164 | ||
1165 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/ip_pool.c linux-2.6.3-rc3/net/ipv4/netfilter/ip_pool.c | |
1166 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/ip_pool.c 1970-01-01 01:00:00.000000000 +0100 | |
1167 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/ip_pool.c 2004-02-16 11:07:21.518803072 +0100 | |
b22bba23 | 1168 | @@ -0,0 +1,334 @@ |
70b033d6 | 1169 | +/* Kernel module for IP pool management */ |
1170 | + | |
1171 | +#include <linux/module.h> | |
1172 | +#include <linux/ip.h> | |
1173 | +#include <linux/skbuff.h> | |
1174 | +#include <linux/netfilter_ipv4/ip_tables.h> | |
1175 | +#include <linux/netfilter_ipv4/ip_pool.h> | |
1176 | +#include <linux/errno.h> | |
1177 | +#include <asm/uaccess.h> | |
1178 | +#include <asm/bitops.h> | |
1179 | +#include <linux/interrupt.h> | |
1180 | +#include <linux/spinlock.h> | |
1181 | + | |
1182 | +#if 0 | |
1183 | +#define DP printk | |
1184 | +#else | |
1185 | +#define DP(format, args...) | |
1186 | +#endif | |
1187 | + | |
1188 | +MODULE_LICENSE("GPL"); | |
1189 | + | |
1190 | +#define NR_POOL 16 | |
1191 | +static int nr_pool = NR_POOL;/* overwrite this when loading module */ | |
1192 | + | |
1193 | +struct ip_pool { | |
1194 | + u_int32_t first_ip; /* host byte order, included in range */ | |
1195 | + u_int32_t last_ip; /* host byte order, included in range */ | |
1196 | + void *members; /* the bitmap proper */ | |
1197 | + int nr_use; /* total nr. of tests through this */ | |
1198 | + int nr_match; /* total nr. of matches through this */ | |
1199 | + rwlock_t lock; | |
1200 | +}; | |
1201 | + | |
1202 | +static struct ip_pool *POOL; | |
1203 | + | |
1204 | +static inline struct ip_pool *lookup(ip_pool_t index) | |
1205 | +{ | |
1206 | + if (index < 0 || index >= nr_pool) { | |
1207 | + DP("ip_pool:lookup: bad index %d\n", index); | |
1208 | + return 0; | |
1209 | + } | |
1210 | + return POOL+index; | |
1211 | +} | |
1212 | + | |
1213 | +int ip_pool_match(ip_pool_t index, u_int32_t addr) | |
1214 | +{ | |
1215 | + struct ip_pool *pool = lookup(index); | |
1216 | + int res = 0; | |
1217 | + | |
1218 | + if (!pool || !pool->members) | |
1219 | + return 0; | |
1220 | + read_lock_bh(&pool->lock); | |
1221 | + if (pool->members) { | |
1222 | + if (addr >= pool->first_ip && addr <= pool->last_ip) { | |
1223 | + addr -= pool->first_ip; | |
1224 | + if (test_bit(addr, pool->members)) { | |
1225 | + res = 1; | |
1226 | +#ifdef CONFIG_IP_POOL_STATISTICS | |
1227 | + pool->nr_match++; | |
1228 | +#endif | |
1229 | + } | |
1230 | + } | |
1231 | +#ifdef CONFIG_IP_POOL_STATISTICS | |
1232 | + pool->nr_use++; | |
1233 | +#endif | |
1234 | + } | |
1235 | + read_unlock_bh(&pool->lock); | |
1236 | + return res; | |
1237 | +} | |
b22bba23 | 1238 | +EXPORT_SYMBOL(ip_pool_match); |
70b033d6 | 1239 | + |
1240 | +static int pool_change(ip_pool_t index, u_int32_t addr, int isdel) | |
1241 | +{ | |
1242 | + struct ip_pool *pool; | |
1243 | + int res = -1; | |
1244 | + | |
1245 | + pool = lookup(index); | |
1246 | + if ( !pool || !pool->members | |
1247 | + || addr < pool->first_ip || addr > pool->last_ip) | |
1248 | + return -1; | |
1249 | + read_lock_bh(&pool->lock); | |
1250 | + if (pool->members && addr >= pool->first_ip && addr <= pool->last_ip) { | |
1251 | + addr -= pool->first_ip; | |
1252 | + res = isdel | |
1253 | + ? (0 != test_and_clear_bit(addr, pool->members)) | |
1254 | + : (0 != test_and_set_bit(addr, pool->members)); | |
1255 | + } | |
1256 | + read_unlock_bh(&pool->lock); | |
1257 | + return res; | |
1258 | +} | |
1259 | + | |
1260 | +int ip_pool_mod(ip_pool_t index, u_int32_t addr, int isdel) | |
1261 | +{ | |
1262 | + int res = pool_change(index,addr,isdel); | |
1263 | + | |
1264 | + if (!isdel) res = !res; | |
1265 | + return res; | |
1266 | +} | |
b22bba23 | 1267 | +EXPORT_SYMBOL(ip_pool_mod); |
70b033d6 | 1268 | + |
1269 | +static inline int bitmap_bytes(u_int32_t a, u_int32_t b) | |
1270 | +{ | |
1271 | + return 4*((((b-a+8)/8)+3)/4); | |
1272 | +} | |
1273 | + | |
1274 | +static inline int poolbytes(ip_pool_t index) | |
1275 | +{ | |
1276 | + struct ip_pool *pool = lookup(index); | |
1277 | + | |
1278 | + return pool ? bitmap_bytes(pool->first_ip, pool->last_ip) : 0; | |
1279 | +} | |
1280 | + | |
1281 | +static int setpool( | |
1282 | + struct sock *sk, | |
1283 | + int optval, | |
1284 | + void *user, | |
1285 | + unsigned int len | |
1286 | +) { | |
1287 | + struct ip_pool_request req; | |
1288 | + | |
1289 | + DP("ip_pool:setpool: optval=%d, user=%p, len=%d\n", optval, user, len); | |
1290 | + if (!capable(CAP_NET_ADMIN)) | |
1291 | + return -EPERM; | |
1292 | + if (optval != SO_IP_POOL) | |
1293 | + return -EBADF; | |
1294 | + if (len != sizeof(req)) | |
1295 | + return -EINVAL; | |
1296 | + if (copy_from_user(&req, user, sizeof(req)) != 0) | |
1297 | + return -EFAULT; | |
1298 | + printk("obsolete op - upgrade your ippool(8) utility.\n"); | |
1299 | + return -EINVAL; | |
1300 | +} | |
1301 | + | |
1302 | +static int getpool( | |
1303 | + struct sock *sk, | |
1304 | + int optval, | |
1305 | + void *user, | |
1306 | + int *len | |
1307 | +) { | |
1308 | + struct ip_pool_request req; | |
1309 | + struct ip_pool *pool; | |
1310 | + ip_pool_t i; | |
1311 | + int newbytes; | |
1312 | + void *newmembers; | |
1313 | + int res; | |
1314 | + | |
1315 | + DP("ip_pool:getpool: optval=%d, user=%p\n", optval, user); | |
1316 | + if (!capable(CAP_NET_ADMIN)) | |
1317 | + return -EINVAL; | |
1318 | + if (optval != SO_IP_POOL) | |
1319 | + return -EINVAL; | |
1320 | + if (*len != sizeof(req)) { | |
1321 | + return -EFAULT; | |
1322 | + } | |
1323 | + if (copy_from_user(&req, user, sizeof(req)) != 0) | |
1324 | + return -EFAULT; | |
1325 | + DP("ip_pool:getpool op=%d, index=%d\n", req.op, req.index); | |
1326 | + if (req.op < IP_POOL_BAD001) { | |
1327 | + printk("obsolete op - upgrade your ippool(8) utility.\n"); | |
1328 | + return -EFAULT; | |
1329 | + } | |
1330 | + switch(req.op) { | |
1331 | + case IP_POOL_HIGH_NR: | |
1332 | + DP("ip_pool HIGH_NR\n"); | |
1333 | + req.index = IP_POOL_NONE; | |
1334 | + for (i=0; i<nr_pool; i++) | |
1335 | + if (POOL[i].members) | |
1336 | + req.index = i; | |
1337 | + return copy_to_user(user, &req, sizeof(req)); | |
1338 | + case IP_POOL_LOOKUP: | |
1339 | + DP("ip_pool LOOKUP\n"); | |
1340 | + pool = lookup(req.index); | |
1341 | + if (!pool) | |
1342 | + return -EINVAL; | |
1343 | + if (!pool->members) | |
1344 | + return -EBADF; | |
1345 | + req.addr = htonl(pool->first_ip); | |
1346 | + req.addr2 = htonl(pool->last_ip); | |
1347 | + return copy_to_user(user, &req, sizeof(req)); | |
1348 | + case IP_POOL_USAGE: | |
1349 | + DP("ip_pool USE\n"); | |
1350 | + pool = lookup(req.index); | |
1351 | + if (!pool) | |
1352 | + return -EINVAL; | |
1353 | + if (!pool->members) | |
1354 | + return -EBADF; | |
1355 | + req.addr = pool->nr_use; | |
1356 | + req.addr2 = pool->nr_match; | |
1357 | + return copy_to_user(user, &req, sizeof(req)); | |
1358 | + case IP_POOL_TEST_ADDR: | |
1359 | + DP("ip_pool TEST 0x%08x\n", req.addr); | |
1360 | + pool = lookup(req.index); | |
1361 | + if (!pool) | |
1362 | + return -EINVAL; | |
1363 | + res = 0; | |
1364 | + read_lock_bh(&pool->lock); | |
1365 | + if (!pool->members) { | |
1366 | + DP("ip_pool TEST_ADDR no members in pool\n"); | |
1367 | + res = -EBADF; | |
1368 | + goto unlock_and_return_res; | |
1369 | + } | |
1370 | + req.addr = ntohl(req.addr); | |
1371 | + if (req.addr < pool->first_ip) { | |
1372 | + DP("ip_pool TEST_ADDR address < pool bounds\n"); | |
1373 | + res = -ERANGE; | |
1374 | + goto unlock_and_return_res; | |
1375 | + } | |
1376 | + if (req.addr > pool->last_ip) { | |
1377 | + DP("ip_pool TEST_ADDR address > pool bounds\n"); | |
1378 | + res = -ERANGE; | |
1379 | + goto unlock_and_return_res; | |
1380 | + } | |
1381 | + req.addr = (0 != test_bit((req.addr - pool->first_ip), | |
1382 | + pool->members)); | |
1383 | + read_unlock_bh(&pool->lock); | |
1384 | + return copy_to_user(user, &req, sizeof(req)); | |
1385 | + case IP_POOL_FLUSH: | |
1386 | + DP("ip_pool FLUSH not yet implemented.\n"); | |
1387 | + return -EBUSY; | |
1388 | + case IP_POOL_DESTROY: | |
1389 | + DP("ip_pool DESTROY not yet implemented.\n"); | |
1390 | + return -EBUSY; | |
1391 | + case IP_POOL_INIT: | |
1392 | + DP("ip_pool INIT 0x%08x-0x%08x\n", req.addr, req.addr2); | |
1393 | + pool = lookup(req.index); | |
1394 | + if (!pool) | |
1395 | + return -EINVAL; | |
1396 | + req.addr = ntohl(req.addr); | |
1397 | + req.addr2 = ntohl(req.addr2); | |
1398 | + if (req.addr > req.addr2) { | |
1399 | + DP("ip_pool INIT bad ip range\n"); | |
1400 | + return -EINVAL; | |
1401 | + } | |
1402 | + newbytes = bitmap_bytes(req.addr, req.addr2); | |
1403 | + newmembers = kmalloc(newbytes, GFP_KERNEL); | |
1404 | + if (!newmembers) { | |
1405 | + DP("ip_pool INIT out of mem for %d bytes\n", newbytes); | |
1406 | + return -ENOMEM; | |
1407 | + } | |
1408 | + memset(newmembers, 0, newbytes); | |
1409 | + write_lock_bh(&pool->lock); | |
1410 | + if (pool->members) { | |
1411 | + DP("ip_pool INIT pool %d exists\n", req.index); | |
1412 | + kfree(newmembers); | |
1413 | + res = -EBUSY; | |
1414 | + goto unlock_and_return_res; | |
1415 | + } | |
1416 | + pool->first_ip = req.addr; | |
1417 | + pool->last_ip = req.addr2; | |
1418 | + pool->nr_use = 0; | |
1419 | + pool->nr_match = 0; | |
1420 | + pool->members = newmembers; | |
1421 | + write_unlock_bh(&pool->lock); | |
1422 | + return 0; | |
1423 | + case IP_POOL_ADD_ADDR: | |
1424 | + DP("ip_pool ADD_ADDR 0x%08x\n", req.addr); | |
1425 | + req.addr = pool_change(req.index, ntohl(req.addr), 0); | |
1426 | + return copy_to_user(user, &req, sizeof(req)); | |
1427 | + case IP_POOL_DEL_ADDR: | |
1428 | + DP("ip_pool DEL_ADDR 0x%08x\n", req.addr); | |
1429 | + req.addr = pool_change(req.index, ntohl(req.addr), 1); | |
1430 | + return copy_to_user(user, &req, sizeof(req)); | |
1431 | + default: | |
1432 | + DP("ip_pool:getpool bad op %d\n", req.op); | |
1433 | + return -EINVAL; | |
1434 | + } | |
1435 | + return -EINVAL; | |
1436 | + | |
1437 | +unlock_and_return_res: | |
1438 | + if (pool) | |
1439 | + read_unlock_bh(&pool->lock); | |
1440 | + return res; | |
1441 | +} | |
1442 | + | |
1443 | +static struct nf_sockopt_ops so_pool | |
1444 | += { { NULL, NULL }, PF_INET, | |
1445 | + SO_IP_POOL, SO_IP_POOL+1, &setpool, | |
1446 | + SO_IP_POOL, SO_IP_POOL+1, &getpool, | |
1447 | + 0, NULL }; | |
1448 | + | |
1449 | +MODULE_PARM(nr_pool, "i"); | |
1450 | + | |
1451 | +static int __init init(void) | |
1452 | +{ | |
1453 | + ip_pool_t i; | |
1454 | + int res; | |
1455 | + | |
1456 | + if (nr_pool < 1) { | |
1457 | + printk("ip_pool module init: bad nr_pool %d\n", nr_pool); | |
1458 | + return -EINVAL; | |
1459 | + } | |
1460 | + POOL = kmalloc(nr_pool * sizeof(*POOL), GFP_KERNEL); | |
1461 | + if (!POOL) { | |
1462 | + printk("ip_pool module init: out of memory for nr_pool %d\n", | |
1463 | + nr_pool); | |
1464 | + return -ENOMEM; | |
1465 | + } | |
1466 | + for (i=0; i<nr_pool; i++) { | |
1467 | + POOL[i].first_ip = 0; | |
1468 | + POOL[i].last_ip = 0; | |
1469 | + POOL[i].members = 0; | |
1470 | + POOL[i].nr_use = 0; | |
1471 | + POOL[i].nr_match = 0; | |
1472 | + POOL[i].lock = RW_LOCK_UNLOCKED; | |
1473 | + } | |
1474 | + res = nf_register_sockopt(&so_pool); | |
1475 | + DP("ip_pool:init %d pools, result %d\n", nr_pool, res); | |
1476 | + if (res != 0) { | |
1477 | + kfree(POOL); | |
1478 | + POOL = 0; | |
1479 | + } | |
1480 | + return res; | |
1481 | +} | |
1482 | + | |
1483 | +static void __exit fini(void) | |
1484 | +{ | |
1485 | + ip_pool_t i; | |
1486 | + | |
1487 | + DP("ip_pool:fini BYEBYE\n"); | |
1488 | + nf_unregister_sockopt(&so_pool); | |
1489 | + for (i=0; i<nr_pool; i++) { | |
1490 | + if (POOL[i].members) { | |
1491 | + kfree(POOL[i].members); | |
1492 | + POOL[i].members = 0; | |
1493 | + } | |
1494 | + } | |
1495 | + kfree(POOL); | |
1496 | + POOL = 0; | |
1497 | + DP("ip_pool:fini these are the famous last words\n"); | |
1498 | + return; | |
1499 | +} | |
1500 | + | |
1501 | +module_init(init); | |
1502 | +module_exit(fini); | |
1503 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c linux-2.6.3-rc3/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c | |
1504 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c 1970-01-01 01:00:00.000000000 +0100 | |
1505 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/ipt_IPV4OPTSSTRIP.c 2004-02-16 11:06:57.518550655 +0100 | |
1506 | @@ -0,0 +1,84 @@ | |
1507 | +/** | |
1508 | + * Strip all IP options in the IP packet header. | |
1509 | + * | |
1510 | + * (C) 2001 by Fabrice MARIE <fabrice@netfilter.org> | |
1511 | + * This software is distributed under GNU GPL v2, 1991 | |
1512 | + */ | |
1513 | + | |
1514 | +#include <linux/module.h> | |
1515 | +#include <linux/skbuff.h> | |
1516 | +#include <linux/ip.h> | |
1517 | +#include <net/checksum.h> | |
1518 | + | |
1519 | +#include <linux/netfilter_ipv4/ip_tables.h> | |
1520 | + | |
1521 | +MODULE_AUTHOR("Fabrice MARIE <fabrice@netfilter.org>"); | |
1522 | +MODULE_DESCRIPTION("Strip all options in IPv4 packets"); | |
1523 | +MODULE_LICENSE("GPL"); | |
1524 | + | |
1525 | +static unsigned int | |
1526 | +target(struct sk_buff **pskb, | |
1527 | + unsigned int hooknum, | |
1528 | + const struct net_device *in, | |
1529 | + const struct net_device *out, | |
1530 | + const void *targinfo, | |
1531 | + void *userinfo) | |
1532 | +{ | |
1533 | + struct iphdr *iph = (*pskb)->nh.iph; | |
1534 | + struct sk_buff *skb = (*pskb); | |
1535 | + struct ip_options * opt; | |
1536 | + unsigned char * optiph = skb->nh.raw; | |
1537 | + int l = ((struct ip_options *)(&(IPCB(skb)->opt)))->optlen; | |
1538 | + | |
1539 | + | |
1540 | + /* if no options in packet then nothing to clear. */ | |
1541 | + if (iph->ihl * 4 == sizeof(struct iphdr)) | |
1542 | + return IPT_CONTINUE; | |
1543 | + | |
1544 | + /* else clear all options */ | |
1545 | + memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options)); | |
1546 | + memset(optiph+sizeof(struct iphdr), IPOPT_NOOP, l); | |
1547 | + opt = &(IPCB(skb)->opt); | |
1548 | + opt->is_data = 0; | |
1549 | + opt->optlen = l; | |
1550 | + | |
1551 | + skb->nfcache |= NFC_ALTERED; | |
1552 | + | |
1553 | + return IPT_CONTINUE; | |
1554 | +} | |
1555 | + | |
1556 | +static int | |
1557 | +checkentry(const char *tablename, | |
1558 | + const struct ipt_entry *e, | |
1559 | + void *targinfo, | |
1560 | + unsigned int targinfosize, | |
1561 | + unsigned int hook_mask) | |
1562 | +{ | |
1563 | + if (strcmp(tablename, "mangle")) { | |
1564 | + printk(KERN_WARNING "IPV4OPTSSTRIP: can only be called from \"mangle\" table, not \"%s\"\n", tablename); | |
1565 | + return 0; | |
1566 | + } | |
1567 | + /* nothing else to check because no parameters */ | |
1568 | + return 1; | |
1569 | +} | |
1570 | + | |
1571 | +static struct ipt_target ipt_ipv4optsstrip_reg | |
1572 | += { { NULL, NULL }, "IPV4OPTSSTRIP", target, checkentry, NULL, THIS_MODULE }; | |
1573 | + | |
1574 | +static int __init init(void) | |
1575 | +{ | |
1576 | + if (ipt_register_target(&ipt_ipv4optsstrip_reg)) | |
1577 | + return -EINVAL; | |
1578 | + printk("ipt_IPV4OPTSSTRIP loaded\n"); | |
1579 | + | |
1580 | + return 0; | |
1581 | +} | |
1582 | + | |
1583 | +static void __exit fini(void) | |
1584 | +{ | |
1585 | + ipt_unregister_target(&ipt_ipv4optsstrip_reg); | |
1586 | + printk("ipt_IPV4OPTSSTRIP unloaded\n"); | |
1587 | +} | |
1588 | + | |
1589 | +module_init(init); | |
1590 | +module_exit(fini); | |
1591 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_NETLINK.c linux-2.6.3-rc3/net/ipv4/netfilter/ipt_NETLINK.c | |
1592 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_NETLINK.c 1970-01-01 01:00:00.000000000 +0100 | |
1593 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/ipt_NETLINK.c 2004-02-16 11:07:05.880548139 +0100 | |
1594 | @@ -0,0 +1,119 @@ | |
1595 | +#include <linux/module.h> | |
1596 | +#include <linux/version.h> | |
1597 | +#include <linux/config.h> | |
1598 | +#include <linux/socket.h> | |
1599 | +#include <linux/skbuff.h> | |
1600 | +#include <linux/kernel.h> | |
1601 | +#include <linux/netlink.h> | |
1602 | +#include <linux/netdevice.h> | |
1603 | +#include <linux/mm.h> | |
1604 | +#include <linux/socket.h> | |
1605 | +#include <linux/netfilter_ipv4/ip_tables.h> | |
1606 | +#include <linux/netfilter_ipv4/ipt_NETLINK.h> | |
1607 | +#include <net/sock.h> | |
1608 | + | |
1609 | +MODULE_AUTHOR("Gianni Tedesco <gianni@ecsc.co.uk>"); | |
1610 | +MODULE_DESCRIPTION("Provides iptables NETLINK target similar to ipchains -o"); | |
1611 | +MODULE_LICENSE("GPL"); | |
1612 | + | |
1613 | +#if 0 | |
1614 | +#define DEBUGP printk | |
1615 | +#else | |
1616 | +#define DEBUGP(format, args...) | |
1617 | +#endif | |
1618 | + | |
1619 | +static struct sock *ipfwsk; | |
1620 | + | |
1621 | +static unsigned int ipt_netlink_target(struct sk_buff **pskb, | |
1622 | + unsigned int hooknum, | |
1623 | + const struct net_device *in, | |
1624 | + const struct net_device *out, | |
1625 | + const void *targinfo, void *userinfo) | |
1626 | +{ | |
1627 | + struct ipt_nldata *nld = (struct ipt_nldata *)targinfo; | |
1628 | + struct iphdr *ip = (*pskb)->nh.iph; | |
1629 | + struct sk_buff *outskb; | |
1630 | + struct netlink_t nlhdr; | |
1631 | + size_t len=0; | |
1632 | + | |
1633 | + /* Allocate a socket buffer */ | |
1634 | + if ( MASK(nld->flags, USE_SIZE) ) | |
1635 | + len = nld->size+sizeof(nlhdr); | |
1636 | + else | |
1637 | + len = ntohs(ip->tot_len)+sizeof(nlhdr); | |
1638 | + | |
1639 | + outskb=alloc_skb(len, GFP_ATOMIC); | |
1640 | + | |
1641 | + if (outskb) { | |
1642 | + nlhdr.len=len; | |
1643 | + | |
1644 | + if ( MASK(nld->flags, USE_MARK) ) | |
1645 | + nlhdr.mark=(*pskb)->nfmark=nld->mark; | |
1646 | + else | |
1647 | + nlhdr.mark=(*pskb)->nfmark; | |
1648 | + | |
1649 | + if ( in && in->name ) { | |
1650 | + strncpy((char *)&nlhdr.iface, in->name, IFNAMSIZ); | |
1651 | + }else if ( out && out->name ){ | |
1652 | + strncpy((char *)&nlhdr.iface, out->name, IFNAMSIZ); | |
1653 | + } | |
1654 | + | |
1655 | + skb_put(outskb, len); | |
1656 | + memcpy(outskb->data, &nlhdr, sizeof(nlhdr)); | |
1657 | + memcpy((outskb->data)+sizeof(nlhdr), ip, len-sizeof(nlhdr)); | |
1658 | + netlink_broadcast(ipfwsk, outskb, 0, ~0, GFP_ATOMIC); | |
1659 | + }else{ | |
1660 | + if (net_ratelimit()) | |
1661 | + printk(KERN_WARNING "ipt_NETLINK: packet drop due to netlink failure\n"); | |
1662 | + } | |
1663 | + | |
1664 | + if ( MASK(nld->flags, USE_DROP) ) | |
1665 | + return NF_DROP; | |
1666 | + | |
1667 | + return IPT_CONTINUE; | |
1668 | +} | |
1669 | + | |
1670 | +static int ipt_netlink_checkentry(const char *tablename, | |
1671 | + const struct ipt_entry *e, | |
1672 | + void *targinfo, | |
1673 | + unsigned int targinfosize, | |
1674 | + unsigned int hookmask) | |
1675 | +{ | |
1676 | + //struct ipt_nldata *nld = (struct ipt_nldata *)targinfo; | |
1677 | + | |
1678 | + return 1; | |
1679 | +} | |
1680 | + | |
1681 | +static struct ipt_target ipt_netlink_reg = { | |
1682 | + {NULL, NULL}, | |
1683 | + "NETLINK", | |
1684 | + ipt_netlink_target, | |
1685 | + ipt_netlink_checkentry, | |
1686 | + NULL, | |
1687 | + THIS_MODULE | |
1688 | +}; | |
1689 | + | |
1690 | +static int __init init(void) | |
1691 | +{ | |
1692 | + DEBUGP("ipt_NETLINK: init module\n"); | |
1693 | + | |
1694 | + if (ipt_register_target(&ipt_netlink_reg) != 0) { | |
1695 | + return -EINVAL; | |
1696 | + } | |
1697 | + | |
1698 | + if ( !(ipfwsk=netlink_kernel_create(NETLINK_FIREWALL, NULL)) ){ | |
1699 | + return -EINVAL; | |
1700 | + } | |
1701 | + | |
1702 | + return 0; | |
1703 | +} | |
1704 | + | |
1705 | +static void __exit fini(void) | |
1706 | +{ | |
1707 | + DEBUGP("ipt_NETLINK: cleanup_module\n"); | |
1708 | + ipt_unregister_target(&ipt_netlink_reg); | |
1709 | +// if(ipfwsk->socket) sock_release(ipfwsk->socket); | |
1710 | +} | |
1711 | + | |
1712 | +module_init(init); | |
1713 | +module_exit(fini); | |
1714 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_POOL.c linux-2.6.3-rc3/net/ipv4/netfilter/ipt_POOL.c | |
1715 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_POOL.c 1970-01-01 01:00:00.000000000 +0100 | |
1716 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/ipt_POOL.c 2004-02-16 11:07:21.518803072 +0100 | |
1717 | @@ -0,0 +1,116 @@ | |
1718 | +/* ipt_POOL.c - netfilter target to manipulate IP pools | |
1719 | + * | |
1720 | + * This target can be used almost everywhere. It acts on some specified | |
1721 | + * IP pool, adding or deleting some IP address in the pool. The address | |
1722 | + * can be either the source (--addsrc, --delsrc), or destination (--add/deldst) | |
1723 | + * of the packet under inspection. | |
1724 | + * | |
1725 | + * The target normally returns IPT_CONTINUE. | |
1726 | + */ | |
1727 | + | |
1728 | +#include <linux/types.h> | |
1729 | +#include <linux/ip.h> | |
1730 | +#include <linux/timer.h> | |
1731 | +#include <linux/module.h> | |
1732 | +#include <linux/netfilter.h> | |
1733 | +#include <linux/netdevice.h> | |
1734 | +#include <linux/if.h> | |
1735 | +#include <linux/inetdevice.h> | |
1736 | +#include <net/protocol.h> | |
1737 | +#include <net/checksum.h> | |
1738 | +#include <linux/netfilter_ipv4.h> | |
1739 | +#include <linux/netfilter_ipv4/ip_nat_rule.h> | |
1740 | +#include <linux/netfilter_ipv4/ipt_pool.h> | |
1741 | + | |
1742 | +#if 0 | |
1743 | +#define DEBUGP printk | |
1744 | +#else | |
1745 | +#define DEBUGP(format, args...) | |
1746 | +#endif | |
1747 | + | |
1748 | +/*** NOTE NOTE NOTE NOTE *** | |
1749 | +** | |
1750 | +** By sheer luck, I get away with using the "struct ipt_pool_info", as defined | |
1751 | +** in <linux/netfilter_ipv4/ipt_pool.h>, both as the match and target info. | |
1752 | +** Here, in the target implementation, ipt_pool_info.src, if not IP_POOL_NONE, | |
1753 | +** is modified for the source IP address of the packet under inspection. | |
1754 | +** The same way, the ipt_pool_info.dst pool is modified for the destination. | |
1755 | +** | |
1756 | +** The address is added to the pool normally. However, if IPT_POOL_DEL_dir | |
1757 | +** flag is set in ipt_pool_info.flags, the address is deleted from the pool. | |
1758 | +** | |
1759 | +** If a modification was done to the pool, we possibly return ACCEPT or DROP, | |
1760 | +** if the right IPT_POOL_MOD_dir_ACCEPT or _MOD_dir_DROP flags are set. | |
1761 | +** The IPT_POOL_INV_MOD_dir flag inverts the sense of the check (i.e. the | |
1762 | +** ACCEPT and DROP flags are evaluated when the pool was not modified.) | |
1763 | +*/ | |
1764 | + | |
1765 | +static int | |
1766 | +do_check(const char *tablename, | |
1767 | + const struct ipt_entry *e, | |
1768 | + void *targinfo, | |
1769 | + unsigned int targinfosize, | |
1770 | + unsigned int hook_mask) | |
1771 | +{ | |
1772 | + const struct ipt_pool_info *ipi = targinfo; | |
1773 | + | |
1774 | + if (targinfosize != IPT_ALIGN(sizeof(*ipi))) { | |
1775 | + DEBUGP("POOL_check: size %u.\n", targinfosize); | |
1776 | + return 0; | |
1777 | + } | |
1778 | + DEBUGP("ipt_POOL:do_check(%d,%d,%d)\n",ipi->src,ipi->dst,ipi->flags); | |
1779 | + return 1; | |
1780 | +} | |
1781 | + | |
1782 | +static unsigned int | |
1783 | +do_target(struct sk_buff **pskb, | |
1784 | + unsigned int hooknum, | |
1785 | + const struct net_device *in, | |
1786 | + const struct net_device *out, | |
1787 | + const void *targinfo, | |
1788 | + void *userinfo) | |
1789 | +{ | |
1790 | + const struct ipt_pool_info *ipi = targinfo; | |
1791 | + int modified; | |
1792 | + unsigned int verdict = IPT_CONTINUE; | |
1793 | + | |
1794 | + if (ipi->src != IP_POOL_NONE) { | |
1795 | + modified = ip_pool_mod(ipi->src, ntohl((*pskb)->nh.iph->saddr), | |
1796 | + ipi->flags & IPT_POOL_DEL_SRC); | |
1797 | + if (!!modified ^ !!(ipi->flags & IPT_POOL_INV_MOD_SRC)) { | |
1798 | + if (ipi->flags & IPT_POOL_MOD_SRC_ACCEPT) | |
1799 | + verdict = NF_ACCEPT; | |
1800 | + else if (ipi->flags & IPT_POOL_MOD_SRC_DROP) | |
1801 | + verdict = NF_DROP; | |
1802 | + } | |
1803 | + } | |
1804 | + if (verdict == IPT_CONTINUE && ipi->dst != IP_POOL_NONE) { | |
1805 | + modified = ip_pool_mod(ipi->dst, ntohl((*pskb)->nh.iph->daddr), | |
1806 | + ipi->flags & IPT_POOL_DEL_DST); | |
1807 | + if (!!modified ^ !!(ipi->flags & IPT_POOL_INV_MOD_DST)) { | |
1808 | + if (ipi->flags & IPT_POOL_MOD_DST_ACCEPT) | |
1809 | + verdict = NF_ACCEPT; | |
1810 | + else if (ipi->flags & IPT_POOL_MOD_DST_DROP) | |
1811 | + verdict = NF_DROP; | |
1812 | + } | |
1813 | + } | |
1814 | + return verdict; | |
1815 | +} | |
1816 | + | |
1817 | +static struct ipt_target pool_reg | |
1818 | += { { NULL, NULL }, "POOL", do_target, do_check, NULL, THIS_MODULE }; | |
1819 | + | |
1820 | +static int __init init(void) | |
1821 | +{ | |
1822 | + DEBUGP("init ipt_POOL\n"); | |
1823 | + return ipt_register_target(&pool_reg); | |
1824 | +} | |
1825 | + | |
1826 | +static void __exit fini(void) | |
1827 | +{ | |
1828 | + DEBUGP("fini ipt_POOL\n"); | |
1829 | + ipt_unregister_target(&pool_reg); | |
1830 | +} | |
1831 | + | |
1832 | +module_init(init); | |
1833 | +module_exit(fini); | |
1834 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_TTL.c linux-2.6.3-rc3/net/ipv4/netfilter/ipt_TTL.c | |
1835 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_TTL.c 1970-01-01 01:00:00.000000000 +0100 | |
1836 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/ipt_TTL.c 2004-02-16 11:07:09.253740328 +0100 | |
1837 | @@ -0,0 +1,110 @@ | |
1838 | +/* TTL modification target for IP tables | |
1839 | + * (C) 2000 by Harald Welte <laforge@gnumonks.org> | |
1840 | + * | |
1841 | + * Version: 1.8 | |
1842 | + * | |
1843 | + * This software is distributed under the terms of GNU GPL | |
1844 | + */ | |
1845 | + | |
1846 | +#include <linux/module.h> | |
1847 | +#include <linux/skbuff.h> | |
1848 | +#include <linux/ip.h> | |
1849 | +#include <net/checksum.h> | |
1850 | + | |
1851 | +#include <linux/netfilter_ipv4/ip_tables.h> | |
1852 | +#include <linux/netfilter_ipv4/ipt_TTL.h> | |
1853 | + | |
1854 | +MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>"); | |
1855 | +MODULE_DESCRIPTION("IP tables TTL modification module"); | |
1856 | +MODULE_LICENSE("GPL"); | |
1857 | + | |
1858 | +static unsigned int ipt_ttl_target(struct sk_buff **pskb, unsigned int hooknum, | |
1859 | + const struct net_device *in, const struct net_device *out, | |
1860 | + const void *targinfo, void *userinfo) | |
1861 | +{ | |
1862 | + struct iphdr *iph = (*pskb)->nh.iph; | |
1863 | + const struct ipt_TTL_info *info = targinfo; | |
1864 | + u_int16_t diffs[2]; | |
1865 | + int new_ttl; | |
1866 | + | |
1867 | + switch (info->mode) { | |
1868 | + case IPT_TTL_SET: | |
1869 | + new_ttl = info->ttl; | |
1870 | + break; | |
1871 | + case IPT_TTL_INC: | |
1872 | + new_ttl = iph->ttl + info->ttl; | |
1873 | + if (new_ttl > 255) | |
1874 | + new_ttl = 255; | |
1875 | + break; | |
1876 | + case IPT_TTL_DEC: | |
1877 | + new_ttl = iph->ttl + info->ttl; | |
1878 | + if (new_ttl < 0) | |
1879 | + new_ttl = 0; | |
1880 | + break; | |
1881 | + default: | |
1882 | + new_ttl = iph->ttl; | |
1883 | + break; | |
1884 | + } | |
1885 | + | |
1886 | + if (new_ttl != iph->ttl) { | |
1887 | + diffs[0] = htons(((unsigned)iph->ttl) << 8) ^ 0xFFFF; | |
1888 | + iph->ttl = new_ttl; | |
1889 | + diffs[1] = htons(((unsigned)iph->ttl) << 8); | |
1890 | + iph->check = csum_fold(csum_partial((char *)diffs, | |
1891 | + sizeof(diffs), | |
1892 | + iph->check^0xFFFF)); | |
1893 | + (*pskb)->nfcache |= NFC_ALTERED; | |
1894 | + } | |
1895 | + | |
1896 | + return IPT_CONTINUE; | |
1897 | +} | |
1898 | + | |
1899 | +static int ipt_ttl_checkentry(const char *tablename, | |
1900 | + const struct ipt_entry *e, | |
1901 | + void *targinfo, | |
1902 | + unsigned int targinfosize, | |
1903 | + unsigned int hook_mask) | |
1904 | +{ | |
1905 | + struct ipt_TTL_info *info = targinfo; | |
1906 | + | |
1907 | + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_TTL_info))) { | |
1908 | + printk(KERN_WARNING "TTL: targinfosize %u != %Zu\n", | |
1909 | + targinfosize, | |
1910 | + IPT_ALIGN(sizeof(struct ipt_TTL_info))); | |
1911 | + return 0; | |
1912 | + } | |
1913 | + | |
1914 | + if (strcmp(tablename, "mangle")) { | |
1915 | + printk(KERN_WARNING "TTL: can only be called from \"mangle\" table, not \"%s\"\n", tablename); | |
1916 | + return 0; | |
1917 | + } | |
1918 | + | |
1919 | + if (info->mode > IPT_TTL_MAXMODE) { | |
1920 | + printk(KERN_WARNING "TTL: invalid or unknown Mode %u\n", | |
1921 | + info->mode); | |
1922 | + return 0; | |
1923 | + } | |
1924 | + | |
1925 | + if ((info->mode != IPT_TTL_SET) && (info->ttl == 0)) { | |
1926 | + printk(KERN_WARNING "TTL: increment/decrement doesn't make sense with value 0\n"); | |
1927 | + return 0; | |
1928 | + } | |
1929 | + | |
1930 | + return 1; | |
1931 | +} | |
1932 | + | |
1933 | +static struct ipt_target ipt_TTL = { { NULL, NULL }, "TTL", | |
1934 | + ipt_ttl_target, ipt_ttl_checkentry, NULL, THIS_MODULE }; | |
1935 | + | |
1936 | +static int __init init(void) | |
1937 | +{ | |
1938 | + return ipt_register_target(&ipt_TTL); | |
1939 | +} | |
1940 | + | |
1941 | +static void __exit fini(void) | |
1942 | +{ | |
1943 | + ipt_unregister_target(&ipt_TTL); | |
1944 | +} | |
1945 | + | |
1946 | +module_init(init); | |
1947 | +module_exit(fini); | |
1948 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_connlimit.c linux-2.6.3-rc3/net/ipv4/netfilter/ipt_connlimit.c | |
1949 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_connlimit.c 1970-01-01 01:00:00.000000000 +0100 | |
1950 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/ipt_connlimit.c 2004-02-16 11:07:11.549190614 +0100 | |
1951 | @@ -0,0 +1,227 @@ | |
1952 | +/* | |
1953 | + * netfilter module to limit the number of parallel tcp | |
1954 | + * connections per IP address. | |
1955 | + * (c) 2000 Gerd Knorr <kraxel@bytesex.org> | |
1956 | + * Nov 2002: Martin Bene <martin.bene@icomedias.com>: | |
1957 | + * only ignore TIME_WAIT or gone connections | |
1958 | + * | |
1959 | + * based on ... | |
1960 | + * | |
1961 | + * Kernel module to match connection tracking information. | |
1962 | + * GPL (C) 1999 Rusty Russell (rusty@rustcorp.com.au). | |
1963 | + */ | |
1964 | +#include <linux/module.h> | |
1965 | +#include <linux/skbuff.h> | |
1966 | +#include <linux/list.h> | |
1967 | +#include <linux/netfilter_ipv4/ip_conntrack.h> | |
1968 | +#include <linux/netfilter_ipv4/ip_conntrack_core.h> | |
1969 | +#include <linux/netfilter_ipv4/ip_conntrack_tcp.h> | |
1970 | +#include <linux/netfilter_ipv4/ip_tables.h> | |
1971 | +#include <linux/netfilter_ipv4/ipt_connlimit.h> | |
1972 | + | |
1973 | +#define DEBUG 0 | |
1974 | + | |
1975 | +MODULE_LICENSE("GPL"); | |
1976 | + | |
1977 | +/* we'll save the tuples of all connections we care about */ | |
1978 | +struct ipt_connlimit_conn | |
1979 | +{ | |
1980 | + struct list_head list; | |
1981 | + struct ip_conntrack_tuple tuple; | |
1982 | +}; | |
1983 | + | |
1984 | +struct ipt_connlimit_data { | |
1985 | + spinlock_t lock; | |
1986 | + struct list_head iphash[256]; | |
1987 | +}; | |
1988 | + | |
1989 | +static int ipt_iphash(u_int32_t addr) | |
1990 | +{ | |
1991 | + int hash; | |
1992 | + | |
1993 | + hash = addr & 0xff; | |
1994 | + hash ^= (addr >> 8) & 0xff; | |
1995 | + hash ^= (addr >> 16) & 0xff; | |
1996 | + hash ^= (addr >> 24) & 0xff; | |
1997 | + return hash; | |
1998 | +} | |
1999 | + | |
2000 | +static int count_them(struct ipt_connlimit_data *data, | |
2001 | + u_int32_t addr, u_int32_t mask, | |
2002 | + struct ip_conntrack *ct) | |
2003 | +{ | |
2004 | +#if DEBUG | |
2005 | + const static char *tcp[] = { "none", "established", "syn_sent", "syn_recv", | |
2006 | + "fin_wait", "time_wait", "close", "close_wait", | |
2007 | + "last_ack", "listen" }; | |
2008 | +#endif | |
2009 | + int addit = 1, matches = 0; | |
2010 | + struct ip_conntrack_tuple tuple; | |
2011 | + struct ip_conntrack_tuple_hash *found; | |
2012 | + struct ipt_connlimit_conn *conn; | |
2013 | + struct list_head *hash,*lh; | |
2014 | + | |
2015 | + spin_lock(&data->lock); | |
2016 | + tuple = ct->tuplehash[0].tuple; | |
2017 | + hash = &data->iphash[ipt_iphash(addr & mask)]; | |
2018 | + | |
2019 | + /* check the saved connections */ | |
2020 | + for (lh = hash->next; lh != hash; lh = lh->next) { | |
2021 | + conn = list_entry(lh,struct ipt_connlimit_conn,list); | |
2022 | + found = ip_conntrack_find_get(&conn->tuple,ct); | |
2023 | + if (0 == memcmp(&conn->tuple,&tuple,sizeof(tuple)) && | |
2024 | + found != NULL && | |
2025 | + found->ctrack->proto.tcp.state != TCP_CONNTRACK_TIME_WAIT) { | |
2026 | + /* Just to be sure we have it only once in the list. | |
2027 | + We should'nt see tuples twice unless someone hooks this | |
2028 | + into a table without "-p tcp --syn" */ | |
2029 | + addit = 0; | |
2030 | + } | |
2031 | +#if DEBUG | |
2032 | + printk("ipt_connlimit [%d]: src=%u.%u.%u.%u:%d dst=%u.%u.%u.%u:%d %s\n", | |
2033 | + ipt_iphash(addr & mask), | |
2034 | + NIPQUAD(conn->tuple.src.ip), ntohs(conn->tuple.src.u.tcp.port), | |
2035 | + NIPQUAD(conn->tuple.dst.ip), ntohs(conn->tuple.dst.u.tcp.port), | |
2036 | + (NULL != found) ? tcp[found->ctrack->proto.tcp.state] : "gone"); | |
2037 | +#endif | |
2038 | + if (NULL == found) { | |
2039 | + /* this one is gone */ | |
2040 | + lh = lh->prev; | |
2041 | + list_del(lh->next); | |
2042 | + kfree(conn); | |
2043 | + continue; | |
2044 | + } | |
2045 | + if (found->ctrack->proto.tcp.state == TCP_CONNTRACK_TIME_WAIT) { | |
2046 | + /* we don't care about connections which are | |
2047 | + closed already -> ditch it */ | |
2048 | + lh = lh->prev; | |
2049 | + list_del(lh->next); | |
2050 | + kfree(conn); | |
2051 | + nf_conntrack_put(&found->ctrack->infos[0]); | |
2052 | + continue; | |
2053 | + } | |
2054 | + if ((addr & mask) == (conn->tuple.src.ip & mask)) { | |
2055 | + /* same source IP address -> be counted! */ | |
2056 | + matches++; | |
2057 | + } | |
2058 | + nf_conntrack_put(&found->ctrack->infos[0]); | |
2059 | + } | |
2060 | + if (addit) { | |
2061 | + /* save the new connection in our list */ | |
2062 | +#if DEBUG | |
2063 | + printk("ipt_connlimit [%d]: src=%u.%u.%u.%u:%d dst=%u.%u.%u.%u:%d new\n", | |
2064 | + ipt_iphash(addr & mask), | |
2065 | + NIPQUAD(tuple.src.ip), ntohs(tuple.src.u.tcp.port), | |
2066 | + NIPQUAD(tuple.dst.ip), ntohs(tuple.dst.u.tcp.port)); | |
2067 | +#endif | |
2068 | + conn = kmalloc(sizeof(*conn),GFP_ATOMIC); | |
2069 | + if (NULL == conn) | |
2070 | + return -1; | |
2071 | + memset(conn,0,sizeof(*conn)); | |
2072 | + INIT_LIST_HEAD(&conn->list); | |
2073 | + conn->tuple = tuple; | |
2074 | + list_add(&conn->list,hash); | |
2075 | + matches++; | |
2076 | + } | |
2077 | + spin_unlock(&data->lock); | |
2078 | + return matches; | |
2079 | +} | |
2080 | + | |
2081 | +static int | |
2082 | +match(const struct sk_buff *skb, | |
2083 | + const struct net_device *in, | |
2084 | + const struct net_device *out, | |
2085 | + const void *matchinfo, | |
2086 | + int offset, | |
2087 | + const void *hdr, | |
2088 | + u_int16_t datalen, | |
2089 | + int *hotdrop) | |
2090 | +{ | |
2091 | + const struct ipt_connlimit_info *info = matchinfo; | |
2092 | + int connections, match; | |
2093 | + struct ip_conntrack *ct; | |
2094 | + enum ip_conntrack_info ctinfo; | |
2095 | + | |
2096 | + ct = ip_conntrack_get((struct sk_buff *)skb, &ctinfo); | |
2097 | + if (NULL == ct) { | |
2098 | + printk("ipt_connlimit: Oops: invalid ct state ?\n"); | |
2099 | + *hotdrop = 1; | |
2100 | + return 0; | |
2101 | + } | |
2102 | + connections = count_them(info->data,skb->nh.iph->saddr,info->mask,ct); | |
2103 | + if (-1 == connections) { | |
2104 | + printk("ipt_connlimit: Hmm, kmalloc failed :-(\n"); | |
2105 | + *hotdrop = 1; /* let's free some memory :-) */ | |
2106 | + return 0; | |
2107 | + } | |
2108 | + match = (info->inverse) ? (connections <= info->limit) : (connections > info->limit); | |
2109 | +#if DEBUG | |
2110 | + printk("ipt_connlimit: src=%u.%u.%u.%u mask=%u.%u.%u.%u " | |
2111 | + "connections=%d limit=%d match=%s\n", | |
2112 | + NIPQUAD(skb->nh.iph->saddr), NIPQUAD(info->mask), | |
2113 | + connections, info->limit, match ? "yes" : "no"); | |
2114 | +#endif | |
2115 | + | |
2116 | + return match; | |
2117 | +} | |
2118 | + | |
2119 | +static int check(const char *tablename, | |
2120 | + const struct ipt_ip *ip, | |
2121 | + void *matchinfo, | |
2122 | + unsigned int matchsize, | |
2123 | + unsigned int hook_mask) | |
2124 | +{ | |
2125 | + struct ipt_connlimit_info *info = matchinfo; | |
2126 | + int i; | |
2127 | + | |
2128 | + /* verify size */ | |
2129 | + if (matchsize != IPT_ALIGN(sizeof(struct ipt_connlimit_info))) | |
2130 | + return 0; | |
2131 | + | |
2132 | + /* refuse anything but tcp */ | |
2133 | + if (ip->proto != IPPROTO_TCP) | |
2134 | + return 0; | |
2135 | + | |
2136 | + /* init private data */ | |
2137 | + info->data = kmalloc(sizeof(struct ipt_connlimit_data),GFP_KERNEL); | |
2138 | + spin_lock_init(&(info->data->lock)); | |
2139 | + for (i = 0; i < 256; i++) | |
2140 | + INIT_LIST_HEAD(&(info->data->iphash[i])); | |
2141 | + | |
2142 | + return 1; | |
2143 | +} | |
2144 | + | |
2145 | +static void destroy(void *matchinfo, unsigned int matchinfosize) | |
2146 | +{ | |
2147 | + struct ipt_connlimit_info *info = matchinfo; | |
2148 | + struct ipt_connlimit_conn *conn; | |
2149 | + struct list_head *hash; | |
2150 | + int i; | |
2151 | + | |
2152 | + /* cleanup */ | |
2153 | + for (i = 0; i < 256; i++) { | |
2154 | + hash = &(info->data->iphash[i]); | |
2155 | + while (hash != hash->next) { | |
2156 | + conn = list_entry(hash->next,struct ipt_connlimit_conn,list); | |
2157 | + list_del(hash->next); | |
2158 | + kfree(conn); | |
2159 | + } | |
2160 | + } | |
2161 | + kfree(info->data); | |
2162 | +} | |
2163 | + | |
2164 | +static struct ipt_match connlimit_match | |
2165 | += { { NULL, NULL }, "connlimit", &match, &check, &destroy, THIS_MODULE }; | |
2166 | + | |
2167 | +static int __init init(void) | |
2168 | +{ | |
2169 | + return ipt_register_match(&connlimit_match); | |
2170 | +} | |
2171 | + | |
2172 | +static void __exit fini(void) | |
2173 | +{ | |
2174 | + ipt_unregister_match(&connlimit_match); | |
2175 | +} | |
2176 | + | |
2177 | +module_init(init); | |
2178 | +module_exit(fini); | |
2179 | diff -Nur linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_dstlimit.c linux-2.6.3-rc3/net/ipv4/netfilter/ipt_dstlimit.c | |
2180 | --- linux-2.6.3-rc3.org/net/ipv4/netfilter/ipt_dstlimit.c 1970-01-01 01:00:00.000000000 +0100 | |
2181 | +++ linux-2.6.3-rc3/net/ipv4/netfilter/ipt_dstlimit.c 2004-02-16 11:07:13.230787904 +0100 | |
2182 | @@ -0,0 +1,623 @@ | |
2183 | +/* iptables match extension to limit the number of packets per second | |
2184 | + * seperately for each destination. | |
2185 | + * | |
2186 | + * (C) 2003 by Harald Welte <laforge@netfilter.org> | |
2187 | + * | |
2188 | + * Development of this code was funded by Astaro AG, http://www.astaro.com/ | |
2189 | + * | |
2190 | + * based on ipt_limit.c by: | |
2191 |