diff --git a/daemon/call.h b/daemon/call.h index 8a2b5f68d..3328ed9b4 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -461,7 +461,10 @@ struct interface_address *get_interface_from_address(struct local_interface *lif const struct transport_protocol *transport_protocol(const str *s); - +void timeval_subtract (struct timeval *result, const struct timeval *a, const struct timeval *b); +void timeval_multiply(struct timeval *result, const struct timeval *a, const long multiplier); +void timeval_devide(struct timeval *result, const struct timeval *a, const long devisor); +void timeval_add(struct timeval *result, const struct timeval *a, const struct timeval *b); INLINE void *call_malloc(struct call *c, size_t l) { diff --git a/daemon/cli.c b/daemon/cli.c index 0c10c66ef..162d6274d 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -62,6 +62,8 @@ static void cli_incoming_list_callid(char* buffer, int len, struct callmaster* m char buf[64]; int printlen=0; char tagtypebuf[16]; memset(&tagtypebuf,0,16); + struct timeval tim_result_duration; memset(&tim_result_duration,0,sizeof(struct timeval)); + struct timeval now; memset(&now,0,sizeof(struct timeval)); if (len<=1) { printlen = snprintf(replybuffer,(outbufend-replybuffer), "%s\n", "More parameters required."); @@ -83,13 +85,18 @@ static void cli_incoming_list_callid(char* buffer, int len, struct callmaster* m ADJUSTLEN(printlen,outbufend,replybuffer); for (l = c->monologues; l; l = l->next) { - ml = l->data; - - printlen = snprintf(replybuffer,(outbufend-replybuffer), "--- Tag '"STR_FORMAT"' type: %s, callduration " - "%u:%02u , in dialogue with '"STR_FORMAT"'\n", + ml = l->data; + if (!ml->terminated.tv_sec) { + gettimeofday(&now, NULL); + } else { + now = ml->terminated; + } + timeval_subtract(&tim_result_duration,&now,&ml->started); + printlen = snprintf(replybuffer,(outbufend-replybuffer), "--- Tag '"STR_FORMAT"' type: %s, callduration " + "%ld.%06ld , in dialogue with '"STR_FORMAT"'\n", STR_FMT(&ml->tag), get_tag_type_text(tagtypebuf,ml->tagtype), - (unsigned int) (poller_now - ml->created) / 60, - (unsigned int) (poller_now - ml->created) % 60, + tim_result_duration.tv_sec, + tim_result_duration.tv_usec, ml->active_dialogue ? ml->active_dialogue->tag.len : 6, ml->active_dialogue ? ml->active_dialogue->tag.s : "(none)"); ADJUSTLEN(printlen,outbufend,replybuffer);