]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/linux-26-headers/include/linux/netfilter_ipv4/ipt_sctp.h
Inital import
[l4.git] / l4 / pkg / linux-26-headers / include / linux / netfilter_ipv4 / ipt_sctp.h
1 #ifndef _IPT_SCTP_H_
2 #define _IPT_SCTP_H_
3
4 #define IPT_SCTP_SRC_PORTS              0x01
5 #define IPT_SCTP_DEST_PORTS             0x02
6 #define IPT_SCTP_CHUNK_TYPES            0x04
7
8 #define IPT_SCTP_VALID_FLAGS            0x07
9
10
11 struct ipt_sctp_flag_info {
12         u_int8_t chunktype;
13         u_int8_t flag;
14         u_int8_t flag_mask;
15 };
16
17 #define IPT_NUM_SCTP_FLAGS      4
18
19 struct ipt_sctp_info {
20         u_int16_t dpts[2];  /* Min, Max */
21         u_int16_t spts[2];  /* Min, Max */
22
23         u_int32_t chunkmap[256 / sizeof (u_int32_t)];  /* Bit mask of chunks to be matched according to RFC 2960 */
24
25 #define SCTP_CHUNK_MATCH_ANY   0x01  /* Match if any of the chunk types are present */
26 #define SCTP_CHUNK_MATCH_ALL   0x02  /* Match if all of the chunk types are present */
27 #define SCTP_CHUNK_MATCH_ONLY  0x04  /* Match if these are the only chunk types present */
28
29         u_int32_t chunk_match_type;
30         struct ipt_sctp_flag_info flag_info[IPT_NUM_SCTP_FLAGS];
31         int flag_count;
32
33         u_int32_t flags;
34         u_int32_t invflags;
35 };
36
37 #define bytes(type) (sizeof(type) * 8)
38
39 #define SCTP_CHUNKMAP_SET(chunkmap, type)               \
40         do {                                            \
41                 chunkmap[type / bytes(u_int32_t)] |=    \
42                         1 << (type % bytes(u_int32_t)); \
43         } while (0)
44
45 #define SCTP_CHUNKMAP_CLEAR(chunkmap, type)                     \
46         do {                                                    \
47                 chunkmap[type / bytes(u_int32_t)] &=            \
48                         ~(1 << (type % bytes(u_int32_t)));      \
49         } while (0)
50
51 #define SCTP_CHUNKMAP_IS_SET(chunkmap, type)                    \
52 ({                                                              \
53         (chunkmap[type / bytes (u_int32_t)] &                   \
54                 (1 << (type % bytes (u_int32_t)))) ? 1: 0;      \
55 })
56
57 #define SCTP_CHUNKMAP_RESET(chunkmap)                           \
58         do {                                                    \
59                 int i;                                          \
60                 for (i = 0; i < ARRAY_SIZE(chunkmap); i++)      \
61                         chunkmap[i] = 0;                        \
62         } while (0)
63
64 #define SCTP_CHUNKMAP_SET_ALL(chunkmap)                         \
65         do {                                                    \
66                 int i;                                          \
67                 for (i = 0; i < ARRAY_SIZE(chunkmap); i++)      \
68                         chunkmap[i] = ~0;                       \
69         } while (0)
70
71 #define SCTP_CHUNKMAP_COPY(destmap, srcmap)                     \
72         do {                                                    \
73                 int i;                                          \
74                 for (i = 0; i < ARRAY_SIZE(chunkmap); i++)      \
75                         destmap[i] = srcmap[i];                 \
76         } while (0)
77
78 #define SCTP_CHUNKMAP_IS_CLEAR(chunkmap)                \
79 ({                                                      \
80         int i;                                          \
81         int flag = 1;                                   \
82         for (i = 0; i < ARRAY_SIZE(chunkmap); i++) {    \
83                 if (chunkmap[i]) {                      \
84                         flag = 0;                       \
85                         break;                          \
86                 }                                       \
87         }                                               \
88         flag;                                           \
89 })
90
91 #define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap)              \
92 ({                                                      \
93         int i;                                          \
94         int flag = 1;                                   \
95         for (i = 0; i < ARRAY_SIZE(chunkmap); i++) {    \
96                 if (chunkmap[i] != ~0) {                \
97                         flag = 0;                       \
98                                 break;                  \
99                 }                                       \
100         }                                               \
101         flag;                                           \
102 })
103
104 #endif /* _IPT_SCTP_H_ */
105