[sr-dev] git:master:ba773d2a: dialog: added duration field in dialog rpc output

Daniel-Constantin Mierla miconda at gmail.com
Mon Dec 13 09:55:05 CET 2021


Module: kamailio
Branch: master
Commit: ba773d2a2bf64e01f1724e61acad765fb311a0a6
URL: https://github.com/kamailio/kamailio/commit/ba773d2a2bf64e01f1724e61acad765fb311a0a6

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-12-13T09:54:29+01:00

dialog: added duration field in dialog rpc output

---

Modified: src/modules/dialog/dialog.c

---

Diff:  https://github.com/kamailio/kamailio/commit/ba773d2a2bf64e01f1724e61acad765fb311a0a6.diff
Patch: https://github.com/kamailio/kamailio/commit/ba773d2a2bf64e01f1724e61acad765fb311a0a6.patch

---

diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 7361887fe5..16abec9e88 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -2324,10 +2324,20 @@ static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c, dlg_cell_t *dlg,
 	void *h, *sh, *ssh;
 	dlg_profile_link_t *pl;
 	dlg_var_t *var;
+	time_t tnow;
+	int tdur;
 
 	if (rpc->add(c, "{", &h) < 0) goto error;
 
-	rpc->struct_add(h, "dddSSSddddddddd",
+	tnow = time(NULL);
+	if(dlg->end_ts) {
+		tdur = (int)(dlg->end_ts - dlg->start_ts);
+	} if(dlg->start_ts) {
+		tdur = (int)(tnow - dlg->start_ts);
+	} else {
+		tdur = 0;
+	}
+	rpc->struct_add(h, "dddSSSdddddddddd",
 		"h_entry", dlg->h_entry,
 		"h_id", dlg->h_id,
 		"ref", dlg->ref,
@@ -2338,7 +2348,8 @@ static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c, dlg_cell_t *dlg,
 		"start_ts", dlg->start_ts,
 		"init_ts", dlg->init_ts,
 		"end_ts", dlg->end_ts,
-		"timeout", dlg->tl.timeout ? time(0) + dlg->tl.timeout - get_ticks() : 0,
+		"duration", tdur,
+		"timeout", dlg->tl.timeout ? tnow + dlg->tl.timeout - get_ticks() : 0,
 		"lifetime", dlg->lifetime,
 		"dflags", dlg->dflags,
 		"sflags", dlg->sflags,




More information about the sr-dev mailing list