20 #if defined(__linux__) || defined(__GLIBC__)
25 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
27 #include <sys/types.h>
28 #include <sys/endian.h>
29 #define __BYTE_ORDER _BYTE_ORDER
30 #define __LITTLE_ENDIAN _LITTLE_ENDIAN
31 #define __BIG_ENDIAN _BIG_ENDIAN
33 #define bswap_16 swap16
34 #define bswap_32 swap32
35 #define bswap_64 swap64
37 #define bswap_16 bswap16
38 #define bswap_32 bswap32
39 #define bswap_64 bswap64
45 #include <sys/types.h>
46 #include <machine/endian.h>
47 #define __BYTE_ORDER _BYTE_ORDER
48 #define __LITTLE_ENDIAN _LITTLE_ENDIAN
49 #define __BIG_ENDIAN _BIG_ENDIAN
50 static inline unsigned short bswap_16(
unsigned short v)
52 return ((v & 0xff) << 8) | (v >> 8);
55 static inline unsigned int bswap_32(
unsigned int v)
57 return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
58 ((v & 0xff0000) >> 8) | (v >> 24);
62 #ifdef CONFIG_TI_COMPILER
63 #define __BIG_ENDIAN 4321
64 #define __LITTLE_ENDIAN 1234
66 #define __BYTE_ORDER __BIG_ENDIAN
68 #define __BYTE_ORDER __LITTLE_ENDIAN
73 #define __BIG_ENDIAN 4321
74 #define __LITTLE_ENDIAN 1234
75 #define __BYTE_ORDER __LITTLE_ENDIAN
78 #ifdef CONFIG_NATIVE_WINDOWS
81 typedef int socklen_t;
84 #define MSG_DONTWAIT 0
90 #define inline __inline
93 #define vsnprintf _vsnprintf
95 #define close closesocket
110 #define WPA_TYPES_DEFINED
114 typedef unsigned long long u64;
118 typedef long long s64;
122 #define WPA_TYPES_DEFINED
125 #ifdef CONFIG_TI_COMPILER
126 #ifdef _LLONG_AVAILABLE
127 typedef unsigned long long u64;
133 typedef unsigned long u64;
135 typedef unsigned int u32;
136 typedef unsigned short u16;
137 typedef unsigned char u8;
138 #define WPA_TYPES_DEFINED
142 #define __REMOVE_PLATSEC_DIAGNOSTICS__
148 #define WPA_TYPES_DEFINED
151 #ifndef WPA_TYPES_DEFINED
152 #ifdef CONFIG_USE_INTTYPES_H
153 #include <inttypes.h>
165 #define WPA_TYPES_DEFINED
171 #if defined(__CYGWIN__) || defined(CONFIG_NATIVE_WINDOWS)
173 static inline unsigned short wpa_swap_16(
unsigned short v)
175 return ((v & 0xff) << 8) | (v >> 8);
178 static inline unsigned int wpa_swap_32(
unsigned int v)
180 return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
181 ((v & 0xff0000) >> 8) | (v >> 24);
184 #define le_to_host16(n) (n)
185 #define host_to_le16(n) (n)
186 #define be_to_host16(n) wpa_swap_16(n)
187 #define host_to_be16(n) wpa_swap_16(n)
188 #define le_to_host32(n) (n)
189 #define be_to_host32(n) wpa_swap_32(n)
190 #define host_to_be32(n) wpa_swap_32(n)
192 #define WPA_BYTE_SWAP_DEFINED
197 #ifndef WPA_BYTE_SWAP_DEFINED
200 #ifndef __LITTLE_ENDIAN
202 #define __LITTLE_ENDIAN 1234
203 #define __BIG_ENDIAN 4321
205 #define __BYTE_ORDER __BIG_ENDIAN
211 #if __BYTE_ORDER == __LITTLE_ENDIAN
212 #define le_to_host16(n) ((__force u16) (le16) (n))
213 #define host_to_le16(n) ((__force le16) (u16) (n))
214 #define be_to_host16(n) bswap_16((__force u16) (be16) (n))
215 #define host_to_be16(n) ((__force be16) bswap_16((n)))
216 #define le_to_host32(n) ((__force u32) (le32) (n))
217 #define host_to_le32(n) ((__force le32) (u32) (n))
218 #define be_to_host32(n) bswap_32((__force u32) (be32) (n))
219 #define host_to_be32(n) ((__force be32) bswap_32((n)))
220 #define le_to_host64(n) ((__force u64) (le64) (n))
221 #define host_to_le64(n) ((__force le64) (u64) (n))
222 #define be_to_host64(n) bswap_64((__force u64) (be64) (n))
223 #define host_to_be64(n) ((__force be64) bswap_64((n)))
224 #elif __BYTE_ORDER == __BIG_ENDIAN
225 #define le_to_host16(n) bswap_16(n)
226 #define host_to_le16(n) bswap_16(n)
227 #define be_to_host16(n) (n)
228 #define host_to_be16(n) (n)
229 #define le_to_host32(n) bswap_32(n)
230 #define be_to_host32(n) (n)
231 #define host_to_be32(n) (n)
232 #define le_to_host64(n) bswap_64(n)
233 #define host_to_le64(n) bswap_64(n)
234 #define be_to_host64(n) (n)
235 #define host_to_be64(n) (n)
236 #ifndef WORDS_BIGENDIAN
237 #define WORDS_BIGENDIAN
240 #error Could not determine CPU byte order
243 #define WPA_BYTE_SWAP_DEFINED
249 #define WPA_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
250 #define WPA_PUT_BE16(a, val) \
252 (a)[0] = ((u16) (val)) >> 8; \
253 (a)[1] = ((u16) (val)) & 0xff; \
256 #define WPA_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
257 #define WPA_PUT_LE16(a, val) \
259 (a)[1] = ((u16) (val)) >> 8; \
260 (a)[0] = ((u16) (val)) & 0xff; \
263 #define WPA_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
265 #define WPA_PUT_BE24(a, val) \
267 (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \
268 (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
269 (a)[2] = (u8) (((u32) (val)) & 0xff); \
272 #define WPA_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
273 (((u32) (a)[2]) << 8) | ((u32) (a)[3]))
274 #define WPA_PUT_BE32(a, val) \
276 (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
277 (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
278 (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
279 (a)[3] = (u8) (((u32) (val)) & 0xff); \
282 #define WPA_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \
283 (((u32) (a)[1]) << 8) | ((u32) (a)[0]))
284 #define WPA_PUT_LE32(a, val) \
286 (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \
287 (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \
288 (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
289 (a)[0] = (u8) (((u32) (val)) & 0xff); \
292 #define WPA_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \
293 (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \
294 (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \
295 (((u64) (a)[6]) << 8) | ((u64) (a)[7]))
296 #define WPA_PUT_BE64(a, val) \
298 (a)[0] = (u8) (((u64) (val)) >> 56); \
299 (a)[1] = (u8) (((u64) (val)) >> 48); \
300 (a)[2] = (u8) (((u64) (val)) >> 40); \
301 (a)[3] = (u8) (((u64) (val)) >> 32); \
302 (a)[4] = (u8) (((u64) (val)) >> 24); \
303 (a)[5] = (u8) (((u64) (val)) >> 16); \
304 (a)[6] = (u8) (((u64) (val)) >> 8); \
305 (a)[7] = (u8) (((u64) (val)) & 0xff); \
308 #define WPA_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \
309 (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \
310 (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \
311 (((u64) (a)[1]) << 8) | ((u64) (a)[0]))
321 #define ETH_P_ALL 0x0003
324 #define ETH_P_PAE 0x888E
327 #define ETH_P_EAPOL ETH_P_PAE
329 #ifndef ETH_P_RSN_PREAUTH
330 #define ETH_P_RSN_PREAUTH 0x88c7
333 #define ETH_P_RRB 0x890D
338 #define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b))))
339 #define STRUCT_PACKED __attribute__ ((packed))
341 #define PRINTF_FORMAT(a,b)
342 #define STRUCT_PACKED
346 #ifdef CONFIG_ANSI_C_EXTRA
348 #if !defined(_MSC_VER) || _MSC_VER < 1400
353 int snprintf(
char *str,
size_t size,
const char *format, ...);
356 int vsnprintf(
char *str,
size_t size,
const char *format, va_list ap);
360 int getopt(
int argc,
char *
const argv[],
const char *optstring);
364 #ifndef CONFIG_NO_SOCKLEN_T_TYPEDEF
365 #ifndef __socklen_t_defined
366 typedef int socklen_t;
371 #ifdef CONFIG_NO_INLINE
374 #define inline __inline
378 #define __func__ "__func__ not defined"
382 #define bswap_16(a) ((((u16) (a) << 8) & 0xff00) | (((u16) (a) >> 8) & 0xff))
386 #define bswap_32(a) ((((u32) (a) << 24) & 0xff000000) | \
387 (((u32) (a) << 8) & 0xff0000) | \
388 (((u32) (a) >> 8) & 0xff00) | \
389 (((u32) (a) >> 24) & 0xff))
393 #define MSG_DONTWAIT 0
397 void perror(
const char *s);
403 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
404 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
408 #define BIT(x) (1 << (x))
416 #define __force __attribute__((force))
417 #define __bitwise __attribute__((bitwise))
431 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
432 #define __must_check __attribute__((__warn_unused_result__))
440 int hexstr2bin(
const char *hex, u8 *buf,
size_t len);
443 int wpa_snprintf_hex(
char *buf,
size_t buf_size,
const u8 *data,
size_t len);
447 #ifdef CONFIG_NATIVE_WINDOWS
451 #define wpa_unicode2ascii_inplace(s) do { } while (0)
452 #define wpa_strdup_tchar(s) strdup((s))
455 const char *
wpa_ssid_txt(
const u8 *ssid,
size_t ssid_len);
457 static inline int is_zero_ether_addr(
const u8 *a)
459 return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
475 #define aliasing_hide_typecast(a,t) (t *) __hide_aliasing_typecast((a))
int wpa_snprintf_hex_uppercase(char *buf, size_t buf_size, const u8 *data, size_t len)
#define wpa_strdup_tchar(s)
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len)
void inc_byte_array(u8 *counter, size_t len)
void * __hide_aliasing_typecast(void *foo)
#define wpa_unicode2ascii_inplace(s)
int wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data, size_t len)
void wpa_get_ntp_timestamp(u8 *buf)
int hwaddr_aton(const char *txt, u8 *addr)
int hexstr2bin(const char *hex, u8 *buf, size_t len)
int hwaddr_aton2(const char *txt, u8 *addr)