libwifi
0.0.3
An 802.11 Frame Parsing and Generation library in C
platform.h
Go to the documentation of this file.
1
#include <errno.h>
2
#include <stddef.h>
3
#include <string.h>
4
5
#if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
6
#include <endian.h>
7
#if defined(__UCLIBC__)
8
#include <asm/byteorder.h>
9
#ifndef le16toh
10
#define le16toh __le16_to_cpu
11
#endif
12
#ifndef le32toh
13
#define le32toh __le32_to_cpu
14
#endif
15
#endif
16
#endif
17
18
#if defined(__CYGWIN32__) || defined(CYGWIN)
19
#include <asm/byteorder.h>
20
#include <endian.h>
21
#endif
22
23
#if defined(__APPLE__)
24
#include <machine/endian.h>
25
#endif
26
27
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__MidnightBSD__) || \
28
defined(__NetBSD__)
29
#include <sys/endian.h>
30
#include <sys/types.h>
31
#endif
32
33
#if defined(__SVR4) && defined(__sun__)
34
#include <sys/byteorder.h>
35
#include <sys/types.h>
36
#endif
37
38
#ifndef le16_to_cpu
39
#define le16_to_cpu le16toh
40
#endif
41
42
#ifndef le32_to_cpu
43
#define le32_to_cpu le32toh
44
#endif
45
46
#if defined(_MSC_VER)
47
// Microsoft
48
#define EXPORT __declspec(dllexport)
49
#define IMPORT __declspec(dllimport)
50
#elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) || defined(__INTEL_COMPILER)
51
#define EXPORT __attribute__((visibility("default"
)))
52
#define IMPORT
53
#else
54
// do nothing and hope for the best?
55
#define EXPORT
56
#define IMPORT
57
#pragma warning Unknown dynamic link import / export semantics.
58
#endif
59
60
#if defined(RADIOTAP_FAST_UNALIGNED_ACCESS)
61
#define get_unaligned(p) \
62
__extension__({ \
63
struct packed_dummy_struct { \
64
typeof(*(p)) __val; \
65
} __attribute__((packed)) *__ptr = (void *) (p); \
66
\
67
__ptr->__val; \
68
})
69
#else
70
#define get_unaligned(p) \
71
__extension__({ \
72
typeof(*(p)) __tmp; \
73
memmove(&__tmp, (p), sizeof(*(p))); \
74
__tmp; \
75
})
76
#endif
77
78
#define get_unaligned_le16(p) le16_to_cpu(get_unaligned((uint16_t *) (p)))
79
#define get_unaligned_le32(p) le32_to_cpu(get_unaligned((uint32_t *) (p)))
80
81
#define UNALIGNED_ADDRESS(x) ((void *) (x))
libwifi
core
radiotap
platform.h
Generated by
1.9.3