pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39611?usp=email )
Change subject: vty: Add cmd to look up route ......................................................................
vty: Add cmd to look up route
Change-Id: I4dbe04862c018a1beea253de99404adb88bb7f4b --- M src/osmo_ss7_vty.c M tests/vty/osmo_stp_route_prio.vty M tests/vty/osmo_stp_test.vty 3 files changed, 53 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/11/39611/1
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 1369640..481316e 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -540,6 +540,51 @@ return CMD_SUCCESS; }
+DEFUN(show_cs7_route, show_cs7_route_cmd, + "show cs7 instance <0-15> route POINT_CODE from POINT_CODE sls <0-15> [list-asps]", + SHOW_STR CS7_STR INST_STR INST_STR + "Look up route\n" "Destination PC\n" + "From\n" "Origin PC\n" + "SLS\n" "SLS value\n" + "List ASPs of the AS if route points to an AS") +{ + int id = atoi(argv[0]); + bool list_asps = argc > 4; + struct osmo_ss7_instance *inst; + struct osmo_ss7_route *rt; + uint32_t dpc; + int pc; + + inst = osmo_ss7_instance_find(id); + if (!inst) { + vty_out(vty, "No SS7 instance %d found%s", id, VTY_NEWLINE); + return CMD_WARNING; + } + + pc = osmo_ss7_pointcode_parse(inst, argv[1]); + if (pc < 0 || !osmo_ss7_pc_is_valid((uint32_t)pc)) { + vty_out(vty, "Invalid point code (%s)%s", argv[1], VTY_NEWLINE); + return CMD_WARNING; + } + dpc = pc; + + pc = osmo_ss7_pointcode_parse(inst, argv[2]); + if (pc < 0 || !osmo_ss7_pc_is_valid((uint32_t)pc)) { + vty_out(vty, "Invalid point code (%s)%s", argv[2], VTY_NEWLINE); + return CMD_WARNING; + } + + rt = osmo_ss7_route_lookup(inst, dpc); + if (!rt) { + vty_out(vty, "No route found for DPC %s%s", + osmo_ss7_pointcode_print(inst, dpc), VTY_NEWLINE); + return CMD_WARNING; + } + + vty_out(vty, "%s%s\n", osmo_ss7_route_name(rt, list_asps), VTY_NEWLINE); + return CMD_SUCCESS; +} + /*********************************************************************** * xUA Listener Configuration (SG) ***********************************************************************/ @@ -3104,6 +3149,7 @@ install_lib_element(L_CS7_AS_NODE, &as_pc_patch_sccp_cmd);
install_lib_element_ve(&show_cs7_route_table_cmd); + install_lib_element_ve(&show_cs7_route_cmd);
vty_init_addr(); } diff --git a/tests/vty/osmo_stp_route_prio.vty b/tests/vty/osmo_stp_route_prio.vty index 73608db..dc02104 100644 --- a/tests/vty/osmo_stp_route_prio.vty +++ b/tests/vty/osmo_stp_route_prio.vty @@ -86,3 +86,7 @@ 3.2.1/14 2 as3 ? ? ? 3.2.1/14 5 as2 ? ? ? 3.2.1/14 6 as1 ? ? ? + +OsmoSTP(config-cs7-rt)# ! NOW TEST LOOKUP WORKS AS DESIRED (as3 PICKED): +OsmoSTP(config-cs7-rt)# do show cs7 instance 0 route 3.2.1 from 0.0.1 sls 0 +pc=6161=3.2.1 mask=0x3fff=7.255.7 via AS as3 proto=m3ua diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty index 4caa40a..90f4501 100644 --- a/tests/vty/osmo_stp_test.vty +++ b/tests/vty/osmo_stp_test.vty @@ -12,6 +12,7 @@ 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> route-table [system] + show cs7 instance <0-15> route POINT_CODE from POINT_CODE sls <0-15> [list-asps] show cs7 instance <0-15> sccp addressbook show cs7 instance <0-15> sccp users show cs7 instance <0-15> sccp ssn <0-65535> @@ -35,6 +36,7 @@ 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> route-table [system] + show cs7 instance <0-15> route POINT_CODE from POINT_CODE sls <0-15> [list-asps] show cs7 instance <0-15> sccp addressbook show cs7 instance <0-15> sccp users show cs7 instance <0-15> sccp ssn <0-65535> @@ -78,6 +80,7 @@ asp-assoc-status Application Server Process (ASP) SCTP association status as Application Server (AS) route-table Routing Table + route Look up route sccp Signalling Connection Control Part
OsmoSTP# show cs7 instance 0 as ?