From ba57d31b35293b8f4afa09b540ae208669fbfe37 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Thu, 14 Sep 2017 13:49:20 +0200 Subject: simple client: prevent overwriting asp settings If the user does not create an AS, but creates an ASP with a name that is equal to the default name, then the simple client detects that and trys to use this ASP. However, unfortunately it then overwrites the settings of the ASP with the default settings. If the detected ASP is not created by the simple client, use it, but preseve the settings of that ASP. Change-Id: I53d73059f804c3bbea6cb43dc73ad49a753b3b15 --- src/sccp_user.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/sccp_user.c b/src/sccp_user.c index 06a7174..21b2eed 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -414,20 +414,35 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name, * we intend to use. */ asp = osmo_ss7_asp_find_by_proto(as, prot); if (!asp) { - LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating ASP instance\n", - name); + /* Check if the user has already created an ASP elsewhere under + * the default asp name. */ asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name); - asp = - osmo_ss7_asp_find_or_create(ss7, asp_name, - default_remote_port, - default_local_port, prot); - talloc_free(asp_name); - if (!asp) - goto out_rt; - asp_created = true; - - asp->cfg.local.host = default_local_ip ? talloc_strdup(asp, default_local_ip) : NULL; - asp->cfg.remote.host = default_remote_ip ? talloc_strdup(asp, default_remote_ip) : NULL; + asp = osmo_ss7_asp_find_by_name(ss7, asp_name); + if (!asp) { + LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating ASP instance\n", + name); + asp = + osmo_ss7_asp_find_or_create(ss7, asp_name, + default_remote_port, + default_local_port, + prot); + talloc_free(asp_name); + if (!asp) + goto out_rt; + asp_created = true; + + asp->cfg.local.host = NULL; + asp->cfg.remote.host = NULL; + if (default_local_ip) { + asp->cfg.local.host = + talloc_strdup(asp, default_local_ip); + } + if (default_remote_ip) { + asp->cfg.remote.host = + talloc_strdup(asp, default_remote_ip); + } + } else + talloc_free(asp_name); osmo_ss7_as_add_asp(as, asp->cfg.name); } -- cgit v1.2.3