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_sctp.h (2329B)


  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _XT_SCTP_H_
  3. #define _XT_SCTP_H_
  4. #include <linux/types.h>
  5. #define XT_SCTP_SRC_PORTS 0x01
  6. #define XT_SCTP_DEST_PORTS 0x02
  7. #define XT_SCTP_CHUNK_TYPES 0x04
  8. #define XT_SCTP_VALID_FLAGS 0x07
  9. struct xt_sctp_flag_info {
  10. __u8 chunktype;
  11. __u8 flag;
  12. __u8 flag_mask;
  13. };
  14. #define XT_NUM_SCTP_FLAGS 4
  15. struct xt_sctp_info {
  16. __u16 dpts[2]; /* Min, Max */
  17. __u16 spts[2]; /* Min, Max */
  18. __u32 chunkmap[256 / sizeof (__u32)]; /* Bit mask of chunks to be matched according to RFC 2960 */
  19. #define SCTP_CHUNK_MATCH_ANY 0x01 /* Match if any of the chunk types are present */
  20. #define SCTP_CHUNK_MATCH_ALL 0x02 /* Match if all of the chunk types are present */
  21. #define SCTP_CHUNK_MATCH_ONLY 0x04 /* Match if these are the only chunk types present */
  22. __u32 chunk_match_type;
  23. struct xt_sctp_flag_info flag_info[XT_NUM_SCTP_FLAGS];
  24. int flag_count;
  25. __u32 flags;
  26. __u32 invflags;
  27. };
  28. #define bytes(type) (sizeof(type) * 8)
  29. #define SCTP_CHUNKMAP_SET(chunkmap, type) \
  30. do { \
  31. (chunkmap)[type / bytes(__u32)] |= \
  32. 1u << (type % bytes(__u32)); \
  33. } while (0)
  34. #define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \
  35. do { \
  36. (chunkmap)[type / bytes(__u32)] &= \
  37. ~(1u << (type % bytes(__u32))); \
  38. } while (0)
  39. #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \
  40. ({ \
  41. ((chunkmap)[type / bytes (__u32)] & \
  42. (1u << (type % bytes (__u32)))) ? 1: 0; \
  43. })
  44. #define SCTP_CHUNKMAP_RESET(chunkmap) \
  45. memset((chunkmap), 0, sizeof(chunkmap))
  46. #define SCTP_CHUNKMAP_SET_ALL(chunkmap) \
  47. memset((chunkmap), ~0U, sizeof(chunkmap))
  48. #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
  49. memcpy((destmap), (srcmap), sizeof(srcmap))
  50. #define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
  51. __sctp_chunkmap_is_clear((chunkmap), ARRAY_SIZE(chunkmap))
  52. static __inline__ _Bool
  53. __sctp_chunkmap_is_clear(const __u32 *chunkmap, unsigned int n)
  54. {
  55. unsigned int i;
  56. for (i = 0; i < n; ++i)
  57. if (chunkmap[i])
  58. return 0;
  59. return 1;
  60. }
  61. #define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
  62. __sctp_chunkmap_is_all_set((chunkmap), ARRAY_SIZE(chunkmap))
  63. static __inline__ _Bool
  64. __sctp_chunkmap_is_all_set(const __u32 *chunkmap, unsigned int n)
  65. {
  66. unsigned int i;
  67. for (i = 0; i < n; ++i)
  68. if (chunkmap[i] != ~0U)
  69. return 0;
  70. return 1;
  71. }
  72. #endif /* _XT_SCTP_H_ */