pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39616?usp=email )
Change subject: vty: Allow filtering by DPC in show cs7 instance route ......................................................................
vty: Allow filtering by DPC in show cs7 instance route
As available in Cisco ITP too.
Change-Id: Iff92e61c7e2cc3186de75cb622686657b6c9cae5 --- M src/osmo_ss7_vty.c M tests/vty/osmo_stp_test.vty 2 files changed, 22 insertions(+), 6 deletions(-)
Approvals: daniel: Looks good to me, approved Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index a15b7c6..b29c93a 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -505,7 +505,8 @@ } }
-static void vty_dump_rtable(struct vty *vty, struct osmo_ss7_route_table *rtbl) +/* "filter_pc == OSMO_SS7_PC_INVALID" means "show all" */ +static void vty_dump_rtable(struct vty *vty, struct osmo_ss7_route_table *rtbl, uint32_t filter_pc) { struct osmo_ss7_route *rt;
@@ -516,6 +517,9 @@ vty_out(vty, "---------------------- - - - ------------------- ------- ------- -------%s", VTY_NEWLINE);
llist_for_each_entry(rt, &rtbl->routes, list) { + if ((filter_pc != OSMO_SS7_PC_INVALID) && ((filter_pc & rt->cfg.mask) != rt->cfg.pc)) + continue; /* Skip routes not matching destination */ + vty_out(vty, "%-22s %c %c %u %-19s %-7s %-7s %-7s%s", osmo_ss7_route_print(rt), ' ', @@ -530,11 +534,14 @@ }
DEFUN(show_cs7_route, show_cs7_route_cmd, - "show cs7 instance <0-15> route", - SHOW_STR CS7_STR INST_STR INST_STR "Routing Table\n") + "show cs7 instance <0-15> route [POINT_CODE]", + SHOW_STR CS7_STR INST_STR INST_STR + "Routing Table\n" + "Destination Point Code\n") { int id = atoi(argv[0]); struct osmo_ss7_instance *inst; + uint32_t filter_pc = OSMO_SS7_PC_INVALID;
inst = osmo_ss7_instance_find(id); if (!inst) { @@ -542,7 +549,16 @@ return CMD_WARNING; }
- vty_dump_rtable(vty, inst->rtable_system); + if (argc > 1) { + int 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; + } + filter_pc = (uint32_t)pc; + } + + vty_dump_rtable(vty, inst->rtable_system, filter_pc); return CMD_SUCCESS; }
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty index 9394cf4..747c7b7 100644 --- a/tests/vty/osmo_stp_test.vty +++ b/tests/vty/osmo_stp_test.vty @@ -11,7 +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> route + 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 show cs7 instance <0-15> sccp users @@ -35,7 +35,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> route + 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 show cs7 instance <0-15> sccp users