aboutsummaryrefslogtreecommitdiff
path: root/src/transport/wlan/byteorder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/wlan/byteorder.h')
-rw-r--r--src/transport/wlan/byteorder.h827
1 files changed, 415 insertions, 412 deletions
diff --git a/src/transport/wlan/byteorder.h b/src/transport/wlan/byteorder.h
index c982669bf..e065e24d6 100644
--- a/src/transport/wlan/byteorder.h
+++ b/src/transport/wlan/byteorder.h
@@ -16,418 +16,421 @@
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 20
21#ifndef _AIRCRACK_NG_BYTEORDER_H_ 21#ifndef _AIRCRACK_NG_BYTEORDER_H_
22#define _AIRCRACK_NG_BYTEORDER_H_ 22#define _AIRCRACK_NG_BYTEORDER_H_
23 23
24 #define ___my_swab16(x) \ 24#define ___my_swab16(x) \
25 ((u_int16_t)( \ 25 ((u_int16_t) (\
26 (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \ 26 (((u_int16_t) (x) & (u_int16_t) 0x00ffU) << 8) | \
27 (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) )) 27 (((u_int16_t) (x) & (u_int16_t) 0xff00U) >> 8)))
28 #define ___my_swab32(x) \ 28#define ___my_swab32(x) \
29 ((u_int32_t)( \ 29 ((u_int32_t) (\
30 (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \ 30 (((u_int32_t) (x) & (u_int32_t) 0x000000ffUL) << 24) | \
31 (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) << 8) | \ 31 (((u_int32_t) (x) & (u_int32_t) 0x0000ff00UL) << 8) | \
32 (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >> 8) | \ 32 (((u_int32_t) (x) & (u_int32_t) 0x00ff0000UL) >> 8) | \
33 (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) )) 33 (((u_int32_t) (x) & (u_int32_t) 0xff000000UL) >> 24)))
34 #define ___my_swab64(x) \ 34#define ___my_swab64(x) \
35 ((u_int64_t)( \ 35 ((u_int64_t) (\
36 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \ 36 (u_int64_t) (((u_int64_t) (x) & (u_int64_t)
37 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \ 37 0x00000000000000ffULL) << 56) |
38 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \ 38 \ (u_int64_t) (((u_int64_t) (x) & (u_int64_t)
39 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) << 8) | \ 39 0x000000000000ff00ULL) << 40) |
40 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >> 8) | \ 40 \ (u_int64_t) (((u_int64_t) (x) & (u_int64_t)
41 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \ 41 0x0000000000ff0000ULL) << 24) |
42 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \ 42 \ (u_int64_t) (((u_int64_t) (x) & (u_int64_t)
43 (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) )) 43 0x00000000ff000000ULL) << 8) |
44 44 \ (u_int64_t) (((u_int64_t) (x) & (u_int64_t)
45 45 0x000000ff00000000ULL) >> 8) |
46 /* 46 \ (u_int64_t) (((u_int64_t) (x) & (u_int64_t)
47 * Linux 47 0x0000ff0000000000ULL) >> 24) |
48 */ 48 \ (u_int64_t) (((u_int64_t) (x) & (u_int64_t)
49 #if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__) 49 0x00ff000000000000ULL) >> 40) |
50 #include <endian.h> 50 \ (u_int64_t) (((u_int64_t) (x) & (u_int64_t)
51 #include <unistd.h> 51 0xff00000000000000ULL) >> 56)))
52 #include <stdint.h> 52 /*
53 53 * Linux
54 #ifndef __int8_t_defined 54 */
55 typedef uint64_t u_int64_t; 55#if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
56 typedef uint32_t u_int32_t; 56#include <endian.h>
57 typedef uint16_t u_int16_t; 57#include <unistd.h>
58 typedef uint8_t u_int8_t; 58#include <stdint.h>
59 #endif 59
60 60#ifndef __int8_t_defined
61typedef uint64_t u_int64_t;
62 typedef uint32_t u_int32_t;
63 typedef uint16_t u_int16_t;
64 typedef uint8_t u_int8_t;
65
66
67#endif /* */
68
61#ifndef htole16 69#ifndef htole16
62# if __BYTE_ORDER == __LITTLE_ENDIAN 70#if __BYTE_ORDER == __LITTLE_ENDIAN
63# define htobe16(x) ___my_swab16 (x) 71#define htobe16(x) ___my_swab16 (x)
64# define htole16(x) (x) 72#define htole16(x) (x)
65# define be16toh(x) ___my_swab16 (x) 73#define be16toh(x) ___my_swab16 (x)
66# define le16toh(x) (x) 74#define le16toh(x) (x)
67 75
68# define htobe32(x) ___my_swab32 (x) 76#define htobe32(x) ___my_swab32 (x)
69# define htole32(x) (x) 77#define htole32(x) (x)
70# define be32toh(x) ___my_swab32 (x) 78#define be32toh(x) ___my_swab32 (x)
71# define le32toh(x) (x) 79#define le32toh(x) (x)
72 80
73# define htobe64(x) ___my_swab64 (x) 81#define htobe64(x) ___my_swab64 (x)
74# define htole64(x) (x) 82#define htole64(x) (x)
75# define be64toh(x) ___my_swab64 (x) 83#define be64toh(x) ___my_swab64 (x)
76# define le64toh(x) (x) 84#define le64toh(x) (x)
77# else 85#else /* */
78# define htobe16(x) (x) 86#define htobe16(x) (x)
79# define htole16(x) ___my_swab16 (x) 87#define htole16(x) ___my_swab16 (x)
80# define be16toh(x) (x) 88#define be16toh(x) (x)
81# define le16toh(x) ___my_swab16 (x) 89#define le16toh(x) ___my_swab16 (x)
82 90
83# define htobe32(x) (x) 91#define htobe32(x) (x)
84# define htole32(x) ___my_swab32 (x) 92#define htole32(x) ___my_swab32 (x)
85# define be32toh(x) (x) 93#define be32toh(x) (x)
86# define le32toh(x) ___my_swab32 (x) 94#define le32toh(x) ___my_swab32 (x)
87 95
88# define htobe64(x) (x) 96#define htobe64(x) (x)
89# define htole64(x) ___my_swab64 (x) 97#define htole64(x) ___my_swab64 (x)
90# define be64toh(x) (x) 98#define be64toh(x) (x)
91# define le64toh(x) ___my_swab64 (x) 99#define le64toh(x) ___my_swab64 (x)
92# endif 100#endif /* */
93#endif 101#endif /* */
94 102
95 103#endif /* */
96 104
97 #endif 105 /*
98 106 * Cygwin
99 /* 107 */
100 * Cygwin 108#if defined(__CYGWIN32__)
101 */ 109#include <asm/byteorder.h>
102 #if defined(__CYGWIN32__) 110#include <unistd.h>
103 #include <asm/byteorder.h> 111
104 #include <unistd.h> 112#define __be64_to_cpu(x) ___my_swab64(x)
105 113#define __be32_to_cpu(x) ___my_swab32(x)
106 #define __be64_to_cpu(x) ___my_swab64(x) 114#define __be16_to_cpu(x) ___my_swab16(x)
107 #define __be32_to_cpu(x) ___my_swab32(x) 115#define __cpu_to_be64(x) ___my_swab64(x)
108 #define __be16_to_cpu(x) ___my_swab16(x) 116#define __cpu_to_be32(x) ___my_swab32(x)
109 #define __cpu_to_be64(x) ___my_swab64(x) 117#define __cpu_to_be16(x) ___my_swab16(x)
110 #define __cpu_to_be32(x) ___my_swab32(x) 118#define __le64_to_cpu(x) (x)
111 #define __cpu_to_be16(x) ___my_swab16(x) 119#define __le32_to_cpu(x) (x)
112 #define __le64_to_cpu(x) (x) 120#define __le16_to_cpu(x) (x)
113 #define __le32_to_cpu(x) (x) 121#define __cpu_to_le64(x) (x)
114 #define __le16_to_cpu(x) (x) 122#define __cpu_to_le32(x) (x)
115 #define __cpu_to_le64(x) (x) 123#define __cpu_to_le16(x) (x)
116 #define __cpu_to_le32(x) (x) 124
117 #define __cpu_to_le16(x) (x) 125#define AIRCRACK_NG_BYTE_ORDER_DEFINED
118 126
119 #define AIRCRACK_NG_BYTE_ORDER_DEFINED 127#endif /* */
120 128
121 #endif 129 /*
122 130 * Windows (DDK)
123 /* 131 */
124 * Windows (DDK) 132#if defined(__WIN__)
125 */ 133
126 #if defined(__WIN__) 134#include <io.h>
127 135
128 #include <io.h> 136#define __be64_to_cpu(x) ___my_swab64(x)
129 137#define __be32_to_cpu(x) ___my_swab32(x)
130 #define __be64_to_cpu(x) ___my_swab64(x) 138#define __be16_to_cpu(x) ___my_swab16(x)
131 #define __be32_to_cpu(x) ___my_swab32(x) 139#define __cpu_to_be64(x) ___my_swab64(x)
132 #define __be16_to_cpu(x) ___my_swab16(x) 140#define __cpu_to_be32(x) ___my_swab32(x)
133 #define __cpu_to_be64(x) ___my_swab64(x) 141#define __cpu_to_be16(x) ___my_swab16(x)
134 #define __cpu_to_be32(x) ___my_swab32(x) 142#define __le64_to_cpu(x) (x)
135 #define __cpu_to_be16(x) ___my_swab16(x) 143#define __le32_to_cpu(x) (x)
136 #define __le64_to_cpu(x) (x) 144#define __le16_to_cpu(x) (x)
137 #define __le32_to_cpu(x) (x) 145#define __cpu_to_le64(x) (x)
138 #define __le16_to_cpu(x) (x) 146#define __cpu_to_le32(x) (x)
139 #define __cpu_to_le64(x) (x) 147#define __cpu_to_le16(x) (x)
140 #define __cpu_to_le32(x) (x) 148
141 #define __cpu_to_le16(x) (x) 149#define AIRCRACK_NG_BYTE_ORDER_DEFINED
142 150
143 #define AIRCRACK_NG_BYTE_ORDER_DEFINED 151#endif /* */
144 152
145 #endif 153 /*
146 154 * MAC (Darwin)
147 /* 155 */
148 * MAC (Darwin) 156#if defined(__APPLE_CC__)
149 */ 157#if defined(__x86_64__) && defined(__APPLE__)
150 #if defined(__APPLE_CC__) 158
151 #if defined(__x86_64__) && defined(__APPLE__) 159#include <libkern/OSByteOrder.h>
152 160
153 #include <libkern/OSByteOrder.h> 161#define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t)x)
154 162#define __swab32(x) (unsigned long) OSSwapInt32((uint32_t)x)
155 #define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t)x) 163#define __swab16(x) (unsigned short) OSSwapInt16((uint16_t)x)
156 #define __swab32(x) (unsigned long) OSSwapInt32((uint32_t)x) 164#define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t)x)
157 #define __swab16(x) (unsigned short) OSSwapInt16((uint16_t)x) 165#define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t)x)
158 #define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t)x) 166#define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t)x)
159 #define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t)x) 167#define __le64_to_cpu(x) (unsigned long long) OSSwapLittleToHostInt64((uint64_t)x)
160 #define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t)x) 168#define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t)x)
161 #define __le64_to_cpu(x) (unsigned long long) OSSwapLittleToHostInt64((uint64_t)x) 169#define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t)x)
162 #define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t)x) 170#define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t)x)
163 #define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t)x) 171#define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t)x)
164 #define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t)x) 172#define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t)x)
165 #define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t)x) 173#define __cpu_to_le64(x) (unsigned long long) OSSwapHostToLittleInt64((uint64_t)x)
166 #define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t)x) 174#define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t)x)
167 #define __cpu_to_le64(x) (unsigned long long) OSSwapHostToLittleInt64((uint64_t)x) 175#define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t)x)
168 #define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t)x) 176
169 #define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t)x) 177#else /* */
170 178
171 #else 179#include <architecture/byte_order.h>
172 180
173 #include <architecture/byte_order.h> 181#define __swab64(x) NXSwapLongLong(x)
174 182#define __swab32(x) NXSwapLong(x)
175 #define __swab64(x) NXSwapLongLong(x) 183#define __swab16(x) NXSwapShort(x)
176 #define __swab32(x) NXSwapLong(x) 184#define __be64_to_cpu(x) NXSwapBigLongLongToHost(x)
177 #define __swab16(x) NXSwapShort(x) 185#define __be32_to_cpu(x) NXSwapBigLongToHost(x)
178 #define __be64_to_cpu(x) NXSwapBigLongLongToHost(x) 186#define __be16_to_cpu(x) NXSwapBigShortToHost(x)
179 #define __be32_to_cpu(x) NXSwapBigLongToHost(x) 187#define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x)
180 #define __be16_to_cpu(x) NXSwapBigShortToHost(x) 188#define __le32_to_cpu(x) NXSwapLittleLongToHost(x)
181 #define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x) 189#define __le16_to_cpu(x) NXSwapLittleShortToHost(x)
182 #define __le32_to_cpu(x) NXSwapLittleLongToHost(x) 190#define __cpu_to_be64(x) NXSwapHostLongLongToBig(x)
183 #define __le16_to_cpu(x) NXSwapLittleShortToHost(x) 191#define __cpu_to_be32(x) NXSwapHostLongToBig(x)
184 #define __cpu_to_be64(x) NXSwapHostLongLongToBig(x) 192#define __cpu_to_be16(x) NXSwapHostShortToBig(x)
185 #define __cpu_to_be32(x) NXSwapHostLongToBig(x) 193#define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x)
186 #define __cpu_to_be16(x) NXSwapHostShortToBig(x) 194#define __cpu_to_le32(x) NXSwapHostLongToLittle(x)
187 #define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x) 195#define __cpu_to_le16(x) NXSwapHostShortToLittle(x)
188 #define __cpu_to_le32(x) NXSwapHostLongToLittle(x) 196
189 #define __cpu_to_le16(x) NXSwapHostShortToLittle(x) 197#endif /* */
190 198
191 #endif 199#define __LITTLE_ENDIAN 1234
192 200#define __BIG_ENDIAN 4321
193 #define __LITTLE_ENDIAN 1234 201#define __PDP_ENDIAN 3412
194 #define __BIG_ENDIAN 4321 202#define __BYTE_ORDER __BIG_ENDIAN
195 #define __PDP_ENDIAN 3412 203
196 #define __BYTE_ORDER __BIG_ENDIAN 204#define AIRCRACK_NG_BYTE_ORDER_DEFINED
197 205
198 #define AIRCRACK_NG_BYTE_ORDER_DEFINED 206#endif /* */
199 207
200 #endif 208 /*
201 209 * Solaris
202 /* 210 * -------
203 * Solaris 211 */
204 * ------- 212#if defined(__sparc__) && defined(__sun__)
205 */ 213#include <sys/byteorder.h>
206 #if defined(__sparc__) && defined(__sun__) 214#include <sys/types.h>
207 #include <sys/byteorder.h> 215#include <unistd.h>
208 #include <sys/types.h> 216
209 #include <unistd.h> 217#define __be64_to_cpu(x) (x)
210 218#define __be32_to_cpu(x) (x)
211 #define __be64_to_cpu(x) (x) 219#define __be16_to_cpu(x) (x)
212 #define __be32_to_cpu(x) (x) 220#define __cpu_to_be64(x) (x)
213 #define __be16_to_cpu(x) (x) 221#define __cpu_to_be32(x) (x)
214 #define __cpu_to_be64(x) (x) 222#define __cpu_to_be16(x) (x)
215 #define __cpu_to_be32(x) (x) 223#define __le64_to_cpu(x) ___my_swab64(x)
216 #define __cpu_to_be16(x) (x) 224#define __le32_to_cpu(x) ___my_swab32(x)
217 #define __le64_to_cpu(x) ___my_swab64(x) 225#define __le16_to_cpu(x) ___my_swab16(x)
218 #define __le32_to_cpu(x) ___my_swab32(x) 226#define __cpu_to_le64(x) ___my_swab64(x)
219 #define __le16_to_cpu(x) ___my_swab16(x) 227#define __cpu_to_le32(x) ___my_swab32(x)
220 #define __cpu_to_le64(x) ___my_swab64(x) 228#define __cpu_to_le16(x) ___my_swab16(x)
221 #define __cpu_to_le32(x) ___my_swab32(x) 229 typedef uint64_t u_int64_t;
222 #define __cpu_to_le16(x) ___my_swab16(x) 230 typedef uint32_t u_int32_t;
223 231 typedef uint16_t u_int16_t;
224 typedef uint64_t u_int64_t; 232 typedef uint8_t u_int8_t;
225 typedef uint32_t u_int32_t; 233
226 typedef uint16_t u_int16_t; 234
227 typedef uint8_t u_int8_t; 235#define AIRCRACK_NG_BYTE_ORDER_DEFINED
228 236
229 #define AIRCRACK_NG_BYTE_ORDER_DEFINED 237#endif /* */
230 238
231 #endif 239 /*
232 240 * Custom stuff
233 /* 241 */
234 * Custom stuff 242#if defined(__MACH__) && !defined(__APPLE_CC__)
235 */ 243#include <libkern/OSByteOrder.h>
236 #if defined(__MACH__) && !defined(__APPLE_CC__) 244#define __cpu_to_be64(x) = OSSwapHostToBigInt64(x)
237 #include <libkern/OSByteOrder.h> 245#define __cpu_to_be32(x) = OSSwapHostToBigInt32(x)
238 #define __cpu_to_be64(x) = OSSwapHostToBigInt64(x) 246
239 #define __cpu_to_be32(x) = OSSwapHostToBigInt32(x) 247#define AIRCRACK_NG_BYTE_ORDER_DEFINED
240 248
241 #define AIRCRACK_NG_BYTE_ORDER_DEFINED 249#endif /* */
242 250
243 #endif 251 // FreeBSD
244 252#ifdef __FreeBSD__
245 253#include <machine/endian.h>
246 // FreeBSD 254#endif /* */
247 #ifdef __FreeBSD__ 255
248 #include <machine/endian.h> 256 // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...?
249 #endif 257
250 258 // XXX: Mac: Check http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h
251 // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...? 259 // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html
252 260 // Write to apple to ask what should be used.
253 261
254 // XXX: Mac: Check http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h 262#if defined(LITTLE_ENDIAN)
255 // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html 263#define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN
256 // Write to apple to ask what should be used. 264#elif defined(__LITTLE_ENDIAN)
257 265#define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN
258 #if defined(LITTLE_ENDIAN) 266#elif defined(_LITTLE_ENDIAN)
259 #define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN 267#define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN
260 #elif defined(__LITTLE_ENDIAN) 268#endif /* */
261 #define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN 269
262 #elif defined(_LITTLE_ENDIAN) 270#if defined(BIG_ENDIAN)
263 #define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN 271#define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN
264 #endif 272#elif defined(__BIG_ENDIAN)
265 273#define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN
266 #if defined(BIG_ENDIAN) 274#elif defined(_BIG_ENDIAN)
267 #define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN 275#define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN
268 #elif defined(__BIG_ENDIAN) 276#endif /* */
269 #define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN 277
270 #elif defined(_BIG_ENDIAN) 278#if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN)
271 #define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN 279#error Impossible to determine endianness (Little or Big endian), please contact the author.
272 #endif 280#endif /* */
273 281
274 #if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN) 282#if defined(BYTE_ORDER)
275 #error Impossible to determine endianness (Little or Big endian), please contact the author. 283#if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
276 #endif 284#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
277 285#elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
278 #if defined(BYTE_ORDER) 286#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
279 #if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) 287#endif /* */
280 #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN 288#elif defined(__BYTE_ORDER)
281 #elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) 289#if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
282 #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN 290#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
283 #endif 291#elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
284 #elif defined(__BYTE_ORDER) 292#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
285 #if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) 293#endif /* */
286 #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN 294#elif defined(_BYTE_ORDER)
287 #elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) 295#if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
288 #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN 296#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
289 #endif 297#elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
290 #elif defined(_BYTE_ORDER) 298#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
291 #if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) 299#endif /* */
292 #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN 300#endif /* */
293 #elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) 301
294 #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN 302#ifndef AIRCRACK_NG_BYTE_ORDER
295 #endif 303#error Impossible to determine endianness (Little or Big endian), please contact the author.
296 #endif 304#endif /* */
297 305
298 #ifndef AIRCRACK_NG_BYTE_ORDER 306#if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
299 #error Impossible to determine endianness (Little or Big endian), please contact the author. 307
300 #endif 308#ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED
301 309#define __be64_to_cpu(x) ___my_swab64(x)
302 #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) 310#define __be32_to_cpu(x) ___my_swab32(x)
303 311#define __be16_to_cpu(x) ___my_swab16(x)
304 #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED 312#define __cpu_to_be64(x) ___my_swab64(x)
305 #define __be64_to_cpu(x) ___my_swab64(x) 313#define __cpu_to_be32(x) ___my_swab32(x)
306 #define __be32_to_cpu(x) ___my_swab32(x) 314#define __cpu_to_be16(x) ___my_swab16(x)
307 #define __be16_to_cpu(x) ___my_swab16(x) 315#define __le64_to_cpu(x) (x)
308 #define __cpu_to_be64(x) ___my_swab64(x) 316#define __le32_to_cpu(x) (x)
309 #define __cpu_to_be32(x) ___my_swab32(x) 317#define __le16_to_cpu(x) (x)
310 #define __cpu_to_be16(x) ___my_swab16(x) 318#define __cpu_to_le64(x) (x)
311 #define __le64_to_cpu(x) (x) 319#define __cpu_to_le32(x) (x)
312 #define __le32_to_cpu(x) (x) 320#define __cpu_to_le16(x) (x)
313 #define __le16_to_cpu(x) (x) 321#endif /* */
314 #define __cpu_to_le64(x) (x) 322
315 #define __cpu_to_le32(x) (x) 323#ifndef htobe16
316 #define __cpu_to_le16(x) (x) 324#define htobe16 ___my_swab16
317 #endif 325#endif /* */
318 326#ifndef htobe32
319 #ifndef htobe16 327#define htobe32 ___my_swab32
320 #define htobe16 ___my_swab16 328#endif /* */
321 #endif 329#ifndef betoh16
322 #ifndef htobe32 330#define betoh16 ___my_swab16
323 #define htobe32 ___my_swab32 331#endif /* */
324 #endif 332#ifndef betoh32
325 #ifndef betoh16 333#define betoh32 ___my_swab32
326 #define betoh16 ___my_swab16 334#endif /* */
327 #endif 335
328 #ifndef betoh32 336#ifndef htole16
329 #define betoh32 ___my_swab32 337#define htole16(x) (x)
330 #endif 338#endif /* */
331 339#ifndef htole32
332 #ifndef htole16 340#define htole32(x) (x)
333 #define htole16(x) (x) 341#endif /* */
334 #endif 342#ifndef letoh16
335 #ifndef htole32 343#define letoh16(x) (x)
336 #define htole32(x) (x) 344#endif /* */
337 #endif 345#ifndef letoh32
338 #ifndef letoh16 346#define letoh32(x) (x)
339 #define letoh16(x) (x) 347#endif /* */
340 #endif 348
341 #ifndef letoh32 349#endif /* */
342 #define letoh32(x) (x) 350
343 #endif 351#if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
344 352
345 #endif 353#ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED
346 354#define __be64_to_cpu(x) (x)
347 #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) 355#define __be32_to_cpu(x) (x)
348 356#define __be16_to_cpu(x) (x)
349 #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED 357#define __cpu_to_be64(x) (x)
350 #define __be64_to_cpu(x) (x) 358#define __cpu_to_be32(x) (x)
351 #define __be32_to_cpu(x) (x) 359#define __cpu_to_be16(x) (x)
352 #define __be16_to_cpu(x) (x) 360#define __le64_to_cpu(x) ___my_swab64(x)
353 #define __cpu_to_be64(x) (x) 361#define __le32_to_cpu(x) ___my_swab32(x)
354 #define __cpu_to_be32(x) (x) 362#define __le16_to_cpu(x) ___my_swab16(x)
355 #define __cpu_to_be16(x) (x) 363#define __cpu_to_le64(x) ___my_swab64(x)
356 #define __le64_to_cpu(x) ___my_swab64(x) 364#define __cpu_to_le32(x) ___my_swab32(x)
357 #define __le32_to_cpu(x) ___my_swab32(x) 365#define __cpu_to_le16(x) ___my_swab16(x)
358 #define __le16_to_cpu(x) ___my_swab16(x) 366#endif /* */
359 #define __cpu_to_le64(x) ___my_swab64(x) 367
360 #define __cpu_to_le32(x) ___my_swab32(x) 368#ifndef htobe16
361 #define __cpu_to_le16(x) ___my_swab16(x) 369#define htobe16(x) (x)
362 #endif 370#endif /* */
363 371#ifndef htobe32
364 #ifndef htobe16 372#define htobe32(x) (x)
365 #define htobe16(x) (x) 373#endif /* */
366 #endif 374#ifndef betoh16
367 #ifndef htobe32 375#define betoh16(x) (x)
368 #define htobe32(x) (x) 376#endif /* */
369 #endif 377#ifndef betoh32
370 #ifndef betoh16 378#define betoh32(x) (x)
371 #define betoh16(x) (x) 379#endif /* */
372 #endif 380
373 #ifndef betoh32 381#ifndef htole16
374 #define betoh32(x) (x) 382#define htole16 ___my_swab16
375 #endif 383#endif /* */
376 384#ifndef htole32
377 #ifndef htole16 385#define htole32 ___my_swab32
378 #define htole16 ___my_swab16 386#endif /* */
379 #endif 387#ifndef letoh16
380 #ifndef htole32 388#define letoh16 ___my_swab16
381 #define htole32 ___my_swab32 389#endif /* */
382 #endif 390#ifndef letoh32
383 #ifndef letoh16 391#define letoh32 ___my_swab32
384 #define letoh16 ___my_swab16 392#endif /* */
385 #endif 393
386 #ifndef letoh32 394#endif /* */
387 #define letoh32 ___my_swab32 395
388 #endif 396 // Common defines
389 397#define cpu_to_le64 __cpu_to_le64
390 #endif 398#define le64_to_cpu __le64_to_cpu
391 399#define cpu_to_le32 __cpu_to_le32
392 // Common defines 400#define le32_to_cpu __le32_to_cpu
393 #define cpu_to_le64 __cpu_to_le64 401#define cpu_to_le16 __cpu_to_le16
394 #define le64_to_cpu __le64_to_cpu 402#define le16_to_cpu __le16_to_cpu
395 #define cpu_to_le32 __cpu_to_le32 403#define cpu_to_be64 __cpu_to_be64
396 #define le32_to_cpu __le32_to_cpu 404#define be64_to_cpu __be64_to_cpu
397 #define cpu_to_le16 __cpu_to_le16 405#define cpu_to_be32 __cpu_to_be32
398 #define le16_to_cpu __le16_to_cpu 406#define be32_to_cpu __be32_to_cpu
399 #define cpu_to_be64 __cpu_to_be64 407#define cpu_to_be16 __cpu_to_be16
400 #define be64_to_cpu __be64_to_cpu 408#define be16_to_cpu __be16_to_cpu
401 #define cpu_to_be32 __cpu_to_be32 409
402 #define be32_to_cpu __be32_to_cpu 410#ifndef le16toh
403 #define cpu_to_be16 __cpu_to_be16 411#define le16toh le16_to_cpu
404 #define be16_to_cpu __be16_to_cpu 412#endif /* */
405 413#ifndef be16toh
406 #ifndef le16toh 414#define be16toh be16_to_cpu
407 #define le16toh le16_to_cpu 415#endif /* */
408 #endif 416#ifndef le32toh
409 #ifndef be16toh 417#define le32toh le32_to_cpu
410 #define be16toh be16_to_cpu 418#endif /* */
411 #endif 419#ifndef be32toh
412 #ifndef le32toh 420#define be32toh be32_to_cpu
413 #define le32toh le32_to_cpu 421#endif /* */
414 #endif 422
415 #ifndef be32toh 423#ifndef htons
416 #define be32toh be32_to_cpu 424#define htons be16_to_cpu
417 #endif 425#endif /* */
418 426#ifndef htonl
419 427#define htonl cpu_to_be16
420 #ifndef htons 428#endif /* */
421 #define htons be16_to_cpu 429#ifndef ntohs
422 #endif 430#define ntohs cpu_to_be16
423 #ifndef htonl 431#endif /* */
424 #define htonl cpu_to_be16 432#ifndef ntohl
425 #endif 433#define ntohl cpu_to_be32
426 #ifndef ntohs 434#endif /* */
427 #define ntohs cpu_to_be16 435
428 #endif 436#endif /* */
429 #ifndef ntohl
430 #define ntohl cpu_to_be32
431 #endif
432
433#endif