jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35391?usp=email )
Change subject: Add LLC and HLC transcoding to MNCC transcoding functions ......................................................................
Add LLC and HLC transcoding to MNCC transcoding functions
low/high layer compatibility are used for capability checking between caller and called entitiy. They are transparently forwarded, so there is no parsing or assembling of the elements.
Related: OS#6152 Change-Id: Ia6a2159ecf810a02f85b558026edf20b934567de --- M include/osmocom/gsm/gsm48_ie.h M include/osmocom/gsm/mncc.h M src/gsm/gsm48_ie.c M src/gsm/libosmogsm.map 4 files changed, 96 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/91/35391/1
diff --git a/include/osmocom/gsm/gsm48_ie.h b/include/osmocom/gsm/gsm48_ie.h index 4768283..7833254 100644 --- a/include/osmocom/gsm/gsm48_ie.h +++ b/include/osmocom/gsm/gsm48_ie.h @@ -34,6 +34,14 @@ /* encode 'call control cap' */ int gsm48_encode_cccap(struct msgb *msg, const struct gsm_mncc_cccap *ccap); +/* encode 'high layer complatibility' */ +int gsm48_encode_highl_compat(struct msgb *msg, const struct gsm_mncc_highl_compat *hlc); +/* decode 'high layer complatibility' */ +int gsm48_decode_highl_compat(struct gsm_mncc_highl_compat *hlc, const uint8_t *lv); +/* encode 'low layer complatibility' */ +int gsm48_encode_lowl_compat(struct msgb *msg, const struct gsm_mncc_lowl_compat *llc); +/* decode 'low layer complatibility' */ +int gsm48_decode_lowl_compat(struct gsm_mncc_lowl_compat *llc, const uint8_t *lv); /* decode 'called party BCD number' */ int gsm48_decode_called(struct gsm_mncc_number *called, const uint8_t *lv); diff --git a/include/osmocom/gsm/mncc.h b/include/osmocom/gsm/mncc.h index db70235..0293648 100644 --- a/include/osmocom/gsm/mncc.h +++ b/include/osmocom/gsm/mncc.h @@ -4,6 +4,8 @@
#include <osmocom/gsm/protocol/gsm_04_08.h>
+#define GSM_MAX_LOWL_COMPAT 16 /* (18 with TLV) */ +#define GSM_MAX_HIGHL_COMPAT 3 /* (5 with TLV) */ #define GSM_MAX_FACILITY 128 #define GSM_MAX_SSVERSION 128 #define GSM_MAX_USERUSER 128 @@ -30,6 +32,16 @@ } data; };
+struct gsm_mncc_lowl_compat { + int len; + char compat[GSM_MAX_LOWL_COMPAT]; +}; + +struct gsm_mncc_highl_compat { + int len; + char compat[GSM_MAX_HIGHL_COMPAT]; +}; + struct gsm_mncc_number { int type; int plan; diff --git a/src/gsm/gsm48_ie.c b/src/gsm/gsm48_ie.c index bb86cf4..aba0055 100644 --- a/src/gsm/gsm48_ie.c +++ b/src/gsm/gsm48_ie.c @@ -409,6 +409,64 @@ return 0; }
+/*! Encode TS 04.08 High Layer compatibility IE (10.5.4.16) */ +int gsm48_encode_highl_compat(struct msgb *msg, const struct gsm_mncc_highl_compat *hlc) +{ + uint8_t lv[sizeof(hlc->compat) + 1]; + + if (hlc->len < 1 || hlc->len > sizeof(hlc->compat)) + return -EINVAL; + + lv[0] = 1 + hlc->len; + memcpy(lv + 1, hlc->compat, hlc->len); + msgb_tlv_put(msg, GSM48_IE_HIGHL_COMPAT, lv[0], lv+1); + + return 0; +} + +/*! Decode TS 04.08 High Layer compatibility IE (10.5.4.16) */ +int gsm48_decode_highl_compat(struct gsm_mncc_highl_compat *hlc, const uint8_t *lv) +{ + uint8_t in_len = lv[0]; + + if (in_len < 1 || in_len > sizeof(hlc->compat)) + return -EINVAL; + + memcpy(hlc->compat, lv+1, in_len); + hlc->len = in_len; + + return 0; +} + +/*! Encode TS 04.08 Lower Layer compatibility IE (10.5.4.18) */ +int gsm48_encode_lowl_compat(struct msgb *msg, const struct gsm_mncc_lowl_compat *llc) +{ + uint8_t lv[sizeof(llc->compat) + 1]; + + if (llc->len < 1 || llc->len > sizeof(llc->compat)) + return -EINVAL; + + lv[0] = 1 + llc->len; + memcpy(lv + 1, llc->compat, llc->len); + msgb_tlv_put(msg, GSM48_IE_LOWL_COMPAT, lv[0], lv+1); + + return 0; +} + +/*! Decode TS 04.08 Lower Layer compatibility IE (10.5.4.18) */ +int gsm48_decode_lowl_compat(struct gsm_mncc_lowl_compat *llc, const uint8_t *lv) +{ + uint8_t in_len = lv[0]; + + if (in_len < 1 || in_len > sizeof(llc->compat)) + return -EINVAL; + + memcpy(llc->compat, lv+1, in_len); + llc->len = in_len; + + return 0; +} + /*! Decode TS 04.08 Called Party BCD Number IE (10.5.4.7) * \param[out] called Caller-provided memory for decoded number * \param[in] lv Length-Value portion of IE diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index db2dbcb..3d5c14f 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -399,6 +399,8 @@ gsm48_decode_calling; gsm48_decode_cause; gsm48_decode_cccap; +gsm48_decode_highl_compat; +gsm48_decode_lowl_compat; gsm48_decode_connected; gsm48_decode_facility; gsm48_decode_freq_list; @@ -418,6 +420,8 @@ gsm48_encode_calling; gsm48_encode_cause; gsm48_encode_cccap; +gsm48_encode_highl_compat; +gsm48_encode_lowl_compat; gsm48_encode_connected; gsm48_encode_facility; gsm48_encode_keypad;