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 #define XT_HASHLIMIT_SCALE_v2 1000000llu 9 /* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490 10 * seconds, or one packet every 59 hours. 11 */ 12 13 /* packet length accounting is done in 16-byte steps */ 14 #define XT_HASHLIMIT_BYTE_SHIFT 4 15 16 /* details of this structure hidden by the implementation */ 17 struct xt_hashlimit_htable; 18 19 enum { 20 XT_HASHLIMIT_HASH_DIP = 1 << 0, 21 XT_HASHLIMIT_HASH_DPT = 1 << 1, 22 XT_HASHLIMIT_HASH_SIP = 1 << 2, 23 XT_HASHLIMIT_HASH_SPT = 1 << 3, 24 XT_HASHLIMIT_INVERT = 1 << 4, 25 XT_HASHLIMIT_BYTES = 1 << 5, 26 XT_HASHLIMIT_RATE_MATCH = 1 << 6, 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 hashlimit_cfg3 { 82 __u64 avg; /* Average secs between packets * scale */ 83 __u64 burst; /* Period multiplier for upper limit. */ 84 __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */ 85 86 /* user specified */ 87 __u32 size; /* how many buckets */ 88 __u32 max; /* max number of entries */ 89 __u32 gc_interval; /* gc interval */ 90 __u32 expire; /* when do entries expire? */ 91 92 __u32 interval; /* in seconds*/ 93 __u8 srcmask, dstmask; 94 }; 95 96 struct xt_hashlimit_mtinfo1 { 97 char name[IFNAMSIZ]; 98 struct hashlimit_cfg1 cfg; 99 100 /* Used internally by the kernel */ 101 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); 102 }; 103 104 struct xt_hashlimit_mtinfo2 { 105 char name[NAME_MAX]; 106 struct hashlimit_cfg2 cfg; 107 108 /* Used internally by the kernel */ 109 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); 110 }; 111 112 struct xt_hashlimit_mtinfo3 { 113 char name[NAME_MAX]; 114 struct hashlimit_cfg3 cfg; 115 116 /* Used internally by the kernel */ 117 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); 118 }; 119 120 #endif /*_XT_HASHLIMIT_H*/ 121