summaryrefslogtreecommitdiff
path: root/target/linux/generic-2.6/patches-2.6.26/950-revert_xt_sctp_simplify.patch
blob: 6c8cdf1576991a971920bac59eb3027bd4133aa1 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--- linux-2.6.26-rc4/include/linux/netfilter/xt_sctp.h	2008-05-26 20:08:11.000000000 +0200
+++ linux-2.6.26-rc4-owrt/include/linux/netfilter/xt_sctp.h	2008-06-02 13:30:15.000000000 +0200
@@ -37,54 +37,68 @@
 
 #define SCTP_CHUNKMAP_SET(chunkmap, type) 		\
 	do { 						\
-		(chunkmap)[type / bytes(u_int32_t)] |= 	\
+		chunkmap[type / bytes(u_int32_t)] |= 	\
 			1 << (type % bytes(u_int32_t));	\
 	} while (0)
 
 #define SCTP_CHUNKMAP_CLEAR(chunkmap, type)		 	\
 	do {							\
-		(chunkmap)[type / bytes(u_int32_t)] &= 		\
+		chunkmap[type / bytes(u_int32_t)] &= 		\
 			~(1 << (type % bytes(u_int32_t)));	\
 	} while (0)
 
 #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) 			\
 ({								\
-	((chunkmap)[type / bytes (u_int32_t)] & 		\
+	(chunkmap[type / bytes (u_int32_t)] & 			\
 		(1 << (type % bytes (u_int32_t)))) ? 1: 0;	\
 })
 
-#define SCTP_CHUNKMAP_RESET(chunkmap) \
-	memset((chunkmap), 0, sizeof(chunkmap))
+#define SCTP_CHUNKMAP_RESET(chunkmap) 				\
+	do {							\
+		int i; 						\
+		for (i = 0; i < ARRAY_SIZE(chunkmap); i++)	\
+			chunkmap[i] = 0;			\
+	} while (0)
 
-#define SCTP_CHUNKMAP_SET_ALL(chunkmap) \
-	memset((chunkmap), ~0U, sizeof(chunkmap))
+#define SCTP_CHUNKMAP_SET_ALL(chunkmap) 			\
+	do {							\
+		int i; 						\
+		for (i = 0; i < ARRAY_SIZE(chunkmap); i++) 	\
+			chunkmap[i] = ~0;			\
+	} while (0)
 
-#define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
-	memcpy((destmap), (srcmap), sizeof(srcmap))
+#define SCTP_CHUNKMAP_COPY(destmap, srcmap) 			\
+	do {							\
+		int i; 						\
+		for (i = 0; i < ARRAY_SIZE(srcmap); i++) 	\
+			destmap[i] = srcmap[i];			\
+	} while (0)
+
+#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) 		\
+({							\
+	int i; 						\
+	int flag = 1;					\
+	for (i = 0; i < ARRAY_SIZE(chunkmap); i++) {	\
+		if (chunkmap[i]) {			\
+			flag = 0;			\
+			break;				\
+		}					\
+	}						\
+        flag;						\
+})
 
-#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
-	__sctp_chunkmap_is_clear((chunkmap), ARRAY_SIZE(chunkmap))
-static inline bool
-__sctp_chunkmap_is_clear(const u_int32_t *chunkmap, unsigned int n)
-{
-	unsigned int i;
-	for (i = 0; i < n; ++i)
-		if (chunkmap[i])
-			return false;
-	return true;
-}
-
-#define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
-	__sctp_chunkmap_is_all_set((chunkmap), ARRAY_SIZE(chunkmap))
-static inline bool
-__sctp_chunkmap_is_all_set(const u_int32_t *chunkmap, unsigned int n)
-{
-	unsigned int i;
-	for (i = 0; i < n; ++i)
-		if (chunkmap[i] != ~0U)
-			return false;
-	return true;
-}
+#define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) 		\
+({							\
+	int i; 						\
+	int flag = 1;					\
+	for (i = 0; i < ARRAY_SIZE(chunkmap); i++) {	\
+		if (chunkmap[i] != ~0) {		\
+			flag = 0;			\
+				break;			\
+		}					\
+	}						\
+        flag;						\
+})
 
 #endif /* _XT_SCTP_H_ */