summaryrefslogtreecommitdiffstats
path: root/src/gsm/gsm0808.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-12-19 19:35:26 +0100
committerHarald Welte <laforge@gnumonks.org>2019-01-07 15:49:36 +0000
commit45f89c938dcd5fce0bcaeee2e88c3ad7247277a0 (patch)
treeafbec3a0841199625c6890308aeb18f14f534778 /src/gsm/gsm0808.c
parent42e567c5a95af3e823a68fe7c949f5282d06d297 (diff)
LCLS: fix LCLS-CONNECT-CONTROL encoder
Previously it could encode both incorrect values as well as incorrect message. Let's fix this by explicitly checking for invalid values and ensuring that at least one of the parameters is valid. This function have no external or internal users so it's better to fix type signature as well to match the rest of gsm0808_create_lcls_*(). Change-Id: I7b33a771acbd391c5f9a494d6450edb18511433f
Diffstat (limited to 'src/gsm/gsm0808.c')
-rw-r--r--src/gsm/gsm0808.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 485e0632..59b16575 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -312,19 +312,24 @@ struct msgb *gsm0808_create_cipher_reject_ext(enum gsm0808_cause_class class, ui
* \param[in] config LCLS Configuration
* \param[in] control LCLS Connection Status Control
* \returns callee-allocated msgb with BSSMAP LCLS NOTIFICATION */
-struct msgb *gsm0808_create_lcls_conn_ctrl(enum gsm0808_lcls_config *config,
- enum gsm0808_lcls_control *control)
+struct msgb *gsm0808_create_lcls_conn_ctrl(enum gsm0808_lcls_config config,
+ enum gsm0808_lcls_control control)
{
- struct msgb *msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM,
- "bssmap: LCLS CONN CTRL");
+ struct msgb *msg;
+
+ /* According to NOTE 1 in ยง3.2.1.91 at least one of the parameters is required */
+ if (config == GSM0808_LCLS_CFG_NA && control == GSM0808_LCLS_CSC_NA)
+ return NULL;
+
+ msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "bssmap: LCLS CONN CTRL");
if (!msg)
return NULL;
msgb_v_put(msg, BSS_MAP_MSG_LCLS_CONNECT_CTRL);
- if (config)
- msgb_tv_put(msg, GSM0808_IE_LCLS_CONFIG, *config);
- if (control)
- msgb_tv_put(msg, GSM0808_IE_LCLS_CONFIG, *control);
+ if (config != GSM0808_LCLS_CFG_NA)
+ msgb_tv_put(msg, GSM0808_IE_LCLS_CONFIG, config);
+ if (control != GSM0808_LCLS_CSC_NA)
+ msgb_tv_put(msg, GSM0808_IE_LCLS_CONFIG, control);
msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));
return msg;