Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetoot...
[cascardo/linux.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/if.h>
6
7 /* timings are in milliseconds. */
8 #define XT_HASHLIMIT_SCALE 10000
9 #define XT_HASHLIMIT_SCALE_v2 1000000llu
10 /* 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 */
18 struct xt_hashlimit_htable;
19
20 enum {
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
29 struct 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
41 struct 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
53 struct 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
67 struct 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
81 struct 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
89 struct 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
97 #endif /* _UAPI_XT_HASHLIMIT_H */