[PATCH] libosmo-sccp[master]: sccp: prefix default parameters of osmo_sccp_simple_client()

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 Aug 10 16:00:48 UTC 2017


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

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, 42 insertions(+), 34 deletions(-)


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

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..41f9587 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,17 +316,16 @@
 
 	/* 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. */
 	ss7 = osmo_ss7_instance_find(ss7_id);
 	if (!ss7) {
-		LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating SS7 instance\n",
-		     name);
+		LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating SS7 instance\n", name);
 
 		/* Create a new ss7 instance */
 		ss7 = osmo_ss7_instance_find_or_create(ctx, ss7_id);
@@ -336,7 +338,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,
@@ -353,8 +355,7 @@
 	 * the protocol we intend to use. If not, we will create one. */
 	as = osmo_ss7_as_find_by_proto(ss7, prot);
 	if (!as) {
-		LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating AS instance\n",
-		     name);
+		LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating AS instance\n", name);
 		as_name = talloc_asprintf(ctx, "as-clnt-%s", name);
 		as = osmo_ss7_as_find_or_create(ss7, as_name, prot);
 		talloc_free(as_name);
@@ -363,7 +364,8 @@
 		as_created = true;
 
 		if (!osmo_ss7_pc_is_valid(ss7->cfg.primary_pc)) {
-			LOGP(DLSCCP, LOGL_ERROR, "SS7 instance %u: no primary point-code set\n",
+			LOGP(DLSCCP, LOGL_ERROR,
+			     "SS7 instance %u: no primary point-code set\n",
 			     ss7->cfg.id);
 			goto out_ss7;
 		}
@@ -389,21 +391,21 @@
 	 * 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);
+		LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating ASP instance\n", 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 +445,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: newchange
Gerrit-Change-Id: Id9e697e8b198e4f58a79e59aaf2e649e84a3eb63
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