Change in libosmo-sccp[master]: Allow ASP role to be configured

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

laforge gerrit-no-reply at lists.osmocom.org
Tue Nov 5 20:50:56 UTC 2019


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

Change subject: Allow ASP role to be configured
......................................................................

Allow ASP role to be configured

So far, we had a static role model:
* SCTP servers (listening, such as OsmoSTP) are role SGW
* SCTP clients (connecting, such as OsmoMSC) are role ASP

While this is customary, it is not actually required by the
specification.  The SGW can establish the SCTP connection to an ASP
but still remain "SG" role.

Let's make things more flexible by having the role configurable.

Related: OS#2005
Change-Id: I2df9cd9747ad5c9a05d567d9a71bab6184c53674
---
M include/osmocom/sigtran/osmo_ss7.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
M src/sccp_user.c
M tests/vty/ss7_asp_test.vty
5 files changed, 36 insertions(+), 6 deletions(-)

Approvals:
  laforge: Verified
  pespin: Looks good to me, approved



diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index 87336a8..826b890 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -418,6 +418,8 @@
 		enum osmo_ss7_asp_protocol proto;
 		enum osmo_ss7_asp_admin_state adm_state;
 		bool is_server;
+		enum osmo_ss7_asp_role role;
+		bool role_set_by_vty;
 
 		struct osmo_ss7_asp_peer local;
 		struct osmo_ss7_asp_peer remote;
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 7a5e35d..8c547e8 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -1287,7 +1287,6 @@
 int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp)
 {
 	int rc;
-	enum osmo_ss7_asp_role role;
 	char bufloc[512], bufrem[512];
 
 	OSMO_ASSERT(ss7_initialized);
@@ -1332,8 +1331,6 @@
 			   will continue to retry (due to timeout being explicitly set with
 			   osmo_stream_cli_set_reconnect_timeout() above) to connect so the error is transient */
 		}
-		/* TODO: make this configurable and not implicit */
-		role = OSMO_SS7_ASP_ROLE_ASP;
 	} else {
 		/* We are in server mode now */
 		if (asp->client) {
@@ -1345,14 +1342,12 @@
 		/* FIXME: ensure we have a SCTP server */
 		LOGPASP(asp, DLSS7, LOGL_NOTICE, "ASP Restart for server "
 			"not implemented yet!\n");
-		/* TODO: make this configurable and not implicit */
-		role = OSMO_SS7_ASP_ROLE_SG;
 	}
 
 	/* (re)start the ASP FSM */
 	if (asp->fi)
 		osmo_fsm_inst_term(asp->fi, OSMO_FSM_TERM_REQUEST, NULL);
-	asp->fi = xua_asp_fsm_start(asp, role, LOGL_DEBUG);
+	asp->fi = xua_asp_fsm_start(asp, asp->cfg.role, LOGL_DEBUG);
 
 	return 0;
 }
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 9c22fb1..1b8b043 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -580,6 +580,7 @@
 		return CMD_WARNING;
 	}
 	asp->cfg.is_server = true;
+	asp->cfg.role = OSMO_SS7_ASP_ROLE_SG;
 
 	vty->node = L_CS7_ASP_NODE;
 	vty->index = asp;
@@ -637,6 +638,29 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(asp_role, asp_role_cmd,
+	"role (sg|asp|ipsp)",
+	"Specify the xUA role for this ASP\n"
+	"SG (Signaling Gateway)\n"
+	"ASP (Application Server Process)\n"
+	"IPSP (IP Signalling Point)\n")
+{
+	struct osmo_ss7_asp *asp = vty->index;
+
+	if (!strcmp(argv[0], "sg")) {
+		asp->cfg.role = OSMO_SS7_ASP_ROLE_SG;
+	} else if (!strcmp(argv[0], "asp")) {
+		asp->cfg.role = OSMO_SS7_ASP_ROLE_ASP;
+	} else if (!strcmp(argv[0], "ipsp")) {
+		vty_out(vty, "IPSP role isn't supported yet%s", VTY_NEWLINE);
+		return CMD_WARNING;
+	} else
+		OSMO_ASSERT(0);
+
+	asp->cfg.role_set_by_vty = true;
+	return CMD_SUCCESS;
+}
+
 DEFUN(asp_block, asp_block_cmd,
 	"block",
 	"Allows a SCTP Association with ASP, but doesn't let it become active\n")
@@ -707,6 +731,10 @@
 	}
 	if (asp->cfg.qos_class)
 		vty_out(vty, "  qos-class %u%s", asp->cfg.qos_class, VTY_NEWLINE);
+	if (asp->cfg.role_set_by_vty) {
+		vty_out(vty, "  role %s%s", get_value_string(osmo_ss7_asp_role_names, asp->cfg.role),
+			VTY_NEWLINE);
+	}
 }
 
 
@@ -1847,6 +1875,7 @@
 	install_element(L_CS7_ASP_NODE, &asp_remote_ip_cmd);
 	install_element(L_CS7_ASP_NODE, &asp_local_ip_cmd);
 	install_element(L_CS7_ASP_NODE, &asp_qos_class_cmd);
+	install_element(L_CS7_ASP_NODE, &asp_role_cmd);
 	install_element(L_CS7_ASP_NODE, &asp_block_cmd);
 	install_element(L_CS7_ASP_NODE, &asp_shutdown_cmd);
 
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 4e4144e..929445f 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -587,6 +587,7 @@
 
 	/* Ensure that the ASP we use is set to client mode. */
 	asp->cfg.is_server = false;
+	asp->cfg.role = OSMO_SS7_ASP_ROLE_ASP;
 
 	/* Restart ASP */
 	if (prot != OSMO_SS7_ASP_PROT_IPA)
@@ -734,6 +735,7 @@
 	if (!asp)
 		goto out_rt;
 	asp->cfg.is_server = true;
+	asp->cfg.role = OSMO_SS7_ASP_ROLE_SG;
 	osmo_ss7_as_add_asp(as, asp_name);
 	talloc_free(asp_name);
 	talloc_free(as_name);
diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index 367c2d9..bc899eb 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -215,6 +215,7 @@
   remote-ip A.B.C.D
   local-ip A.B.C.D
   qos-class <0-255>
+  role (sg|asp|ipsp)
   block
   shutdown
 
@@ -224,6 +225,7 @@
   remote-ip    Specify Remote IP Address of ASP
   local-ip     Specify Local IP Address from which to contact ASP
   qos-class    Specify QoS Class of ASP
+  role         Specify the xUA role for this ASP
   block        Allows a SCTP Association with ASP, but doesn't let it become active
   shutdown     Terminates SCTP association; New associations will be rejected
 

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

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I2df9cd9747ad5c9a05d567d9a71bab6184c53674
Gerrit-Change-Number: 15974
Gerrit-PatchSet: 5
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
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/20191105/37db8c7d/attachment.htm>


More information about the gerrit-log mailing list