Change in libosmocore[master]: gsm0808: Make a function to extract Cause IE publicly available.

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/.

laforge gerrit-no-reply at lists.osmocom.org
Wed May 13 09:56:28 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/18229 )

Change subject: gsm0808: Make a function to extract Cause IE publicly available.
......................................................................

gsm0808: Make a function to extract Cause IE publicly available.

Function gsm0808_get_cipher_reject_cause() was previously available
in private gsm0808_utils.h. In practice, the exact same code is useful
to extract Cause IE value from any of the many other BSSMAP messages
which use it.

So let's rename it to gsm0808_get_cause() and make it avilable
to everyone to use.

Change-Id: Idf2b99e9ef014eba26e3d4f0f38c2714d3a0520a
---
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808.c
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
6 files changed, 22 insertions(+), 19 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 373b434..5a33f60 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -315,6 +315,10 @@
 const char *gsm0808_cause_name(enum gsm0808_cause cause);
 const char *gsm0808_cause_class_name(enum gsm0808_cause_class class);
 
+/*! Parse Cause TLV 3GPP TS 08.08 §3.2.2.5
+ * \returns Cause value */
+enum gsm0808_cause gsm0808_get_cause(const struct tlv_parsed *tp);
+
 extern const struct value_string gsm0808_lcls_config_names[];
 extern const struct value_string gsm0808_lcls_control_names[];
 extern const struct value_string gsm0808_lcls_status_names[];
diff --git a/include/osmocom/gsm/gsm0808_utils.h b/include/osmocom/gsm/gsm0808_utils.h
index ccdf5ed..1cdca8c 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -155,8 +155,6 @@
 	return (cause & 0x80) && !(cause & 0x0F);
 }
 
-int gsm0808_get_cipher_reject_cause(const struct tlv_parsed *tp);
-
 /*! \returns 3GPP TS 48.008 3.2.2.49 Current Channel Type 1 from enum gsm_chan_t. */
 static inline uint8_t gsm0808_current_channel_type_1(enum gsm_chan_t type)
 {
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 02288e6..788f6c3 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -1654,6 +1654,22 @@
 	return get_value_string(gsm0808_cause_names, cause);
 }
 
+enum gsm0808_cause gsm0808_get_cause(const struct tlv_parsed *tp)
+{
+	const uint8_t *buf = TLVP_VAL_MINLEN(tp, GSM0808_IE_CAUSE, 1);
+
+	if (!buf)
+		return -EBADMSG;
+
+	if (TLVP_LEN(tp, GSM0808_IE_CAUSE) > 1) {
+		if (!gsm0808_cause_ext(buf[0]))
+			return -EINVAL;
+		return buf[1];
+	}
+
+	return buf[0];
+}
+
 const struct value_string gsm0808_lcls_config_names[] = {
 	{ GSM0808_LCLS_CFG_BOTH_WAY, "Connect both-way" },
 	{ GSM0808_LCLS_CFG_BOTH_WAY_AND_BICAST_UL,
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 7416d8f..6f3c07a 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -1563,22 +1563,6 @@
 	return 0;
 }
 
-int gsm0808_get_cipher_reject_cause(const struct tlv_parsed *tp)
-{
-	const uint8_t *buf = TLVP_VAL_MINLEN(tp, GSM0808_IE_CAUSE, 1);
-
-	if (!buf)
-		return -EBADMSG;
-
-	if (TLVP_LEN(tp, GSM0808_IE_CAUSE) > 1) {
-		if (!gsm0808_cause_ext(buf[0]))
-			return -EINVAL;
-		return buf[1];
-	}
-
-	return buf[0];
-}
-
 /*! Print a human readable name of the cell identifier to the char buffer.
  * This is useful both for struct gsm0808_cell_id and struct gsm0808_cell_id_list2.
  * See also gsm0808_cell_id_name() and gsm0808_cell_id_list_name().
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index a518b28..1ff1286 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -157,6 +157,7 @@
 gsm0808_bssmap_name;
 gsm0808_cause_name;
 gsm0808_cause_class_name;
+gsm0808_get_cause;
 gsm0808_create_ass;
 gsm0808_create_ass2;
 gsm0808_create_assignment_completed;
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index ec24914..ce73390 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -306,7 +306,7 @@
 	if (rc < 0)
 		printf("FIXME: failed (%d) to parse created message %s\n", rc, msgb_hexdump(msg));
 
-	rc = gsm0808_get_cipher_reject_cause(&tp);
+	rc = gsm0808_get_cause(&tp);
 	if (rc < 0)
 		printf("FIXME: failed (%s) to extract Cause from created message %s\n",
 		       strerror(-rc), msgb_hexdump(msg));

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Idf2b99e9ef014eba26e3d4f0f38c2714d3a0520a
Gerrit-Change-Number: 18229
Gerrit-PatchSet: 1
Gerrit-Owner: ipse <Alexander.Chemeris at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200513/b3368d52/attachment.htm>


More information about the gerrit-log mailing list