Merge tag 'stable/for-linus-3.6-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / include / linux / netfilter / xt_hashlimit.h
1 #ifndef _XT_HASHLIMIT_H
2 #define _XT_HASHLIMIT_H
3
4 #include <linux/types.h>
5
6 /* timings are in milliseconds. */
7 #define XT_HASHLIMIT_SCALE 10000
8 /* 1/10,000 sec period => max of 10,000/sec.  Min rate is then 429490
9  * seconds, or one packet every 59 hours.
10  */
11
12 /* packet length accounting is done in 16-byte steps */
13 #define XT_HASHLIMIT_BYTE_SHIFT 4
14
15 /* details of this structure hidden by the implementation */
16 struct xt_hashlimit_htable;
17
18 enum {
19         XT_HASHLIMIT_HASH_DIP = 1 << 0,
20         XT_HASHLIMIT_HASH_DPT = 1 << 1,
21         XT_HASHLIMIT_HASH_SIP = 1 << 2,
22         XT_HASHLIMIT_HASH_SPT = 1 << 3,
23         XT_HASHLIMIT_INVERT   = 1 << 4,
24         XT_HASHLIMIT_BYTES    = 1 << 5,
25 };
26 #ifdef __KERNEL__
27 #define XT_HASHLIMIT_ALL (XT_HASHLIMIT_HASH_DIP | XT_HASHLIMIT_HASH_DPT | \
28                           XT_HASHLIMIT_HASH_SIP | XT_HASHLIMIT_HASH_SPT | \
29                           XT_HASHLIMIT_INVERT | XT_HASHLIMIT_BYTES)
30 #endif
31
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. */
36
37         /* user specified */
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? */
42 };
43
44 struct xt_hashlimit_info {
45         char name [IFNAMSIZ];           /* name */
46         struct hashlimit_cfg cfg;
47
48         /* Used internally by the kernel */
49         struct xt_hashlimit_htable *hinfo;
50         union {
51                 void *ptr;
52                 struct xt_hashlimit_info *master;
53         } u;
54 };
55
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. */
60
61         /* user specified */
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? */
66
67         __u8 srcmask, dstmask;
68 };
69
70 struct xt_hashlimit_mtinfo1 {
71         char name[IFNAMSIZ];
72         struct hashlimit_cfg1 cfg;
73
74         /* Used internally by the kernel */
75         struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
76 };
77
78 #endif /*_XT_HASHLIMIT_H*/