summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2019-10-29 21:55:49 +0100
committerlaforge <laforge@osmocom.org>2019-11-05 20:50:51 +0000
commit1a822635f8e5a389aaae68d2d4fed3e310739129 (patch)
tree4425e2bfea8139c19841cc6884032405ae0e318e
parent79fb8a66f3f68a387c75312e08572589846e89c0 (diff)
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
-rw-r--r--include/osmocom/sigtran/osmo_ss7.h2
-rw-r--r--src/osmo_ss7.c7
-rw-r--r--src/osmo_ss7_vty.c29
-rw-r--r--src/sccp_user.c2
-rw-r--r--tests/vty/ss7_asp_test.vty2
5 files changed, 36 insertions, 6 deletions
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 @@ struct osmo_ss7_asp {
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 @@ static int xua_cli_connect_cb(struct osmo_stream_cli *cli);
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 @@ int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp)
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 @@ int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp)
/* 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 @@ DEFUN(cs7_asp, cs7_asp_cmd,
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 @@ DEFUN(asp_qos_clas, asp_qos_class_cmd,
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 @@ static void write_one_asp(struct vty *vty, struct osmo_ss7_asp *asp)
}
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 @@ static void vty_init_shared(void *ctx)
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 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
/* 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 @@ osmo_sccp_simple_server_add_clnt(struct osmo_sccp_instance *inst,
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 @@ ss7_asp_vty_test(config-cs7-asp)# list
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 @@ ss7_asp_vty_test(config-cs7-asp)# ?
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