18 #include "../utils/allocs.h"
19 #include "../utils/attributes.h"
20 #include "../utils/log.h"
36 #define __force __attribute__((force))
38 #define __bitwise __attribute__((bitwise))
53 #define BIT(x) (1U << (x))
57 #define bswap_16(a) ((((u16)(a) << 8) & 0xff00) | (((u16)(a) >> 8) & 0xff))
60 #if __BYTE_ORDER == __LITTLE_ENDIAN
61 #define le_to_host16(n) ((__force u16)(le16)(n))
62 #define host_to_le16(n) ((__force le16)(u16)(n))
63 #define be_to_host16(n) bswap_16((__force u16)(be16)(n))
64 #define host_to_be16(n) ((__force be16)bswap_16((n)))
65 #define le_to_host32(n) ((__force u32)(le32)(n))
66 #define host_to_le32(n) ((__force le32)(u32)(n))
67 #define be_to_host32(n) bswap_32((__force u32)(be32)(n))
68 #define host_to_be32(n) ((__force be32)bswap_32((n)))
69 #define le_to_host64(n) ((__force u64)(le64)(n))
70 #define host_to_le64(n) ((__force le64)(u64)(n))
71 #define be_to_host64(n) bswap_64((__force u64)(be64)(n))
72 #define host_to_be64(n) ((__force be64)bswap_64((n)))
73 #elif __BYTE_ORDER == __BIG_ENDIAN
74 #define le_to_host16(n) bswap_16(n)
75 #define host_to_le16(n) bswap_16(n)
76 #define be_to_host16(n) (n)
77 #define host_to_be16(n) (n)
78 #define le_to_host32(n) bswap_32(n)
79 #define host_to_le32(n) bswap_32(n)
80 #define be_to_host32(n) (n)
81 #define host_to_be32(n) (n)
82 #define le_to_host64(n) bswap_64(n)
83 #define host_to_le64(n) bswap_64(n)
84 #define be_to_host64(n) (n)
85 #define host_to_be64(n) (n)
86 #ifndef WORDS_BIGENDIAN
87 #define WORDS_BIGENDIAN
90 #error Could not determine CPU byte order
93 static inline void WPA_PUT_LE16(
u8 *a,
u16 val) {
98 static inline void WPA_PUT_LE32(
u8 *a,
u32 val) {
99 a[3] = (val >> 24) & 0xff;
100 a[2] = (val >> 16) & 0xff;
101 a[1] = (val >> 8) & 0xff;
105 static inline void WPA_PUT_LE64(
u8 *a,
u64 val) {
116 static inline void WPA_PUT_BE16(
u8 *a,
u16 val) {
121 static inline void WPA_PUT_BE24(
u8 *a,
u32 val) {
122 a[0] = (val >> 16) & 0xff;
123 a[1] = (val >> 8) & 0xff;
127 static inline void WPA_PUT_BE32(
u8 *a,
u32 val) {
128 a[0] = (val >> 24) & 0xff;
129 a[1] = (val >> 16) & 0xff;
130 a[2] = (val >> 8) & 0xff;
134 static inline void WPA_PUT_BE64(
u8 *a,
u64 val) {
145 static inline u32 WPA_GET_BE32(
const u8 *a) {
146 return ((
u32)a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
149 static inline u32 WPA_GET_BE24(
const u8 *a) {
150 return (a[0] << 16) | (a[1] << 8) | a[2];
166 static inline int os_snprintf_error(
size_t size,
int res) {
167 return res < 0 || (
unsigned int)res >= size;
185 static inline void bin_clear_free(
void *bin,
size_t len) {
234 #define wpa_printf(level, ...) \
235 log_levels(level, __FILENAME__, __LINE__, __VA_ARGS__)
250 #define wpa_snprintf_hex(buf, buf_size, data, len) \
251 printf_hex(buf, buf_size, data, len, false)
266 const char *title,
const void *buf,
269 printf_hex(hex_buf,
sizeof(hex_buf), buf, len,
false);
274 static inline void printf_encode(
char *txt,
size_t maxlen,
const uint8_t *data,
276 char *
end = txt + maxlen;
279 for (i = 0; i < len; i++) {
312 if (data[i] >= 32 && data[i] <= 126) {
313 *txt++ = (char)data[i];
317 size_t max_chars_to_print = (size_t)(end - txt);
318 txt +=
snprintf(txt, max_chars_to_print,
"\\x%02x", data[i]);
327 #ifndef wpa_trace_show
338 #define wpa_trace_show(s) log_trace("%s", s)
347 #define TEST_FAIL() 0
#define os_free(p)
Definition: allocs.h:52
#define os_memset(s, c, n)
Definition: allocs.h:69
#define __bitwise
Definition: common.h:42
int64_t s64
Definition: common.h:26
u16 __bitwise be16
Definition: common.h:45
uint64_t u64
Definition: common.h:22
u32 __bitwise le32
Definition: common.h:48
ieee802_11_reason_code
Definition: common.h:200
@ WLAN_REASON_IEEE_802_1X_AUTH_FAILED
Definition: common.h:200
u64 __bitwise be64
Definition: common.h:49
u16 __bitwise le16
Definition: common.h:46
u32 __bitwise be32
Definition: common.h:47
uint8_t u8
Definition: common.h:25
int8_t s8
Definition: common.h:29
int16_t s16
Definition: common.h:28
hostap_log_level
Definition: common.h:218
@ MSG_MSGDUMP
Definition: common.h:220
@ MSG_ERROR
Definition: common.h:224
@ MSG_DEBUG
Definition: common.h:221
@ MSG_EXCESSIVE
Definition: common.h:219
@ MSG_WARNING
Definition: common.h:223
@ MSG_INFO
Definition: common.h:222
uint16_t u16
Definition: common.h:24
u64 __bitwise le64
Definition: common.h:50
int32_t s32
Definition: common.h:27
uint32_t u32
Definition: common.h:23
size_t printf_hex(char *buf, size_t buf_size, const uint8_t *data, size_t len, bool uppercase)
Prints the data in data to buf as hex.
Definition: log.c:324
void log_levels(uint8_t level, const char *file, uint32_t line, const char *format,...)
Definition: log.c:259
uint8_t level
Definition: log.c:57
@ LOGC_WARN
Definition: log.h:29
@ LOGC_DEBUG
Definition: log.h:29
@ LOGC_ERROR
Definition: log.h:29
@ LOGC_TRACE
Definition: log.h:29
@ LOGC_INFO
Definition: log.h:29
#define __FILENAME__
Definition: log.h:24
uint8_t type
Definition: common.h:209
struct wpabuf * val
Definition: common.h:210
struct hostapd_radius_attr * next
Definition: common.h:211