VTY: rename 'sctp-role' to 'transport-role', add an alias

Now that we're adding support for M3UA-over-TCP, the transport layer
role is no longer an SCTP specific paremeter, but rather a generic one.
This is also the case for the OSMO_SS7_ASP_PROT_IPA, which employs TCP,
and for which we can also choose between the client and server role.

The 'sctp-role' now becomes an alias to 'transport-role', so that
we keep backwards compatibility with old config files.

Change-Id: Iab6c898181d79a5ed2bea767ee90e55bc3af16a5
Related: SYS#5424
This commit is contained in:
Vadim Yanitskiy 2024-02-15 05:29:14 +07:00
parent 22929b1c04
commit 4d7e20193c
4 changed files with 35 additions and 27 deletions

View File

@ -433,7 +433,7 @@ struct osmo_ss7_asp {
bool is_server;
enum osmo_ss7_asp_role role;
bool role_set_by_vty;
bool sctp_role_set_by_vty;
bool trans_role_set_by_vty;
struct osmo_ss7_asp_peer local;
struct osmo_ss7_asp_peer remote;

View File

@ -1054,11 +1054,11 @@ DEFUN_ATTR(asp_role, asp_role_cmd,
return CMD_SUCCESS;
}
DEFUN_ATTR(sctp_role, asp_sctp_role_cmd,
"sctp-role (client|server)",
"Specify the SCTP role for this ASP\n"
"Operate as SCTP client; connect to a server\n"
"Operate as SCTP server; wait for client connections\n",
DEFUN_ATTR(asp_transport_role, asp_transport_role_cmd,
"transport-role (client|server)",
"Specify the transport layer role for this ASP\n"
"Operate as a client; connect to a server\n"
"Operate as a server; wait for client connections\n",
CMD_ATTR_NODE_EXIT)
{
struct osmo_ss7_asp *asp = vty->index;
@ -1070,10 +1070,17 @@ DEFUN_ATTR(sctp_role, asp_sctp_role_cmd,
else
OSMO_ASSERT(0);
asp->cfg.sctp_role_set_by_vty = true;
asp->cfg.trans_role_set_by_vty = true;
return CMD_SUCCESS;
}
ALIAS_ATTR(asp_transport_role, asp_sctp_role_cmd,
"sctp-role (client|server)",
"Specify the SCTP role for this ASP\n"
"Operate as SCTP client; connect to a server\n"
"Operate as SCTP server; wait for client connections\n",
CMD_ATTR_HIDDEN | CMD_ATTR_NODE_EXIT);
#define ASP_SCTP_PARAM_INIT_DESC \
"Configure SCTP parameters\n" \
"Configure INIT related parameters\n" \
@ -1719,7 +1726,7 @@ static void write_one_asp(struct vty *vty, struct osmo_ss7_asp *asp, bool show_d
vty_out(vty, " qos-class %u%s", asp->cfg.qos_class, VTY_NEWLINE);
vty_out(vty, " role %s%s", osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)),
VTY_NEWLINE);
vty_out(vty, " sctp-role %s%s", asp->cfg.is_server ? "server" : "client", VTY_NEWLINE);
vty_out(vty, " transport-role %s%s", asp->cfg.is_server ? "server" : "client", VTY_NEWLINE);
if (asp->cfg.sctp_init.num_ostreams_present)
vty_out(vty, " sctp-param init num-ostreams %u%s", asp->cfg.sctp_init.num_ostreams_value, VTY_NEWLINE);
if (asp->cfg.sctp_init.max_instreams_present)
@ -2984,6 +2991,7 @@ static void vty_init_shared(void *ctx)
install_lib_element(L_CS7_ASP_NODE, &asp_no_local_ip_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_qos_class_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_role_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_transport_role_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_sctp_role_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_sctp_param_init_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_no_sctp_param_init_cmd);

View File

@ -636,7 +636,7 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
if (!asp)
goto out_rt;
asp_created = true;
/* Ensure that the ASP we use is set to sctp-role client. */
/* Ensure that the ASP we use is set to operate as a client. */
asp->cfg.is_server = false;
/* Ensure that the ASP we use is set to role ASP. */
asp->cfg.role = OSMO_SS7_ASP_ROLE_ASP;
@ -655,7 +655,7 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
/* Extra sanity checks if the ASP asp-clnt-* was pre-configured over VTY: */
if (!asp->simple_client_allocated) {
/* Forbid ASPs defined through VTY that are not entirely
* configured. "role" and "sctp-role" must be explicitly provided:
* configured. "role" and "transport-role" must be explicitly provided:
*/
if (!asp->cfg.role_set_by_vty) {
LOGP(DLSCCP, LOGL_ERROR,
@ -663,9 +663,9 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
name, asp->cfg.name);
goto out_asp;
}
if (!asp->cfg.sctp_role_set_by_vty) {
if (!asp->cfg.trans_role_set_by_vty) {
LOGP(DLSCCP, LOGL_ERROR,
"%s: ASP %s defined in VTY but 'sctp-role' was not set there, please set it.\n",
"%s: ASP %s defined in VTY but 'transport-role' was not set there, please set it.\n",
name, asp->cfg.name);
goto out_asp;
}
@ -673,19 +673,19 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
/* If ASP was configured through VTY it may be explicitly configured as
* SCTP server. It may be a bit confusing since this function is to create
* a "SCCP simple client", but this allows users of this API such as
* osmo-hnbgw to support SCTP-role server if properly configured through VTY.
* osmo-hnbgw to support transport-role server if properly configured through VTY.
*/
if (asp->cfg.is_server) {
struct osmo_xua_server *xs;
LOGP(DLSCCP, LOGL_NOTICE,
"%s: Requesting an SCCP simple client on ASP %s configured with 'sctp-role server'\n",
"%s: Requesting an SCCP simple client on ASP %s configured with 'transport-role server'\n",
name, asp->cfg.name);
xs = osmo_ss7_xua_server_find2(ss7,
asp->cfg.trans_proto, prot,
asp->cfg.local.port);
if (!xs) {
LOGP(DLSCCP, LOGL_ERROR, "%s: Requesting an SCCP simple client on ASP %s configured "
"with 'sctp-role server' but no matching xUA server was configured!\n",
"with 'transport-role server' but no matching xUA server was configured!\n",
name, asp->cfg.name);
goto out_asp;
}

View File

@ -257,7 +257,7 @@ ss7_asp_vty_test(config-cs7-asp)# list
no local-ip (A.B.C.D|X:X::X:X)
qos-class <0-255>
role (sg|asp|ipsp)
sctp-role (client|server)
transport-role (client|server)
sctp-param init (num-ostreams|max-instreams|max-attempts|timeout) <0-65535>
no sctp-param init (num-ostreams|max-instreams|max-attempts|timeout)
block
@ -266,16 +266,16 @@ ss7_asp_vty_test(config-cs7-asp)# list
ss7_asp_vty_test(config-cs7-asp)# ?
...
description Save human-readable description of the object
remote-ip Specify Remote IP Address of ASP
no Negate a command or set its defaults
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
sctp-role Specify the SCTP role for this ASP
sctp-param Configure SCTP parameters
block Allows a SCTP Association with ASP, but doesn't let it become active
shutdown Terminates SCTP association; New associations will be rejected
description Save human-readable description of the object
remote-ip Specify Remote IP Address of ASP
no Negate a command or set its defaults
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
transport-role Specify the transport layer role for this ASP
sctp-param Configure SCTP parameters
block Allows a SCTP Association with ASP, but doesn't let it become active
shutdown Terminates SCTP association; New associations will be rejected
...
ss7_asp_vty_test(config-cs7-asp)# no ?
@ -423,7 +423,7 @@ cs7 instance 0
remote-ip 127.0.0.200
remote-ip 127.0.0.201
role sg
sctp-role server
transport-role server
as my-ass m3ua
asp my-asp
routing-key 0 3.2.1