Change in libosmo-sccp[master]: ss7: Set ASP addresses using asp_peer APIs

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

pespin gerrit-no-reply at lists.osmocom.org
Mon Jan 13 12:41:35 UTC 2020


pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/16796 )

Change subject: ss7: Set ASP addresses using asp_peer APIs
......................................................................

ss7: Set ASP addresses using asp_peer APIs

Change-Id: I4736cb107a1987dab123744b98fb2b06a5e1167a
---
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
M src/sccp_user.c
3 files changed, 14 insertions(+), 31 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved



diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 7eb94b2..70ec847 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -1800,7 +1800,6 @@
 	struct osmo_xua_server *oxs = osmo_stream_srv_link_get_data(link);
 	struct osmo_stream_srv *srv;
 	struct osmo_ss7_asp *asp;
-	int i;
 	char *sock_name = osmo_sock_get_name(link, fd);
 	const char *proto_name = get_value_string(osmo_ss7_asp_protocol_vals, oxs->cfg.proto);
 
@@ -1840,6 +1839,7 @@
 							  oxs->cfg.proto);
 			if (asp) {
 				char hostbuf[INET6_ADDRSTRLEN];
+				const char *hostbuf_ptr = &hostbuf[0];
 				char portbuf[16];
 
 				osmo_sock_get_ip_and_port(fd, hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf), false);
@@ -1848,14 +1848,14 @@
 				asp->cfg.is_server = true;
 				asp->cfg.role = OSMO_SS7_ASP_ROLE_SG;
 				asp->cfg.local.port = oxs->cfg.local.port;
-				for (i = 0; i < oxs->cfg.local.host_cnt; i++)
-					asp->cfg.local.host[i] = talloc_strdup(asp, oxs->cfg.local.host[i]);
-				asp->cfg.local.host_cnt = oxs->cfg.local.host_cnt;
 				asp->cfg.remote.port = atoi(portbuf);
-				asp->cfg.remote.host[0] = talloc_strdup(asp, hostbuf);
-				asp->cfg.remote.host_cnt = 1;
 				asp->dyn_allocated = true;
 				asp->server = srv;
+				osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp,
+							    (const char* const*)oxs->cfg.local.host,
+							    oxs->cfg.local.host_cnt);
+				osmo_ss7_asp_peer_set_hosts(&asp->cfg.remote, asp,
+							    &hostbuf_ptr, 1);
 				osmo_ss7_asp_restart(asp);
 			}
 		}
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 591254e..2931fb9 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -615,8 +615,7 @@
 	"Local IP Address from which to contact of ASP\n")
 {
 	struct osmo_ss7_asp *asp = vty->index;
-	osmo_talloc_replace_string(asp, &asp->cfg.local.host[asp->cfg.local.host_cnt], argv[0]);
-	asp->cfg.local.host_cnt++;
+	osmo_ss7_asp_peer_add_host(&asp->cfg.local, asp, argv[0]);
 	return CMD_SUCCESS;
 }
 
@@ -626,8 +625,7 @@
 	"Remote IP Address of ASP\n")
 {
 	struct osmo_ss7_asp *asp = vty->index;
-	osmo_talloc_replace_string(asp, &asp->cfg.remote.host[asp->cfg.remote.host_cnt], argv[0]);
-	asp->cfg.remote.host_cnt++;
+	osmo_ss7_asp_peer_add_host(&asp->cfg.remote, asp, argv[0]);
 	return CMD_SUCCESS;
 }
 
@@ -1780,15 +1778,11 @@
 	case L_CS7_ASP_NODE:
 		asp = vty->index;
 		/* If no local addr was set */
-		if (!asp->cfg.local.host_cnt) {
-			asp->cfg.local.host[0] = NULL;
-			asp->cfg.local.host_cnt = 1;
-		}
+		if (!asp->cfg.local.host_cnt)
+			osmo_ss7_asp_peer_add_host(&asp->cfg.local, asp, NULL);
 		/* If no remote addr was set */
-		if (!asp->cfg.remote.host_cnt) {
-			asp->cfg.remote.host[0] = "127.0.0.1";
-			asp->cfg.remote.host_cnt = 1;
-		}
+		if (!asp->cfg.remote.host_cnt)
+			osmo_ss7_asp_peer_add_host(&asp->cfg.remote, asp, "127.0.0.1");
 		osmo_ss7_asp_restart(asp);
 		vty->node = L_CS7_NODE;
 		vty->index = asp->inst;
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 49cc212..39ebc71 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -566,19 +566,8 @@
 			if (!asp)
 				goto out_rt;
 			asp_created = true;
-
-			asp->cfg.local.host[0] = NULL;
-			asp->cfg.remote.host[0] = NULL;
-			if (default_local_ip) {
-				asp->cfg.local.host[0] =
-				    talloc_strdup(asp, default_local_ip);
-			}
-			if (default_remote_ip) {
-				asp->cfg.remote.host[0] =
-				    talloc_strdup(asp, default_remote_ip);
-			}
-			asp->cfg.local.host_cnt = 1;
-			asp->cfg.remote.host_cnt = 1;
+			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);

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

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I4736cb107a1987dab123744b98fb2b06a5e1167a
Gerrit-Change-Number: 16796
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200113/091fc4c8/attachment.htm>


More information about the gerrit-log mailing list