<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmo-sccp/+/19014">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">osmo_sccp_simple_client_on_ss7_id(): do not care about ASP name<br><br>Our manuals explain that the cs7 config automatically adds missing parts.<br>However, previous code requires an ASP to exactly match the default name that<br>the autoconfiguration would choose -- that is unintuitive.<br><br>If a config included only an ASP, or both AS and ASP but omitting to add the<br>ASP to the AS, auto configuration would pick it up iff it exactly had the name<br>the application chose. For osmo-bsc, that was 'asp-clnt-msc-0', if 'msc 0' is<br>the first MSC in the config file. For osmo-msc, it is 'asp-clnt-OsmoMSC-A' or<br>'asp-clnt-OsmoMSC-A-Iu' and so forth, so it is not always clear which name the<br>user should pick to get the ASP used by auto config.<br><br>Refactor so that any ASP with a matching protocol that is not associated with<br>any AS yet is picked up by the auto configuration, i.e. associated with the AS<br>etc., regardless of the name chosen in the config file.<br><br>Related: OS#4635<br>Change-Id: I2954e0167729fd0b1a7d0144a5b5775fc1c44c35<br>---<br>M src/sccp_user.c<br>1 file changed, 28 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/sccp_user.c b/src/sccp_user.c</span><br><span>index d8a7357..e1329ac 100644</span><br><span>--- a/src/sccp_user.c</span><br><span>+++ b/src/sccp_user.c</span><br><span>@@ -25,6 +25,7 @@</span><br><span> </span><br><span> #include <stdbool.h></span><br><span> #include <string.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <limits.h></span><br><span> </span><br><span> #include <osmocom/core/linuxlist.h></span><br><span> #include <osmocom/core/logging.h></span><br><span>@@ -574,13 +575,33 @@</span><br><span>         * we intend to use. */</span><br><span>      asp = osmo_ss7_asp_find_by_proto(as, prot);</span><br><span>  if (!asp) {</span><br><span style="color: hsl(0, 100%, 40%);">-             /* Check if the user has already created an ASP elsewhere under</span><br><span style="color: hsl(0, 100%, 40%);">-          * the default asp name. */</span><br><span style="color: hsl(0, 100%, 40%);">-             asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name);</span><br><span style="color: hsl(0, 100%, 40%);">-         asp = osmo_ss7_asp_find_by_name(ss7, asp_name);</span><br><span style="color: hsl(120, 100%, 40%);">+               /* Check if the user has created an ASP for this proto that is not added on any AS yet. */</span><br><span style="color: hsl(120, 100%, 40%);">+            struct osmo_ss7_asp *asp_i;</span><br><span style="color: hsl(120, 100%, 40%);">+           llist_for_each_entry(asp_i, &ss7->asp_list, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    struct osmo_ss7_as *as_i;</span><br><span style="color: hsl(120, 100%, 40%);">+                     bool is_on_as = false;</span><br><span style="color: hsl(120, 100%, 40%);">+                        if (asp_i->cfg.proto != prot)</span><br><span style="color: hsl(120, 100%, 40%);">+                              continue;</span><br><span style="color: hsl(120, 100%, 40%);">+                     llist_for_each_entry(as_i, &ss7->as_list, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+                              if (!osmo_ss7_as_has_asp(as_i, asp_i))</span><br><span style="color: hsl(120, 100%, 40%);">+                                        continue;</span><br><span style="color: hsl(120, 100%, 40%);">+                             is_on_as = true;</span><br><span style="color: hsl(120, 100%, 40%);">+                              break;</span><br><span style="color: hsl(120, 100%, 40%);">+                        }</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (is_on_as) {</span><br><span style="color: hsl(120, 100%, 40%);">+                               /* This ASP is already on another AS. If it was on this AS, we'd have found it above. */</span><br><span style="color: hsl(120, 100%, 40%);">+                          continue;</span><br><span style="color: hsl(120, 100%, 40%);">+                     }</span><br><span style="color: hsl(120, 100%, 40%);">+                     /* This ASP matches the protocol and is not yet associated to any AS. Use it. */</span><br><span style="color: hsl(120, 100%, 40%);">+                      asp = asp_i;</span><br><span style="color: hsl(120, 100%, 40%);">+                  LOGP(DLSCCP, LOGL_NOTICE, "%s: ASP %s for %s is not associated with any AS, using it\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                         name, asp->cfg.name, osmo_ss7_asp_protocol_name(prot));</span><br><span style="color: hsl(120, 100%, 40%);">+                       break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span>            if (!asp) {</span><br><span style="color: hsl(0, 100%, 40%);">-                     LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating ASP instance\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                           name);</span><br><span style="color: hsl(120, 100%, 40%);">+                   asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name);</span><br><span style="color: hsl(120, 100%, 40%);">+                       LOGP(DLSCCP, LOGL_NOTICE, "%s: No unassociated ASP for %s, creating new ASP %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                       name, osmo_ss7_asp_protocol_name(prot), asp_name);</span><br><span>                      asp =</span><br><span>                            osmo_ss7_asp_find_or_create(ss7, asp_name,</span><br><span>                                                       default_remote_port,</span><br><span>@@ -593,8 +614,7 @@</span><br><span>                   osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp, &default_local_ip, 1);</span><br><span>                  osmo_ss7_asp_peer_set_hosts(&asp->cfg.remote, asp, &default_remote_ip, 1);</span><br><span>                        asp->simple_client_allocated = true;</span><br><span style="color: hsl(0, 100%, 40%);">-         } else</span><br><span style="color: hsl(0, 100%, 40%);">-                  talloc_free(asp_name);</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span> </span><br><span>                osmo_ss7_as_add_asp(as, asp->cfg.name);</span><br><span>   }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmo-sccp/+/19014">change 19014</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmo-sccp/+/19014"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-sccp </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I2954e0167729fd0b1a7d0144a5b5775fc1c44c35 </div>
<div style="display:none"> Gerrit-Change-Number: 19014 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>