summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-07-13 12:24:15 +0200
committerHarald Welte <laforge@gnumonks.org>2012-07-13 14:24:28 +0200
commit207024ad1019f82e3f9d8e970cb0f25458c96e66 (patch)
tree5b6e323cf94959bf1abb7c14ae8b393d88281970
parentb40aa66c0509d322fead6029ea9d6cd86ae0d9c0 (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 a415661..8fc44ea 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;
}