Neels Hofmeyr has submitted this change and it was merged.

Change subject: sccp: prefix default parameters of osmo_sccp_simple_client()
......................................................................


sccp: prefix default parameters of osmo_sccp_simple_client()

The simple client takes certain parameters (pc, ip and port
numbers) which serve as a fallback default in case the user
did not configure any suitable parameters via the VTY.

Prefix all default variables with default_ to make the
purpose clear to the API user

Change-Id: Id9e697e8b198e4f58a79e59aaf2e649e84a3eb63
---
M include/osmocom/sigtran/osmo_ss7.h
M src/sccp_user.c
2 files changed, 37 insertions(+), 27 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index a457709..71c2022 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -445,17 +445,20 @@
 
 void osmo_ss7_xua_server_destroy(struct osmo_xua_server *xs);
 
-
 struct osmo_sccp_instance *
-osmo_sccp_simple_client(void *ctx, const char *name, uint32_t pc,
-                       enum osmo_ss7_asp_protocol prot, int local_port,
-                       const char *local_ip, int remote_port, const char 
*remote_ip);
+osmo_sccp_simple_client(void *ctx, const char *name, uint32_t default_pc,
+                       enum osmo_ss7_asp_protocol prot, int default_local_port,
+                       const char *default_local_ip, int default_remote_port,
+                       const char *default_remote_ip);
 
 struct osmo_sccp_instance *
 osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
-                                 uint32_t pc, enum osmo_ss7_asp_protocol prot,
-                                 int local_port, const char *local_ip,
-                                 int remote_port, const char *remote_ip);
+                                 uint32_t default_pc,
+                                 enum osmo_ss7_asp_protocol prot,
+                                 int default_local_port,
+                                 const char *default_local_ip,
+                                 int default_remote_port,
+                                 const char *default_remote_ip);
 
 struct osmo_sccp_instance *
 osmo_sccp_simple_server(void *ctx, uint32_t pc,
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 1d59d3c..9116b60 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -297,9 +297,12 @@
 
 struct osmo_sccp_instance *
 osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
-                                 uint32_t pc, enum osmo_ss7_asp_protocol prot,
-                                 int local_port, const char *local_ip,
-                                 int remote_port, const char *remote_ip)
+                                 uint32_t default_pc,
+                                 enum osmo_ss7_asp_protocol prot,
+                                 int default_local_port,
+                                 const char *default_local_ip,
+                                 int default_remote_port,
+                                 const char *default_remote_ip)
 {
        struct osmo_ss7_instance *ss7;
        bool ss7_created = false;
@@ -313,10 +316,10 @@
 
        /* Choose default ports when the caller does not supply valid port
         * numbers. */
-       if (!remote_port || remote_port < 0)
-               remote_port = osmo_ss7_asp_protocol_port(prot);
-       if (local_port < 0)
-               local_port = osmo_ss7_asp_protocol_port(prot);
+       if (!default_remote_port || default_remote_port < 0)
+               default_remote_port = osmo_ss7_asp_protocol_port(prot);
+       if (default_local_port < 0)
+               default_local_port = osmo_ss7_asp_protocol_port(prot);
 
        /* Check if there is already an ss7 instance present under
         * the given id. If not, we will create a new one. */
@@ -336,7 +339,7 @@
                /* Setup primary pointcode
                 * NOTE: This means that the user must set the pointcode to a
                 * proper value when a cs7 instance is defined via the VTY. */
-               ss7->cfg.primary_pc = pc;
+               ss7->cfg.primary_pc = default_pc;
                ss7_created = true;
        }
        LOGP(DLSCCP, LOGL_NOTICE, "%s: Using SS7 instance %u, pc:%s\n", name,
@@ -393,17 +396,18 @@
                     name);
                asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name);
                asp =
-                   osmo_ss7_asp_find_or_create(ss7, asp_name, remote_port,
-                                               local_port, prot);
+                   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;
 
-               local_ip ? asp->cfg.local.host =
-                   talloc_strdup(asp, local_ip) : NULL;
-               remote_ip ? asp->cfg.remote.host =
-                   talloc_strdup(asp, remote_ip) : NULL;
+               default_local_ip ? asp->cfg.local.host =
+                   talloc_strdup(asp, default_local_ip) : NULL;
+               default_remote_ip ? asp->cfg.remote.host =
+                   talloc_strdup(asp, default_remote_ip) : NULL;
 
                osmo_ss7_as_add_asp(as, asp->cfg.name);
        }
@@ -443,13 +447,16 @@
 }
 
 struct osmo_sccp_instance *
-osmo_sccp_simple_client(void *ctx, const char *name, uint32_t pc,
-                       enum osmo_ss7_asp_protocol prot, int local_port,
-                       const char *local_ip, int remote_port, const char 
*remote_ip)
+osmo_sccp_simple_client(void *ctx, const char *name, uint32_t default_pc,
+                       enum osmo_ss7_asp_protocol prot, int default_local_port,
+                       const char *default_local_ip, int default_remote_port,
+                       const char *default_remote_ip)
 {
-       return osmo_sccp_simple_client_on_ss7_id(ctx, 1, name, pc, prot,
-                                                local_port, local_ip,
-                                                remote_port, remote_ip);
+       return osmo_sccp_simple_client_on_ss7_id(ctx, 1, name, default_pc, prot,
+                                                default_local_port,
+                                                default_local_ip,
+                                                default_remote_port,
+                                                default_remote_ip);
 }
 
 /***********************************************************************

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id9e697e8b198e4f58a79e59aaf2e649e84a3eb63
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofm...@sysmocom.de>
Gerrit-Reviewer: neels <nhofm...@sysmocom.de>

Reply via email to