Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 216545) +++ channels/chan_sip.c (working copy) @@ -16035,8 +16035,8 @@ /*! \brief Callback for show_chanstats */ static int show_chanstats_cb(void *__cur, void *__arg, int flags) { -#define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s (%-2.2s) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n" -#define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u %-10.10u%-1.1s %-10.10u (%-2.2u%%) %-6.6u\n" +#define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s ( %%) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n" +#define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.6u %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.6u\n" struct sip_pvt *cur = __cur; struct ast_rtp_instance_stats stats; char durbuf[10]; @@ -16075,12 +16075,12 @@ stats.rxcount > (unsigned int) 100000 ? (unsigned int) (stats.rxcount)/(unsigned int) 1000 : stats.rxcount, stats.rxcount > (unsigned int) 100000 ? "K":" ", stats.rxploss, - stats.rxcount > stats.rxploss ? (stats.rxploss / stats.rxcount * 100) : 0, + (stats.rxcount + stats.rxploss) > 0 ? (double) stats.rxploss / (stats.rxcount + stats.rxploss) * 100 : 0, stats.rxjitter, stats.txcount > (unsigned int) 100000 ? (unsigned int) (stats.txcount)/(unsigned int) 1000 : stats.txcount, stats.txcount > (unsigned int) 100000 ? "K":" ", stats.txploss, - stats.txcount > stats.txploss ? (stats.txploss / stats.txcount * 100) : 0, + stats.txcount > 0 ? (double) stats.txploss / stats.txcount * 100 : 0, stats.txjitter ); arg->numchans++; @@ -16108,7 +16108,7 @@ if (a->argc != 3) return CLI_SHOWUSAGE; - ast_cli(a->fd, FORMAT2, "Peer", "Call ID", "Duration", "Recv: Pack", "Lost", "%", "Jitter", "Send: Pack", "Lost", "Jitter"); + ast_cli(a->fd, FORMAT2, "Peer", "Call ID", "Duration", "Recv: Pack", "Lost", "Jitter", "Send: Pack", "Lost", "Jitter"); /* iterate on the container and invoke the callback on each item */ ao2_t_callback(dialogs, OBJ_NODATA, show_chanstats_cb, &arg, "callback to sip show chanstats"); ast_cli(a->fd, "%d active SIP channel%s\n", arg.numchans, (arg.numchans != 1) ? "s" : ""); Index: res/res_rtp_asterisk.c =================================================================== --- res/res_rtp_asterisk.c (revision 216545) +++ res/res_rtp_asterisk.c (working copy) @@ -396,6 +396,8 @@ if (!(rtp = ast_calloc(1, sizeof(*rtp)))) { return -1; } + /* Clear all statistics values */ + memset(rtp, 0, sizeof(struct ast_rtp)); /* Set default parameters on the newly created RTP structure */ rtp->ssrc = ast_random(); @@ -2163,6 +2165,9 @@ if (!(rtp->rtcp = ast_calloc(1, sizeof(*rtp->rtcp)))) { return; } + /* Clear all statistics values */ + memset(rtp->rtcp, 0, sizeof(struct ast_rtcp)); + if ((rtp->rtcp->s = create_new_socket("RTCP")) < 0) { ast_debug(1, "Failed to create a new socket for RTCP on instance '%p'\n", instance); ast_free(rtp->rtcp);