diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2021-02-04 12:37:25 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2021-02-08 17:23:25 +0000 |
commit | 15b5acb332f49f31e2719510f447622b0b5ad7d5 (patch) | |
tree | 550d4658e0db7d51a8fa4f096185e96a8d014633 | |
parent | 53aff13af4c76c7b51cf68ebbd4a07a2509e7ebd (diff) |
Fix struct bitfields on big endian systems
Changes done by contrib/struct_endianess.py.
Change-Id: Ia9cb1ef2ba2bfff9ef713c7d1cf388931dae1c46
-rw-r--r-- | include/osmocom/gprs/protocol/gsm_08_18.h | 1 | ||||
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_23_032.h | 80 | ||||
-rw-r--r-- | src/gb/frame_relay.c | 7 |
3 files changed, 88 insertions, 0 deletions
diff --git a/include/osmocom/gprs/protocol/gsm_08_18.h b/include/osmocom/gprs/protocol/gsm_08_18.h index c10c2442..0d002b57 100644 --- a/include/osmocom/gprs/protocol/gsm_08_18.h +++ b/include/osmocom/gprs/protocol/gsm_08_18.h @@ -4,6 +4,7 @@ #pragma once #include <stdint.h> +#include <osmocom/core/endian.h> /*! Fixed BVCI definitions (Section 5.4.1) */ #define BVCI_SIGNALLING 0x0000 diff --git a/include/osmocom/gsm/protocol/gsm_23_032.h b/include/osmocom/gsm/protocol/gsm_23_032.h index 5be98a29..a4c05061 100644 --- a/include/osmocom/gsm/protocol/gsm_23_032.h +++ b/include/osmocom/gsm/protocol/gsm_23_032.h @@ -50,8 +50,13 @@ enum gad_type { }; struct gad_raw_head { +#if OSMO_IS_LITTLE_ENDIAN uint8_t spare:4, type:4; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t type:4, spare:4; +#endif } __attribute__ ((packed)); struct gad_raw_ell_point { @@ -61,14 +66,23 @@ struct gad_raw_ell_point { } __attribute__ ((packed)); struct gad_raw_ell_point_unc_circle { +#if OSMO_IS_LITTLE_ENDIAN struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_UNC_CIRCLE */ uint8_t lat[3]; uint8_t lon[3]; uint8_t unc:7, spare2:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + struct gad_raw_head h; + uint8_t lat[3]; + uint8_t lon[3]; + uint8_t spare2:1, unc:7; +#endif } __attribute__ ((packed)); struct gad_raw_ell_point_unc_ellipse { +#if OSMO_IS_LITTLE_ENDIAN struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_UNC_ELLIPSE */ uint8_t lat[3]; uint8_t lon[3]; @@ -79,12 +93,27 @@ struct gad_raw_ell_point_unc_ellipse { uint8_t major_ori; uint8_t confidence:7, spare3:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + struct gad_raw_head h; + uint8_t lat[3]; + uint8_t lon[3]; + uint8_t spare1:1, unc_semi_major:7; + uint8_t spare2:1, unc_semi_minor:7; + uint8_t major_ori; + uint8_t spare3:1, confidence:7; +#endif } __attribute__ ((packed)); struct gad_raw_polygon { struct { +#if OSMO_IS_LITTLE_ENDIAN uint8_t num_points:4; uint8_t type:4; /*!< type = GAD_TYPE_POLYGON */ +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t type:4, num_points:4; +#endif } h; struct { uint8_t lat[3]; @@ -100,6 +129,7 @@ struct gad_raw_ell_point_alt { } __attribute__ ((packed)); struct gad_raw_ell_point_alt_unc_ell { +#if OSMO_IS_LITTLE_ENDIAN struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_POINT_ALT_UNC_ELL */ uint8_t lat[3]; uint8_t lon[3]; @@ -113,9 +143,22 @@ struct gad_raw_ell_point_alt_unc_ell { spare3:1; uint8_t confidence:7, spare4:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + struct gad_raw_head h; + uint8_t lat[3]; + uint8_t lon[3]; + uint8_t alt[2]; + uint8_t spare1:1, unc_semi_major:7; + uint8_t spare2:1, unc_semi_minor:7; + uint8_t major_ori; + uint8_t spare3:1, unc_alt:7; + uint8_t spare4:1, confidence:7; +#endif } __attribute__ ((packed)); struct gad_raw_ell_arc { +#if OSMO_IS_LITTLE_ENDIAN struct gad_raw_head h; /*!< type = GAD_TYPE_ELL_ARC */ uint8_t lat[3]; uint8_t lon[3]; @@ -126,9 +169,21 @@ struct gad_raw_ell_arc { uint8_t incl_angle; uint8_t confidence:7, spare2:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + struct gad_raw_head h; + uint8_t lat[3]; + uint8_t lon[3]; + uint8_t inner_r[2]; + uint8_t spare1:1, unc_r:7; + uint8_t ofs_angle; + uint8_t incl_angle; + uint8_t spare2:1, confidence:7; +#endif } __attribute__ ((packed)); struct gad_raw_ha_ell_point_unc_ell { +#if OSMO_IS_LITTLE_ENDIAN struct gad_raw_head h; /*!< type = GAD_TYPE_HA_ELL_POINT_UNC_ELLIPSE */ uint8_t lat[4]; uint8_t lon[4]; @@ -138,9 +193,21 @@ struct gad_raw_ha_ell_point_unc_ell { uint8_t major_ori; uint8_t confidence:7, spare1:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + struct gad_raw_head h; + uint8_t lat[4]; + uint8_t lon[4]; + uint8_t alt[3]; + uint8_t unc_semi_major; + uint8_t unc_semi_minor; + uint8_t major_ori; + uint8_t spare1:1, confidence:7; +#endif } __attribute__ ((packed)); struct gad_raw_ha_ell_point_alt_unc_ell { +#if OSMO_IS_LITTLE_ENDIAN struct gad_raw_head h; /*!< type = GAD_TYPE_HA_ELL_POINT_ALT_UNC_ELL */ uint8_t lat[4]; uint8_t lon[4]; @@ -153,6 +220,19 @@ struct gad_raw_ha_ell_point_alt_unc_ell { uint8_t unc_alt; uint8_t v_confidence:7, spare2:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + struct gad_raw_head h; + uint8_t lat[4]; + uint8_t lon[4]; + uint8_t alt[3]; + uint8_t unc_semi_major; + uint8_t unc_semi_minor; + uint8_t major_ori; + uint8_t spare1:1, h_confidence:7; + uint8_t unc_alt; + uint8_t spare2:1, v_confidence:7; +#endif } __attribute__ ((packed)); /*! GAD PDU in network-byte-order according to 3GPP TS 23.032 GAD: Universal Geographical Area Description. */ diff --git a/src/gb/frame_relay.c b/src/gb/frame_relay.c index c54384e7..84cd17f5 100644 --- a/src/gb/frame_relay.c +++ b/src/gb/frame_relay.c @@ -123,6 +123,7 @@ struct q933_a_hdr { /* Value part of the Q.933 Annex A.3.3 IE */ struct q933_a_pvc_sts { +#if OSMO_IS_LITTLE_ENDIAN uint8_t dlci_msb:6, spare:1, ext0:1; @@ -136,6 +137,12 @@ struct q933_a_pvc_sts { spare2:3, ext2:1; +#elif OSMO_IS_BIG_ENDIAN +/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ + uint8_t ext0:1, spare:1, dlci_msb:6; + uint8_t ext1:1, dlci_lsb:4, space1:3; + uint8_t ext2:1, spare2:3, new:1, delete:1, active:1, reserved:1; +#endif } __attribute__((packed)); /* RX Message: 14 [ 00 01 03 08 00 75 95 01 01 00 03 02 01 00 ] */ |