aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-10-10 17:04:28 +0200
committerHarald Welte <laforge@gnumonks.org>2018-10-10 20:43:25 +0000
commit4290803d89d129c1eb8b762b9b547e5df6204401 (patch)
tree83d308cf3a101a031e079ea33fc04d041a28b8ab
parentf653821fb30f511be6cb775403ae3a5fc9e8ccd6 (diff)
gsm_08_58.h: Introduce struct abis_rsl_link_id
It will allow to make code handling link_id values more easier to read and less prone to errors. union is used to be able to get the full octet in case we need to pass it somewhere else or encode it. An extra union is used in struct abis_rsl_common_hdr to allow using fields directly while keeping API compatibility. Change-Id: Ibd75a493bcfdf46c028ea466867d0c0d83d46343
-rw-r--r--include/osmocom/gsm/protocol/gsm_08_58.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/include/osmocom/gsm/protocol/gsm_08_58.h b/include/osmocom/gsm/protocol/gsm_08_58.h
index e5ff4646..c7a7d8aa 100644
--- a/include/osmocom/gsm/protocol/gsm_08_58.h
+++ b/include/osmocom/gsm/protocol/gsm_08_58.h
@@ -25,10 +25,30 @@
#include <stdint.h>
+#include <osmocom/core/endian.h>
+
/*! \addtogroup rsl
* @{
* \file gsm_08_58.h */
+/* Link Identifier 9.3.2 */
+union abis_rsl_link_id {
+#if OSMO_IS_BIG_ENDIAN
+ uint8_t cbits:2,
+ na:1,
+ reserved:2;
+ sapi:3;
+#elif OSMO_IS_LITTLE_ENDIAN
+ uint8_t sapi:3,
+ reserved:2,
+ na:1,
+ cbits:2;
+#endif
+ uint8_t link_id;
+} __attribute__ ((packed));
+#define ABIS_RSL_LINK_ID_CBITS_FACCH_SDCCH 0x00
+#define ABIS_RSL_LINK_ID_CBITS_SACCH 0x01
+
/*! RSL common header */
struct abis_rsl_common_hdr {
uint8_t msg_discr; /*!< message discriminator (ABIS_RSL_MDISC_*) */
@@ -42,7 +62,10 @@ struct abis_rsl_rll_hdr {
uint8_t ie_chan; /*!< \ref RSL_IE_CHAN_NR (tag) */
uint8_t chan_nr; /*!< RSL channel number (value) */
uint8_t ie_link_id; /*!< \ref RSL_IE_LINK_IDENT (tag) */
- uint8_t link_id; /*!< RSL link identifier (value) */
+ union {
+ uint8_t link_id; /* API backward compat */
+ union abis_rsl_link_id link_id_fields; /*!< RSL link identifier (value) */
+ };
uint8_t data[0]; /*!< message payload data */
} __attribute__ ((packed));