Change in osmo-pcu[master]: use new osmo_mobile_identity api (avoid deprecation)

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

neels gerrit-no-reply at lists.osmocom.org
Fri Aug 21 14:34:08 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/19767 )


Change subject: use new osmo_mobile_identity api (avoid deprecation)
......................................................................

use new osmo_mobile_identity api (avoid deprecation)

Note: subsequent patch Iad845acb0096b75dc453105c9c16b2252879b4ca will change to
passing a struct osmo_mobile_identity in the Paging code path, instead of
passing the encoded IE data.

Change-Id: Ibb03b8e601160427944f434761ca59811d1fc12f
---
M src/bts.cpp
M src/gprs_bssgp_pcu.cpp
M src/gprs_rlcmac.cpp
M src/pdch.cpp
4 files changed, 37 insertions(+), 21 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/67/19767/1

diff --git a/src/bts.cpp b/src/bts.cpp
index 22b4c08..c415dd4 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -369,9 +369,13 @@
 		NULL
 	};
 
-
-	LOGP(DRLCMAC, LOGL_INFO, "Add RR paging: chan-needed=%d MI=%s\n",
-		chan_needed, osmo_mi_name(mi, mi_len));
+	if (log_check_level(DRLCMAC, LOGL_INFO)) {
+		struct osmo_mobile_identity omi = {};
+		char str[64];
+		osmo_mobile_identity_decode(&omi, mi, mi_len, true);
+		osmo_mobile_identity_to_str_buf(str, sizeof(str), &omi);
+		LOGP(DRLCMAC, LOGL_INFO, "Add RR paging: chan-needed=%d MI=%s\n", chan_needed, str);
+	}
 
 	/* collect slots to page
 	 * Mark slots for every TBF, but only mark one of it.
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index a4bcff3..4fb5989 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -87,7 +87,12 @@
 	uint32_t tlli_old = 0;
 	uint8_t *data;
 	uint16_t len;
-	char imsi[OSMO_IMSI_BUF_SIZE] = "000";
+	/* TODO: is it really necessary to initialize this as a "000" IMSI? It seems, the function should just return an
+	 * error if no IMSI IE was found. */
+	struct osmo_mobile_identity mi_imsi = {
+		.type = GSM_MI_TYPE_TMSI,
+		.imsi = { '0', '0', '0', '\0' },
+	};
 	uint8_t ms_class = 0;
 	uint8_t egprs_ms_class = 0;
 	int rc;
@@ -116,10 +121,9 @@
 	 * will listen to all paging blocks. */
 	if (TLVP_PRESENT(tp, BSSGP_IE_IMSI))
 	{
-		/* gsm48_mi_to_string() returns number of bytes written, including '\0' */
-		rc = gsm48_mi_to_string(imsi, sizeof(imsi), TLVP_VAL(tp, BSSGP_IE_IMSI),
-							    TLVP_LEN(tp, BSSGP_IE_IMSI));
-		if (rc != GSM23003_IMSI_MAX_DIGITS + 1) {
+		rc = osmo_mobile_identity_decode(&mi_imsi, TLVP_VAL(tp, BSSGP_IE_IMSI), TLVP_LEN(tp, BSSGP_IE_IMSI),
+						 true);
+		if (rc < 0 || mi_imsi.type != GSM_MI_TYPE_TMSI) {
 			LOGP(DBSSGP, LOGL_NOTICE, "Failed to parse IMSI IE (rc=%d)\n", rc);
 			return bssgp_tx_status(BSSGP_CAUSE_COND_IE_ERR, NULL, msg);
 		}
@@ -160,9 +164,9 @@
 				"TLLI (old) IE\n");
 	}
 
-	LOGP(DBSSGP, LOGL_INFO, "LLC [SGSN -> PCU] = TLLI: 0x%08x IMSI: %s len: %d\n", tlli, imsi, len);
+	LOGP(DBSSGP, LOGL_INFO, "LLC [SGSN -> PCU] = TLLI: 0x%08x IMSI: %s len: %d\n", tlli, mi_imsi.imsi, len);
 
