pespin submitted this change.
vty: Add cmd to look up route
Implement a command which allows looking up a given route, similar to
linux "ip route get", which is helpful to debug routing setup.
Related: SYS#7112
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(-)
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 6b404b3..d1885ea 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -539,6 +539,51 @@
return CMD_SUCCESS;
}
+DEFUN(show_cs7_route_lookup, show_cs7_route_lookup_cmd,
+ "show cs7 instance <0-15> route-lookup 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", osmo_ss7_route_name(rt, list_asps), VTY_NEWLINE);
+ return CMD_SUCCESS;
+}
+
/***********************************************************************
* xUA Listener Configuration (SG)
***********************************************************************/
@@ -3103,6 +3148,7 @@
install_lib_element(L_CS7_AS_NODE, &as_pc_patch_sccp_cmd);
install_lib_element_ve(&show_cs7_route_cmd);
+ install_lib_element_ve(&show_cs7_route_lookup_cmd);
vty_init_addr();
}
diff --git a/tests/vty/osmo_stp_route_prio.vty b/tests/vty/osmo_stp_route_prio.vty
index 10833ea..2c68080 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-lookup 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 cb24560..9394cf4 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
+ 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
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
+ 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
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 Routing Table
+ route-lookup Look up route
sccp Signalling Connection Control Part
OsmoSTP# show cs7 instance 0 as ?
To view, visit change 39611. To unsubscribe, or for help writing mail filters, visit settings.