-/*\r
- * Compatibility header\r
- *\r
- * Copyright (C) 2009 Thomas d'Otreppe\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- */\r
-\r
-#ifndef _AIRCRACK_NG_BYTEORDER_H_\r
-#define _AIRCRACK_NG_BYTEORDER_H_\r
-\r
- #define ___my_swab16(x) \\r
- ((u_int16_t)( \\r
- (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \\r
- (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) ))\r
- #define ___my_swab32(x) \\r
- ((u_int32_t)( \\r
- (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \\r
- (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) << 8) | \\r
- (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >> 8) | \\r
- (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) ))\r
- #define ___my_swab64(x) \\r
- ((u_int64_t)( \\r
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \\r
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \\r
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \\r
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) << 8) | \\r
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >> 8) | \\r
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \\r
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \\r
- (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) ))\r
-\r
-\r
- /*\r
- * Linux\r
- */\r
- #if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__)\r
- #include <endian.h>\r
- #include <unistd.h>\r
- #include <stdint.h>\r
-\r
- #ifndef __int8_t_defined\r
- typedef uint64_t u_int64_t;\r
- typedef uint32_t u_int32_t;\r
- typedef uint16_t u_int16_t;\r
- typedef uint8_t u_int8_t;\r
- #endif\r
-\r
- #endif\r
-\r
- /*\r
- * Cygwin\r
- */\r
- #if defined(__CYGWIN32__)\r
- #include <asm/byteorder.h>\r
- #include <unistd.h>\r
-\r
- #define __be64_to_cpu(x) ___my_swab64(x)\r
- #define __be32_to_cpu(x) ___my_swab32(x)\r
- #define __be16_to_cpu(x) ___my_swab16(x)\r
- #define __cpu_to_be64(x) ___my_swab64(x)\r
- #define __cpu_to_be32(x) ___my_swab32(x)\r
- #define __cpu_to_be16(x) ___my_swab16(x)\r
- #define __le64_to_cpu(x) (x)\r
- #define __le32_to_cpu(x) (x)\r
- #define __le16_to_cpu(x) (x)\r
- #define __cpu_to_le64(x) (x)\r
- #define __cpu_to_le32(x) (x)\r
- #define __cpu_to_le16(x) (x)\r
-\r
- #define AIRCRACK_NG_BYTE_ORDER_DEFINED\r
-\r
- #endif\r
-\r
- /*\r
- * Windows (DDK)\r
- */\r
- #if defined(__WIN__)\r
-\r
- #include <io.h>\r
-\r
- #define __be64_to_cpu(x) ___my_swab64(x)\r
- #define __be32_to_cpu(x) ___my_swab32(x)\r
- #define __be16_to_cpu(x) ___my_swab16(x)\r
- #define __cpu_to_be64(x) ___my_swab64(x)\r
- #define __cpu_to_be32(x) ___my_swab32(x)\r
- #define __cpu_to_be16(x) ___my_swab16(x)\r
- #define __le64_to_cpu(x) (x)\r
- #define __le32_to_cpu(x) (x)\r
- #define __le16_to_cpu(x) (x)\r
- #define __cpu_to_le64(x) (x)\r
- #define __cpu_to_le32(x) (x)\r
- #define __cpu_to_le16(x) (x)\r
-\r
- #define AIRCRACK_NG_BYTE_ORDER_DEFINED\r
-\r
- #endif\r
-\r
- /*\r
- * MAC (Darwin)\r
- */\r
- #if defined(__APPLE_CC__)\r
- #if defined(__x86_64__) && defined(__APPLE__)\r
-\r
- #include <libkern/OSByteOrder.h>\r
-\r
- #define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t)x)\r
- #define __swab32(x) (unsigned long) OSSwapInt32((uint32_t)x)\r
- #define __swab16(x) (unsigned short) OSSwapInt16((uint16_t)x)\r
- #define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t)x)\r
- #define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t)x)\r
- #define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t)x)\r
- #define __le64_to_cpu(x) (unsigned long long) OSSwapLittleToHostInt64((uint64_t)x)\r
- #define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t)x)\r
- #define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t)x)\r
- #define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t)x)\r
- #define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t)x)\r
- #define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t)x)\r
- #define __cpu_to_le64(x) (unsigned long long) OSSwapHostToLittleInt64((uint64_t)x)\r
- #define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t)x)\r
- #define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t)x)\r
-\r
- #else\r
-\r
- #include <architecture/byte_order.h>\r
-\r
- #define __swab64(x) NXSwapLongLong(x)\r
- #define __swab32(x) NXSwapLong(x)\r
- #define __swab16(x) NXSwapShort(x)\r
- #define __be64_to_cpu(x) NXSwapBigLongLongToHost(x)\r
- #define __be32_to_cpu(x) NXSwapBigLongToHost(x)\r
- #define __be16_to_cpu(x) NXSwapBigShortToHost(x)\r
- #define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x)\r
- #define __le32_to_cpu(x) NXSwapLittleLongToHost(x)\r
- #define __le16_to_cpu(x) NXSwapLittleShortToHost(x)\r
- #define __cpu_to_be64(x) NXSwapHostLongLongToBig(x)\r
- #define __cpu_to_be32(x) NXSwapHostLongToBig(x)\r
- #define __cpu_to_be16(x) NXSwapHostShortToBig(x)\r
- #define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x)\r
- #define __cpu_to_le32(x) NXSwapHostLongToLittle(x)\r
- #define __cpu_to_le16(x) NXSwapHostShortToLittle(x)\r
-\r
- #endif\r
-\r
- #define __LITTLE_ENDIAN 1234\r
- #define __BIG_ENDIAN 4321\r
- #define __PDP_ENDIAN 3412\r
- #define __BYTE_ORDER __BIG_ENDIAN\r
-\r
- #define AIRCRACK_NG_BYTE_ORDER_DEFINED\r
-\r
- #endif\r
-\r
- /*\r
- * Solaris\r
- * -------\r
- */\r
- #if defined(__sparc__)\r
- #include <sys/byteorder.h>\r
- #include <sys/types.h>\r
- #include <unistd.h>\r
-\r
- #define __be64_to_cpu(x) (x)\r
- #define __be32_to_cpu(x) (x)\r
- #define __be16_to_cpu(x) (x)\r
- #define __cpu_to_be64(x) (x)\r
- #define __cpu_to_be32(x) (x)\r
- #define __cpu_to_be16(x) (x)\r
- #define __le64_to_cpu(x) ___my_swab64(x)\r
- #define __le32_to_cpu(x) ___my_swab32(x)\r
- #define __le16_to_cpu(x) ___my_swab16(x)\r
- #define __cpu_to_le64(x) ___my_swab64(x)\r
- #define __cpu_to_le32(x) ___my_swab32(x)\r
- #define __cpu_to_le16(x) ___my_swab16(x)\r
-\r
- typedef uint64_t u_int64_t;\r
- typedef uint32_t u_int32_t;\r
- typedef uint16_t u_int16_t;\r
- typedef uint8_t u_int8_t;\r
-\r
- #define AIRCRACK_NG_BYTE_ORDER_DEFINED\r
-\r
- #endif\r
-\r
- /*\r
- * Custom stuff\r
- */\r
- #if defined(__MACH__) && !defined(__APPLE_CC__)\r
- #include <libkern/OSByteOrder.h>\r
- #define __cpu_to_be64(x) = OSSwapHostToBigInt64(x)\r
- #define __cpu_to_be32(x) = OSSwapHostToBigInt32(x)\r
-\r
- #define AIRCRACK_NG_BYTE_ORDER_DEFINED\r
-\r
- #endif\r
-\r
-\r
- // FreeBSD\r
- #ifdef __FreeBSD__\r
- #include <machine/endian.h>\r
- #endif\r
-\r
- // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...?\r
-\r
-\r
- // XXX: Mac: Check http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h\r
- // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html\r
- // Write to apple to ask what should be used.\r
-\r
- #if defined(LITTLE_ENDIAN)\r
- #define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN\r
- #elif defined(__LITTLE_ENDIAN)\r
- #define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN\r
- #elif defined(_LITTLE_ENDIAN)\r
- #define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN\r
- #endif\r
-\r
- #if defined(BIG_ENDIAN)\r
- #define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN\r
- #elif defined(__BIG_ENDIAN)\r
- #define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN\r
- #elif defined(_BIG_ENDIAN)\r
- #define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN\r
- #endif\r
-\r
- #if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN)\r
- #error Impossible to determine endianness (Little or Big endian), please contact the author.\r
- #endif\r
-\r
- #if defined(BYTE_ORDER)\r
- #if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)\r
- #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN\r
- #elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)\r
- #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN\r
- #endif\r
- #elif defined(__BYTE_ORDER)\r
- #if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)\r
- #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN\r
- #elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)\r
- #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN\r
- #endif\r
- #elif defined(_BYTE_ORDER)\r
- #if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)\r
- #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN\r
- #elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)\r
- #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN\r
- #endif\r
- #endif\r
-\r
- #ifndef AIRCRACK_NG_BYTE_ORDER\r
- #error Impossible to determine endianness (Little or Big endian), please contact the author.\r
- #endif\r
-\r
- #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)\r
-\r
- #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED\r
- #define __be64_to_cpu(x) ___my_swab64(x)\r
- #define __be32_to_cpu(x) ___my_swab32(x)\r
- #define __be16_to_cpu(x) ___my_swab16(x)\r
- #define __cpu_to_be64(x) ___my_swab64(x)\r
- #define __cpu_to_be32(x) ___my_swab32(x)\r
- #define __cpu_to_be16(x) ___my_swab16(x)\r
- #define __le64_to_cpu(x) (x)\r
- #define __le32_to_cpu(x) (x)\r
- #define __le16_to_cpu(x) (x)\r
- #define __cpu_to_le64(x) (x)\r
- #define __cpu_to_le32(x) (x)\r
- #define __cpu_to_le16(x) (x)\r
- #endif\r
-\r
- #ifndef htobe16\r
- #define htobe16 ___my_swab16\r
- #endif\r
- #ifndef htobe32\r
- #define htobe32 ___my_swab32\r
- #endif\r
- #ifndef betoh16\r
- #define betoh16 ___my_swab16\r
- #endif\r
- #ifndef betoh32\r
- #define betoh32 ___my_swab32\r
- #endif\r
-\r
- #ifndef htole16\r
- #define htole16(x) (x)\r
- #endif\r
- #ifndef htole32\r
- #define htole32(x) (x)\r
- #endif\r
- #ifndef letoh16\r
- #define letoh16(x) (x)\r
- #endif\r
- #ifndef letoh32\r
- #define letoh32(x) (x)\r
- #endif\r
-\r
- #endif\r
-\r
- #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)\r
-\r
- #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED\r
- #define __be64_to_cpu(x) (x)\r
- #define __be32_to_cpu(x) (x)\r
- #define __be16_to_cpu(x) (x)\r
- #define __cpu_to_be64(x) (x)\r
- #define __cpu_to_be32(x) (x)\r
- #define __cpu_to_be16(x) (x)\r
- #define __le64_to_cpu(x) ___my_swab64(x)\r
- #define __le32_to_cpu(x) ___my_swab32(x)\r
- #define __le16_to_cpu(x) ___my_swab16(x)\r
- #define __cpu_to_le64(x) ___my_swab64(x)\r
- #define __cpu_to_le32(x) ___my_swab32(x)\r
- #define __cpu_to_le16(x) ___my_swab16(x)\r
- #endif\r
-\r
- #ifndef htobe16\r
- #define htobe16(x) (x)\r
- #endif\r
- #ifndef htobe32\r
- #define htobe32(x) (x)\r
- #endif\r
- #ifndef betoh16\r
- #define betoh16(x) (x)\r
- #endif\r
- #ifndef betoh32\r
- #define betoh32(x) (x)\r
- #endif\r
-\r
- #ifndef htole16\r
- #define htole16 ___my_swab16\r
- #endif\r
- #ifndef htole32\r
- #define htole32 ___my_swab32\r
- #endif\r
- #ifndef letoh16\r
- #define letoh16 ___my_swab16\r
- #endif\r
- #ifndef letoh32\r
- #define letoh32 ___my_swab32\r
- #endif\r
-\r
- #endif\r
-\r
- // Common defines\r
- #define cpu_to_le64 __cpu_to_le64\r
- #define le64_to_cpu __le64_to_cpu\r
- #define cpu_to_le32 __cpu_to_le32\r
- #define le32_to_cpu __le32_to_cpu\r
- #define cpu_to_le16 __cpu_to_le16\r
- #define le16_to_cpu __le16_to_cpu\r
- #define cpu_to_be64 __cpu_to_be64\r
- #define be64_to_cpu __be64_to_cpu\r
- #define cpu_to_be32 __cpu_to_be32\r
- #define be32_to_cpu __be32_to_cpu\r
- #define cpu_to_be16 __cpu_to_be16\r
- #define be16_to_cpu __be16_to_cpu\r
-\r
- #ifndef le16toh\r
- #define le16toh le16_to_cpu\r
- #endif\r
- #ifndef be16toh\r
- #define be16toh be16_to_cpu\r
- #endif\r
- #ifndef le32toh\r
- #define le32toh le32_to_cpu\r
- #endif\r
- #ifndef be32toh\r
- #define be32toh be32_to_cpu\r
- #endif\r
-\r
-\r
- #ifndef htons\r
- #define htons be16_to_cpu\r
- #endif\r
- #ifndef htonl\r
- #define htonl cpu_to_be16\r
- #endif\r
- #ifndef ntohs\r
- #define ntohs cpu_to_be16\r
- #endif\r
- #ifndef ntohl\r
- #define ntohl cpu_to_be32\r
- #endif\r
-\r
-#endif\r
+/*
+ * Compatibility header
+ *
+ * Copyright (C) 2009 Thomas d'Otreppe
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _AIRCRACK_NG_BYTEORDER_H_
+#define _AIRCRACK_NG_BYTEORDER_H_
+
+ /* *INDENT-OFF* */
+#define ___my_swab16(x) \
+((u_int16_t)( \
+ (((u_int16_t)(x) & (u_int16_t)0x00ffU) << 8) | \
+ (((u_int16_t)(x) & (u_int16_t)0xff00U) >> 8) ))
+
+#define ___my_swab32(x) \
+((u_int32_t)( \
+ (((u_int32_t)(x) & (u_int32_t)0x000000ffUL) << 24) | \
+ (((u_int32_t)(x) & (u_int32_t)0x0000ff00UL) << 8) | \
+ (((u_int32_t)(x) & (u_int32_t)0x00ff0000UL) >> 8) | \
+ (((u_int32_t)(x) & (u_int32_t)0xff000000UL) >> 24) ))
+#define ___my_swab64(x) \
+((u_int64_t)( \
+ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000000000ffULL) << 56) | \
+ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000000000ff00ULL) << 40) | \
+ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000000000ff0000ULL) << 24) | \
+ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00000000ff000000ULL) << 8) | \
+ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x000000ff00000000ULL) >> 8) | \
+ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x0000ff0000000000ULL) >> 24) | \
+ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0x00ff000000000000ULL) >> 40) | \
+ (u_int64_t)(((u_int64_t)(x) & (u_int64_t)0xff00000000000000ULL) >> 56) ))
+ /* *INDENT-ON* */
+ /*
+ * Linux
+ */
+#if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
+#include <endian.h>
+#include <unistd.h>
+#include <stdint.h>
+
+#ifndef __int8_t_defined
+typedef uint64_t u_int64_t;
+typedef uint32_t u_int32_t;
+typedef uint16_t u_int16_t;
+typedef uint8_t u_int8_t;
+
+
+#endif /* */
+
+#ifndef htole16
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define htobe16(x) ___my_swab16 (x)
+#define htole16(x) (x)
+#define be16toh(x) ___my_swab16 (x)
+#define le16toh(x) (x)
+
+#define htobe32(x) ___my_swab32 (x)
+#define htole32(x) (x)
+#define be32toh(x) ___my_swab32 (x)
+#define le32toh(x) (x)
+
+#define htobe64(x) ___my_swab64 (x)
+#define htole64(x) (x)
+#define be64toh(x) ___my_swab64 (x)
+#define le64toh(x) (x)
+#else /* */
+#define htobe16(x) (x)
+#define htole16(x) ___my_swab16 (x)
+#define be16toh(x) (x)
+#define le16toh(x) ___my_swab16 (x)
+
+#define htobe32(x) (x)
+#define htole32(x) ___my_swab32 (x)
+#define be32toh(x) (x)
+#define le32toh(x) ___my_swab32 (x)
+
+#define htobe64(x) (x)
+#define htole64(x) ___my_swab64 (x)
+#define be64toh(x) (x)
+#define le64toh(x) ___my_swab64 (x)
+#endif /* */
+#endif /* */
+
+#endif /* */
+ /*
+ * Cygwin
+ */
+#if defined(__CYGWIN32__)
+#include <asm/byteorder.h>
+#include <unistd.h>
+#define __be64_to_cpu(x) ___my_swab64(x)
+#define __be32_to_cpu(x) ___my_swab32(x)
+#define __be16_to_cpu(x) ___my_swab16(x)
+#define __cpu_to_be64(x) ___my_swab64(x)
+#define __cpu_to_be32(x) ___my_swab32(x)
+#define __cpu_to_be16(x) ___my_swab16(x)
+#define __le64_to_cpu(x) (x)
+#define __le32_to_cpu(x) (x)
+#define __le16_to_cpu(x) (x)
+#define __cpu_to_le64(x) (x)
+#define __cpu_to_le32(x) (x)
+#define __cpu_to_le16(x) (x)
+#define AIRCRACK_NG_BYTE_ORDER_DEFINED
+#endif /* */
+ /*
+ * Windows (DDK)
+ */
+#if defined(__WIN__)
+#include <io.h>
+#define __be64_to_cpu(x) ___my_swab64(x)
+#define __be32_to_cpu(x) ___my_swab32(x)
+#define __be16_to_cpu(x) ___my_swab16(x)
+#define __cpu_to_be64(x) ___my_swab64(x)
+#define __cpu_to_be32(x) ___my_swab32(x)
+#define __cpu_to_be16(x) ___my_swab16(x)
+#define __le64_to_cpu(x) (x)
+#define __le32_to_cpu(x) (x)
+#define __le16_to_cpu(x) (x)
+#define __cpu_to_le64(x) (x)
+#define __cpu_to_le32(x) (x)
+#define __cpu_to_le16(x) (x)
+#define AIRCRACK_NG_BYTE_ORDER_DEFINED
+#endif /* */
+ /*
+ * MAC (Darwin)
+ */
+#if defined(__APPLE_CC__)
+#if defined(__x86_64__) && defined(__APPLE__)
+#include <libkern/OSByteOrder.h>
+#define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t)x)
+#define __swab32(x) (unsigned long) OSSwapInt32((uint32_t)x)
+#define __swab16(x) (unsigned short) OSSwapInt16((uint16_t)x)
+#define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t)x)
+#define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t)x)
+#define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t)x)
+#define __le64_to_cpu(x) (unsigned long long) OSSwapLittleToHostInt64((uint64_t)x)
+#define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t)x)
+#define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t)x)
+#define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t)x)
+#define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t)x)
+#define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t)x)
+#define __cpu_to_le64(x) (unsigned long long) OSSwapHostToLittleInt64((uint64_t)x)
+#define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t)x)
+#define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t)x)
+#else /* */
+#include <architecture/byte_order.h>
+#define __swab64(x) NXSwapLongLong(x)
+#define __swab32(x) NXSwapLong(x)
+#define __swab16(x) NXSwapShort(x)
+#define __be64_to_cpu(x) NXSwapBigLongLongToHost(x)
+#define __be32_to_cpu(x) NXSwapBigLongToHost(x)
+#define __be16_to_cpu(x) NXSwapBigShortToHost(x)
+#define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x)
+#define __le32_to_cpu(x) NXSwapLittleLongToHost(x)
+#define __le16_to_cpu(x) NXSwapLittleShortToHost(x)
+#define __cpu_to_be64(x) NXSwapHostLongLongToBig(x)
+#define __cpu_to_be32(x) NXSwapHostLongToBig(x)
+#define __cpu_to_be16(x) NXSwapHostShortToBig(x)
+#define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x)
+#define __cpu_to_le32(x) NXSwapHostLongToLittle(x)
+#define __cpu_to_le16(x) NXSwapHostShortToLittle(x)
+#endif /* */
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+#define __BYTE_ORDER __BIG_ENDIAN
+#define AIRCRACK_NG_BYTE_ORDER_DEFINED
+#endif /* */
+ /*
+ * Solaris
+ * -------
+ */
+#if defined(__sparc__) && defined(__sun__)
+#include <sys/byteorder.h>
+#include <sys/types.h>
+#include <unistd.h>
+#define __be64_to_cpu(x) (x)
+#define __be32_to_cpu(x) (x)
+#define __be16_to_cpu(x) (x)
+#define __cpu_to_be64(x) (x)
+#define __cpu_to_be32(x) (x)
+#define __cpu_to_be16(x) (x)
+#define __le64_to_cpu(x) ___my_swab64(x)
+#define __le32_to_cpu(x) ___my_swab32(x)
+#define __le16_to_cpu(x) ___my_swab16(x)
+#define __cpu_to_le64(x) ___my_swab64(x)
+#define __cpu_to_le32(x) ___my_swab32(x)
+#define __cpu_to_le16(x) ___my_swab16(x)
+typedef uint64_t u_int64_t;
+typedef uint32_t u_int32_t;
+typedef uint16_t u_int16_t;
+typedef uint8_t u_int8_t;
+
+
+#define AIRCRACK_NG_BYTE_ORDER_DEFINED
+#endif /* */
+ /*
+ * Custom stuff
+ */
+#if defined(__MACH__) && !defined(__APPLE_CC__)
+#include <libkern/OSByteOrder.h>
+#define __cpu_to_be64(x) = OSSwapHostToBigInt64(x)
+#define __cpu_to_be32(x) = OSSwapHostToBigInt32(x)
+#define AIRCRACK_NG_BYTE_ORDER_DEFINED
+#endif /* */
+
+ // FreeBSD
+#ifdef __FreeBSD__
+#include <machine/endian.h>
+#endif /* */
+ // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...?
+
+ // XXX: Mac: Check http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h
+ // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html
+ // Write to apple to ask what should be used.
+#if defined(LITTLE_ENDIAN)
+#define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN
+#elif defined(__LITTLE_ENDIAN)
+#define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN
+#elif defined(_LITTLE_ENDIAN)
+#define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN
+#endif /* */
+#if defined(BIG_ENDIAN)
+#define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN
+#elif defined(__BIG_ENDIAN)
+#define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN
+#elif defined(_BIG_ENDIAN)
+#define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN
+#endif /* */
+#if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN)
+#error Impossible to determine endianness (Little or Big endian), please contact the author.
+#endif /* */
+#if defined(BYTE_ORDER)
+#if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
+#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
+#elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
+#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
+#endif /* */
+#elif defined(__BYTE_ORDER)
+#if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
+#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
+#elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
+#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
+#endif /* */
+#elif defined(_BYTE_ORDER)
+#if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
+#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN
+#elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
+#define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN
+#endif /* */
+#endif /* */
+#ifndef AIRCRACK_NG_BYTE_ORDER
+#error Impossible to determine endianness (Little or Big endian), please contact the author.
+#endif /* */
+#if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN)
+#ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED
+#define __be64_to_cpu(x) ___my_swab64(x)
+#define __be32_to_cpu(x) ___my_swab32(x)
+#define __be16_to_cpu(x) ___my_swab16(x)
+#define __cpu_to_be64(x) ___my_swab64(x)
+#define __cpu_to_be32(x) ___my_swab32(x)
+#define __cpu_to_be16(x) ___my_swab16(x)
+#define __le64_to_cpu(x) (x)
+#define __le32_to_cpu(x) (x)
+#define __le16_to_cpu(x) (x)
+#define __cpu_to_le64(x) (x)
+#define __cpu_to_le32(x) (x)
+#define __cpu_to_le16(x) (x)
+#endif /* */
+#ifndef htobe16
+#define htobe16 ___my_swab16
+#endif /* */
+#ifndef htobe32
+#define htobe32 ___my_swab32
+#endif /* */
+#ifndef betoh16
+#define betoh16 ___my_swab16
+#endif /* */
+#ifndef betoh32
+#define betoh32 ___my_swab32
+#endif /* */
+#ifndef htole16
+#define htole16(x) (x)
+#endif /* */
+#ifndef htole32
+#define htole32(x) (x)
+#endif /* */
+#ifndef letoh16
+#define letoh16(x) (x)
+#endif /* */
+#ifndef letoh32
+#define letoh32(x) (x)
+#endif /* */
+#endif /* */
+#if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN)
+#ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED
+#define __be64_to_cpu(x) (x)
+#define __be32_to_cpu(x) (x)
+#define __be16_to_cpu(x) (x)
+#define __cpu_to_be64(x) (x)
+#define __cpu_to_be32(x) (x)
+#define __cpu_to_be16(x) (x)
+#define __le64_to_cpu(x) ___my_swab64(x)
+#define __le32_to_cpu(x) ___my_swab32(x)
+#define __le16_to_cpu(x) ___my_swab16(x)
+#define __cpu_to_le64(x) ___my_swab64(x)
+#define __cpu_to_le32(x) ___my_swab32(x)
+#define __cpu_to_le16(x) ___my_swab16(x)
+#endif /* */
+#ifndef htobe16
+#define htobe16(x) (x)
+#endif /* */
+#ifndef htobe32
+#define htobe32(x) (x)
+#endif /* */
+#ifndef betoh16
+#define betoh16(x) (x)
+#endif /* */
+#ifndef betoh32
+#define betoh32(x) (x)
+#endif /* */
+#ifndef htole16
+#define htole16 ___my_swab16
+#endif /* */
+#ifndef htole32
+#define htole32 ___my_swab32
+#endif /* */
+#ifndef letoh16
+#define letoh16 ___my_swab16
+#endif /* */
+#ifndef letoh32
+#define letoh32 ___my_swab32
+#endif /* */
+#endif /* */
+ // Common defines
+#define cpu_to_le64 __cpu_to_le64
+#define le64_to_cpu __le64_to_cpu
+#define cpu_to_le32 __cpu_to_le32
+#define le32_to_cpu __le32_to_cpu
+#define cpu_to_le16 __cpu_to_le16
+#define le16_to_cpu __le16_to_cpu
+#define cpu_to_be64 __cpu_to_be64
+#define be64_to_cpu __be64_to_cpu
+#define cpu_to_be32 __cpu_to_be32
+#define be32_to_cpu __be32_to_cpu
+#define cpu_to_be16 __cpu_to_be16
+#define be16_to_cpu __be16_to_cpu
+#ifndef le16toh
+#define le16toh le16_to_cpu
+#endif /* */
+#ifndef be16toh
+#define be16toh be16_to_cpu
+#endif /* */
+#ifndef le32toh
+#define le32toh le32_to_cpu
+#endif /* */
+#ifndef be32toh
+#define be32toh be32_to_cpu
+#endif /* */
+
+#ifndef htons
+#define htons be16_to_cpu
+#endif /* */
+#ifndef htonl
+#define htonl cpu_to_be16
+#endif /* */
+#ifndef ntohs
+#define ntohs cpu_to_be16
+#endif /* */
+#ifndef ntohl
+#define ntohl cpu_to_be32
+#endif /* */
+#endif /* */