-	return gprs_rlcmac_dl_tbf::handle(the_pcu.bts, tlli, tlli_old, imsi,
+	return gprs_rlcmac_dl_tbf::handle(the_pcu.bts, tlli, tlli_old, mi_imsi.imsi,
 			ms_class, egprs_ms_class, delay_csec, data, len);
 }
 
@@ -212,7 +216,7 @@
 
 static int gprs_bssgp_pcu_rx_paging_ps(struct msgb *msg, struct tlv_parsed *tp)
 {
-	char imsi[OSMO_IMSI_BUF_SIZE];
+	struct osmo_mobile_identity mi_imsi;
 	uint16_t pgroup;
 	const uint8_t *mi;
 	uint8_t mi_len;
@@ -223,16 +227,14 @@
 		return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
 	}
 
-	/* gsm48_mi_to_string() returns number of bytes written, including '\0' */
-	rc = gsm48_mi_to_string(imsi, sizeof(imsi), TLVP_VAL(tp, BSSGP_IE_IMSI),
-				TLVP_LEN(tp, BSSGP_IE_IMSI));
-	if (rc != GSM23003_IMSI_MAX_DIGITS + 1) {
+	rc = osmo_mobile_identity_decode(&mi_imsi, TLVP_VAL(tp, BSSGP_IE_IMSI), TLVP_LEN(tp, BSSGP_IE_IMSI), true);
+	if (rc < 0 || mi_imsi.type != GSM_MI_TYPE_IMSI) {
 		LOGP(DBSSGP, LOGL_NOTICE, "Failed to parse IMSI IE (rc=%d)\n", rc);
 		return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg);
 	}
-	pgroup = imsi2paging_group(imsi);
+	pgroup = imsi2paging_group(mi_imsi.imsi);
 	if (pgroup > 999) {
-		LOGP(DBSSGP, LOGL_NOTICE, "Failed to compute IMSI %s paging group\n", imsi);
+		LOGP(DBSSGP, LOGL_NOTICE, "Failed to compute IMSI %s paging group\n", mi_imsi.imsi);
 		return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg);
 	}
 
diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp
index c890021..879ea85 100644
--- a/src/gprs_rlcmac.cpp
+++ b/src/gprs_rlcmac.cpp
@@ -34,8 +34,13 @@
 
 int gprs_rlcmac_paging_request(const uint8_t *mi, uint8_t mi_len, uint16_t pgroup)
 {
-	LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH) MI=%s\n",
-	    osmo_mi_name(mi, mi_len));
+	if (log_check_level(DRLCMAC, LOGL_NOTICE)) {
+		struct osmo_mobile_identity omi = {};
+		char str[64];
+		osmo_mobile_identity_decode(&omi, mi, mi_len, true);
+		osmo_mobile_identity_to_str_buf(str, sizeof(str), &omi);
+		LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH) MI=%s\n", str);
+	}
 	bitvec *paging_request = bitvec_alloc(22, tall_pcu_ctx);
 	bitvec_unhex(paging_request, DUMMY_VEC);
 	int plen = Encoding::write_paging_request(paging_request, mi, mi_len);
diff --git a/src/pdch.cpp b/src/pdch.cpp
index b34f532..af84724 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -205,8 +205,13 @@
 
 	/* loop until message is full */
 	while (pag) {
-		LOGP(DRLCMAC, LOGL_DEBUG, "Paging MI - %s\n",
-		     osmo_mi_name(pag->identity_lv + 1, pag->identity_lv[0]));
+		if (log_check_level(DRLCMAC, LOGL_DEBUG)) {
+			struct osmo_mobile_identity omi = {};
+			char str[64];
+			osmo_mobile_identity_decode(&omi, pag->identity_lv + 1, pag->identity_lv[0], true);
+			osmo_mobile_identity_to_str_buf(str, sizeof(str), &omi);
+			LOGP(DRLCMAC, LOGL_DEBUG, "Paging MI - %s\n", str);
+		}
 
 		/* try to add paging */
 		if ((pag->identity_lv[1] & GSM_MI_TYPE_MASK) == GSM_MI_TYPE_TMSI) {

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ibb03b8e601160427944f434761ca59811d1fc12f
Gerrit-Change-Number: 19767
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200821/2e027ba6/attachment.htm>


More information about the gerrit-log mailing list