|
|
|
@ -21,6 +21,10 @@
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#if defined(__MACH__)
|
|
|
|
|
# include "clang_compat.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
@ -220,6 +224,54 @@ static inline uint32_t byteorder_swapl(uint32_t v);
|
|
|
|
|
*/
|
|
|
|
|
static inline uint64_t byteorder_swapll(uint64_t v);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Convert from host byte order to network byte order, 16 bit.
|
|
|
|
|
* @see byteorder_htons()
|
|
|
|
|
* @param[in] v The integer to convert.
|
|
|
|
|
* @returns Converted integer.
|
|
|
|
|
*/
|
|
|
|
|
static inline uint16_t HTONS(uint16_t a);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Convert from host byte order to network byte order, 32 bit.
|
|
|
|
|
* @see byteorder_htonl()
|
|
|
|
|
* @param[in] v The integer to convert.
|
|
|
|
|
* @returns Converted integer.
|
|
|
|
|
*/
|
|
|
|
|
static inline uint32_t HTONL(uint32_t a);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Convert from host byte order to network byte order, 64 bit.
|
|
|
|
|
* @see byteorder_htonll()
|
|
|
|
|
* @param[in] v The integer to convert.
|
|
|
|
|
* @returns Converted integer.
|
|
|
|
|
*/
|
|
|
|
|
static inline uint64_t HTONLL(uint64_t a);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Convert from network byte order to host byte order, 16 bit.
|
|
|
|
|
* @see byteorder_ntohs()
|
|
|
|
|
* @param[in] v The integer to convert.
|
|
|
|
|
* @returns Converted integer.
|
|
|
|
|
*/
|
|
|
|
|
static inline uint16_t NTOHS(uint16_t a);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Convert from network byte order to host byte order, 32 bit.
|
|
|
|
|
* @see byteorder_ntohl()
|
|
|
|
|
* @param[in] v The integer to convert.
|
|
|
|
|
* @returns Converted integer.
|
|
|
|
|
*/
|
|
|
|
|
static inline uint32_t NTOHL(uint32_t a);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Convert from network byte order to host byte order, 64 bit.
|
|
|
|
|
* @see byteorder_ntohll()
|
|
|
|
|
* @param[in] v The integer to convert.
|
|
|
|
|
* @returns Converted integer.
|
|
|
|
|
*/
|
|
|
|
|
static inline uint64_t NTOHLL(uint64_t a);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* **************************** IMPLEMENTATION ***************************** */
|
|
|
|
|
|
|
|
|
@ -327,6 +379,39 @@ static inline uint64_t byteorder_ntohll(network_uint64_t v)
|
|
|
|
|
return _byteorder_swap(v.u64, ll);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint16_t HTONS(uint16_t a)
|
|
|
|
|
{
|
|
|
|
|
return byteorder_htons(a).u16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint32_t HTONL(uint32_t a)
|
|
|
|
|
{
|
|
|
|
|
return byteorder_htonl(a).u32;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint64_t HTONLL(uint64_t a)
|
|
|
|
|
{
|
|
|
|
|
return byteorder_htonll(a).u64;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint16_t NTOHS(uint16_t a)
|
|
|
|
|
{
|
|
|
|
|
network_uint16_t input = { .u16 = a };
|
|
|
|
|
return byteorder_ntohs(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint32_t NTOHL(uint32_t a)
|
|
|
|
|
{
|
|
|
|
|
network_uint32_t input = { .u32 = a };
|
|
|
|
|
return byteorder_ntohl(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline uint64_t NTOHLL(uint64_t a)
|
|
|
|
|
{
|
|
|
|
|
network_uint64_t input = { .u64 = a };
|
|
|
|
|
return byteorder_ntohll(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|