From 512cc24f9ae66e7b56a41257ac95b546dff829b5 Mon Sep 17 00:00:00 2001 From: Lucian Balaceanu Date: Tue, 19 Jul 2016 10:51:20 +0300 Subject: [PATCH] Print relay IP information Add relay IP info in MDR, `rtpengine-ctl list sessions `, call_destroy() --- daemon/call.c | 11 +++++++++-- daemon/cli.c | 14 ++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 89027b30b..306801ed1 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1980,6 +1980,7 @@ void call_destroy(struct call *c) { continue; char *addr = sockaddr_print_buf(&ps->endpoint.address); + char *local_addr = ps->selected_sfd ? sockaddr_print_buf(&ps->selected_sfd->socket.local.address) : "0.0.0.0"; if (_log_facility_cdr) { const char* protocol = (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) ? "rtcp" : "rtp"; @@ -1988,6 +1989,7 @@ void call_destroy(struct call *c) { printlen = snprintf(cdrbufcur, CDRBUFREMAINDER, "ml%i_midx%u_%s_endpoint_ip=%s, " "ml%i_midx%u_%s_endpoint_port=%u, " + "ml%i_midx%u_%s_local_relay_ip=%s, " "ml%i_midx%u_%s_local_relay_port=%u, " "ml%i_midx%u_%s_relayed_packets="UINT64F", " "ml%i_midx%u_%s_relayed_bytes="UINT64F", " @@ -1996,6 +1998,7 @@ void call_destroy(struct call *c) { "ml%i_midx%u_%s_in_tos_tclass=%" PRIu8 ", ", cdrlinecnt, md->index, protocol, addr, cdrlinecnt, md->index, protocol, ps->endpoint.port, + cdrlinecnt, md->index, protocol, local_addr, cdrlinecnt, md->index, protocol, (ps->selected_sfd ? ps->selected_sfd->socket.local.port : 0), cdrlinecnt, md->index, protocol, @@ -2014,6 +2017,7 @@ void call_destroy(struct call *c) { printlen = snprintf(cdrbufcur, CDRBUFREMAINDER, "ml%i_midx%u_%s_endpoint_ip=%s, " "ml%i_midx%u_%s_endpoint_port=%u, " + "ml%i_midx%u_%s_local_relay_ip=%s, " "ml%i_midx%u_%s_local_relay_port=%u, " "ml%i_midx%u_%s_relayed_packets="UINT64F", " "ml%i_midx%u_%s_relayed_bytes="UINT64F", " @@ -2025,6 +2029,7 @@ void call_destroy(struct call *c) { "ml%i_midx%u_%s_delay_max=%.9f, ", cdrlinecnt, md->index, protocol, addr, cdrlinecnt, md->index, protocol, ps->endpoint.port, + cdrlinecnt, md->index, protocol, local_addr, cdrlinecnt, md->index, protocol, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), cdrlinecnt, md->index, protocol, atomic64_get(&ps->stats.packets), @@ -2044,6 +2049,7 @@ void call_destroy(struct call *c) { printlen = snprintf(cdrbufcur, CDRBUFREMAINDER, "ml%i_midx%u_%s_endpoint_ip=%s, " "ml%i_midx%u_%s_endpoint_port=%u, " + "ml%i_midx%u_%s_local_relay_ip=%s, " "ml%i_midx%u_%s_local_relay_port=%u, " "ml%i_midx%u_%s_relayed_packets="UINT64F", " "ml%i_midx%u_%s_relayed_bytes="UINT64F", " @@ -2052,6 +2058,7 @@ void call_destroy(struct call *c) { "ml%i_midx%u_%s_in_tos_tclass=%" PRIu8 ", ", cdrlinecnt, md->index, protocol, addr, cdrlinecnt, md->index, protocol, ps->endpoint.port, + cdrlinecnt, md->index, protocol, local_addr, cdrlinecnt, md->index, protocol, (ps->selected_sfd ? ps->selected_sfd->socket.local.port : 0), cdrlinecnt, md->index, protocol, @@ -2069,8 +2076,8 @@ void call_destroy(struct call *c) { } } - ilog(LOG_INFO, "--------- Port %5u <> %15s:%-5u%s, " - ""UINT64F" p, "UINT64F" b, "UINT64F" e, "UINT64F" last_packet", + ilog(LOG_INFO, "--------- Port %15s:%-5u <> %15s:%-5u%s, " + ""UINT64F" p, "UINT64F" b, "UINT64F" e, "UINT64F" last_packet", local_addr, (unsigned int) (ps->selected_sfd ? ps->selected_sfd->socket.local.port : 0), addr, ps->endpoint.port, (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) ? " (RTCP)" : "", diff --git a/daemon/cli.c b/daemon/cli.c index a3051247d..d3b4bceb3 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -262,6 +262,7 @@ static void cli_incoming_list_callid(char* buffer, int len, struct callmaster* m int printlen=0; struct timeval tim_result_duration; struct timeval now; + char * local_addr; if (len<=1) { printlen = snprintf(replybuffer,(outbufend-replybuffer), "%s\n", "More parameters required."); @@ -309,12 +310,13 @@ static void cli_incoming_list_callid(char* buffer, int len, struct callmaster* m if (PS_ISSET(ps, FALLBACK_RTCP)) continue; + local_addr = ps->selected_sfd ? sockaddr_print_buf(&ps->selected_sfd->socket.local.address) : "0.0.0.0"; #if (RE_HAS_MEASUREDELAY) if (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) { - printlen = snprintf(replybuffer,(outbufend-replybuffer), "------ Media #%u, port %5u <> %15s:%-5hu%s, " + printlen = snprintf(replybuffer,(outbufend-replybuffer), "------ Media #%u, %15s:%-5hu <> %15s:%-5hu%s, " ""UINT64F" p, "UINT64F" b, "UINT64F" e, "UINT64F" last_packet\n", md->index, - (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), + local_addr, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), sockaddr_print_buf(&ps->endpoint.ip46), ps->endpoint.port, (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) ? " (RTCP)" : "", atomic64_get(&ps->stats.packets), @@ -322,10 +324,10 @@ static void cli_incoming_list_callid(char* buffer, int len, struct callmaster* m atomic64_get(&ps->stats.errors), atomic64_get(&ps->last_packet)); } else { - printlen = snprintf(replybuffer,(outbufend-replybuffer), "------ Media #%u, port %5u <> %15s:%-5hu%s, " + printlen = snprintf(replybuffer,(outbufend-replybuffer), "------ Media #%u, %15s:%-5hu <> %15s:%-5hu%s, " ""UINT64F" p, "UINT64F" b, "UINT64F" e, "UINT64F" last_packet, %.9f delay_min, %.9f delay_avg, %.9f delay_max\n", md->index, - (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), + local_addr, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), sockaddr_print_buf(&ps->endpoint.ip46), ps->endpoint.port, (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) ? " (RTCP)" : "", atomic64_get(&ps->stats.packets), @@ -337,10 +339,10 @@ static void cli_incoming_list_callid(char* buffer, int len, struct callmaster* m (double) ps->stats.delay_max / 1000000); } #else - printlen = snprintf(replybuffer,(outbufend-replybuffer), "------ Media #%u, port %5u <> %15s:%-5u%s, " + printlen = snprintf(replybuffer,(outbufend-replybuffer), "------ Media #%u, %15s:%-5u <> %15s:%-5u%s, " ""UINT64F" p, "UINT64F" b, "UINT64F" e, "UINT64F" last_packet\n", md->index, - (unsigned int) (ps->selected_sfd ? ps->selected_sfd->socket.local.port : 0), + local_addr, (unsigned int) (ps->selected_sfd ? ps->selected_sfd->socket.local.port : 0), sockaddr_print_buf(&ps->endpoint.address), ps->endpoint.port, (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) ? " (RTCP)" : "", atomic64_get(&ps->stats.packets),