From aa934630530af05a84b62b204ce4da7688c5e3ad Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 7 Nov 2018 13:16:54 +0100 Subject: Update 3GPP TS 08.08 Cause handling * add Class definitions * add helper to check for extended bit * add helper to get Cause's Class * use enum in gsm0808_cause_name() and gsm0808_create_cipher_reject() to avoid confusion between class and cause * update gsm0808_create_cipher_reject() comments Change-Id: I31b31dfc22eb4b6b07089e1255246ac458125340 Related: OS#3187 --- src/gsm/gsm0808.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/gsm/gsm0808.c') diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c index e5c3e30a..791ebc2c 100644 --- a/src/gsm/gsm0808.c +++ b/src/gsm/gsm0808.c @@ -265,18 +265,18 @@ struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id) } /*! Create BSSMAP Cipher Mode Reject message - * \param[in] cause TS 08.08 cause value + * \param[in] cause 3GPP TS 08.08 §3.2.2.5 cause value * \returns callee-allocated msgb with BSSMAP Cipher Mode Reject message */ -struct msgb *gsm0808_create_cipher_reject(uint8_t cause) +struct msgb *gsm0808_create_cipher_reject(enum gsm0808_cause cause) { struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, - "bssmap: clear complete"); + "bssmap: cipher mode reject"); if (!msg) return NULL; msgb_v_put(msg, BSS_MAP_MSG_CIPHER_MODE_REJECT); - /* FIXME: support 2-byte cause value as per 3GPP TS 08.08 §3.2.2.5 */ - msgb_tlv_put(msg, GSM0808_IE_CAUSE, 1, &cause); + + msgb_tlv_put(msg, GSM0808_IE_CAUSE, 1, (const uint8_t *)&cause); msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg)); @@ -1271,8 +1271,26 @@ static const struct value_string gsm0808_cause_names[] = { { 0, NULL } }; +static const struct value_string gsm0808_cause_class_names[] = { + { GSM0808_CAUSE_CLASS_NORM0, "Normal event" }, + { GSM0808_CAUSE_CLASS_NORM1, "Normal event" }, + { GSM0808_CAUSE_CLASS_RES_UNAVAIL, "Resource unavailable" }, + { GSM0808_CAUSE_CLASS_SRV_OPT_NA, "Service or option not available" }, + { GSM0808_CAUSE_CLASS_SRV_OPT_NIMPL, "Service or option not implemented" }, + { GSM0808_CAUSE_CLASS_INVAL, "Invalid message" }, + { GSM0808_CAUSE_CLASS_PERR, "Protocol error" }, + { GSM0808_CAUSE_CLASS_INTW, "Interworking" }, + { 0, NULL } +}; + +/*! Return string name of BSSMAP Cause Class name */ +const char *gsm0808_cause_class_name(enum gsm0808_cause_class class) +{ + return get_value_string(gsm0808_cause_class_names, class); +} + /*! Return string name of BSSMAP Cause name */ -const char *gsm0808_cause_name(uint8_t cause) +const char *gsm0808_cause_name(enum gsm0808_cause cause) { return get_value_string(gsm0808_cause_names, cause); } -- cgit v1.2.3