Change in libosmocore[master]: LCLS: fix LCLS-CONNECT-CONTROL encoder

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Wed Dec 19 18:39:06 UTC 2018


Max has uploaded this change for review. ( https://gerrit.osmocom.org/12376


Change subject: LCLS: fix LCLS-CONNECT-CONTROL encoder
......................................................................

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
---
M TODO-RELEASE
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
3 files changed, 16 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/12376/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 16d96ec..8b5f841 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -19,3 +19,4 @@
 libosmogsm	osmo_gsup_message			extended with SMS related fields
 libosmogsm	osmo_gsup_sms_{en|de}code_sm_rp_da	GSUP SM-RP-DA coding helpers
 libosmogsm	osmo_gsup_sms_{en|de}code_sm_rp_oa	GSUP SM-RP-OA coding helpers
+libosmogsm	gsm0808_create_lcls_conn_ctrl()		API/ABI break: change parameters from pointers to plain values
diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 79d89e5..ac88748 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -92,8 +92,8 @@
 				   const struct gsm0808_cell_id_list *cil,
 				   const uint8_t *chan_needed)
 				   OSMO_DEPRECATED("use gsm0808_create_paging2 instead");
-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 *gsm0808_create_lcls_conn_ctrl_ack(enum gsm0808_lcls_status status);
 struct msgb *gsm0808_create_lcls_notification(enum gsm0808_lcls_status status, bool break_req);
 
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 0f9e8df..6df3ba4 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -312,19 +312,24 @@
  *  \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;

-- 
To view, visit https://gerrit.osmocom.org/12376
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b33a771acbd391c5f9a494d6450edb18511433f
Gerrit-Change-Number: 12376
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181219/f1e89a3a/attachment.htm>


More information about the gerrit-log mailing list