aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-07-13 12:24:15 +0200
committerHarald Welte <laforge@gnumonks.org>2015-11-15 14:15:19 +0100
commit958c473bb0b23d6933f01266df7b7be8fe1e29d8 (patch)
tree604f5a0f1aa402fe8ed02022cede89026685b5e3
parent60ff8c6901e2e0739a369218e8225f566465d542 (diff)
ganc vty: show keep-alive time-out for every peer in vty
-rw-r--r--openbsc/src/osmo-ganc/ganc_vty.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/openbsc/src/osmo-ganc/ganc_vty.c b/openbsc/src/osmo-ganc/ganc_vty.c
index a41566198..8fc44eaf0 100644
--- a/openbsc/src/osmo-ganc/ganc_vty.c
+++ b/openbsc/src/osmo-ganc/ganc_vty.c
@@ -23,6 +23,7 @@
#include <openbsc/vty.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/core/timer.h>
#include <osmocom/sccp/sccp.h>
#include <openbsc/osmo_bsc.h>
@@ -36,11 +37,19 @@ const struct value_string ganc_state_names[] = {
{ 0, NULL }
};
-static void show_peer(struct vty *vty, struct gan_peer *peer)
+static void show_peer(struct vty *vty, struct gan_peer *peer,
+ struct timeval *now)
{
- vty_out(vty, "IMSI: %s, State: %s%s", peer->imsi,
+ struct timeval rem;
+ int rc;
+
+ /* we determine the time once globally if we leave the select
+ * loop, and not for every peer we display */
+ rc = osmo_timer_remaining(&peer->keepalive_timer, NULL, now);
+
+ vty_out(vty, "IMSI: %s, State: %s, Timeout: %u s%s", peer->imsi,
get_value_string(ganc_state_names, peer->csr_state),
- VTY_NEWLINE);
+ rc == 0 ? (int) rem.tv_sec : 0, VTY_NEWLINE);
if (peer->conn) {
struct osmo_conn *conn = peer->conn;
vty_out(vty, " GAN MS Remote IP/Port: %s:%u%s",
@@ -77,9 +86,12 @@ DEFUN(show_gan_peer, show_gan_peer_cmd,
SHOW_STR "GANC Peers (MS attached to the GANC)")
{
struct gan_peer *peer;
+ struct timeval now;
+
+ gettimeofday(&now, NULL);
llist_for_each_entry(peer, &g_ganc_bts->net->peers, entry)
- show_peer(vty, peer);
+ show_peer(vty, peer, &now);
return CMD_SUCCESS;
}