blob: b1925b5925e959af7482f124e360ce79dfcf51bd [file] [log] [blame]
Yasuyuki KOZAKAId62a9db2007-08-04 08:08:20 +00001#ifndef _XT_HASHLIMIT_H
2#define _XT_HASHLIMIT_H
Harald Weltea5374b22004-10-20 14:06:58 +00003
Jan Engelhardt350661a2010-01-31 22:42:52 +01004#include <linux/types.h>
5
Harald Weltea5374b22004-10-20 14:06:58 +00006/* timings are in milliseconds. */
Yasuyuki KOZAKAId62a9db2007-08-04 08:08:20 +00007#define XT_HASHLIMIT_SCALE 10000
Harald Weltea5374b22004-10-20 14:06:58 +00008/* 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 KOZAKAId62a9db2007-08-04 08:08:20 +000012struct xt_hashlimit_htable;
Harald Weltea5374b22004-10-20 14:06:58 +000013
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010014enum {
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 Weltea5374b22004-10-20 14:06:58 +000021
22struct hashlimit_cfg {
Jan Engelhardt350661a2010-01-31 22:42:52 +010023 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
24 __u32 avg; /* Average secs between packets * scale */
25 __u32 burst; /* Period multiplier for upper limit. */
Harald Weltea5374b22004-10-20 14:06:58 +000026
27 /* user specified */
Jan Engelhardt350661a2010-01-31 22:42:52 +010028 __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 Weltea5374b22004-10-20 14:06:58 +000032};
33
Yasuyuki KOZAKAId62a9db2007-08-04 08:08:20 +000034struct xt_hashlimit_info {
Harald Weltea5374b22004-10-20 14:06:58 +000035 char name [IFNAMSIZ]; /* name */
36 struct hashlimit_cfg cfg;
Harald Weltea5374b22004-10-20 14:06:58 +000037
38 /* Used internally by the kernel */
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010039 struct xt_hashlimit_htable *hinfo;
Harald Weltea5374b22004-10-20 14:06:58 +000040 union {
41 void *ptr;
Yasuyuki KOZAKAId62a9db2007-08-04 08:08:20 +000042 struct xt_hashlimit_info *master;
Harald Weltea5374b22004-10-20 14:06:58 +000043 } u;
44};
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010045
46struct hashlimit_cfg1 {
Jan Engelhardt350661a2010-01-31 22:42:52 +010047 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
48 __u32 avg; /* Average secs between packets * scale */
49 __u32 burst; /* Period multiplier for upper limit. */
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010050
51 /* user specified */
Jan Engelhardt350661a2010-01-31 22:42:52 +010052 __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 Engelhardt9a8c77f2008-02-11 00:55:33 +010056
Jan Engelhardt350661a2010-01-31 22:42:52 +010057 __u8 srcmask, dstmask;
Jan Engelhardt9a8c77f2008-02-11 00:55:33 +010058};
59
60struct 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 KOZAKAId62a9db2007-08-04 08:08:20 +000068#endif /*_XT_HASHLIMIT_H*/