pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39710?usp=email )
Change subject: vty: Add cmd 'show cs7 instance <0-15> as name AS_NAME' ...................................................................... vty: Add cmd 'show cs7 instance <0-15> as name AS_NAME' As also available in Cisco ITP. Change-Id: I76be29aeacb60201ecb5bab2203f02e3cdfc0943 --- M src/osmo_ss7_vty.c M tests/vty/osmo_stp_test.vty 2 files changed, 65 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/10/39710/1 diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 83890b8..63b127c 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -2358,29 +2358,43 @@ vty_out(vty, " point-code override patch-sccp both%s", VTY_NEWLINE); } -DEFUN(show_cs7_as, show_cs7_as_cmd, - "show cs7 instance <0-15> as (active|all|m3ua|sua)", - SHOW_STR CS7_STR INST_STR INST_STR "Application Server (AS)\n" - "Display all active ASs\n" - "Display all ASs (default)\n" - "Display all m3ua ASs\n" - "Display all SUA ASs\n") +static void show_one_as(struct vty *vty, struct osmo_ss7_as *as) +{ + vty_out(vty, "%-12s %-12s %-10u %-13s %4s %13s %3s %5s %4s %10s%s", + as->cfg.name, osmo_fsm_inst_state_name(as->fi), as->cfg.routing_key.context, + osmo_ss7_pointcode_print(as->inst, as->cfg.routing_key.pc), + "", "", "", "", "", osmo_ss7_as_traffic_mode_name(as->cfg.mode), + VTY_NEWLINE); +} + +static int show_as(struct vty *vty, int id, const char *as_name, const char *filter) { struct osmo_ss7_instance *inst; - struct osmo_ss7_as *as; - const char *filter = argv[1]; - int id = atoi(argv[0]); + struct osmo_ss7_as *as = NULL; inst = osmo_ss7_instance_find(id); if (!inst) { - vty_out(vty, "No SS7 instance %d found%s", id, VTY_NEWLINE); + vty_out(vty, "%% No SS7 instance %d found%s", id, VTY_NEWLINE); return CMD_WARNING; } + if (as_name) { + as = osmo_ss7_as_find_by_name(inst, as_name); + if (!as) { + vty_out(vty, "%% No AS '%s' found%s", as_name, VTY_NEWLINE); + return CMD_WARNING; + } + } + vty_out(vty, " Routing Routing Key Cic Cic Traffic%s", VTY_NEWLINE); vty_out(vty, "AS Name State Context Dpc Si Opc Ssn Min Max Mode%s", VTY_NEWLINE); vty_out(vty, "------------ ------------ ---------- ------------- ---- ------------- --- ----- ----- -------%s", VTY_NEWLINE); + if (as) { + show_one_as(vty, as); + return CMD_SUCCESS; + } + llist_for_each_entry(as, &inst->as_list, list) { if (filter && !strcmp(filter, "m3ua") && as->cfg.proto != OSMO_SS7_ASP_PROT_M3UA) continue; @@ -2388,15 +2402,37 @@ continue; if (filter && !strcmp(filter, "active") && !osmo_ss7_as_active(as)) continue; - vty_out(vty, "%-12s %-12s %-10u %-13s %4s %13s %3s %5s %4s %10s%s", - as->cfg.name, osmo_fsm_inst_state_name(as->fi), as->cfg.routing_key.context, - osmo_ss7_pointcode_print(as->inst, as->cfg.routing_key.pc), - "", "", "", "", "", osmo_ss7_as_traffic_mode_name(as->cfg.mode), - VTY_NEWLINE); + show_one_as(vty, as); } return CMD_SUCCESS; } +DEFUN(show_cs7_as, show_cs7_as_cmd, + "show cs7 instance <0-15> as (active|all|m3ua|sua)", + SHOW_STR CS7_STR INST_STR INST_STR "Application Server (AS)\n" + "Display all active ASs\n" + "Display all ASs (default)\n" + "Display all m3ua ASs\n" + "Display all SUA ASs\n") +{ + const char *filter = argv[1]; + int id = atoi(argv[0]); + + return show_as(vty, id, NULL, filter); +} + +DEFUN(show_cs7_as_name, show_cs7_as_name_cmd, + "show cs7 instance <0-15> as name AS_NAME", + SHOW_STR CS7_STR INST_STR INST_STR "Application Server (AS)\n" + "Look up AS with a given name\n" + "Name of the Application Server (AS)\n") +{ + int id = atoi(argv[0]); + const char *as_name = argv[1]; + + return show_as(vty, id, as_name, NULL); +} + /*********************************************************************** * SCCP addressbook handling ***********************************************************************/ @@ -3269,6 +3305,7 @@ install_node(&as_node, NULL); install_lib_element_ve(&show_cs7_as_cmd); + install_lib_element_ve(&show_cs7_as_name_cmd); install_lib_element(L_CS7_NODE, &cs7_as_cmd); install_lib_element(L_CS7_NODE, &no_cs7_as_cmd); install_lib_element(L_CS7_AS_NODE, &cfg_description_cmd); diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty index 58a1ee0..81515c1 100644 --- a/tests/vty/osmo_stp_test.vty +++ b/tests/vty/osmo_stp_test.vty @@ -11,6 +11,7 @@ show cs7 instance <0-15> asp-assoc-status show cs7 instance <0-15> asp-assoc-status name ASP_NAME show cs7 instance <0-15> as (active|all|m3ua|sua) + show cs7 instance <0-15> as name AS_NAME show cs7 instance <0-15> route [POINT_CODE] show cs7 instance <0-15> route-lookup POINT_CODE from POINT_CODE sls <0-15> [list-asps] show cs7 instance <0-15> sccp addressbook @@ -35,6 +36,7 @@ show cs7 instance <0-15> asp-assoc-status show cs7 instance <0-15> asp-assoc-status name ASP_NAME show cs7 instance <0-15> as (active|all|m3ua|sua) + show cs7 instance <0-15> as name AS_NAME show cs7 instance <0-15> route [POINT_CODE] show cs7 instance <0-15> route-lookup POINT_CODE from POINT_CODE sls <0-15> [list-asps] show cs7 instance <0-15> sccp addressbook @@ -88,6 +90,7 @@ all Display all ASs (default) m3ua Display all m3ua ASs sua Display all SUA ASs + name Look up AS with a given name OsmoSTP# show cs7 instance 0 sccp ? addressbook List all SCCP addressbook entries @@ -402,6 +405,15 @@ ------------ ------------ ---------- ------------- ---- ------------- --- ----- ----- ------- my-ass AS_DOWN 0 0.0.0 override +OsmoSTP(config-cs7-as)# do show cs7 instance 0 as name my-ass + Routing Routing Key Cic Cic Traffic +AS Name State Context Dpc Si Opc Ssn Min Max Mode +------------ ------------ ---------- ------------- ---- ------------- --- ----- ----- ------- +my-ass AS_DOWN 0 0.0.0 override + +OsmoSTP(config-cs7-as)# do show cs7 instance 0 as name my-ass-not-exists +% No AS 'my-ass-not-exists' found + OsmoSTP(config-cs7-as)# asp my-asp OsmoSTP(config-cs7-as)# routing-key 0 3.2.1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39710?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I76be29aeacb60201ecb5bab2203f02e3cdfc0943 Gerrit-Change-Number: 39710 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de>