diff options
author | Max <msuraev@sysmocom.de> | 2018-12-19 18:51:00 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-12-23 10:20:05 +0000 |
commit | 470221575deaa14c670a5d4233df80119599141d (patch) | |
tree | 6665bd28d7d8be42c85aacedaf87573be1529be3 /src/gsm/gsm0808_utils.c | |
parent | e5bde9053238ba8fdce9797f97d76016abf474f7 (diff) |
LCLS: enc/dec entire parameter set instead of GCR
In 3GPP TS 48.008 the Global Call Reference IE is only used in HANDOVER
REQUEST (§3.2.1.8) and ASSIGNMENT REQUEST (§3.2.1.1) messages which
also include LCLS Config and CSC parameters. Hence, there's no point in
using GCR encode/decode functions alone.
Introduce gsm0808_dec_lcls() and gsm0808_enc_lcls() as trivial wrappers
on top of GCR enc/dec routines which are made static. Adjust tests
accordingly. Test output intentionally left unchanged.
Change-Id: Icfbb2404e1a1d500243e2071173299b557369335
Diffstat (limited to 'src/gsm/gsm0808_utils.c')
-rw-r--r-- | src/gsm/gsm0808_utils.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index aa0d3d7a..2a458c38 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -512,7 +512,7 @@ int gsm0808_dec_channel_type(struct gsm0808_channel_type *ct, * \param[out] msg Message Buffer for appending IE * \param[in] g Global Call Reference, 3GPP TS 29.205 Table B 2.1.9.1 * \returns number of bytes added to \a msg or 0 on error */ -uint8_t gsm0808_enc_gcr(struct msgb *msg, const struct osmo_gcr_parsed *g) +static uint8_t gsm0808_enc_gcr(struct msgb *msg, const struct osmo_gcr_parsed *g) { uint8_t enc, *len = msgb_tl_put(msg, GSM0808_IE_GLOBAL_CALL_REF); @@ -528,7 +528,7 @@ uint8_t gsm0808_enc_gcr(struct msgb *msg, const struct osmo_gcr_parsed *g) * \param[out] gcr Caller-provided memory to store Global Call Reference * \param[in] tp IE values to be decoded * \returns number of bytes parsed; negative on error */ -int gsm0808_dec_gcr(struct osmo_gcr_parsed *gcr, const struct tlv_parsed *tp) +static int gsm0808_dec_gcr(struct osmo_gcr_parsed *gcr, const struct tlv_parsed *tp) { int ret; const uint8_t *buf = TLVP_VAL_MINLEN(tp, GSM0808_IE_GLOBAL_CALL_REF, OSMO_GCR_MIN_LEN); @@ -542,6 +542,56 @@ int gsm0808_dec_gcr(struct osmo_gcr_parsed *gcr, const struct tlv_parsed *tp) return 2 + ret; } +/*! Add LCLS parameters to a given msgb, 3GPP TS 48.008 §3.2.2.115 - 3.2.2.120. + * \param[out] msg Message Buffer for appending IE + * \param[in] lcls LCLS-related data + * \returns number of bytes added to \a msg or 0 on error */ +uint8_t gsm0808_enc_lcls(struct msgb *msg, const struct osmo_lcls *lcls) +{ + uint8_t enc = 0; + + /* LCLS: §3.2.2.115 Global Call Reference */ + if (lcls->gcr) + enc = gsm0808_enc_gcr(msg, lcls->gcr); + + /* LCLS: §3.2.2.116 Configuration */ + if (lcls->config != GSM0808_LCLS_CFG_NA) { + msgb_tv_put(msg, GSM0808_IE_LCLS_CONFIG, lcls->config); + enc += 2; + } + + /* LCLS: §3.2.2.117 Connection Status Control */ + if (lcls->control != GSM0808_LCLS_CSC_NA) { + msgb_tv_put(msg, GSM0808_IE_LCLS_CONN_STATUS_CTRL, lcls->control); + enc += 2; + } + + /* LCLS: §3.2.2.118 Correlation-Not-Needed */ + if (!lcls->corr_needed) { + msgb_v_put(msg, GSM0808_IE_LCLS_CORR_NOT_NEEDED); + enc++; + } + + return enc; +} + +/*! Decode LCLS parameters to a given msgb, 3GPP TS 48.008 §3.2.2.115 - 3.2.2.120. + * \param[out] lcls Caller-provided memory to store LCLS-related data + * \param[in] tp IE values to be decoded + * \returns GCR size or negative on error */ +int gsm0808_dec_lcls(struct osmo_lcls *lcls, const struct tlv_parsed *tp) +{ + int ret = gsm0808_dec_gcr(lcls->gcr, tp); + if (ret < 0) + return ret; + + lcls->config = tlvp_val8(tp, GSM0808_IE_LCLS_CONFIG, GSM0808_LCLS_CFG_NA); + lcls->control = tlvp_val8(tp, GSM0808_IE_LCLS_CONN_STATUS_CTRL, GSM0808_LCLS_CSC_NA); + lcls->corr_needed = TLVP_PRESENT(tp, GSM0808_IE_LCLS_CORR_NOT_NEEDED) ? false : true; + + return ret; +} + /*! Encode TS 08.08 Encryption Information IE * \param[out] msg Message Buffer to which IE is to be appended * \param[in] ei Encryption Information to be encoded |