aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libcommon/gsup_client.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-04 03:15:53 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-16 18:10:03 +0100
commit6a0213de0b8e715c8ff76988d51134505e76e419 (patch)
treece449f3613f3f9e63fcc52f5a3599b7b7f2d1159 /openbsc/src/libcommon/gsup_client.c
parent865bc8650b294c04de84a3b0dab31591b7a87a50 (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
Diffstat (limited to 'openbsc/src/libcommon/gsup_client.c')
-rw-r--r--openbsc/src/libcommon/gsup_client.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/openbsc/src/libcommon/gsup_client.c b/openbsc/src/libcommon/gsup_client.c
index 2e920a6b6..3bceaa72a 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);
@@ -263,7 +266,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)
@@ -274,6 +278,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)