jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35156?usp=email )
Change subject: Fix union abis_rsl_chan_nr and abis_rsl_link_id ......................................................................
Fix union abis_rsl_chan_nr and abis_rsl_link_id
All bit fields in a union will overlap in memory, as all elements in a union do. To prevent the bit fields from overlapping, wrap them into a packed structure.
Change-Id: I5ef5aa62be8310da4ebe9ea73ebbedcbcc2ba49c --- M include/osmocom/gsm/protocol/gsm_08_58.h 1 file changed, 19 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/56/35156/1
diff --git a/include/osmocom/gsm/protocol/gsm_08_58.h b/include/osmocom/gsm/protocol/gsm_08_58.h index 0a44db9..e8758df 100644 --- a/include/osmocom/gsm/protocol/gsm_08_58.h +++ b/include/osmocom/gsm/protocol/gsm_08_58.h @@ -29,6 +29,7 @@
/* Channel Number 9.3.1 */ union abis_rsl_chan_nr { + struct { #if OSMO_IS_BIG_ENDIAN uint8_t cbits:5, tn:3; @@ -36,7 +37,8 @@ uint8_t tn:3, cbits:5; #endif - uint8_t chan_nr; + } __attribute__ ((packed)); + uint8_t chan_nr; } __attribute__ ((packed)); #define ABIS_RSL_CHAN_NR_CBITS_Bm_ACCHs 0x01 #define ABIS_RSL_CHAN_NR_CBITS_Lm_ACCHs(ss) (0x02 + (ss)) @@ -55,6 +57,7 @@
/* Link Identifier 9.3.2 */ union abis_rsl_link_id { + struct { #if OSMO_IS_BIG_ENDIAN uint8_t cbits:2, na:1, @@ -66,7 +69,8 @@ na:1, cbits:2; #endif - uint8_t link_id; + } __attribute__ ((packed)); + uint8_t link_id; } __attribute__ ((packed)); #define ABIS_RSL_LINK_ID_CBITS_FACCH_SDCCH 0x00 #define ABIS_RSL_LINK_ID_CBITS_SACCH 0x01