pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/42115?usp=email )
(
2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: Allow configuring local ASP Identifier ......................................................................
Allow configuring local ASP Identifier
If configured, it will be transmitted during ASP UP and ASP UP ACK. This may be needed if facing an SG/IPSP peer who requires ASP Identifier to be set.
Related: OS#6953 Change-Id: Ib94d542f940e13d5c007bc3319e7dde65cf81f12 --- M src/ss7_asp.h M src/ss7_asp_vty.c M src/xua_asp_fsm.c M tests/vty/osmo_stp_test.vty M tests/vty/ss7_asp_test.vty 5 files changed, 55 insertions(+), 29 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved
diff --git a/src/ss7_asp.h b/src/ss7_asp.h index 0d047cb..75be6cc 100644 --- a/src/ss7_asp.h +++ b/src/ss7_asp.h @@ -73,12 +73,8 @@ /*! pre-formatted human readable local/remote socket name */ char *sock_name;
- /* ASP Identifier for ASP-UP + NTFY, as received by the peer. - * FIXME: This should actually be stored in a AS-ASP relation, since it - * can be different per AS, see RFC4666 3.5.1 - * "The optional ASP Identifier parameter contains a unique value that - * is locally significant among the ASPs that support an AS". - */ + /* Peer's ASP Identifier, as received during ASPUP (SG/IPSP) and ASPUP ACK (IPSP), + * and transmitted during NOTIFY. */ uint32_t remote_asp_id; bool remote_asp_id_present;
@@ -128,6 +124,13 @@ * "[no] shutdown" explicitly in cfg files. */ bool explicit_shutdown_state_by_vty_since_node_enter;
+ /* Local ASP Identifier transmitted during ASPUP (ASP/IPSP) and ASPUP ACK (IPSP), + * and received during NOTIFY. + * "The optional ASP Identifier parameter contains a unique value + * that is locally significant among the ASPs that support an AS". */ + uint32_t local_asp_id; + bool local_asp_id_present; + struct osmo_ss7_asp_peer local; struct osmo_ss7_asp_peer remote; uint8_t qos_class; diff --git a/src/ss7_asp_vty.c b/src/ss7_asp_vty.c index 241863a..6b03275 100644 --- a/src/ss7_asp_vty.c +++ b/src/ss7_asp_vty.c @@ -28,6 +28,7 @@ #include <errno.h> #include <stdint.h> #include <string.h> +#include <inttypes.h>
#include <netdb.h> #include <arpa/inet.h> @@ -453,6 +454,35 @@ return CMD_SUCCESS; }
+DEFUN_ATTR(asp_identifier, asp_identifier_cmd, + "asp-identifier <0-4294967295>", + "Specify ASP Identifier for this ASP\n" + "ASP Identifier\n", + CMD_ATTR_NODE_EXIT) +{ + struct osmo_ss7_asp *asp = vty->index; + int64_t id64 = 0; + int rc = osmo_str_to_int64(&id64, argv[0], 10, 0, UINT32_MAX); + if (rc < 0) + return CMD_WARNING; + + asp->cfg.local_asp_id_present = true; + asp->cfg.local_asp_id = (uint32_t)id64; + return CMD_SUCCESS; +} + +DEFUN_ATTR(asp_no_identifier, asp_no_identifier_cmd, + "no asp-identifier", + NO_STR "Specify ASP Identifier for this ASP\n", + CMD_ATTR_NODE_EXIT) +{ + struct osmo_ss7_asp *asp = vty->index; + + asp->cfg.local_asp_id_present = false; + asp->cfg.local_asp_id = 0; + return CMD_SUCCESS; +} + DEFUN_ATTR(asp_transport_role, asp_transport_role_cmd, "transport-role (client|server)", "Specify the transport layer role for this ASP\n" @@ -1322,6 +1352,8 @@ vty_out(vty, "%s", VTY_NEWLINE); if (asp->cfg.description) vty_out(vty, " description %s%s", asp->cfg.description, VTY_NEWLINE); + if (asp->cfg.local_asp_id_present) + vty_out(vty, " asp-identifier %" PRIu32 "%s", asp->cfg.local_asp_id, VTY_NEWLINE); for (i = 0; i < asp->cfg.local.host_cnt; i++) { if (asp->cfg.local.host[i]) vty_out(vty, " local-ip %s%s%s", asp->cfg.local.host[i], @@ -1443,6 +1475,8 @@ install_lib_element(L_CS7_NODE, &cs7_asp_trans_proto_cmd); install_lib_element(L_CS7_NODE, &no_cs7_asp_cmd); install_lib_element(L_CS7_ASP_NODE, &cfg_description_cmd); + install_lib_element(L_CS7_ASP_NODE, &asp_identifier_cmd); + install_lib_element(L_CS7_ASP_NODE, &asp_no_identifier_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_remote_ip_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_no_remote_ip_cmd); install_lib_element(L_CS7_ASP_NODE, &asp_local_ip_cmd); diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c index 4204e31..cdbb0da 100644 --- a/src/xua_asp_fsm.c +++ b/src/xua_asp_fsm.c @@ -226,33 +226,16 @@ /* RFC 3868 Ch. 3.5.1 */ xua->hdr = XUA_HDR(SUA_MSGC_ASPSM, SUA_ASPSM_UP); /* Optional: ASP ID */ -#if 0 - /* TODO: RFC 4666 3.8.1: - * 'The "ASP Identifier Required" error is sent by an SGP in - * response to an ASP Up message that does not contain an ASP - * Identifier parameter when the SGP requires one. The ASP SHOULD - * resend the ASP Up message with an ASP Identifier.' */ - if (ss7_asp_peer_requires_asp_id(asp)) { /* Maybe configure in VTY "asp" node? */ - asp_id = /* get a unique id of asp within as, eg. the index in as->asps[] */; - xua_msg_add_u32(xua, SUA_IEI_ASP_ID, asp_id); - } -#endif + if (asp->cfg.local_asp_id_present) + xua_msg_add_u32(xua, SUA_IEI_ASP_ID, asp->cfg.local_asp_id); /* Optional: Info String */ break; case XUA_ASP_E_ASPSM_ASPUP_ACK: /* RFC3868 Ch. 3.5.2 */ xua->hdr = XUA_HDR(SUA_MSGC_ASPSM, SUA_ASPSM_UP_ACK); /* Optional: ASP ID */ -#if 0 - /* TODO: RFC 4666 3.5.2: - * "The optional ASP Identifier parameter is specifically useful for IPSP - * communication. In that case, the IPSP answering the ASP Up message - * MAY include its own ASP Identifier value." */ - if (ss7_asp_peer_requires_asp_id(asp)) { /* Maybe configure in VTY "asp" node? */ - asp_id = /* get a unique id of asp within as, eg. the index in as->asps[] */; - xua_msg_add_u32(xua, SUA_IEI_ASP_ID, asp_id); - } -#endif + if (asp->cfg.local_asp_id_present) + xua_msg_add_u32(xua, SUA_IEI_ASP_ID, asp->cfg.local_asp_id); /* Optional: Info String */ break; case XUA_ASP_E_ASPSM_ASPDN: diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty index 72eb0de..6e98bb4 100644 --- a/tests/vty/osmo_stp_test.vty +++ b/tests/vty/osmo_stp_test.vty @@ -279,6 +279,8 @@ OsmoSTP(config-cs7-asp)# list ... description .TEXT + asp-identifier <0-4294967295> + no asp-identifier remote-ip (A.B.C.D|X:X::X:X) [primary] no remote-ip (A.B.C.D|X:X::X:X) local-ip (A.B.C.D|X:X::X:X) [primary] @@ -308,8 +310,9 @@ OsmoSTP(config-cs7-asp)# ? ... description Save human-readable description of the object - remote-ip Specify Remote IP Address of ASP + asp-identifier Specify ASP Identifier for this ASP no Negate a command or set its defaults + 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 diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty index 1ff4e36..ee6f9c2 100644 --- a/tests/vty/ss7_asp_test.vty +++ b/tests/vty/ss7_asp_test.vty @@ -275,6 +275,8 @@ ss7_asp_vty_test(config-cs7-asp)# list ... description .TEXT + asp-identifier <0-4294967295> + no asp-identifier remote-ip (A.B.C.D|X:X::X:X) [primary] no remote-ip (A.B.C.D|X:X::X:X) local-ip (A.B.C.D|X:X::X:X) [primary] @@ -304,8 +306,9 @@ ss7_asp_vty_test(config-cs7-asp)# ? ... description Save human-readable description of the object - remote-ip Specify Remote IP Address of ASP + asp-identifier Specify ASP Identifier for this ASP no Negate a command or set its defaults + 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