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