[NETFILTER]: xt_sctp: fix mistake to pass a pointer where array is required
[sfrench/cifs-2.6.git] / include / linux / netfilter / xt_sctp.h
1 #ifndef _XT_SCTP_H_
2 #define _XT_SCTP_H_
3
4 #define XT_SCTP_SRC_PORTS               0x01
5 #define XT_SCTP_DEST_PORTS              0x02
6 #define XT_SCTP_CHUNK_TYPES             0x04
7
8 #define XT_SCTP_VALID_FLAGS             0x07
9
10 struct xt_sctp_flag_info {
11         u_int8_t chunktype;
12         u_int8_t flag;
13         u_int8_t flag_mask;
14 };
15
16 #define XT_NUM_SCTP_FLAGS       4
17
18 struct xt_sctp_info {
19         u_int16_t dpts[2];  /* Min, Max */
20         u_int16_t spts[2];  /* Min, Max */
21
22         u_int32_t chunkmap[256 / sizeof (u_int32_t)];  /* Bit mask of chunks to be matched according to RFC 2960 */
23
24 #define SCTP_CHUNK_MATCH_ANY   0x01  /* Match if any of the chunk types are present */
25 #define SCTP_CHUNK_MATCH_ALL   0x02  /* Match if all of the chunk types are present */
26 #define SCTP_CHUNK_MATCH_ONLY  0x04  /* Match if these are the only chunk types present */
27
28         u_int32_t chunk_match_type;
29         struct xt_sctp_flag_info flag_info[XT_NUM_SCTP_FLAGS];
30         int flag_count;
31
32         u_int32_t flags;
33         u_int32_t invflags;
34 };
35
36 #define bytes(type) (sizeof(type) * 8)
37
38 #define SCTP_CHUNKMAP_SET(chunkmap, type)               \
39         do {                                            \
40                 chunkmap[type / bytes(u_int32_t)] |=    \
41                         1 << (type % bytes(u_int32_t)); \
42         } while (0)
43
44 #define SCTP_CHUNKMAP_CLEAR(chunkmap, type)                     \
45         do {                                                    \
46                 chunkmap[type / bytes(u_int32_t)] &=            \
47                         ~(1 << (type % bytes(u_int32_t)));      \
48         } while (0)
49
50 #define SCTP_CHUNKMAP_IS_SET(chunkmap, type)                    \
51 ({                                                              \
52         (chunkmap[type / bytes (u_int32_t)] &                   \
53                 (1 << (type % bytes (u_int32_t)))) ? 1: 0;      \
54 })
55
56 #define SCTP_CHUNKMAP_RESET(chunkmap)                           \
57         do {                                                    \
58                 int i;                                          \
59                 for (i = 0; i < ARRAY_SIZE(chunkmap); i++)      \
60                         chunkmap[i] = 0;                        \
61         } while (0)
62
63 #define SCTP_CHUNKMAP_SET_ALL(chunkmap)                         \
64         do {                                                    \
65                 int i;                                          \
66                 for (i = 0; i < ARRAY_SIZE(chunkmap); i++)      \
67                         chunkmap[i] = ~0;                       \
68         } while (0)
69
70 #define SCTP_CHUNKMAP_COPY(destmap, srcmap)                     \
71         do {                                                    \
72                 int i;                                          \
73                 for (i = 0; i < ARRAY_SIZE(srcmap); i++)        \
74                         destmap[i] = srcmap[i];                 \
75         } while (0)
76
77 #define SCTP_CHUNKMAP_IS_CLEAR(chunkmap)                \
78 ({                                                      \
79         int i;                                          \
80         int flag = 1;                                   \
81         for (i = 0; i < ARRAY_SIZE(chunkmap); i++) {    \
82                 if (chunkmap[i]) {                      \
83                         flag = 0;                       \
84                         break;                          \
85                 }                                       \
86         }                                               \
87         flag;                                           \
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
103 #endif /* _XT_SCTP_H_ */
104