1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_XT_HASHLIMIT_H
3 #define _UAPI_XT_HASHLIMIT_H
5 #include <linux/types.h>
6 #include <linux/limits.h>
9 /* timings are in milliseconds. */
10 #define XT_HASHLIMIT_SCALE 10000
11 #define XT_HASHLIMIT_SCALE_v2 1000000llu
12 /* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
13 * seconds, or one packet every 59 hours.
16 /* packet length accounting is done in 16-byte steps */
17 #define XT_HASHLIMIT_BYTE_SHIFT 4
19 /* details of this structure hidden by the implementation */
20 struct xt_hashlimit_htable;
23 XT_HASHLIMIT_HASH_DIP = 1 << 0,
24 XT_HASHLIMIT_HASH_DPT = 1 << 1,
25 XT_HASHLIMIT_HASH_SIP = 1 << 2,
26 XT_HASHLIMIT_HASH_SPT = 1 << 3,
27 XT_HASHLIMIT_INVERT = 1 << 4,
28 XT_HASHLIMIT_BYTES = 1 << 5,
29 XT_HASHLIMIT_RATE_MATCH = 1 << 6,
32 struct hashlimit_cfg {
33 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
34 __u32 avg; /* Average secs between packets * scale */
35 __u32 burst; /* Period multiplier for upper limit. */
38 __u32 size; /* how many buckets */
39 __u32 max; /* max number of entries */
40 __u32 gc_interval; /* gc interval */
41 __u32 expire; /* when do entries expire? */
44 struct xt_hashlimit_info {
45 char name [IFNAMSIZ]; /* name */
46 struct hashlimit_cfg cfg;
48 /* Used internally by the kernel */
49 struct xt_hashlimit_htable *hinfo;
52 struct xt_hashlimit_info *master;
56 struct hashlimit_cfg1 {
57 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
58 __u32 avg; /* Average secs between packets * scale */
59 __u32 burst; /* Period multiplier for upper limit. */
62 __u32 size; /* how many buckets */
63 __u32 max; /* max number of entries */
64 __u32 gc_interval; /* gc interval */
65 __u32 expire; /* when do entries expire? */
67 __u8 srcmask, dstmask;
70 struct hashlimit_cfg2 {
71 __u64 avg; /* Average secs between packets * scale */
72 __u64 burst; /* Period multiplier for upper limit. */
73 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
76 __u32 size; /* how many buckets */
77 __u32 max; /* max number of entries */
78 __u32 gc_interval; /* gc interval */
79 __u32 expire; /* when do entries expire? */
81 __u8 srcmask, dstmask;
84 struct hashlimit_cfg3 {
85 __u64 avg; /* Average secs between packets * scale */
86 __u64 burst; /* Period multiplier for upper limit. */
87 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
90 __u32 size; /* how many buckets */
91 __u32 max; /* max number of entries */
92 __u32 gc_interval; /* gc interval */
93 __u32 expire; /* when do entries expire? */
96 __u8 srcmask, dstmask;
99 struct xt_hashlimit_mtinfo1 {
101 struct hashlimit_cfg1 cfg;
103 /* Used internally by the kernel */
104 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
107 struct xt_hashlimit_mtinfo2 {
109 struct hashlimit_cfg2 cfg;
111 /* Used internally by the kernel */
112 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
115 struct xt_hashlimit_mtinfo3 {
117 struct hashlimit_cfg3 cfg;
119 /* Used internally by the kernel */
120 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
123 #endif /* _UAPI_XT_HASHLIMIT_H */