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