diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2023-11-29 08:32:46 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2023-11-29 10:15:33 +0000 |
commit | 5560c040bde7ebbad0779a83ebd8804d3e958ea9 (patch) | |
tree | 87438c548f8b4f1c09469bc3ef2e0867121314df | |
parent | d6e16decadc5dd0be7ee850cabdfda469c4be8b0 (diff) |
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
-rw-r--r-- | include/osmocom/gsm/protocol/gsm_08_58.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/osmocom/gsm/protocol/gsm_08_58.h b/include/osmocom/gsm/protocol/gsm_08_58.h index 0a44db90..e8758df0 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 @@ union abis_rsl_chan_nr { 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 @@ union abis_rsl_chan_nr { /* 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 @@ union abis_rsl_link_id { 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 |