From a93c6f3113f71d3128ae516586319e22215970bd Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 22 Mar 2015 09:10:03 +0100 Subject: endian: Use new osmocom/core/endian.h Use the new osmocom/core/endian.h to gaim portability. This has only been compiled/make check on two little endian systems. --- include/mtp/mtp_level3.h | 23 ++++++++++++----------- include/sccp/sccp_types.h | 14 +++++++------- 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/include/mtp/mtp_level3.h b/include/mtp/mtp_level3.h index 7d72d9e..2395041 100644 --- a/include/mtp/mtp_level3.h +++ b/include/mtp/mtp_level3.h @@ -23,7 +23,8 @@ #ifndef mtp_level3_h #define mtp_level3_h -#include +#include + #include #include @@ -62,7 +63,7 @@ #define MTP_APOC_MASK 0x3f -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN #define MTP_LINK_SLS(addr) ((addr >>28) & MTP_LINK_MASK) #define MTP_ADDR(link, dpc, opc) \ (((dpc) & MTP_ADDR_MASK) << 0 | \ @@ -70,7 +71,7 @@ ((link) & MTP_LINK_MASK) << 28) #define MTP_MAKE_APOC(apoc) \ (apoc & 0x3fff) -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN static inline uint32_t c_swap_32(uint32_t in) { return (((in & 0x000000ff) << 24) | @@ -108,11 +109,11 @@ struct mtp_addr { * wireshark dissectors too */ struct mtp_level_3_hdr { -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t ser_ind : 4, spare : 2, ni : 2; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN uint8_t ni : 2, spare : 2, ser_ind : 4; @@ -122,10 +123,10 @@ struct mtp_level_3_hdr { } __attribute__((packed)); struct mtp_level_3_cmn { -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t h0 : 4, h1 : 4; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN uint8_t h1 : 4, h0 : 4; #endif @@ -133,10 +134,10 @@ struct mtp_level_3_cmn { struct mtp_level_3_mng { struct mtp_level_3_cmn cmn; -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t spare : 4, length : 4; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN uint8_t length : 4, spare : 4; #endif @@ -153,10 +154,10 @@ struct sccp_con_ctrl_prt_mgt { uint8_t sst; uint8_t assn; /* affected sub system number */ uint16_t apoc; -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t mul_ind : 2, spare : 6; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN uint8_t spare : 6, mul_ind : 2; #endif diff --git a/include/sccp/sccp_types.h b/include/sccp/sccp_types.h index 4b14064..986de0d 100644 --- a/include/sccp/sccp_types.h +++ b/include/sccp/sccp_types.h @@ -24,7 +24,7 @@ #ifndef SCCP_TYPES_H #define SCCP_TYPES_H -#include +#include /* Table 1/Q.713 - SCCP message types */ enum sccp_message_types { @@ -89,13 +89,13 @@ enum { }; struct sccp_called_party_address { -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t point_code_indicator : 1, ssn_indicator : 1, global_title_indicator : 4, routing_indicator : 1, reserved : 1; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN uint8_t reserved : 1, routing_indicator : 1, global_title_indicator : 4, @@ -110,10 +110,10 @@ struct sccp_called_party_address { /* Figure 6/Q.713 */ struct sccp_signalling_point_code { uint8_t lsb; -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t msb : 6, reserved : 2; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN uint8_t reserved : 2, msb : 6; #endif @@ -152,10 +152,10 @@ enum { }; struct sccp_global_title { -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t nature_of_addr_ind : 7, odd_even : 1; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN uint8_t odd_even : 1, nature_of_addr_ind : 7; #endif -- cgit v1.2.3