[PATCH] openbsc[vlr_3G]: gsup_client: allow passing a unit id to identify with HLR

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

daniel gerrit-no-reply at lists.osmocom.org
Mon May 8 12:39:21 UTC 2017


Review at  https://gerrit.osmocom.org/2523

gsup_client: allow passing a unit id to identify with HLR

Before, each GSUP client would contact the HLR with an identical unit id, i.e.
"SGSN-00-00-00-00-00-00", with the result that some messages were sucked off by
the wrong client.

Pass explicit unit name from each gsup client user, so that OsmoMSC is "MSC"
and OsmoSGSN is "SGSN". Hence the HLR can properly route the messages.

Todo: also set some values instead of the zeros.

Unrelated cosmetic change while editing the arguments: gsup_client_create()'s
definition's oap client config arg name mismatched the one used in the
declaration. Use oapc_config in both.

Change-Id: I3f8d6dd47c7013920e2a4bde006ed77afd974e80
---
M openbsc/include/openbsc/gsup_client.h
M openbsc/src/gprs/gprs_subscriber.c
M openbsc/src/libcommon/gsup_client.c
M openbsc/src/libcommon/gsup_test_client.c
4 files changed, 21 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/23/2523/1

diff --git a/openbsc/include/openbsc/gsup_client.h b/openbsc/include/openbsc/gsup_client.h
index a113225..4a25490 100644
--- a/openbsc/include/openbsc/gsup_client.h
+++ b/openbsc/include/openbsc/gsup_client.h
@@ -37,6 +37,8 @@
 				     struct msgb *msg);
 
 struct gsup_client {
+	const char *unit_name;
+
 	struct ipa_client_conn *link;
 	gsup_client_read_cb_t read_cb;
 	void *data;
@@ -49,10 +51,11 @@
 	int got_ipa_pong;
 };
 
-struct gsup_client *gsup_client_create(const char *ip_addr,
+struct gsup_client *gsup_client_create(const char *unit_name,
+				       const char *ip_addr,
 				       unsigned int tcp_port,
 				       gsup_client_read_cb_t read_cb,
-				       struct oap_client_config *oap_config);
+				       struct oap_client_config *oapc_config);
 
 void gsup_client_destroy(struct gsup_client *gsupc);
 int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c
index 1bb5141..176583b 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -69,6 +69,7 @@
 	addr_str = inet_ntoa(sgi->cfg.gsup_server_addr.sin_addr);
 
 	sgi->gsup_client = gsup_client_create(
+		"SGSN",
 		addr_str, sgi->cfg.gsup_server_port,
 		&gsup_read_cb,
 		&sgi->cfg.oap);
diff --git a/openbsc/src/libcommon/gsup_client.c b/openbsc/src/libcommon/gsup_client.c
index 2e920a6..3bceaa7 100644
--- a/openbsc/src/libcommon/gsup_client.c
+++ b/openbsc/src/libcommon/gsup_client.c
@@ -173,9 +173,12 @@
 	struct ipaccess_head_ext *he = (struct ipaccess_head_ext *) msgb_l2(msg);
 	struct gsup_client *gsupc = (struct gsup_client *)link->data;
 	int rc;
-	static struct ipaccess_unit ipa_dev = {
-		.unit_name = "SGSN"
+	struct ipaccess_unit ipa_dev = {
+		/* see gsup_client_create() on const vs non-const */
+		.unit_name = (char*)gsupc->unit_name,
 	};
+
+	OSMO_ASSERT(ipa_dev.unit_name);
 
 	msg->l2h = &hh->data[0];
 
@@ -263,7 +266,8 @@
 	gsup_client_send_ping(gsupc);
 }
 
-struct gsup_client *gsup_client_create(const char *ip_addr,
+struct gsup_client *gsup_client_create(const char *unit_name,
+				       const char *ip_addr,
 				       unsigned int tcp_port,
 				       gsup_client_read_cb_t read_cb,
 				       struct oap_client_config *oapc_config)
@@ -274,6 +278,12 @@
 	gsupc = talloc_zero(tall_bsc_ctx, struct gsup_client);
 	OSMO_ASSERT(gsupc);
 
+	/* struct ipaccess_unit has a non-const unit_name, so let's copy to be
+	 * able to have a non-const unit_name here as well. To not taint the
+	 * public gsup_client API, let's store it in a const char* anyway. */
+	gsupc->unit_name = talloc_strdup(gsupc, unit_name);
+	OSMO_ASSERT(gsupc->unit_name);
+
 	/* a NULL oapc_config will mark oap_state disabled. */
 	rc = oap_client_init(oapc_config, &gsupc->oap_state);
 	if (rc != 0)
diff --git a/openbsc/src/libcommon/gsup_test_client.c b/openbsc/src/libcommon/gsup_test_client.c
index 8be4e7a..c71a522 100644
--- a/openbsc/src/libcommon/gsup_test_client.c
+++ b/openbsc/src/libcommon/gsup_test_client.c
@@ -276,8 +276,8 @@
 
 	osmo_init_logging(&gsup_test_client_log_info);
 
-	g_gc = gsup_client_create(server_host, server_port, gsupc_read_cb,
-				       NULL);
+	g_gc = gsup_client_create("GSUPTEST", server_host, server_port,
+				  gsupc_read_cb, NULL);
 
 
 	signal(SIGINT, sig_cb);

-- 
To view, visit https://gerrit.osmocom.org/2523
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f8d6dd47c7013920e2a4bde006ed77afd974e80
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: vlr_3G
Gerrit-Owner: daniel <dwillmann at sysmocom.de>



More information about the gerrit-log mailing list