Yasuyuki KOZAKAI | d62a9db | 2007-08-04 08:08:20 +0000 | [diff] [blame] | 1 | #ifndef _XT_HASHLIMIT_H |
| 2 | #define _XT_HASHLIMIT_H |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 3 | |
Jan Engelhardt | 350661a | 2010-01-31 22:42:52 +0100 | [diff] [blame^] | 4 | #include <linux/types.h> |
| 5 | |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 6 | /* timings are in milliseconds. */ |
Yasuyuki KOZAKAI | d62a9db | 2007-08-04 08:08:20 +0000 | [diff] [blame] | 7 | #define XT_HASHLIMIT_SCALE 10000 |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 8 | /* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 |
| 9 | seconds, or one every 59 hours. */ |
| 10 | |
| 11 | /* details of this structure hidden by the implementation */ |
Yasuyuki KOZAKAI | d62a9db | 2007-08-04 08:08:20 +0000 | [diff] [blame] | 12 | struct xt_hashlimit_htable; |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 13 | |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 14 | enum { |
| 15 | XT_HASHLIMIT_HASH_DIP = 1 << 0, |
| 16 | XT_HASHLIMIT_HASH_DPT = 1 << 1, |
| 17 | XT_HASHLIMIT_HASH_SIP = 1 << 2, |
| 18 | XT_HASHLIMIT_HASH_SPT = 1 << 3, |
| 19 | XT_HASHLIMIT_INVERT = 1 << 4, |
| 20 | }; |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 21 | |
| 22 | struct hashlimit_cfg { |
Jan Engelhardt | 350661a | 2010-01-31 22:42:52 +0100 | [diff] [blame^] | 23 | __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */ |
| 24 | __u32 avg; /* Average secs between packets * scale */ |
| 25 | __u32 burst; /* Period multiplier for upper limit. */ |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 26 | |
| 27 | /* user specified */ |
Jan Engelhardt | 350661a | 2010-01-31 22:42:52 +0100 | [diff] [blame^] | 28 | __u32 size; /* how many buckets */ |
| 29 | __u32 max; /* max number of entries */ |
| 30 | __u32 gc_interval; /* gc interval */ |
| 31 | __u32 expire; /* when do entries expire? */ |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 32 | }; |
| 33 | |
Yasuyuki KOZAKAI | d62a9db | 2007-08-04 08:08:20 +0000 | [diff] [blame] | 34 | struct xt_hashlimit_info { |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 35 | char name [IFNAMSIZ]; /* name */ |
| 36 | struct hashlimit_cfg cfg; |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 37 | |
| 38 | /* Used internally by the kernel */ |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 39 | struct xt_hashlimit_htable *hinfo; |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 40 | union { |
| 41 | void *ptr; |
Yasuyuki KOZAKAI | d62a9db | 2007-08-04 08:08:20 +0000 | [diff] [blame] | 42 | struct xt_hashlimit_info *master; |
Harald Welte | a5374b2 | 2004-10-20 14:06:58 +0000 | [diff] [blame] | 43 | } u; |
| 44 | }; |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 45 | |
| 46 | struct hashlimit_cfg1 { |
Jan Engelhardt | 350661a | 2010-01-31 22:42:52 +0100 | [diff] [blame^] | 47 | __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */ |
| 48 | __u32 avg; /* Average secs between packets * scale */ |
| 49 | __u32 burst; /* Period multiplier for upper limit. */ |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 50 | |
| 51 | /* user specified */ |
Jan Engelhardt | 350661a | 2010-01-31 22:42:52 +0100 | [diff] [blame^] | 52 | __u32 size; /* how many buckets */ |
| 53 | __u32 max; /* max number of entries */ |
| 54 | __u32 gc_interval; /* gc interval */ |
| 55 | __u32 expire; /* when do entries expire? */ |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 56 | |
Jan Engelhardt | 350661a | 2010-01-31 22:42:52 +0100 | [diff] [blame^] | 57 | __u8 srcmask, dstmask; |
Jan Engelhardt | 9a8c77f | 2008-02-11 00:55:33 +0100 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | struct xt_hashlimit_mtinfo1 { |
| 61 | char name[IFNAMSIZ]; |
| 62 | struct hashlimit_cfg1 cfg; |
| 63 | |
| 64 | /* Used internally by the kernel */ |
| 65 | struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); |
| 66 | }; |
| 67 | |
Yasuyuki KOZAKAI | d62a9db | 2007-08-04 08:08:20 +0000 | [diff] [blame] | 68 | #endif /*_XT_HASHLIMIT_H*/ |