diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-06-27 13:06:53 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-06-27 16:49:55 +0200 |
commit | a8aab235884c91204312a727be89922f12e64561 (patch) | |
tree | 862864e0537d877e57dc43410b1f00f060c98d0f | |
parent | 1470379c2748bbcbabf95b1837787ccc9d47dfbb (diff) |
vty: Improve output of show cs7 instance <0-15> asp
Role and SCTP Role are now printed. Several formatting issues are fixed
or improved.
Related: SYS#6488
Change-Id: Id22bd4e74fb6f79950adba58862d379203d36760
-rw-r--r-- | src/osmo_ss7_vty.c | 35 | ||||
-rw-r--r-- | tests/vty/ss7_asp_test.vty | 38 |
2 files changed, 48 insertions, 25 deletions
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index ebec5f6..9398bc1 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -790,6 +790,24 @@ DEFUN_ATTR(asp_no_quirk, asp_no_quirk_cmd, return CMD_SUCCESS; } +static char *as_list_for_asp(const struct osmo_ss7_asp *asp, char *buf, size_t buf_len) +{ + struct osmo_strbuf sb = { .buf = buf, .len = buf_len }; + const struct osmo_ss7_as *as; + unsigned int count = 0; + llist_for_each_entry(as, &asp->inst->as_list, list) { + if (!osmo_ss7_as_has_asp(as, asp)) + continue; + OSMO_STRBUF_PRINTF(sb, "%s%s", count != 0 ? "," : "", as->cfg.name); + count++; + break; + } + + if (count == 0) + OSMO_STRBUF_PRINTF(sb, "?"); + return buf; +} + DEFUN(show_cs7_asp, show_cs7_asp_cmd, "show cs7 instance <0-15> asp", SHOW_STR CS7_STR INST_STR INST_STR "Application Server Process (ASP)\n") @@ -797,6 +815,7 @@ DEFUN(show_cs7_asp, show_cs7_asp_cmd, struct osmo_ss7_instance *inst; struct osmo_ss7_asp *asp; char buf[512]; + char as_buf[64]; int id = atoi(argv[0]); inst = osmo_ss7_instance_find(id); @@ -805,9 +824,9 @@ DEFUN(show_cs7_asp, show_cs7_asp_cmd, return CMD_WARNING; } - vty_out(vty, " Effect Primary%s", VTY_NEWLINE); - vty_out(vty, "ASP Name AS Name State Type Remote IP Addr:Rmt Port SCTP%s", VTY_NEWLINE); - vty_out(vty, "------------ ------------ ------------- ---- ----------------------- ----------%s", VTY_NEWLINE); + vty_out(vty, " Current Primary Link%s", VTY_NEWLINE); + vty_out(vty, "ASP Name AS Name State Type Role Remote IPaddr & Port SCTP Role%s", VTY_NEWLINE); + vty_out(vty, "------------ ------------ ------------- ---- ---- ----------------------- ---------%s", VTY_NEWLINE); llist_for_each_entry(asp, &inst->asp_list, list) { if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA && asp->cfg.remote.port == 0 && asp->server) { @@ -819,11 +838,15 @@ DEFUN(show_cs7_asp, show_cs7_asp_cmd, snprintf(buf, sizeof(buf), "%s:%s", hostbuf, portbuf); } else osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), &asp->cfg.remote); - vty_out(vty, "%-12s %-12s %-13s %-4s %-14s %-10s%s", - asp->cfg.name, "?", + vty_out(vty, "%-12s %-12s %-13s %-4s %-4s %-23s %-9s%s", + asp->cfg.name, + as_list_for_asp(asp, as_buf, sizeof(as_buf)), asp->fi? osmo_fsm_inst_state_name(asp->fi) : "uninitialized", get_value_string(osmo_ss7_asp_protocol_vals, asp->cfg.proto), - buf, "", VTY_NEWLINE); + osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)), + buf, + asp->cfg.is_server ? "server" : "client", + VTY_NEWLINE); } return CMD_SUCCESS; } diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty index ffa263f..f7d92bd 100644 --- a/tests/vty/ss7_asp_test.vty +++ b/tests/vty/ss7_asp_test.vty @@ -244,10 +244,10 @@ ss7_asp_vty_test(config-cs7-asp)# ? ss7_asp_vty_test(config-cs7-asp)# remote-ip 127.0.0.200 ss7_asp_vty_test(config-cs7-asp)# local-ip 127.0.0.100 ss7_asp_vty_test(config-cs7-asp)# do show cs7 instance 0 asp - Effect Primary -ASP Name AS Name State Type Remote IP Addr:Rmt Port SCTP ------------- ------------ ------------- ---- ----------------------- ---------- -my-asp ? uninitialized m3ua 127.0.0.200:12345 + Current Primary Link +ASP Name AS Name State Type Role Remote IPaddr & Port SCTP Role +------------ ------------ ------------- ---- ---- ----------------------- --------- +my-asp ? uninitialized m3ua sg 127.0.0.200:12345 server ss7_asp_vty_test(config-cs7-asp)# exit ss7_asp_vty_test(config-cs7)# as my-ass m3ua @@ -308,26 +308,26 @@ ss7_asp_vty_test(config-cs7-as)# asp my-asp ss7_asp_vty_test(config-cs7-as)# routing-key 0 3.2.1 ss7_asp_vty_test(config-cs7-as)# do show cs7 instance 0 asp - Effect Primary -ASP Name AS Name State Type Remote IP Addr:Rmt Port SCTP ------------- ------------ ------------- ---- ----------------------- ---------- -my-asp ? ASP_DOWN m3ua 127.0.0.200:12345 + Current Primary Link +ASP Name AS Name State Type Role Remote IPaddr & Port SCTP Role +------------ ------------ ------------- ---- ---- ----------------------- --------- +my-asp my-ass ASP_DOWN m3ua sg 127.0.0.200:12345 server ss7_asp_vty_test(config-cs7-as)# exit ss7_asp_vty_test(config-cs7)# do show cs7 instance 0 asp - Effect Primary -ASP Name AS Name State Type Remote IP Addr:Rmt Port SCTP ------------- ------------ ------------- ---- ----------------------- ---------- -my-asp ? ASP_DOWN m3ua 127.0.0.200:12345 + Current Primary Link +ASP Name AS Name State Type Role Remote IPaddr & Port SCTP Role +------------ ------------ ------------- ---- ---- ----------------------- --------- +my-asp my-ass ASP_DOWN m3ua sg 127.0.0.200:12345 server ss7_asp_vty_test(config-cs7)# exit ss7_asp_vty_test(config)# do show cs7 instance 0 asp - Effect Primary -ASP Name AS Name State Type Remote IP Addr:Rmt Port SCTP ------------- ------------ ------------- ---- ----------------------- ---------- -my-asp ? ASP_DOWN m3ua 127.0.0.200:12345 + Current Primary Link +ASP Name AS Name State Type Role Remote IPaddr & Port SCTP Role +------------ ------------ ------------- ---- ---- ----------------------- --------- +my-asp my-ass ASP_DOWN m3ua sg 127.0.0.200:12345 server ss7_asp_vty_test(config)# do show cs7 instance 0 as all Routing Routing Key Cic Cic Traffic @@ -368,9 +368,9 @@ No ASP named 'unknown-asp' found ss7_asp_vty_test(config-cs7)# no asp my-asp ss7_asp_vty_test(config-cs7)# do show cs7 instance 0 asp - Effect Primary -ASP Name AS Name State Type Remote IP Addr:Rmt Port SCTP ------------- ------------ ------------- ---- ----------------------- ---------- + Current Primary Link +ASP Name AS Name State Type Role Remote IPaddr & Port SCTP Role +------------ ------------ ------------- ---- ---- ----------------------- --------- ss7_asp_vty_test(config-cs7)# do show cs7 instance 0 as all Routing Routing Key Cic Cic Traffic |