diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netfilter/xt_sctp.h | 84 |
1 files changed, 35 insertions, 49 deletions
diff --git a/include/linux/netfilter/xt_sctp.h b/include/linux/netfilter/xt_sctp.h index dd5a4fd4cfd3..32000ba6ecef 100644 --- a/include/linux/netfilter/xt_sctp.h +++ b/include/linux/netfilter/xt_sctp.h | |||
@@ -37,68 +37,54 @@ struct xt_sctp_info { | |||
37 | 37 | ||
38 | #define SCTP_CHUNKMAP_SET(chunkmap, type) \ | 38 | #define SCTP_CHUNKMAP_SET(chunkmap, type) \ |
39 | do { \ | 39 | do { \ |
40 | chunkmap[type / bytes(u_int32_t)] |= \ | 40 | (chunkmap)[type / bytes(u_int32_t)] |= \ |
41 | 1 << (type % bytes(u_int32_t)); \ | 41 | 1 << (type % bytes(u_int32_t)); \ |
42 | } while (0) | 42 | } while (0) |
43 | 43 | ||
44 | #define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \ | 44 | #define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \ |
45 | do { \ | 45 | do { \ |
46 | chunkmap[type / bytes(u_int32_t)] &= \ | 46 | (chunkmap)[type / bytes(u_int32_t)] &= \ |
47 | ~(1 << (type % bytes(u_int32_t))); \ | 47 | ~(1 << (type % bytes(u_int32_t))); \ |
48 | } while (0) | 48 | } while (0) |
49 | 49 | ||
50 | #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \ | 50 | #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \ |
51 | ({ \ | 51 | ({ \ |
52 | (chunkmap[type / bytes (u_int32_t)] & \ | 52 | ((chunkmap)[type / bytes (u_int32_t)] & \ |
53 | (1 << (type % bytes (u_int32_t)))) ? 1: 0; \ | 53 | (1 << (type % bytes (u_int32_t)))) ? 1: 0; \ |
54 | }) | 54 | }) |
55 | 55 | ||
56 | #define SCTP_CHUNKMAP_RESET(chunkmap) \ | 56 | #define SCTP_CHUNKMAP_RESET(chunkmap) \ |
57 | do { \ | 57 | memset((chunkmap), 0, sizeof(chunkmap)) |
58 | int i; \ | 58 | |
59 | for (i = 0; i < ARRAY_SIZE(chunkmap); i++) \ | 59 | #define SCTP_CHUNKMAP_SET_ALL(chunkmap) \ |
60 | chunkmap[i] = 0; \ | 60 | memset((chunkmap), ~0U, sizeof(chunkmap)) |
61 | } while (0) | 61 | |
62 | 62 | #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \ | |
63 | #define SCTP_CHUNKMAP_SET_ALL(chunkmap) \ | 63 | memcpy((destmap), (srcmap), sizeof(srcmap)) |
64 | do { \ | 64 | |
65 | int i; \ | 65 | #define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \ |
66 | for (i = 0; i < ARRAY_SIZE(chunkmap); i++) \ | 66 | __sctp_chunkmap_is_clear((chunkmap), ARRAY_SIZE(chunkmap)) |
67 | chunkmap[i] = ~0; \ | 67 | static inline bool |
68 | } while (0) | 68 | __sctp_chunkmap_is_clear(const u_int32_t *chunkmap, unsigned int n) |
69 | 69 | { | |
70 | #define SCTP_CHUNKMAP_COPY(destmap, srcmap) \ | 70 | unsigned int i; |
71 | do { \ | 71 | for (i = 0; i < n; ++i) |
72 | int i; \ | 72 | if (chunkmap[i]) |
73 | for (i = 0; i < ARRAY_SIZE(srcmap); i++) \ | 73 | return false; |
74 | destmap[i] = srcmap[i]; \ | 74 | return true; |
75 | } while (0) | 75 | } |
76 | 76 | ||
77 | #define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \ | 77 | #define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \ |
78 | ({ \ | 78 | __sctp_chunkmap_is_all_set((chunkmap), ARRAY_SIZE(chunkmap)) |
79 | int i; \ | 79 | static inline bool |
80 | int flag = 1; \ | 80 | __sctp_chunkmap_is_all_set(const u_int32_t *chunkmap, unsigned int n) |
81 | for (i = 0; i < ARRAY_SIZE(chunkmap); i++) { \ | 81 | { |
82 | if (chunkmap[i]) { \ | 82 | unsigned int i; |
83 | flag = 0; \ | 83 | for (i = 0; i < n; ++i) |
84 | break; \ | 84 | if (chunkmap[i] != ~0U) |
85 | } \ | 85 | return false; |
86 | } \ | 86 | return true; |
87 | flag; \ | 87 | } |
88 | }) | ||
89 | |||
90 | #define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \ | ||
91 | ({ \ | ||
92 | int i; \ | ||
93 | int flag = 1; \ | ||
94 | for (i = 0; i < ARRAY_SIZE(chunkmap); i++) { \ | ||
95 | if (chunkmap[i] != ~0) { \ | ||
96 | flag = 0; \ | ||
97 | break; \ | ||
98 | } \ | ||
99 | } \ | ||
100 | flag; \ | ||
101 | }) | ||
102 | 88 | ||
103 | #endif /* _XT_SCTP_H_ */ | 89 | #endif /* _XT_SCTP_H_ */ |
104 | 90 | ||