linux/include/uapi/linux/netfilter/xt_hashlimit.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
   2#ifndef _UAPI_XT_HASHLIMIT_H
   3#define _UAPI_XT_HASHLIMIT_H
   4
   5#include <linux/types.h>
   6#include <linux/limits.h>
   7#include <linux/if.h>
   8
   9/* timings are in milliseconds. */
  10#define XT_HASHLIMIT_SCALE 10000
  11#define XT_HASHLIMIT_SCALE_v2 1000000llu
  12/* 1/10,000 sec period => max of 10,000/sec.  Min rate is then 429490
  13 * seconds, or one packet every 59 hours.
  14 */
  15
  16/* packet length accounting is done in 16-byte steps */
  17#define XT_HASHLIMIT_BYTE_SHIFT 4
  18
  19/* details of this structure hidden by the implementation */
  20struct xt_hashlimit_htable;
  21
  22enum {
  23        XT_HASHLIMIT_HASH_DIP           = 1 << 0,
  24        XT_HASHLIMIT_HASH_DPT           = 1 << 1,
  25        XT_HASHLIMIT_HASH_SIP           = 1 << 2,
  26        XT_HASHLIMIT_HASH_SPT           = 1 << 3,
  27        XT_HASHLIMIT_INVERT             = 1 << 4,
  28        XT_HASHLIMIT_BYTES              = 1 << 5,
  29        XT_HASHLIMIT_RATE_MATCH         = 1 << 6,
  30};
  31
  32struct 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
  44struct 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
  56struct 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
  70struct hashlimit_cfg2 {
  71        __u64 avg;              /* Average secs between packets * scale */
  72        __u64 burst;            /* Period multiplier for upper limit. */
  73        __u32 mode;             /* bitmask of XT_HASHLIMIT_HASH_* */
  74
  75        /* user specified */
  76        __u32 size;             /* how many buckets */
  77        __u32 max;              /* max number of entries */
  78        __u32 gc_interval;      /* gc interval */
  79        __u32 expire;           /* when do entries expire? */
  80
  81        __u8 srcmask, dstmask;
  82};
  83
  84struct hashlimit_cfg3 {
  85        __u64 avg;              /* Average secs between packets * scale */
  86        __u64 burst;            /* Period multiplier for upper limit. */
  87        __u32 mode;             /* bitmask of XT_HASHLIMIT_HASH_* */
  88
  89        /* user specified */
  90        __u32 size;             /* how many buckets */
  91        __u32 max;              /* max number of entries */
  92        __u32 gc_interval;      /* gc interval */
  93        __u32 expire;           /* when do entries expire? */
  94
  95        __u32 interval;
  96        __u8 srcmask, dstmask;
  97};
  98
  99struct xt_hashlimit_mtinfo1 {
 100        char name[IFNAMSIZ];
 101        struct hashlimit_cfg1 cfg;
 102
 103        /* Used internally by the kernel */
 104        struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
 105};
 106
 107struct xt_hashlimit_mtinfo2 {
 108        char name[NAME_MAX];
 109        struct hashlimit_cfg2 cfg;
 110
 111        /* Used internally by the kernel */
 112        struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
 113};
 114
 115struct xt_hashlimit_mtinfo3 {
 116        char name[NAME_MAX];
 117        struct hashlimit_cfg3 cfg;
 118
 119        /* Used internally by the kernel */
 120        struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
 121};
 122
 123#endif /* _UAPI_XT_HASHLIMIT_H */
 124