diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm/gsm0808.c | 19 | ||||
-rw-r--r-- | src/gsm/gsm0808_utils.c | 54 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 4 |
3 files changed, 56 insertions, 21 deletions
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c index 69da57da..485e0632 100644 --- a/src/gsm/gsm0808.c +++ b/src/gsm/gsm0808.c @@ -488,23 +488,8 @@ struct msgb *gsm0808_create_ass2(const struct gsm0808_channel_type *ct, if (kc) msgb_tv_fixed_put(msg, GSM0808_IE_KC_128, 16, kc); - if (lcls) { - /* LCLS: §3.2.2.115 Global Call Reference */ - if (lcls->gcr) - 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); - - /* 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); - - /* LCLS: §3.2.2.118 Correlation-Not-Needed */ - if (!lcls->corr_needed) - msgb_v_put(msg, GSM0808_IE_LCLS_CORR_NOT_NEEDED); - } + if (lcls) + gsm0808_enc_lcls(msg, lcls); /* push the bssmap header */ msg->l3h = 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 diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 90c21954..76b3fd02 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -220,8 +220,8 @@ gsm0808_channel_type_name; gsm0808_lcls_config_names; gsm0808_lcls_control_names; gsm0808_lcls_status_names; -gsm0808_enc_gcr; -gsm0808_dec_gcr; +gsm0808_enc_lcls; +gsm0808_dec_lcls; gsm29118_msgb_alloc; gsm29118_create_alert_req; |