pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39617?usp=email )
Change subject: vty: Improve route status display in show cs7 instance route ......................................................................
vty: Improve route status display in show cs7 instance route
Change-Id: I7f4ca56f9308803a306e7d6a3cde2faec27c3e7f --- M src/osmo_ss7_link.c M src/osmo_ss7_linkset.c M src/osmo_ss7_route.c M src/osmo_ss7_vty.c M src/ss7_link.h M src/ss7_linkset.h M src/ss7_route.h M tests/vty/osmo_stp_route_prio.vty 8 files changed, 48 insertions(+), 6 deletions(-)
Approvals: Jenkins Builder: Verified daniel: Looks good to me, approved osmith: Looks good to me, but someone else must approve
diff --git a/src/osmo_ss7_link.c b/src/osmo_ss7_link.c index 321d72e..6310824 100644 --- a/src/osmo_ss7_link.c +++ b/src/osmo_ss7_link.c @@ -75,3 +75,11 @@
return link; } + +/* Whether link is available, ITU Q.704 section 3.2 */ +bool +ss7_link_is_available(const struct osmo_ss7_link *link) +{ + /* TODO: manage operational availability of a link... */ + return link->cfg.adm_state == OSMO_SS7_LS_ENABLED; +} diff --git a/src/osmo_ss7_linkset.c b/src/osmo_ss7_linkset.c index 146ec92..c6d4a68 100644 --- a/src/osmo_ss7_linkset.c +++ b/src/osmo_ss7_linkset.c @@ -100,3 +100,14 @@
return lset; } + +bool +ss7_linkset_is_available(const struct osmo_ss7_linkset *lset) +{ + for (unsigned int i = 0; i < ARRAY_SIZE(lset->links); i++) { + struct osmo_ss7_link *link = lset->links[i]; + if (link && ss7_link_is_available(link)) + return true; + } + return false; +} diff --git a/src/osmo_ss7_route.c b/src/osmo_ss7_route.c index 8a1592f..2787895 100644 --- a/src/osmo_ss7_route.c +++ b/src/osmo_ss7_route.c @@ -372,3 +372,15 @@ { return rt->dest.as; } + + +/* Whether route is available, ITU Q.704 */ +bool ss7_route_is_available(const struct osmo_ss7_route *rt) +{ + OSMO_ASSERT(rt); + if (rt->dest.as) + return osmo_ss7_as_active(rt->dest.as); + if (rt->dest.linkset) + return ss7_linkset_is_available(rt->dest.linkset); + return false; +} diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index b29c93a..576ad7c 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -520,15 +520,18 @@ 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", + bool rt_avail = ss7_route_is_available(rt); + + vty_out(vty, "%-16s %-5s %c %c %u %-19s %-7s %-7s %-7s%s", osmo_ss7_route_print(rt), + rt_avail ? "acces" : "INACC", ' ', '0' + rt->cfg.qos_class, rt->cfg.priority, rt->cfg.linkset_name, + rt_avail ? "avail" : "UNAVAIL", "?", - "?", - "?", + rt_avail ? "avail" : "UNAVAIL", VTY_NEWLINE); } } diff --git a/src/ss7_link.h b/src/ss7_link.h index 5ea6556..1bdcf12 100644 --- a/src/ss7_link.h +++ b/src/ss7_link.h @@ -31,3 +31,6 @@ void ss7_link_destroy(struct osmo_ss7_link *link); struct osmo_ss7_link * ss7_link_find_or_create(struct osmo_ss7_linkset *lset, uint32_t id); + +bool +ss7_link_is_available(const struct osmo_ss7_link *link); diff --git a/src/ss7_linkset.h b/src/ss7_linkset.h index daa442f..beb60a1 100644 --- a/src/ss7_linkset.h +++ b/src/ss7_linkset.h @@ -30,3 +30,6 @@ ss7_linkset_find_by_name(struct osmo_ss7_instance *inst, const char *name); struct osmo_ss7_linkset * ss7_linkset_find_or_create(struct osmo_ss7_instance *inst, const char *name, uint32_t pc); + +bool +ss7_linkset_is_available(const struct osmo_ss7_linkset *lset); diff --git a/src/ss7_route.h b/src/ss7_route.h index 7a29b7b..0382564 100644 --- a/src/ss7_route.h +++ b/src/ss7_route.h @@ -54,3 +54,5 @@
int ss7_route_set_linkset(struct osmo_ss7_route *rt, const char *linkset_name); int ss7_route_insert(struct osmo_ss7_route *rt); + +bool ss7_route_is_available(const struct osmo_ss7_route *rt); diff --git a/tests/vty/osmo_stp_route_prio.vty b/tests/vty/osmo_stp_route_prio.vty index 255128e..6f60d9a 100644 --- a/tests/vty/osmo_stp_route_prio.vty +++ b/tests/vty/osmo_stp_route_prio.vty @@ -83,9 +83,9 @@
Destination C Q P Linkset Name Linkset Non-adj Route ---------------------- - - - ------------------- ------- ------- ------- -3.2.1/14 0 2 as3 ? ? ? -3.2.1/14 0 5 as2 ? ? ? -3.2.1/14 7 6 as1 ? ? ? +3.2.1/14 INACC 0 2 as3 UNAVAIL ? UNAVAIL +3.2.1/14 INACC 0 5 as2 UNAVAIL ? UNAVAIL +3.2.1/14 INACC 7 6 as1 UNAVAIL ? UNAVAIL
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