aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-04 03:15:53 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-18 17:41:10 +0200
commit4be4afe9b792852be011e6a2af8e30fef76b8b53 (patch)
treeb344744b9940c77a4c2070b6ebb22c690b721821
parent8bca67a60af40de9f8653b3510f67f35c15c727e (diff)
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
-rw-r--r--openbsc/include/openbsc/gsup_client.h7
-rw-r--r--openbsc/src/gprs/gprs_subscriber.c1
-rw-r--r--openbsc/src/libcommon/gsup_client.c16
-rw-r--r--openbsc/src/libcommon/gsup_test_client.c4
4 files changed, 21 insertions, 7 deletions
diff --git a/openbsc/include/openbsc/gsup_client.h b/openbsc/include/openbsc/gsup_client.h
index a113225e1..4a25490f6 100644
--- a/openbsc/include/openbsc/gsup_client.h
+++ b/openbsc/include/openbsc/gsup_client.h
@@ -37,6 +37,8 @@ typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc,
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 @@ struct gsup_client {
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 1bb51418a..176583b6f 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -69,6 +69,7 @@ int gprs_subscr_init(struct sgsn_instance *sgi)
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 de00d8d4f..46f25bb98 100644
--- a/openbsc/src/libcommon/gsup_client.c
+++ b/openbsc/src/libcommon/gsup_client.c
@@ -173,10 +173,13 @@ static int gsup_client_read_cb(struct ipa_client_conn *link, struct msgb *msg)
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];
rc = ipaccess_bts_handle_ccm(link, &ipa_dev, msg);
@@ -262,7 +265,8 @@ static void start_test_procedure(struct gsup_client *gsupc)
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)
@@ -273,6 +277,12 @@ struct gsup_client *gsup_client_create(const char *ip_addr,
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 8fc38d60d..1b39670de 100644
--- a/openbsc/src/libcommon/gsup_test_client.c
+++ b/openbsc/src/libcommon/gsup_test_client.c
@@ -275,8 +275,8 @@ int main(int argc, char **argv)
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);