Module: sip-router
Branch: master
Commit: 33e7e899e5aa7dc291ec45a711100e6200896f14
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=33e7e89…
Author: Ovidiu Sas <osas(a)voipembedded.com>
Committer: Ovidiu Sas <osas(a)voipembedded.com>
Date: Wed Jan 29 15:39:47 2014 -0500
dialog: enhance list* RPC commands
- human readable format for dialog start/stop timestamps
- adding lifetime parameter
---
modules/dialog/dialog.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c
index 307b90f..9c3f839 100644
--- a/modules/dialog/dialog.c
+++ b/modules/dialog/dialog.c
@@ -90,6 +90,8 @@
MODULE_VERSION
+#define RPC_DATE_BUF_LEN 21
+
static int mod_init(void);
static int child_init(int rank);
static void mod_destroy(void);
@@ -1445,9 +1447,28 @@ static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c,
dlg_cell_t *dlg,
int with_context)
{
rpc_cb_ctx_t rpc_cb;
+ time_t _start_ts, _stop_ts;
+ struct tm *_start_t, *_stop_t;
+ char _start_date_buf[RPC_DATE_BUF_LEN]="UNSPECIFIED";
+ char _stop_date_buf[RPC_DATE_BUF_LEN]="UNSPECIFIED";
+
+ _start_ts = (time_t)dlg->start_ts;
+ if (_start_ts) {
+ _start_t = localtime(&_start_ts);
+ strftime(_start_date_buf, RPC_DATE_BUF_LEN - 1,
+ "%Y-%m-%d %H:%M:%S", _start_t);
+ if (dlg->tl.timeout) {
+ _stop_ts = (time_t)(dlg->tl.timeout);
+ _stop_t = localtime(&_stop_ts);
+ strftime(_stop_date_buf, RPC_DATE_BUF_LEN - 1,
+ "%Y-%m-%d %H:%M:%S", _stop_t);
+ }
+ }
- rpc->printf(c, "hash:%u:%u state:%u ref_count:%u timestart:%u timeout:%u",
- dlg->h_entry, dlg->h_id, dlg->state, dlg->ref, dlg->start_ts,
dlg->tl.timeout);
+ rpc->printf(c, "hash:%u:%u state:%u ref_count:%u "
+ "timestart:%u timeout:%u lifetime:%u datestart:%s datestop:%s",
+ dlg->h_entry, dlg->h_id, dlg->state, dlg->ref, _start_ts,
dlg->tl.timeout, dlg->lifetime,
+ _start_date_buf, _stop_date_buf);
rpc->printf(c, "\tcallid:%.*s from_tag:%.*s to_tag:%.*s",
dlg->callid.len, dlg->callid.s,
dlg->tag[DLG_CALLER_LEG].len, dlg->tag[DLG_CALLER_LEG].s,