• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * wpa_supplicant/hostapd / common helper functions, etc.
3  * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef COMMON_H
10 #define COMMON_H
11 
12 #include "os.h"
13 #include "byteswap.h"
14 
15 #if defined(__linux__) || defined(__GLIBC__)
16 #include <endian.h>
17 #include <byteswap.h>
18 #endif /* __linux__ */
19 
20 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
21     defined(__OpenBSD__)
22 #include <sys/types.h>
23 #include <sys/endian.h>
24 #define __BYTE_ORDER	_BYTE_ORDER
25 #define	__LITTLE_ENDIAN	_LITTLE_ENDIAN
26 #define	__BIG_ENDIAN	_BIG_ENDIAN
27 #ifdef __OpenBSD__
28 #define bswap_16 swap16
29 #define bswap_32 swap32
30 #define bswap_64 swap64
31 #else /* __OpenBSD__ */
32 #define bswap_16 bswap16
33 #define bswap_32 bswap32
34 #define bswap_64 bswap64
35 #endif /* __OpenBSD__ */
36 #endif /* defined(__FreeBSD__) || defined(__NetBSD__) ||
37 	* defined(__DragonFly__) || defined(__OpenBSD__) */
38 
39 #ifdef __APPLE__
40 #include <sys/types.h>
41 #include <machine/endian.h>
42 #define __BYTE_ORDER	_BYTE_ORDER
43 #define __LITTLE_ENDIAN	_LITTLE_ENDIAN
44 #define __BIG_ENDIAN	_BIG_ENDIAN
bswap_16(unsigned short v)45 static inline unsigned short bswap_16(unsigned short v)
46 {
47 	return ((v & 0xff) << 8) | (v >> 8);
48 }
49 
bswap_32(unsigned int v)50 static inline unsigned int bswap_32(unsigned int v)
51 {
52 	return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
53 		((v & 0xff0000) >> 8) | (v >> 24);
54 }
55 #endif /* __APPLE__ */
56 
57 #ifdef __rtems__
58 #include <rtems/endian.h>
59 #define __BYTE_ORDER BYTE_ORDER
60 #define __LITTLE_ENDIAN LITTLE_ENDIAN
61 #define __BIG_ENDIAN BIG_ENDIAN
62 #define bswap_16 CPU_swap_u16
63 #define bswap_32 CPU_swap_u32
64 #endif /* __rtems__ */
65 
66 #ifdef CONFIG_NATIVE_WINDOWS
67 #include <winsock.h>
68 
69 typedef int socklen_t;
70 
71 #ifndef MSG_DONTWAIT
72 #define MSG_DONTWAIT 0 /* not supported */
73 #endif
74 
75 #endif /* CONFIG_NATIVE_WINDOWS */
76 
77 #ifdef _MSC_VER
78 #define inline __inline
79 
80 #undef vsnprintf
81 #define vsnprintf _vsnprintf
82 #undef close
83 #define close closesocket
84 #endif /* _MSC_VER */
85 
86 
87 /* Define platform specific integer types */
88 
89 #ifdef _MSC_VER
90 typedef UINT64 u64;
91 typedef UINT32 u32;
92 typedef UINT16 u16;
93 typedef UINT8 u8;
94 typedef INT64 s64;
95 typedef INT32 s32;
96 typedef INT16 s16;
97 typedef INT8 s8;
98 #define WPA_TYPES_DEFINED
99 #endif /* _MSC_VER */
100 
101 #ifdef __vxworks
102 typedef unsigned long long u64;
103 typedef UINT32 u32;
104 typedef UINT16 u16;
105 typedef UINT8 u8;
106 typedef long long s64;
107 typedef INT32 s32;
108 typedef INT16 s16;
109 typedef INT8 s8;
110 #define WPA_TYPES_DEFINED
111 #endif /* __vxworks */
112 
113 #ifndef WPA_TYPES_DEFINED
114 #ifdef CONFIG_USE_INTTYPES_H
115 #include <inttypes.h>
116 #else
117 #include <stdint.h>
118 #endif
119 typedef uint64_t u64;
120 typedef uint32_t u32;
121 typedef uint16_t u16;
122 typedef uint8_t u8;
123 typedef int64_t s64;
124 typedef int32_t s32;
125 typedef int16_t s16;
126 typedef int8_t s8;
127 #define WPA_TYPES_DEFINED
128 #endif /* !WPA_TYPES_DEFINED */
129 
130 
131 /* Define platform specific byte swapping macros */
132 
133 #if defined(__CYGWIN__) || defined(CONFIG_NATIVE_WINDOWS)
134 
wpa_swap_16(unsigned short v)135 static inline unsigned short wpa_swap_16(unsigned short v)
136 {
137 	return ((v & 0xff) << 8) | (v >> 8);
138 }
139 
wpa_swap_32(unsigned int v)140 static inline unsigned int wpa_swap_32(unsigned int v)
141 {
142 	return ((v & 0xff) << 24) | ((v & 0xff00) << 8) |
143 		((v & 0xff0000) >> 8) | (v >> 24);
144 }
145 
146 #define le_to_host16(n) (n)
147 #define host_to_le16(n) (n)
148 #define be_to_host16(n) wpa_swap_16(n)
149 #define host_to_be16(n) wpa_swap_16(n)
150 #define le_to_host32(n) (n)
151 #define host_to_le32(n) (n)
152 #define be_to_host32(n) wpa_swap_32(n)
153 #define host_to_be32(n) wpa_swap_32(n)
154 #define host_to_le64(n) (n)
155 
156 #define WPA_BYTE_SWAP_DEFINED
157 
158 #endif /* __CYGWIN__ || CONFIG_NATIVE_WINDOWS */
159 
160 
161 #ifndef WPA_BYTE_SWAP_DEFINED
162 
163 #ifndef __BYTE_ORDER
164 #ifndef __LITTLE_ENDIAN
165 #ifndef __BIG_ENDIAN
166 #define __LITTLE_ENDIAN 1234
167 #define __BIG_ENDIAN 4321
168 #if defined(sparc)
169 #define __BYTE_ORDER __BIG_ENDIAN
170 #endif
171 #endif /* __BIG_ENDIAN */
172 #endif /* __LITTLE_ENDIAN */
173 #endif /* __BYTE_ORDER */
174 
175 #if __BYTE_ORDER == __LITTLE_ENDIAN
176 #define le_to_host16(n) ((__force u16) (le16) (n))
177 #define host_to_le16(n) ((__force le16) (u16) (n))
178 #define be_to_host16(n) bswap_16((__force u16) (be16) (n))
179 #define host_to_be16(n) ((__force be16) bswap_16((n)))
180 #define le_to_host32(n) ((__force u32) (le32) (n))
181 #define host_to_le32(n) ((__force le32) (u32) (n))
182 #define be_to_host32(n) bswap_32((__force u32) (be32) (n))
183 #define host_to_be32(n) ((__force be32) bswap_32((n)))
184 #define le_to_host64(n) ((__force u64) (le64) (n))
185 #define host_to_le64(n) ((__force le64) (u64) (n))
186 #define be_to_host64(n) bswap_64((__force u64) (be64) (n))
187 #define host_to_be64(n) ((__force be64) bswap_64((n)))
188 #elif __BYTE_ORDER == __BIG_ENDIAN
189 #define le_to_host16(n) bswap_16(n)
190 #define host_to_le16(n) bswap_16(n)
191 #define be_to_host16(n) (n)
192 #define host_to_be16(n) (n)
193 #define le_to_host32(n) bswap_32(n)
194 #define host_to_le32(n) bswap_32(n)
195 #define be_to_host32(n) (n)
196 #define host_to_be32(n) (n)
197 #define le_to_host64(n) bswap_64(n)
198 #define host_to_le64(n) bswap_64(n)
199 #define be_to_host64(n) (n)
200 #define host_to_be64(n) (n)
201 #ifndef WORDS_BIGENDIAN
202 #define WORDS_BIGENDIAN
203 #endif
204 #else
205 #error Could not determine CPU byte order
206 #endif
207 
208 #define WPA_BYTE_SWAP_DEFINED
209 #endif /* !WPA_BYTE_SWAP_DEFINED */
210 
211 
212 /* Macros for handling unaligned memory accesses */
213 
WPA_GET_BE16(const u8 * a)214 static inline u16 WPA_GET_BE16(const u8 *a)
215 {
216 	return (a[0] << 8) | a[1];
217 }
218 
WPA_PUT_BE16(u8 * a,u16 val)219 static inline void WPA_PUT_BE16(u8 *a, u16 val)
220 {
221 	a[0] = val >> 8;
222 	a[1] = val & 0xff;
223 }
224 
WPA_GET_LE16(const u8 * a)225 static inline u16 WPA_GET_LE16(const u8 *a)
226 {
227 	return (a[1] << 8) | a[0];
228 }
229 
WPA_PUT_LE16(u8 * a,u16 val)230 static inline void WPA_PUT_LE16(u8 *a, u16 val)
231 {
232 	a[1] = val >> 8;
233 	a[0] = val & 0xff;
234 }
235 
WPA_GET_BE24(const u8 * a)236 static inline u32 WPA_GET_BE24(const u8 *a)
237 {
238 	return (a[0] << 16) | (a[1] << 8) | a[2];
239 }
240 
WPA_PUT_BE24(u8 * a,u32 val)241 static inline void WPA_PUT_BE24(u8 *a, u32 val)
242 {
243 	a[0] = (val >> 16) & 0xff;
244 	a[1] = (val >> 8) & 0xff;
245 	a[2] = val & 0xff;
246 }
247 
WPA_GET_BE32(const u8 * a)248 static inline u32 WPA_GET_BE32(const u8 *a)
249 {
250 	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
251 }
252 
WPA_PUT_BE32(u8 * a,u32 val)253 static inline void WPA_PUT_BE32(u8 *a, u32 val)
254 {
255 	a[0] = (val >> 24) & 0xff;
256 	a[1] = (val >> 16) & 0xff;
257 	a[2] = (val >> 8) & 0xff;
258 	a[3] = val & 0xff;
259 }
260 
WPA_GET_LE32(const u8 * a)261 static inline u32 WPA_GET_LE32(const u8 *a)
262 {
263 	return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
264 }
265 
WPA_PUT_LE32(u8 * a,u32 val)266 static inline void WPA_PUT_LE32(u8 *a, u32 val)
267 {
268 	a[3] = (val >> 24) & 0xff;
269 	a[2] = (val >> 16) & 0xff;
270 	a[1] = (val >> 8) & 0xff;
271 	a[0] = val & 0xff;
272 }
273 
WPA_GET_BE64(const u8 * a)274 static inline u64 WPA_GET_BE64(const u8 *a)
275 {
276 	return (((u64) a[0]) << 56) | (((u64) a[1]) << 48) |
277 		(((u64) a[2]) << 40) | (((u64) a[3]) << 32) |
278 		(((u64) a[4]) << 24) | (((u64) a[5]) << 16) |
279 		(((u64) a[6]) << 8) | ((u64) a[7]);
280 }
281 
WPA_PUT_BE64(u8 * a,u64 val)282 static inline void WPA_PUT_BE64(u8 *a, u64 val)
283 {
284 	a[0] = val >> 56;
285 	a[1] = val >> 48;
286 	a[2] = val >> 40;
287 	a[3] = val >> 32;
288 	a[4] = val >> 24;
289 	a[5] = val >> 16;
290 	a[6] = val >> 8;
291 	a[7] = val & 0xff;
292 }
293 
WPA_GET_LE64(const u8 * a)294 static inline u64 WPA_GET_LE64(const u8 *a)
295 {
296 	return (((u64) a[7]) << 56) | (((u64) a[6]) << 48) |
297 		(((u64) a[5]) << 40) | (((u64) a[4]) << 32) |
298 		(((u64) a[3]) << 24) | (((u64) a[2]) << 16) |
299 		(((u64) a[1]) << 8) | ((u64) a[0]);
300 }
301 
WPA_PUT_LE64(u8 * a,u64 val)302 static inline void WPA_PUT_LE64(u8 *a, u64 val)
303 {
304 	a[7] = val >> 56;
305 	a[6] = val >> 48;
306 	a[5] = val >> 40;
307 	a[4] = val >> 32;
308 	a[3] = val >> 24;
309 	a[2] = val >> 16;
310 	a[1] = val >> 8;
311 	a[0] = val & 0xff;
312 }
313 
314 
315 #ifndef ETH_ALEN
316 #define ETH_ALEN 6
317 #endif
318 #ifndef ETH_HLEN
319 #define ETH_HLEN 14
320 #endif
321 #ifndef IFNAMSIZ
322 #define IFNAMSIZ 16
323 #endif
324 #ifndef ETH_P_ALL
325 #define ETH_P_ALL 0x0003
326 #endif
327 #ifndef ETH_P_IP
328 #define ETH_P_IP 0x0800
329 #endif
330 #ifndef ETH_P_80211_ENCAP
331 #define ETH_P_80211_ENCAP 0x890d /* TDLS comes under this category */
332 #endif
333 #ifndef ETH_P_PAE
334 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
335 #endif /* ETH_P_PAE */
336 #ifndef ETH_P_EAPOL
337 #define ETH_P_EAPOL ETH_P_PAE
338 #endif /* ETH_P_EAPOL */
339 #ifndef ETH_P_RSN_PREAUTH
340 #define ETH_P_RSN_PREAUTH 0x88c7
341 #endif /* ETH_P_RSN_PREAUTH */
342 #ifndef ETH_P_RRB
343 #define ETH_P_RRB 0x890D
344 #endif /* ETH_P_RRB */
345 #ifndef ETH_P_OUI
346 #define ETH_P_OUI 0x88B7
347 #endif /* ETH_P_OUI */
348 #ifndef ETH_P_8021Q
349 #define ETH_P_8021Q 0x8100
350 #endif /* ETH_P_8021Q */
351 
352 
353 #ifdef __GNUC__
354 #define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b))))
355 #define STRUCT_PACKED __attribute__ ((packed))
356 #else
357 #define PRINTF_FORMAT(a,b)
358 #define STRUCT_PACKED
359 #endif
360 
361 
362 #ifdef CONFIG_ANSI_C_EXTRA
363 
364 #if !defined(_MSC_VER) || _MSC_VER < 1400
365 /* snprintf - used in number of places; sprintf() is _not_ a good replacement
366  * due to possible buffer overflow; see, e.g.,
367  * http://www.ijs.si/software/snprintf/ for portable implementation of
368  * snprintf. */
369 int snprintf(char *str, size_t size, const char *format, ...);
370 
371 /* vsnprintf - only used for wpa_msg() in wpa_supplicant.c */
372 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
373 #endif /* !defined(_MSC_VER) || _MSC_VER < 1400 */
374 
375 /* getopt - only used in main.c */
376 int getopt(int argc, char *const argv[], const char *optstring);
377 extern char *optarg;
378 extern int optind;
379 
380 #ifndef CONFIG_NO_SOCKLEN_T_TYPEDEF
381 #ifndef __socklen_t_defined
382 typedef int socklen_t;
383 #endif
384 #endif
385 
386 /* inline - define as __inline or just define it to be empty, if needed */
387 #ifdef CONFIG_NO_INLINE
388 #define inline
389 #else
390 #define inline __inline
391 #endif
392 
393 #ifndef __func__
394 #define __func__ "__func__ not defined"
395 #endif
396 
397 #ifndef bswap_16
398 #define bswap_16(a) ((((u16) (a) << 8) & 0xff00) | (((u16) (a) >> 8) & 0xff))
399 #endif
400 
401 #ifndef bswap_32
402 #define bswap_32(a) ((((u32) (a) << 24) & 0xff000000) | \
403 		     (((u32) (a) << 8) & 0xff0000) | \
404      		     (((u32) (a) >> 8) & 0xff00) | \
405      		     (((u32) (a) >> 24) & 0xff))
406 #endif
407 
408 #ifndef MSG_DONTWAIT
409 #define MSG_DONTWAIT 0
410 #endif
411 
412 #ifdef _WIN32_WCE
413 void perror(const char *s);
414 #endif /* _WIN32_WCE */
415 
416 #endif /* CONFIG_ANSI_C_EXTRA */
417 
418 #ifndef MAC2STR
419 #define MAC2STR_SEC(a) mac_to_str(a)
420 #define MACSTR_SEC "%s"
421 
422 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
423 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
424 
425 /*
426  * Compact form for string representation of MAC address
427  * To be used, e.g., for constructing dbus paths for P2P Devices
428  */
429 #define COMPACT_MACSTR "%02x%02x%02x%02x%02x%02x"
430 #endif
431 
432 #define MAC2DBGSTR(a) (a)[0], (wpa_debug_level < MSG_INFO) ? (a)[1] : 0x0, \
433 (wpa_debug_level < MSG_INFO) ? (a)[2] : 0x0, (wpa_debug_level < MSG_INFO) ? (a)[3] : 0x0, \
434 (wpa_debug_level < MSG_INFO) ? (a)[4] : 0x0, (a)[5]
435 
436 #ifndef BIT
437 #define BIT(x) (1U << (x))
438 #endif
439 
440 /*
441  * Definitions for sparse validation
442  * (http://kernel.org/pub/linux/kernel/people/josh/sparse/)
443  */
444 #ifdef __CHECKER__
445 #define __force __attribute__((force))
446 #undef __bitwise
447 #define __bitwise __attribute__((bitwise))
448 #else
449 #define __force
450 #undef __bitwise
451 #define __bitwise
452 #endif
453 
454 typedef u16 __bitwise be16;
455 typedef u16 __bitwise le16;
456 typedef u32 __bitwise be32;
457 typedef u32 __bitwise le32;
458 typedef u64 __bitwise be64;
459 typedef u64 __bitwise le64;
460 
461 #ifndef __must_check
462 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
463 #define __must_check __attribute__((__warn_unused_result__))
464 #else
465 #define __must_check
466 #endif /* __GNUC__ */
467 #endif /* __must_check */
468 
469 #ifndef __maybe_unused
470 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
471 #define __maybe_unused __attribute__((unused))
472 #else
473 #define __maybe_unused
474 #endif /* __GNUC__ */
475 #endif /* __must_check */
476 
477 #define SSID_MAX_LEN 32
478 
479 struct wpa_ssid_value {
480 	u8 ssid[SSID_MAX_LEN];
481 	size_t ssid_len;
482 };
483 
484 int hwaddr_aton(const char *txt, u8 *addr);
485 int hwaddr_masked_aton(const char *txt, u8 *addr, u8 *mask, u8 maskable);
486 int hwaddr_compact_aton(const char *txt, u8 *addr);
487 int hwaddr_aton2(const char *txt, u8 *addr);
488 int hex2byte(const char *hex);
489 int hexstr2bin(const char *hex, u8 *buf, size_t len);
490 #ifdef CONFIG_EAP_AUTH
491 void bin2hexstr(const unsigned char* bin, size_t bin_len, char* hexstr, size_t hexstr_len);
492 #endif
493 void inc_byte_array(u8 *counter, size_t len);
494 void buf_shift_right(u8 *buf, size_t len, size_t bits);
495 void wpa_get_ntp_timestamp(u8 *buf);
496 int wpa_scnprintf(char *buf, size_t size, const char *fmt, ...)
497 	PRINTF_FORMAT(3, 4);
498 int wpa_snprintf_hex_sep(char *buf, size_t buf_size, const u8 *data, size_t len,
499 			 char sep);
500 int wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data, size_t len);
501 int wpa_snprintf_hex_uppercase(char *buf, size_t buf_size, const u8 *data,
502 			       size_t len);
503 
504 int hwaddr_mask_txt(char *buf, size_t len, const u8 *addr, const u8 *mask);
505 int ssid_parse(const char *buf, struct wpa_ssid_value *ssid);
506 
507 #ifdef CONFIG_NATIVE_WINDOWS
508 void wpa_unicode2ascii_inplace(TCHAR *str);
509 TCHAR * wpa_strdup_tchar(const char *str);
510 #else /* CONFIG_NATIVE_WINDOWS */
511 #define wpa_unicode2ascii_inplace(s) do { } while (0)
512 #define wpa_strdup_tchar(s) strdup((s))
513 #endif /* CONFIG_NATIVE_WINDOWS */
514 
515 void printf_encode(char *txt, size_t maxlen, const u8 *data, size_t len);
516 size_t printf_decode(u8 *buf, size_t maxlen, const char *str);
517 
518 const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
519 
520 char * wpa_config_parse_string(const char *value, size_t *len);
521 int is_hex(const u8 *data, size_t len);
522 int has_ctrl_char(const u8 *data, size_t len);
523 int has_newline(const char *str);
524 size_t merge_byte_arrays(u8 *res, size_t res_len,
525 			 const u8 *src1, size_t src1_len,
526 			 const u8 *src2, size_t src2_len);
527 char * dup_binstr(const void *src, size_t len);
528 
is_zero_ether_addr(const u8 * a)529 static inline int is_zero_ether_addr(const u8 *a)
530 {
531 	return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
532 }
533 
is_broadcast_ether_addr(const u8 * a)534 static inline int is_broadcast_ether_addr(const u8 *a)
535 {
536 	return (a[0] & a[1] & a[2] & a[3] & a[4] & a[5]) == 0xff;
537 }
538 
is_multicast_ether_addr(const u8 * a)539 static inline int is_multicast_ether_addr(const u8 *a)
540 {
541 	return a[0] & 0x01;
542 }
543 
544 #define broadcast_ether_addr (const u8 *) "\xff\xff\xff\xff\xff\xff"
545 
546 #include "wpa_debug.h"
547 
548 
549 struct wpa_freq_range_list {
550 	struct wpa_freq_range {
551 		unsigned int min;
552 		unsigned int max;
553 	} *range;
554 	unsigned int num;
555 };
556 
557 int freq_range_list_parse(struct wpa_freq_range_list *res, const char *value);
558 int freq_range_list_includes(const struct wpa_freq_range_list *list,
559 			     unsigned int freq);
560 char * freq_range_list_str(const struct wpa_freq_range_list *list);
561 
562 size_t int_array_len(const int *a);
563 void int_array_concat(int **res, const int *a);
564 void int_array_sort_unique(int *a);
565 void int_array_add_unique(int **res, int a);
566 
567 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
568 
569 void str_clear_free(char *str);
570 void bin_clear_free(void *bin, size_t len);
571 
572 int random_mac_addr(u8 *addr);
573 int random_mac_addr_keep_oui(u8 *addr);
574 
575 const char * cstr_token(const char *str, const char *delim, const char **last);
576 char * str_token(char *str, const char *delim, char **context);
577 size_t utf8_escape(const char *inp, size_t in_size,
578 		   char *outp, size_t out_size);
579 size_t utf8_unescape(const char *inp, size_t in_size,
580 		     char *outp, size_t out_size);
581 int is_ctrl_char(char c);
582 
583 int str_starts(const char *str, const char *start);
584 
585 u8 rssi_to_rcpi(int rssi);
586 char * get_param(const char *cmd, const char *param);
587 
588 void forced_memzero(void *ptr, size_t len);
589 
590 const char *mac_to_str(const u8 *addr);
591 
592 /*
593  * gcc 4.4 ends up generating strict-aliasing warnings about some very common
594  * networking socket uses that do not really result in a real problem and
595  * cannot be easily avoided with union-based type-punning due to struct
596  * definitions including another struct in system header files. To avoid having
597  * to fully disable strict-aliasing warnings, provide a mechanism to hide the
598  * typecast from aliasing for now. A cleaner solution will hopefully be found
599  * in the future to handle these cases.
600  */
601 void * __hide_aliasing_typecast(void *foo);
602 #define aliasing_hide_typecast(a,t) (t *) __hide_aliasing_typecast((a))
603 
604 #ifdef CONFIG_VALGRIND
605 #include <valgrind/memcheck.h>
606 #define WPA_MEM_DEFINED(ptr, len) VALGRIND_MAKE_MEM_DEFINED((ptr), (len))
607 #else /* CONFIG_VALGRIND */
608 #define WPA_MEM_DEFINED(ptr, len) do { } while (0)
609 #endif /* CONFIG_VALGRIND */
610 
611 #endif /* COMMON_H */
612