pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/40459?usp=email )
Change subject: asp: Introduce VTY configurations 'timer xua (ack|beat)'
......................................................................
asp: Introduce VTY configurations 'timer xua (ack|beat)'
T(beat) is not yet implemented in this commit, will be done in a
future step.
Related: OS#4072
Change-Id: Id83446a1846847e68745b29c8dd4388aedcc0660
---
M src/sccp_vty.c
M src/ss7_asp.c
M src/ss7_asp.h
M src/ss7_asp_vty.c
M src/xua_asp_fsm.c
M src/xua_internal.h
M tests/vty/osmo_stp_test.vty
7 files changed, 132 insertions(+), 15 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
osmith: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/sccp_vty.c b/src/sccp_vty.c
index 49f3577..d809c1f 100644
--- a/src/sccp_vty.c
+++ b/src/sccp_vty.c
@@ -42,6 +42,7 @@
#include "xua_internal.h"
#include "sccp_internal.h"
#include "ss7_instance.h"
+#include "ss7_vty.h"
static void show_user(struct vty *vty, struct osmo_sccp_user *user)
{
diff --git a/src/ss7_asp.c b/src/ss7_asp.c
index 61e5415..71e5627 100644
--- a/src/ss7_asp.c
+++ b/src/ss7_asp.c
@@ -113,6 +113,29 @@
}
/***********************************************************************
+ * Timer Handling
+ ***********************************************************************/
+
+const struct osmo_tdef ss7_asp_xua_timer_defaults[SS7_ASP_XUA_TIMERS_LEN] = {
+ { .T = SS7_ASP_XUA_T_ACK, .default_val = SS7_ASP_XUA_DEFAULT_T_ACK_SEC, .unit =
OSMO_TDEF_S,
+ .desc = "Resend ASP Up/Down/Active/Inactive after timeout waiting for ASP
Up/Down/Active/Inactive ACK (ASP role)(s)" },
+ { .T = SS7_ASP_XUA_T_BEAT, .default_val = SS7_ASP_XUA_DEFAULT_T_BEAT_SEC, .unit =
OSMO_TDEF_S,
+ .desc = "Heartbeat Timer (0 = disabled) (s)" },
+ {}
+};
+
+/* Appendix C.4 of ITU-T Q.714 */
+const struct value_string ss7_asp_xua_timer_names[] = {
+ { SS7_ASP_XUA_T_ACK, "ack" },
+ { SS7_ASP_XUA_T_BEAT, "beat" },
+ {}
+};
+
+osmo_static_assert(ARRAY_SIZE(ss7_asp_xua_timer_defaults) == (SS7_ASP_XUA_TIMERS_LEN)
&&
+ ARRAY_SIZE(ss7_asp_xua_timer_names) == (SS7_ASP_XUA_TIMERS_LEN),
+ assert_ss7_asp_xua_timer_count);
+
+/***********************************************************************
* SS7 Application Server Process
***********************************************************************/
@@ -570,6 +593,9 @@
asp->cfg.proto = proto;
asp->cfg.name = talloc_strdup(asp, name);
+ asp->cfg.T_defs_xua = talloc_memdup(asp, ss7_asp_xua_timer_defaults,
+ sizeof(ss7_asp_xua_timer_defaults));
+ osmo_tdefs_reset(asp->cfg.T_defs_xua);
asp->cfg.T_defs_lm = talloc_memdup(asp, ss7_asp_lm_timer_defaults,
sizeof(ss7_asp_lm_timer_defaults));
osmo_tdefs_reset(asp->cfg.T_defs_lm);
diff --git a/src/ss7_asp.h b/src/ss7_asp.h
index 2e25f97..889b5c9 100644
--- a/src/ss7_asp.h
+++ b/src/ss7_asp.h
@@ -19,6 +19,20 @@
struct osmo_ss7_instance;
struct osmo_xua_layer_manager;
+enum ss7_asp_xua_timer {
+ /* 0 kept unused on purpose since it's handled specially by osmo_fsm */
+ SS7_ASP_XUA_T_ACK = 1, /* RFC3868 & RFC4666 timer T(ack) */
+ SS7_ASP_XUA_T_BEAT, /* RFC3868 & RFC4666 timer T(beat) */
+ /* This must remain the last item: */
+ SS7_ASP_XUA_TIMERS_LEN
+};
+extern const struct value_string ss7_asp_xua_timer_names[];
+extern const struct osmo_tdef ss7_asp_xua_timer_defaults[SS7_ASP_XUA_TIMERS_LEN];
+/* According to SUA RFC3868 Section 8, M3UA RFC4666 Section 4.3.4.1 */
+#define SS7_ASP_XUA_DEFAULT_T_ACK_SEC 2
+/* According to SUA RFC3868 Section 8 */
+#define SS7_ASP_XUA_DEFAULT_T_BEAT_SEC 30
+
enum ss7_asp_ctr {
SS7_ASP_CTR_PKT_RX_TOTAL,
SS7_ASP_CTR_PKT_RX_UNKNOWN,
@@ -100,6 +114,9 @@
uint32_t quirks;
/* T_defs used by the default_lm: */
+ struct osmo_tdef *T_defs_xua;
+
+ /* T_defs used by the default_lm: */
struct osmo_tdef *T_defs_lm;
struct {
diff --git a/src/ss7_asp_vty.c b/src/ss7_asp_vty.c
index 2934ea3..3e22465 100644
--- a/src/ss7_asp_vty.c
+++ b/src/ss7_asp_vty.c
@@ -519,9 +519,65 @@
return CMD_SUCCESS;
}
+/* timer xua <name> <1-999999>
+ * (cmdstr and doc are dynamically generated from ss7_asp_xua_timer_names.) */
+DEFUN_ATTR(asp_timer_xua, asp_timer_xua_cmd,
+ NULL, NULL, CMD_ATTR_IMMEDIATE)
+{
+ struct osmo_ss7_asp *asp = vty->index;
+ enum ss7_asp_xua_timer timer = get_string_value(ss7_asp_xua_timer_names, argv[0]);
+
+ if (timer <= 0 || timer >= SS7_ASP_XUA_TIMERS_LEN) {
+ vty_out(vty, "%% Invalid timer: %s%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ osmo_tdef_set(asp->cfg.T_defs_xua, timer, atoi(argv[1]), OSMO_TDEF_S);
+ return CMD_SUCCESS;
+}
+
+static void gen_asp_timer_xua_cmd_strs(struct cmd_element *cmd)
+{
+ int i;
+ char *cmd_str = NULL;
+ char *doc_str = NULL;
+
+ OSMO_ASSERT(cmd->string == NULL);
+ OSMO_ASSERT(cmd->doc == NULL);
+
+ osmo_talloc_asprintf(tall_vty_ctx, cmd_str, "timer xua (");
+ osmo_talloc_asprintf(tall_vty_ctx, doc_str,
+ "Configure ASP default timer values\n"
+ "Configure ASP default xua timer values\n");
+
+ for (i = 0; ss7_asp_xua_timer_names[i].str; i++) {
+ const struct osmo_tdef *def;
+ enum ss7_asp_xua_timer timer;
+
+ timer = ss7_asp_xua_timer_names[i].value;
+ def = osmo_tdef_get_entry((struct osmo_tdef *)&ss7_asp_xua_timer_defaults, timer);
+ OSMO_ASSERT(def);
+
+ osmo_talloc_asprintf(tall_vty_ctx, cmd_str, "%s%s",
+ i ? "|" : "",
+ ss7_asp_xua_timer_names[i].str);
+ osmo_talloc_asprintf(tall_vty_ctx, doc_str, "%s (default: %lu)\n",
+ def->desc,
+ def->default_val);
+ }
+
+ osmo_talloc_asprintf(tall_vty_ctx, cmd_str, ") <1-999999>");
+ osmo_talloc_asprintf(tall_vty_ctx, doc_str,
+ "Timer value, in seconds\n");
+
+ cmd->string = cmd_str;
+ cmd->doc = doc_str;
+}
+
+
/* timer lm <name> <1-999999>
* (cmdstr and doc are dynamically generated from ss7_asp_lm_timer_names.) */
-DEFUN_ATTR(asp_timer, asp_timer_cmd,
+DEFUN_ATTR(asp_timer_lm, asp_timer_lm_cmd,
NULL, NULL, CMD_ATTR_IMMEDIATE)
{
struct osmo_ss7_asp *asp = vty->index;
@@ -536,7 +592,7 @@
return CMD_SUCCESS;
}
-static void gen_asp_timer_cmd_strs(struct cmd_element *cmd)
+static void gen_asp_timer_lm_cmd_strs(struct cmd_element *cmd)
{
int i;
char *cmd_str = NULL;
@@ -574,7 +630,23 @@
cmd->doc = doc_str;
}
-static void write_asp_timers(struct vty *vty, const char *indent,
+static void write_asp_timers_xua(struct vty *vty, const char *indent,
+ struct osmo_ss7_asp *asp)
+{
+ int i;
+
+ for (i = 0; ss7_asp_xua_timer_names[i].str; i++) {
+ const struct osmo_tdef *tdef = osmo_tdef_get_entry(asp->cfg.T_defs_xua,
ss7_asp_xua_timer_names[i].value);
+ if (!tdef)
+ continue;
+ if (tdef->val == tdef->default_val)
+ continue;
+ vty_out(vty, "%stimer xua %s %lu%s", indent, ss7_asp_xua_timer_names[i].str,
+ tdef->val, VTY_NEWLINE);
+ }
+}
+
+static void write_asp_timers_lm(struct vty *vty, const char *indent,
struct osmo_ss7_asp *asp)
{
int i;
@@ -1074,7 +1146,8 @@
continue;
vty_out(vty, " quirk %s%s", get_value_string(asp_quirk_names, (1 <<
i)), VTY_NEWLINE);
}
- write_asp_timers(vty, " ", asp);
+ write_asp_timers_xua(vty, " ", asp);
+ write_asp_timers_lm(vty, " ", asp);
switch (asp->cfg.adm_state) {
case OSMO_SS7_ASP_ADM_S_SHUTDOWN:
@@ -1155,8 +1228,10 @@
install_lib_element(L_CS7_ASP_NODE, &asp_no_sctp_param_init_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_quirk_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_no_quirk_cmd);
- gen_asp_timer_cmd_strs(&asp_timer_cmd);
- install_lib_element(L_CS7_ASP_NODE, &asp_timer_cmd);
+ gen_asp_timer_xua_cmd_strs(&asp_timer_xua_cmd);
+ install_lib_element(L_CS7_ASP_NODE, &asp_timer_xua_cmd);
+ gen_asp_timer_lm_cmd_strs(&asp_timer_lm_cmd);
+ install_lib_element(L_CS7_ASP_NODE, &asp_timer_lm_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_block_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_shutdown_cmd);
install_lib_element(L_CS7_ASP_NODE, &asp_no_shutdown_cmd);
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index f7117d3..1d6b078 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -44,9 +44,6 @@
* *
*/
-/* According to SUA RFC3868 Section 8, M3UA RFC4666 Section 4.3.4.1 */
-#define XUA_T_ACK_SEC 2
-
static const struct value_string xua_asp_event_names[] = {
{ XUA_ASP_E_M_ASP_UP_REQ, "M-ASP_UP.req" },
{ XUA_ASP_E_M_ASP_ACTIVE_REQ, "M-ASP_ACTIVE.req" },
@@ -317,6 +314,7 @@
{
struct osmo_fsm_inst *fi = data;
struct xua_asp_fsm_priv *xafp = fi->priv;
+ uint32_t timeout_sec;
LOGPFSML(fi, LOGL_INFO, "T(ack) callback: re-transmitting event %s\n",
osmo_fsm_event_name(fi->fsm, xafp->t_ack.out_event));
@@ -325,13 +323,15 @@
peer_send(fi, xafp->t_ack.out_event, NULL);
/* Re-start the timer */
- osmo_timer_schedule(&xafp->t_ack.timer, XUA_T_ACK_SEC, 0);
+ timeout_sec = osmo_tdef_get(xafp->asp->cfg.T_defs_xua, SS7_ASP_XUA_T_ACK,
OSMO_TDEF_S, -1);
+ osmo_timer_schedule(&xafp->t_ack.timer, timeout_sec, 0);
}
static int peer_send_and_start_t_ack(struct osmo_fsm_inst *fi,
int out_event)
{
struct xua_asp_fsm_priv *xafp = fi->priv;
+ uint32_t timeout_sec;
int rc;
rc = peer_send(fi, out_event, NULL);
@@ -342,7 +342,8 @@
xafp->t_ack.timer.cb = xua_t_ack_cb,
xafp->t_ack.timer.data = fi;
- osmo_timer_schedule(&xafp->t_ack.timer, XUA_T_ACK_SEC, 0);
+ timeout_sec = osmo_tdef_get(xafp->asp->cfg.T_defs_xua, SS7_ASP_XUA_T_ACK,
OSMO_TDEF_S, -1);
+ osmo_timer_schedule(&xafp->t_ack.timer, timeout_sec, 0);
return rc;
}
diff --git a/src/xua_internal.h b/src/xua_internal.h
index 4d99231..60d751c 100644
--- a/src/xua_internal.h
+++ b/src/xua_internal.h
@@ -111,10 +111,6 @@
extern const struct value_string m3ua_rkm_reg_status_vals[];
extern const struct value_string m3ua_rkm_dereg_status_vals[];
-#define CS7_STR "ITU-T Signaling System 7\n"
-#define PC_STR "Point Code\n"
-#define INST_STR "An instance of the SS7 stack\n"
-
int xua_as_transmit_msg(struct osmo_ss7_as *as, struct xua_msg *xua);
int xua_find_as_for_asp(struct osmo_ss7_as **as, const struct osmo_ss7_asp *asp,
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty
index c22eea9..be2beb5 100644
--- a/tests/vty/osmo_stp_test.vty
+++ b/tests/vty/osmo_stp_test.vty
@@ -285,6 +285,7 @@
no sctp-param init (num-ostreams|max-instreams|max-attempts|timeout)
quirk (no_notify|daud_in_asp|snm_inactive)
no quirk (no_notify|daud_in_asp|snm_inactive)
+ timer xua (ack|beat) <1-999999>
timer lm (wait_asp_up|wait_notify|wait_notify_rkm|wait_rk_reg_resp) <1-999999>
block
shutdown
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sigtran/+/40459?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Id83446a1846847e68745b29c8dd4388aedcc0660
Gerrit-Change-Number: 40459
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>