blob: 3efc0ca18345e397e6c9704f2777d61b192ed455 [file] [log] [blame]
David Howells94d0ec52012-10-09 09:48:54 +01001#ifndef _UAPI_XT_HASHLIMIT_H
2#define _UAPI_XT_HASHLIMIT_H
3
4#include <linux/types.h>
Mikko Rapeli1ffad832015-10-15 07:56:30 +02005#include <linux/if.h>
David Howells94d0ec52012-10-09 09:48:54 +01006
7/* timings are in milliseconds. */
8#define XT_HASHLIMIT_SCALE 10000
Vishwanath Pai11d5f152016-09-22 12:43:44 -04009#define XT_HASHLIMIT_SCALE_v2 1000000llu
David Howells94d0ec52012-10-09 09:48:54 +010010/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
11 * seconds, or one packet every 59 hours.
12 */
13
14/* packet length accounting is done in 16-byte steps */
15#define XT_HASHLIMIT_BYTE_SHIFT 4
16
17/* details of this structure hidden by the implementation */
18struct xt_hashlimit_htable;
19
20enum {
21 XT_HASHLIMIT_HASH_DIP = 1 << 0,
22 XT_HASHLIMIT_HASH_DPT = 1 << 1,
23 XT_HASHLIMIT_HASH_SIP = 1 << 2,
24 XT_HASHLIMIT_HASH_SPT = 1 << 3,
25 XT_HASHLIMIT_INVERT = 1 << 4,
26 XT_HASHLIMIT_BYTES = 1 << 5,
27};
28
29struct hashlimit_cfg {
30 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
31 __u32 avg; /* Average secs between packets * scale */
32 __u32 burst; /* Period multiplier for upper limit. */
33
34 /* user specified */
35 __u32 size; /* how many buckets */
36 __u32 max; /* max number of entries */
37 __u32 gc_interval; /* gc interval */
38 __u32 expire; /* when do entries expire? */
39};
40
41struct xt_hashlimit_info {
42 char name [IFNAMSIZ]; /* name */
43 struct hashlimit_cfg cfg;
44
45 /* Used internally by the kernel */
46 struct xt_hashlimit_htable *hinfo;
47 union {
48 void *ptr;
49 struct xt_hashlimit_info *master;
50 } u;
51};
52
53struct hashlimit_cfg1 {
54 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
55 __u32 avg; /* Average secs between packets * scale */
56 __u32 burst; /* Period multiplier for upper limit. */
57
58 /* user specified */
59 __u32 size; /* how many buckets */
60 __u32 max; /* max number of entries */
61 __u32 gc_interval; /* gc interval */
62 __u32 expire; /* when do entries expire? */
63
64 __u8 srcmask, dstmask;
65};
66
Vishwanath Pai11d5f152016-09-22 12:43:44 -040067struct hashlimit_cfg2 {
68 __u64 avg; /* Average secs between packets * scale */
69 __u64 burst; /* Period multiplier for upper limit. */
70 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
71
72 /* user specified */
73 __u32 size; /* how many buckets */
74 __u32 max; /* max number of entries */
75 __u32 gc_interval; /* gc interval */
76 __u32 expire; /* when do entries expire? */
77
78 __u8 srcmask, dstmask;
79};
80
David Howells94d0ec52012-10-09 09:48:54 +010081struct xt_hashlimit_mtinfo1 {
82 char name[IFNAMSIZ];
83 struct hashlimit_cfg1 cfg;
84
85 /* Used internally by the kernel */
86 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
87};
88
Vishwanath Pai11d5f152016-09-22 12:43:44 -040089struct xt_hashlimit_mtinfo2 {
90 char name[NAME_MAX];
91 struct hashlimit_cfg2 cfg;
92
93 /* Used internally by the kernel */
94 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
95};
96
David Howells94d0ec52012-10-09 09:48:54 +010097#endif /* _UAPI_XT_HASHLIMIT_H */