aboutsummaryrefslogtreecommitdiffstats
path: root/src/sccp_vty.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-07-07 17:14:16 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-07-11 14:55:14 +0200
commitc086a8ed423ce4044a92c84f64657af2886425fd (patch)
tree5eba17d762aba96065a4476a9edee09cc37f08ff /src/sccp_vty.c
parent15327917981a4671dbe2eb6c5345b43f02f026fc (diff)
sccp: Use tdef to implement osmo_sccp_timers
Diffstat (limited to 'src/sccp_vty.c')
-rw-r--r--src/sccp_vty.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/src/sccp_vty.c b/src/sccp_vty.c
index dda3ff0..4bd1e4d 100644
--- a/src/sccp_vty.c
+++ b/src/sccp_vty.c
@@ -150,9 +150,8 @@ DEFUN_ATTR(sccp_timer, sccp_timer_cmd,
{
struct osmo_ss7_instance *ss7 = vty->index;
enum osmo_sccp_timer timer = get_string_value(osmo_sccp_timer_names, argv[0]);
- struct osmo_sccp_timer_val set_val = { .s = atoi(argv[1]) };
- if (timer < 0 || timer >= OSMO_SCCP_TIMERS_COUNT) {
+ if (timer <= 0 || timer >= OSMO_SCCP_TIMERS_LEN) {
vty_out(vty, "%% Invalid timer: %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
@@ -163,7 +162,8 @@ DEFUN_ATTR(sccp_timer, sccp_timer_cmd,
return CMD_WARNING;
}
- ss7->sccp->timers[timer] = set_val;
+ OSMO_ASSERT(ss7->sccp->tdefs);
+ osmo_tdef_set(ss7->sccp->tdefs, timer, atoi(argv[1]), OSMO_TDEF_S);
return CMD_SUCCESS;
}
@@ -197,14 +197,6 @@ DEFUN_ATTR(sccp_max_optional_data, sccp_max_optional_data_cmd,
return CMD_SUCCESS;
}
-static const char *osmo_sccp_timer_val_name(const struct osmo_sccp_timer_val *val)
-{
- static char buf[16];
-
- snprintf(buf, sizeof(buf), "%u", val->s);
- return buf;
-}
-
static void gen_sccp_timer_cmd_strs(struct cmd_element *cmd)
{
int i;
@@ -219,19 +211,19 @@ static void gen_sccp_timer_cmd_strs(struct cmd_element *cmd)
"Configure SCCP timer values, see ITU-T Q.714\n");
for (i = 0; osmo_sccp_timer_names[i].str; i++) {
- const struct osmo_sccp_timer_val *def;
+ const struct osmo_tdef *def;
enum osmo_sccp_timer timer;
timer = osmo_sccp_timer_names[i].value;
- def = &osmo_sccp_timer_defaults[timer];
- OSMO_ASSERT(timer >= 0 && timer < OSMO_SCCP_TIMERS_COUNT);
+ def = osmo_tdef_get_entry((struct osmo_tdef *)&osmo_sccp_timer_defaults, timer);
+ OSMO_ASSERT(def);
osmo_talloc_asprintf(tall_vty_ctx, cmd_str, "%s%s",
i ? "|" : "",
- osmo_sccp_timer_name(timer));
- osmo_talloc_asprintf(tall_vty_ctx, doc_str, "%s (default: %s)\n",
- osmo_sccp_timer_description(timer),
- osmo_sccp_timer_val_name(def));
+ osmo_sccp_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>");
@@ -247,12 +239,14 @@ static void write_sccp_timers(struct vty *vty, const char *indent,
{
int i;
- for (i = 0; i < ARRAY_SIZE(inst->timers); i++) {
- const struct osmo_sccp_timer_val *val = osmo_sccp_timer_get(inst, i, default_if_unset);
- if (!val)
+ for (i = 0; osmo_sccp_timer_names[i].str; i++) {
+ const struct osmo_tdef *tdef = osmo_tdef_get_entry(inst->tdefs, osmo_sccp_timer_names[i].value);
+ if (!tdef)
+ continue;
+ if (!default_if_unset && tdef->val == tdef->default_val)
continue;
- vty_out(vty, "%ssccp-timer %s %s%s", indent, osmo_sccp_timer_name(i),
- osmo_sccp_timer_val_name(val), VTY_NEWLINE);
+ vty_out(vty, "%ssccp-timer %s %lu%s", indent, osmo_sccp_timer_names[i].str,
+ tdef->val, VTY_NEWLINE);
}
}