summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-09-14 13:49:20 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2017-09-14 13:53:32 +0200
commitba57d31b35293b8f4afa09b540ae208669fbfe37 (patch)
treeb007832bf214fbcdda37d67f89a3aa217ec1af46
parent3488cf5b8570cc7a2e6894870705645cfc9baa88 (diff)
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
-rw-r--r--src/sccp_user.c41
1 files 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);
}