4 #define XT_SCTP_SRC_PORTS 0x01
5 #define XT_SCTP_DEST_PORTS 0x02
6 #define XT_SCTP_CHUNK_TYPES 0x04
8 #define XT_SCTP_VALID_FLAGS 0x07
11 #define SCTP_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
14 struct xt_sctp_flag_info {
20 #define XT_NUM_SCTP_FLAGS 4
23 u_int16_t dpts[2]; /* Min, Max */
24 u_int16_t spts[2]; /* Min, Max */
26 u_int32_t chunkmap[256 / sizeof (u_int32_t)]; /* Bit mask of chunks to be matched according to RFC 2960 */
28 #define SCTP_CHUNK_MATCH_ANY 0x01 /* Match if any of the chunk types are present */
29 #define SCTP_CHUNK_MATCH_ALL 0x02 /* Match if all of the chunk types are present */
30 #define SCTP_CHUNK_MATCH_ONLY 0x04 /* Match if these are the only chunk types present */
32 u_int32_t chunk_match_type;
33 struct xt_sctp_flag_info flag_info[XT_NUM_SCTP_FLAGS];
40 #define bytes(type) (sizeof(type) * 8)
42 #define SCTP_CHUNKMAP_SET(chunkmap, type) \
44 (chunkmap)[type / bytes(u_int32_t)] |= \
45 1 << (type % bytes(u_int32_t)); \
48 #define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \
50 (chunkmap)[type / bytes(u_int32_t)] &= \
51 ~(1 << (type % bytes(u_int32_t))); \
54 #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \
56 ((chunkmap)[type / bytes (u_int32_t)] & \
57 (1 << (type % bytes (u_int32_t)))) ? 1: 0; \
60 #define SCTP_CHUNKMAP_RESET(chunkmap) \
61 memset((chunkmap), 0, sizeof(chunkmap))
63 #define SCTP_CHUNKMAP_SET_ALL(chunkmap) \
64 memset((chunkmap), ~0U, sizeof(chunkmap))
66 #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
67 memcpy((destmap), (srcmap), sizeof(srcmap))
69 #define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
70 __sctp_chunkmap_is_clear((chunkmap), SCTP_ARRAY_SIZE(chunkmap))
72 __sctp_chunkmap_is_clear(const u_int32_t *chunkmap, unsigned int n)
75 for (i = 0; i < n; ++i)
81 #define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
82 __sctp_chunkmap_is_all_set((chunkmap), ARRAY_SIZE(chunkmap))
84 __sctp_chunkmap_is_all_set(const u_int32_t *chunkmap, unsigned int n)
87 for (i = 0; i < n; ++i)
88 if (chunkmap[i] != ~0U)
93 #endif /* _XT_SCTP_H_ */