summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-11-07 02:52:29 +0700
committerlaforge <laforge@osmocom.org>2019-11-14 22:31:40 +0000
commitc19962e1e12fdf4badba64d2111dba16226c8e76 (patch)
tree5530a1c8c359327f8e97aa9eac0150014d698da3
parent535e43268cef88439320a4cf8b614c976ff78a4f (diff)
osmo_ss7_vty.c: implement 'active' filter for show_cs7_as_cmd
-rw-r--r--include/osmocom/sigtran/osmo_ss7.h1
-rw-r--r--src/osmo_ss7.c10
-rw-r--r--src/osmo_ss7_vty.c3
-rw-r--r--src/xua_as_fsm.c7
-rw-r--r--src/xua_as_fsm.h7
-rw-r--r--tests/vty/ss7_asp_test.vty1
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