EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Data Structures | Macros | Typedefs | Enumerations
common.h File Reference

File containing the common definitions used by radius and eap. More...

#include <stddef.h>
#include "../utils/allocs.h"
#include "../utils/attributes.h"
#include "../utils/log.h"
Include dependency graph for common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hostapd_radius_attr
 

Macros

#define __force
 
#define __bitwise
 
#define BIT(x)   (1U << (x))
 
#define bswap_16(a)   ((((u16)(a) << 8) & 0xff00) | (((u16)(a) >> 8) & 0xff))
 
#define le_to_host16(n)   ((__force u16)(le16)(n))
 
#define host_to_le16(n)   ((__force le16)(u16)(n))
 
#define be_to_host16(n)   bswap_16((__force u16)(be16)(n))
 
#define host_to_be16(n)   ((__force be16)bswap_16((n)))
 
#define le_to_host32(n)   ((__force u32)(le32)(n))
 
#define host_to_le32(n)   ((__force le32)(u32)(n))
 
#define be_to_host32(n)   bswap_32((__force u32)(be32)(n))
 
#define host_to_be32(n)   ((__force be32)bswap_32((n)))
 
#define le_to_host64(n)   ((__force u64)(le64)(n))
 
#define host_to_le64(n)   ((__force le64)(u64)(n))
 
#define be_to_host64(n)   bswap_64((__force u64)(be64)(n))
 
#define host_to_be64(n)   ((__force be64)bswap_64((n)))
 
#define wpa_printf(level, ...)    log_levels(level, __FILENAME__, __LINE__, __VA_ARGS__)
 
#define wpa_snprintf_hex(buf, buf_size, data, len)    printf_hex(buf, buf_size, data, len, false)
 
#define wpa_trace_show(s)   log_trace("%s", s)
 
#define TEST_FAIL()   0
 

Typedefs

typedef uint64_t u64
 
typedef uint32_t u32
 
typedef uint16_t u16
 
typedef uint8_t u8
 
typedef int64_t s64
 
typedef int32_t s32
 
typedef int16_t s16
 
typedef int8_t s8
 
typedef u16 __bitwise be16
 
typedef u16 __bitwise le16
 
typedef u32 __bitwise be32
 
typedef u32 __bitwise le32
 
typedef u64 __bitwise be64
 
typedef u64 __bitwise le64
 

Enumerations

enum  ieee802_11_reason_code { WLAN_REASON_IEEE_802_1X_AUTH_FAILED = 23 }
 
enum  hostap_log_level {
  MSG_EXCESSIVE = LOGC_TRACE , MSG_MSGDUMP = LOGC_TRACE , MSG_DEBUG = LOGC_DEBUG , MSG_INFO = LOGC_INFO ,
  MSG_WARNING = LOGC_WARN , MSG_ERROR = LOGC_ERROR
}
 

Detailed Description

File containing the common definitions used by radius and eap.

Author
Alexandru Mereacre, Jouni Malinen
Version
Adapted from hostap 2.10 - src/utils/common.h

Macro Definition Documentation

◆ __bitwise

#define __bitwise

◆ __force

#define __force

◆ be_to_host16

#define be_to_host16 (   n)    bswap_16((__force u16)(be16)(n))

◆ be_to_host32

#define be_to_host32 (   n)    bswap_32((__force u32)(be32)(n))

◆ be_to_host64

#define be_to_host64 (   n)    bswap_64((__force u64)(be64)(n))

◆ BIT

#define BIT (   x)    (1U << (x))

◆ bswap_16

#define bswap_16 (   a)    ((((u16)(a) << 8) & 0xff00) | (((u16)(a) >> 8) & 0xff))

◆ host_to_be16

#define host_to_be16 (   n)    ((__force be16)bswap_16((n)))

◆ host_to_be32

#define host_to_be32 (   n)    ((__force be32)bswap_32((n)))

◆ host_to_be64

#define host_to_be64 (   n)    ((__force be64)bswap_64((n)))

◆ host_to_le16

#define host_to_le16 (   n)    ((__force le16)(u16)(n))

◆ host_to_le32

#define host_to_le32 (   n)    ((__force le32)(u32)(n))

◆ host_to_le64

#define host_to_le64 (   n)    ((__force le64)(u64)(n))

◆ le_to_host16

#define le_to_host16 (   n)    ((__force u16)(le16)(n))

◆ le_to_host32

#define le_to_host32 (   n)    ((__force u32)(le32)(n))

◆ le_to_host64

#define le_to_host64 (   n)    ((__force u64)(le64)(n))

◆ TEST_FAIL

#define TEST_FAIL ( )    0

◆ wpa_printf

#define wpa_printf (   level,
  ... 
)     log_levels(level, __FILENAME__, __LINE__, __VA_ARGS__)

Logs the given text.

Remarks
This macro has an API compatible with hostap's wpa_printf() function, see https://w1.fi/cgit/hostap/tree/src/utils/wpa_debug.h?h=hostap_2_10#n62

◆ wpa_snprintf_hex

#define wpa_snprintf_hex (   buf,
  buf_size,
  data,
  len 
)     printf_hex(buf, buf_size, data, len, false)

Print data as a hex string into a buffer.

Parameters
[out]bufMemory area to use as the output buffer
buf_sizeMaximum buffer size in bytes (should be at least 2 * len + 1)
[in]dataData to be printed
lenLength of data in bytes
Returns
Number of bytes written
Remarks
This function has an API compatible with hostap's wpa_snprintf_hex() function, see https://w1.fi/cgit/hostap/tree/src/utils/common.c?h=hostap_2_10#n338

◆ wpa_trace_show

#define wpa_trace_show (   s)    log_trace("%s", s)

Dummy implementation of hostap's wpa_trace_show()

See also
https://w1.fi/cgit/hostap/tree/src/utils/trace.h?h=hostap_2_10#n33
Note
In the future, we could use something like GCC's backtrace_symbols() to implement this, https://www.gnu.org/software/libc/manual/html_node/Backtraces.html

Typedef Documentation

◆ be16

typedef u16 __bitwise be16

◆ be32

typedef u32 __bitwise be32

◆ be64

typedef u64 __bitwise be64

◆ le16

typedef u16 __bitwise le16

◆ le32

typedef u32 __bitwise le32

◆ le64

typedef u64 __bitwise le64

◆ s16

typedef int16_t s16

◆ s32

typedef int32_t s32

◆ s64

typedef int64_t s64

◆ s8

typedef int8_t s8

◆ u16

typedef uint16_t u16

◆ u32

typedef uint32_t u32

◆ u64

typedef uint64_t u64

◆ u8

typedef uint8_t u8

Enumeration Type Documentation

◆ hostap_log_level

Log levels used by source-code taken from hostap. Used as the level parameter for functions like wpa_hexdump_ascii().

Enumerator
MSG_EXCESSIVE 
MSG_MSGDUMP 
MSG_DEBUG 
MSG_INFO 
MSG_WARNING 
MSG_ERROR 

◆ ieee802_11_reason_code

Reason codes (IEEE Std 802.11-2016, 9.4.1.7, Table 9-45)

See also
https://w1.fi/cgit/hostap/tree/src/common/ieee802_11_defs.h?h=hostap_2_10#n213
Enumerator
WLAN_REASON_IEEE_802_1X_AUTH_FAILED