[PATCH] libosmo-sccp[master]: simple client: prevent overwriting asp settings

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

dexter gerrit-no-reply at lists.osmocom.org
Thu Sep 14 11:53:38 UTC 2017


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

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
---
M src/sccp_user.c
1 file changed, 27 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/48/3948/1

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 @@
 	 * 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 = 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 = 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->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);
 	}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I53d73059f804c3bbea6cb43dc73ad49a753b3b15
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list