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