From c19962e1e12fdf4badba64d2111dba16226c8e76 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Thu, 7 Nov 2019 02:52:29 +0700 Subject: osmo_ss7_vty.c: implement 'active' filter for show_cs7_as_cmd Change-Id: I356d90642a500be6a70f60c8240ce1211fd0d934 --- include/osmocom/sigtran/osmo_ss7.h | 1 + src/osmo_ss7.c | 10 ++++++++++ src/osmo_ss7_vty.c | 3 ++- src/xua_as_fsm.c | 7 ------- src/xua_as_fsm.h | 7 +++++++ tests/vty/ss7_asp_test.vty | 1 - 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index d0aa9a1..6778409 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -346,6 +346,7 @@ int osmo_ss7_as_del_asp(struct osmo_ss7_as *as, const char *asp_name); void osmo_ss7_as_destroy(struct osmo_ss7_as *as); bool osmo_ss7_as_has_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp); +bool osmo_ss7_as_active(const struct osmo_ss7_as *as); bool osmo_ss7_as_tmode_compatible_xua(struct osmo_ss7_as *as, uint32_t m3ua_tmt); void osmo_ss7_asp_disconnect(struct osmo_ss7_asp *asp); diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 0d49d1a..d74f8f9 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -1068,6 +1068,16 @@ bool osmo_ss7_as_has_asp(struct osmo_ss7_as *as, return false; } +/*! Determine if given AS is in the active state. + * \param[in] as Application Server. + * \returns true in case as is active; false otherwise. */ +bool osmo_ss7_as_active(const struct osmo_ss7_as *as) +{ + if (!as->fi) + return false; + return as->fi->state == XUA_AS_S_ACTIVE; +} + /*********************************************************************** * SS7 Application Server Process ***********************************************************************/ diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 1a246db..84f616a 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -1096,7 +1096,8 @@ DEFUN(show_cs7_as, show_cs7_as_cmd, continue; if (filter && !strcmp(filter, "sua") && as->cfg.proto != OSMO_SS7_ASP_PROT_SUA) continue; - /* FIXME: active filter */ + 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), diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c index 394061b..602c433 100644 --- a/src/xua_as_fsm.c +++ b/src/xua_as_fsm.c @@ -147,13 +147,6 @@ int xua_as_transmit_msg(struct osmo_ss7_as *as, struct msgb *msg) #define MSEC_TO_S_US(x) (x/1000), ((x%1000)*10) -enum xua_as_state { - XUA_AS_S_DOWN, - XUA_AS_S_INACTIVE, - XUA_AS_S_ACTIVE, - XUA_AS_S_PENDING, -}; - static const struct value_string xua_as_event_names[] = { { XUA_ASPAS_ASP_INACTIVE_IND, "ASPAS-ASP_INACTIVE.ind" }, { XUA_ASPAS_ASP_DOWN_IND, "ASPAS-ASP_DOWN.ind" }, diff --git a/src/xua_as_fsm.h b/src/xua_as_fsm.h index 0128919..0e71350 100644 --- a/src/xua_as_fsm.h +++ b/src/xua_as_fsm.h @@ -2,6 +2,13 @@ struct osmo_ss7_as; +enum xua_as_state { + XUA_AS_S_DOWN, + XUA_AS_S_INACTIVE, + XUA_AS_S_ACTIVE, + XUA_AS_S_PENDING, +}; + enum xua_as_event { XUA_ASPAS_ASP_INACTIVE_IND, XUA_ASPAS_ASP_DOWN_IND, diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty index eeda4c8..a7fe492 100644 --- a/tests/vty/ss7_asp_test.vty +++ b/tests/vty/ss7_asp_test.vty @@ -280,7 +280,6 @@ ss7_asp_vty_test(config-cs7-as)# do show cs7 instance 0 as active 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 ss7_asp_vty_test(config-cs7-as)# do show cs7 instance 0 as sua Routing Routing Key Cic Cic Traffic -- cgit v1.2.3