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/* packet length accounting is done in 16-byte steps */
12#define XT_HASHLIMIT_BYTE_SHIFT 4
13
14/* details of this structure hidden by the implementation */
15struct xt_hashlimit_htable;
16
17enum {
18	XT_HASHLIMIT_HASH_DIP = 1 << 0,
19	XT_HASHLIMIT_HASH_DPT = 1 << 1,
20	XT_HASHLIMIT_HASH_SIP = 1 << 2,
21	XT_HASHLIMIT_HASH_SPT = 1 << 3,
22	XT_HASHLIMIT_INVERT   = 1 << 4,
23	XT_HASHLIMIT_BYTES    = 1 << 5,
24};
25
26struct hashlimit_cfg {
27	__u32 mode;	  /* bitmask of XT_HASHLIMIT_HASH_* */
28	__u32 avg;    /* Average secs between packets * scale */
29	__u32 burst;  /* Period multiplier for upper limit. */
30
31	/* user specified */
32	__u32 size;		/* how many buckets */
33	__u32 max;		/* max number of entries */
34	__u32 gc_interval;	/* gc interval */
35	__u32 expire;	/* when do entries expire? */
36};
37
38struct xt_hashlimit_info {
39	char name [IFNAMSIZ];		/* name */
40	struct hashlimit_cfg cfg;
41
42	/* Used internally by the kernel */
43	struct xt_hashlimit_htable *hinfo;
44	union {
45		void *ptr;
46		struct xt_hashlimit_info *master;
47	} u;
48};
49
50struct hashlimit_cfg1 {
51	__u32 mode;	  /* bitmask of XT_HASHLIMIT_HASH_* */
52	__u32 avg;    /* Average secs between packets * scale */
53	__u32 burst;  /* Period multiplier for upper limit. */
54
55	/* user specified */
56	__u32 size;		/* how many buckets */
57	__u32 max;		/* max number of entries */
58	__u32 gc_interval;	/* gc interval */
59	__u32 expire;	/* when do entries expire? */
60
61	__u8 srcmask, dstmask;
62};
63
64struct xt_hashlimit_mtinfo1 {
65	char name[IFNAMSIZ];
66	struct hashlimit_cfg1 cfg;
67
68	/* Used internally by the kernel */
69	struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
70};
71
72#endif /*_XT_HASHLIMIT_H*/
73