Change in osmo-hlr[master]: USSD: send 'unknown imsi' back to source

osmith gerrit-no-reply at lists.osmocom.org
Thu Apr 4 11:51:56 UTC 2019


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/13515


Change subject: USSD: send 'unknown imsi' back to source
......................................................................

USSD: send 'unknown imsi' back to source

Depends: Ic00b0601eacff6d72927cea51767801142ee75db (libosmocore.git)
Change-Id: If5a65f471672949192061c5fe396603611123bc1
---
M src/hlr_ussd.c
1 file changed, 32 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/15/13515/1

diff --git a/src/hlr_ussd.c b/src/hlr_ussd.c
index 7de750f..3a9151c 100644
--- a/src/hlr_ussd.c
+++ b/src/hlr_ussd.c
@@ -171,6 +171,11 @@
 	 * Still, this should be refreshed in due time, e.g. once per received message. */
 	struct hlr_subscriber *subscr;
 
+	/* The IPA name of the entity (MSC/VLR) that sent this message, so we can send "unknown IMSI" errors back.*/
+	uint8_t *source_name;
+	size_t source_name_len;
+	bool source_fallback;
+
 	/* we don't keep a pointer to the osmo_gsup_{route,conn} towards the MSC/VLR here,
 	 * as this might change during inter-VLR hand-over, and we simply look-up the serving MSC/VLR
 	 * every time we receive an USSD component from the EUSE */
@@ -202,7 +207,8 @@
 	ss_session_free(ss);
 }
 
-struct ss_session *ss_session_alloc(struct hlr *hlr, const char *imsi, uint32_t session_id)
+struct ss_session *ss_session_alloc(struct hlr *hlr, const char *imsi, uint32_t session_id, const uint8_t *source_name,
+				    size_t source_name_len)
 {
 	struct ss_session *ss;
 
@@ -214,6 +220,10 @@
 	OSMO_STRLCPY_ARRAY(ss->imsi, imsi);
 	ss->session_id = session_id;
 
+	ss->source_name = talloc_memdup(ss, source_name, source_name_len);
+	OSMO_ASSERT(ss->source_name);
+	ss->source_name_len = source_name_len;
+
 	/* Schedule self-destruction timer */
 	osmo_timer_setup(&ss->timeout, ss_session_timeout, ss);
 	if (g_hlr->ncss_guard_timeout > 0)
@@ -232,6 +242,8 @@
 {
 	struct hlr_subscriber _subscr = {};
 	struct hlr_subscriber *subscr = ss->subscr;
+	uint8_t *vlr_number;
+	size_t vlr_number_len;
 	int rc;
 
 	/* Use subscr as looked up by the caller, or look up now. */
@@ -245,14 +257,24 @@
 		subscr = &_subscr;
 	}
 
-	if (!subscr->vlr_number[0]) {
-		LOGP(DLGSUP, LOGL_ERROR, "Cannot send GSUP message, no VLR number stored for subscriber %s\n",
-		     subscr->imsi);
-		return -EINVAL;
+	vlr_number = (uint8_t *)&subscr->vlr_number;
+	vlr_number_len = strlen(subscr->vlr_number);
+	if (!vlr_number_len) {
+		if (ss->source_fallback) {
+			LOGP(DLGSUP, LOGL_DEBUG, "No VLR number stored for subscriber %s, sending to source instead\n",
+			     subscr->imsi);
+			vlr_number = ss->source_name;
+			vlr_number_len = ss->source_name_len;
+		} else {
+			LOGP(DLGSUP, LOGL_ERROR, "Cannot send GSUP message, no VLR number stored for subscriber %s\n",
+			     subscr->imsi);
+			return -EINVAL;
+		}
 	}
 
-	LOGPSS(ss, LOGL_DEBUG, "Tx USSD for IMSI %s to VLR '%s'\n", subscr->imsi, subscr->vlr_number);
-	return osmo_gsup_addr_send(gs, (uint8_t *)subscr->vlr_number, strlen(subscr->vlr_number), msg);
+	LOGPSS(ss, LOGL_DEBUG, "Tx USSD for IMSI %s to VLR %s\n", subscr->imsi,
+	       osmo_quote_str((const char *)vlr_number, vlr_number_len));
+	return osmo_gsup_addr_send(gs, vlr_number, vlr_number_len, msg);
 }
 
 static int ss_tx_to_ms(struct ss_session *ss, enum osmo_gsup_message_type gsup_msg_type,
@@ -527,7 +549,7 @@
 				gsup->imsi, gsup->session_id);
 			goto out_err;
 		}
-		ss = ss_session_alloc(hlr, gsup->imsi, gsup->session_id);
+		ss = ss_session_alloc(hlr, gsup->imsi, gsup->session_id, gsup->source_name, gsup->source_name_len);
 		if (!ss) {
 			LOGP(DSS, LOGL_ERROR, "%s/0x%08x: Unable to allocate SS session\n",
 				gsup->imsi, gsup->session_id);
@@ -555,6 +577,8 @@
 						ss->u.euse = hlr->euse_default;
 					}
 				}
+				/* send "unknown IMSI" errors back to source */
+				ss->source_fallback = true;
 			}
 			/* dispatch unstructured SS to routing */
 			handle_ussd(conn, ss, gsup, &req);

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If5a65f471672949192061c5fe396603611123bc1
Gerrit-Change-Number: 13515
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190404/73021b83/attachment.html>


More information about the gerrit-log mailing list