Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


xt_sctp.h
01: #ifndef _XT_SCTP_H_
02: #define _XT_SCTP_H_
03: 
04: #include <linux/types.h>
05: 
06: #define XT_SCTP_SRC_PORTS               0x01
07: #define XT_SCTP_DEST_PORTS              0x02
08: #define XT_SCTP_CHUNK_TYPES             0x04
09: 
10: #define XT_SCTP_VALID_FLAGS             0x07
11: 
12: struct xt_sctp_flag_info {
13:         __u8 chunktype;
14:         __u8 flag;
15:         __u8 flag_mask;
16: };
17: 
18: #define XT_NUM_SCTP_FLAGS       4
19: 
20: struct xt_sctp_info {
21:         __u16 dpts[2];  /* Min, Max */
22:         __u16 spts[2];  /* Min, Max */
23: 
24:         __u32 chunkmap[256 / sizeof (__u32)];  /* Bit mask of chunks to be matched according to RFC 2960 */
25: 
26: #define SCTP_CHUNK_MATCH_ANY   0x01  /* Match if any of the chunk types are present */
27: #define SCTP_CHUNK_MATCH_ALL   0x02  /* Match if all of the chunk types are present */
28: #define SCTP_CHUNK_MATCH_ONLY  0x04  /* Match if these are the only chunk types present */
29: 
30:         __u32 chunk_match_type;
31:         struct xt_sctp_flag_info flag_info[XT_NUM_SCTP_FLAGS];
32:         int flag_count;
33: 
34:         __u32 flags;
35:         __u32 invflags;
36: };
37: 
38: #define bytes(type) (sizeof(type) * 8)
39: 
40: #define SCTP_CHUNKMAP_SET(chunkmap, type)               \
41:         do {                                            \
42:                 (chunkmap)[type / bytes(__u32)] |=      \
43:                         1 << (type % bytes(__u32));     \
44:         } while (0)
45: 
46: #define SCTP_CHUNKMAP_CLEAR(chunkmap, type)                     \
47:         do {                                                    \
48:                 (chunkmap)[type / bytes(__u32)] &=              \
49:                         ~(1 << (type % bytes(__u32)));  \
50:         } while (0)
51: 
52: #define SCTP_CHUNKMAP_IS_SET(chunkmap, type)                    \
53: ({                                                              \
54:         ((chunkmap)[type / bytes (__u32)] &             \
55:                 (1 << (type % bytes (__u32)))) ? 1: 0;  \
56: })
57: 
58: #define SCTP_CHUNKMAP_RESET(chunkmap) \
59:         memset((chunkmap), 0, sizeof(chunkmap))
60: 
61: #define SCTP_CHUNKMAP_SET_ALL(chunkmap) \
62:         memset((chunkmap), ~0U, sizeof(chunkmap))
63: 
64: #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
65:         memcpy((destmap), (srcmap), sizeof(srcmap))
66: 
67: #define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
68:         __sctp_chunkmap_is_clear((chunkmap), ARRAY_SIZE(chunkmap))
69: static __inline__ bool
70: __sctp_chunkmap_is_clear(const __u32 *chunkmap, unsigned int n)
71: {
72:         unsigned int i;
73:         for (i = 0; i < n; ++i)
74:                 if (chunkmap[i])
75:                         return false;
76:         return true;
77: }
78: 
79: #define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
80:         __sctp_chunkmap_is_all_set((chunkmap), ARRAY_SIZE(chunkmap))
81: static __inline__ bool
82: __sctp_chunkmap_is_all_set(const __u32 *chunkmap, unsigned int n)
83: {
84:         unsigned int i;
85:         for (i = 0; i < n; ++i)
86:                 if (chunkmap[i] != ~0U)
87:                         return false;
88:         return true;
89: }
90: 
91: #endif /* _XT_SCTP_H_ */
92: 
93: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/