Change in osmo-hlr[master]: USSD: fix routing to multiple MSC

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

osmith gerrit-no-reply at lists.osmocom.org
Tue Apr 9 08:34:31 UTC 2019


osmith has submitted this change and it was merged. ( https://gerrit.osmocom.org/13479 )

Change subject: USSD: fix routing to multiple MSC
......................................................................

USSD: fix routing to multiple MSC

hlr_ussd.c so far hardcoded osmo-msc's default IPA-name and hence was
only able to negotiate USSD sessions to
- a single osmo-msc
- that has no custom IPA-name set.
Fix: correctly route USSD to any number of MSC with any custom IPA
names.

Resolve the right MSC's IPA name from the USSD session's IMSI, using
hlr_subscriber->vlr_number to determine the right GSUP peer. Cache it in
ss_session->vlr_number to have at most one db hit for routing per
session.

Related: OS#3710
Change-Id: I18067bfadd33a6bc59a9ee336b6937313826fce3
---
M src/hlr_ussd.c
1 file changed, 33 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Vadim Yanitskiy: Looks good to me, approved



diff --git a/src/hlr_ussd.c b/src/hlr_ussd.c
index cc6aa8a..ea69cd9 100644
--- a/src/hlr_ussd.c
+++ b/src/hlr_ussd.c
@@ -34,6 +34,7 @@
 #include "gsup_server.h"
 #include "gsup_router.h"
 #include "logging.h"
+#include "db.h"
 
 /***********************************************************************
  * core data structures expressing config from VTY
@@ -166,6 +167,9 @@
 		const struct hlr_iuse *iuse;
 	} u;
 
+	/* subscriber's vlr_number, will be looked up once per session and cached here */
+	char vlr_number[32];
+
 	/* 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 */
@@ -222,6 +226,33 @@
  * handling functions for encoding SS messages + wrapping them in GSUP
  ***********************************************************************/
 
+/* Resolve the target MSC by ss->imsi and send GSUP message. */
+static int ss_gsup_send(struct ss_session *ss, struct osmo_gsup_server *gs, struct msgb *msg)
+{
+	struct hlr_subscriber subscr = {};
+	int rc;
+
+	/* Use vlr_number as looked up by the caller, or look up now. */
+	if (!ss->vlr_number[0]) {
+		rc = db_subscr_get_by_imsi(g_hlr->dbc, ss->imsi, &subscr);
+		if (rc < 0) {
+			LOGPSS(ss, LOGL_ERROR, "Cannot find subscriber, cannot route GSUP message\n");
+			msgb_free(msg);
+			return -EINVAL;
+		}
+		osmo_strlcpy(ss->vlr_number, subscr.vlr_number, sizeof(ss->vlr_number));
+	}
+
+	if (!ss->vlr_number[0]) {
+		LOGPSS(ss, LOGL_ERROR, "Cannot send GSUP message, no VLR number stored for subscriber\n");
+		msgb_free(msg);
+		return -EINVAL;
+	}
+
+	LOGPSS(ss, LOGL_DEBUG, "Tx SS/USSD to VLR '%s'\n", ss->vlr_number);
+	return osmo_gsup_addr_send(gs, (uint8_t *)ss->vlr_number, strlen(ss->vlr_number) + 1, msg);
+}
+
 static int ss_tx_to_ms(struct ss_session *ss, enum osmo_gsup_message_type gsup_msg_type,
 			bool final, struct msgb *ss_msg)
 
@@ -246,8 +277,7 @@
 	osmo_gsup_encode(resp_msg, &resp);
 	msgb_free(ss_msg);
 
-	/* FIXME: resolve this based on the database vlr_addr */
-	return osmo_gsup_addr_send(g_hlr->gs, (uint8_t *)"MSC-00-00-00-00-00-00", 22, resp_msg);
+	return ss_gsup_send(ss, g_hlr->gs, resp_msg);
 }
 
 #if 0
@@ -433,8 +463,7 @@
 		OSMO_ASSERT(msg_out);
 		/* Received from EUSE, Forward to VLR */
 		osmo_gsup_encode(msg_out, gsup);
-		/* FIXME: resolve this based on the database vlr_addr */
-		osmo_gsup_addr_send(conn->server, (uint8_t *)"MSC-00-00-00-00-00-00", 22, msg_out);
+		ss_gsup_send(ss, conn->server, msg_out);
 	} else {
 		/* Received from VLR (MS) */
 		if (ss->is_external) {

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I18067bfadd33a6bc59a9ee336b6937313826fce3
Gerrit-Change-Number: 13479
Gerrit-PatchSet: 9
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190409/1a6d000d/attachment.htm>


More information about the gerrit-log mailing list