Change in libosmo-sccp[master]: osmo_sccp_simple_client_on_ss7_id(): do not care about ASP name

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

neels gerrit-no-reply at lists.osmocom.org
Thu Jun 25 17:55:10 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/19014 )


Change subject: osmo_sccp_simple_client_on_ss7_id(): do not care about ASP name
......................................................................

osmo_sccp_simple_client_on_ss7_id(): do not care about ASP name

Our manuals explain that the cs7 config automatically adds missing parts.
However, previous code requires an ASP to exactly match the default name that
the autoconfiguration would choose -- that is unintuitive.

If a config included only an ASP, or both AS and ASP but omitting to add the
ASP to the AS, auto configuration would pick it up iff it exactly had the name
the application chose. For osmo-bsc, that was 'asp-clnt-msc-0', if 'msc 0' is
the first MSC in the config file. For osmo-msc, it is 'asp-clnt-OsmoMSC-A' or
'asp-clnt-OsmoMSC-A-Iu' and so forth, so it is not always clear which name the
user should pick to get the ASP used by auto config.

Refactor so that any ASP with a matching protocol that is not associated with
any AS yet is picked up by the auto configuration, i.e. associated with the AS
etc., regardless of the name chosen in the config file.

Related: OS#4635
Change-Id: I2954e0167729fd0b1a7d0144a5b5775fc1c44c35
---
M src/sccp_user.c
1 file changed, 22 insertions(+), 8 deletions(-)



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

diff --git a/src/sccp_user.c b/src/sccp_user.c
index d8a7357..794a0d5 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -25,6 +25,7 @@
 
 #include <stdbool.h>
 #include <string.h>
+#include <limits.h>
 
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/logging.h>
@@ -574,13 +575,27 @@
 	 * we intend to use. */
 	asp = osmo_ss7_asp_find_by_proto(as, prot);
 	if (!asp) {
-		/* 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_by_name(ss7, asp_name);
+		unsigned int asp_idx;
+		/* Check if the user has created an ASP for this proto that is not added on any AS yet. */
+		for (asp_idx = 0; asp_idx < UINT_MAX; asp_idx++) {
+			asp = osmo_ss7_instance_asp_find_by_proto(ss7, prot, asp_idx);
+			if (!asp) {
+				/* No ASP found for that protocol */
+				break;
+			}
+			if (osmo_ss7_asp_get_as(asp)) {
+				/* This ASP is already on another AS. If it was on this AS, we'd have found it above. */
+				continue;
+			}
+			/* This ASP matches the protocol and is not yet associated to any AS. Use it. */
+			LOGP(DLSCCP, LOGL_NOTICE, "%s: ASP %s for %s is not associated with any AS, using it\n",
+			     name, asp->cfg.name, osmo_ss7_asp_protocol_name(prot));
+			break;
+		}
 		if (!asp) {
-			LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating ASP instance\n",
-			     name);
+			asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name);
+			LOGP(DLSCCP, LOGL_NOTICE, "%s: No unassociated ASP for %s, creating new ASP %s\n",
+			     name, osmo_ss7_asp_protocol_name(prot), asp_name);
 			asp =
 			    osmo_ss7_asp_find_or_create(ss7, asp_name,
 							default_remote_port,
@@ -593,8 +608,7 @@
 			osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp, &default_local_ip, 1);
 			osmo_ss7_asp_peer_set_hosts(&asp->cfg.remote, asp, &default_remote_ip, 1);
 			asp->simple_client_allocated = true;
-		} else
-			talloc_free(asp_name);
+		}
 
 		osmo_ss7_as_add_asp(as, asp->cfg.name);
 	}

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/19014
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I2954e0167729fd0b1a7d0144a5b5775fc1c44c35
Gerrit-Change-Number: 19014
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200625/3f61f637/attachment.htm>


More information about the gerrit-log mailing list