logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

xt_hashlimit.h (3256B)


  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _XT_HASHLIMIT_H
  3. #define _XT_HASHLIMIT_H
  4. #include <linux/types.h>
  5. #include <linux/limits.h>
  6. #include <linux/if.h>
  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. /* packet length accounting is done in 16-byte steps */
  14. #define XT_HASHLIMIT_BYTE_SHIFT 4
  15. /* details of this structure hidden by the implementation */
  16. struct xt_hashlimit_htable;
  17. enum {
  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. XT_HASHLIMIT_RATE_MATCH = 1 << 6,
  25. };
  26. struct 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. /* user specified */
  31. __u32 size; /* how many buckets */
  32. __u32 max; /* max number of entries */
  33. __u32 gc_interval; /* gc interval */
  34. __u32 expire; /* when do entries expire? */
  35. };
  36. struct xt_hashlimit_info {
  37. char name [IFNAMSIZ]; /* name */
  38. struct hashlimit_cfg cfg;
  39. /* Used internally by the kernel */
  40. struct xt_hashlimit_htable *hinfo;
  41. union {
  42. void *ptr;
  43. struct xt_hashlimit_info *master;
  44. } u;
  45. };
  46. struct hashlimit_cfg1 {
  47. __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
  48. __u32 avg; /* Average secs between packets * scale */
  49. __u32 burst; /* Period multiplier for upper limit. */
  50. /* user specified */
  51. __u32 size; /* how many buckets */
  52. __u32 max; /* max number of entries */
  53. __u32 gc_interval; /* gc interval */
  54. __u32 expire; /* when do entries expire? */
  55. __u8 srcmask, dstmask;
  56. };
  57. struct hashlimit_cfg2 {
  58. __u64 avg; /* Average secs between packets * scale */
  59. __u64 burst; /* Period multiplier for upper limit. */
  60. __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
  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. __u8 srcmask, dstmask;
  67. };
  68. struct hashlimit_cfg3 {
  69. __u64 avg; /* Average secs between packets * scale */
  70. __u64 burst; /* Period multiplier for upper limit. */
  71. __u32 mode; /* bitmask of XT_HASHLIMIT_HASH_* */
  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. __u32 interval;
  78. __u8 srcmask, dstmask;
  79. };
  80. struct xt_hashlimit_mtinfo1 {
  81. char name[IFNAMSIZ];
  82. struct hashlimit_cfg1 cfg;
  83. /* Used internally by the kernel */
  84. struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
  85. };
  86. struct xt_hashlimit_mtinfo2 {
  87. char name[NAME_MAX];
  88. struct hashlimit_cfg2 cfg;
  89. /* Used internally by the kernel */
  90. struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
  91. };
  92. struct xt_hashlimit_mtinfo3 {
  93. char name[NAME_MAX];
  94. struct hashlimit_cfg3 cfg;
  95. /* Used internally by the kernel */
  96. struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
  97. };
  98. #endif /* _XT_HASHLIMIT_H */