From 5925e25626303a6b41d5a9e25ad8a90ad1537d60 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 3 Jul 2012 12:06:47 -0400 Subject: [PATCH 1/4] added mod_rad_cdr --- build/modules.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/build/modules.conf.in b/build/modules.conf.in index 67844ea342..2a73456541 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -12,3 +12,4 @@ endpoints/mod_sofia xml_int/mod_xml_cdr event_handlers/mod_event_socket codecs/mod_sangoma_codec +event_handlers/mod_radius_cdr From c544ff4b813b4f24c34a22fc573749cd9e8335be Mon Sep 17 00:00:00 2001 From: James Zhang Date: Tue, 3 Jul 2012 14:29:50 -0400 Subject: [PATCH 2/4] sip: add receiver report to rtcp - only one to one rtcp is supported for currently - jitter stats and loss stats are not real --- src/include/switch_types.h | 3 +- src/switch_rtp.c | 91 +++++++++++++++++++++++++++++++++++--- 2 files changed, 88 insertions(+), 6 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 185fdb64af..593e921bcd 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -547,6 +547,8 @@ typedef struct { typedef struct { uint32_t packet_count; uint32_t octet_count; + + uint32_t peer_ssrc; } switch_rtcp_numbers_t; typedef struct { @@ -769,7 +771,6 @@ typedef struct { unsigned type:8; /* packet type */ unsigned length:16; /* length in 32-bit words - 1 */ } switch_rtcp_hdr_t; - #else /* BIG_ENDIAN */ typedef struct { diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 5e741c4eb7..ff03a8d054 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -264,6 +264,46 @@ struct switch_rtp { switch_size_t last_flush_packet_count; }; +struct switch_rtcp_source { + unsigned ssrc1:32; + unsigned fraction_lost:8; + unsigned cumulative_lost:24; + unsigned hi_seq_recieved:32; + unsigned interarrival_jitter:32; + unsigned lsr:32; + unsigned lsr_delay:32; +}; + + +#if SWITCH_BYTE_ORDER == __BIG_ENDIAN +struct switch_rtcp_s_desc_head { + unsigned v:2; + unsigned padding:1; + unsigned sc:5; + unsigned pt:8; + unsigned length:16; +}; + +#else /* BIG_ENDIAN */ + +struct switch_rtcp_s_desc_head { + unsigned sc:5; + unsigned padding:1; + unsigned v:2; + unsigned pt:8; + unsigned length:16; +}; + +#endif + + +struct switch_rtcp_s_desc_trunk { + unsigned ssrc:32; + unsigned cname:8; + unsigned length:8; + char text[1]; +}; + struct switch_rtcp_senderinfo { unsigned ssrc:32; unsigned ntp_msw:32; @@ -271,6 +311,9 @@ struct switch_rtcp_senderinfo { unsigned ts:32; unsigned pc:32; unsigned oc:32; + struct switch_rtcp_source sr_source; + struct switch_rtcp_s_desc_head sr_desc_head; + struct switch_rtcp_s_desc_trunk sr_desc_ssrc; }; typedef enum { @@ -1637,8 +1680,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session rtp_session->rtcp_send_msg.header.version = 2; rtp_session->rtcp_send_msg.header.p = 0; rtp_session->rtcp_send_msg.header.type = 200; - rtp_session->rtcp_send_msg.header.count = 0; - rtp_session->rtcp_send_msg.header.length = htons(6); + rtp_session->rtcp_send_msg.header.count = 1; + rtp_session->rtcp_send_msg.header.length = htons(12); switch_rtp_set_interval(rtp_session, ms_per_packet, samples_per_interval); @@ -2823,9 +2866,10 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t rtp_session->stats.rtcp.packet_count += sr->pc; rtp_session->stats.rtcp.octet_count += sr->oc; + rtp_session->stats.rtcp.peer_ssrc = ntohl(sr->ssrc); /* sender report */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10,"Received a SR with %d report blocks, " \ + switch_log_printf(SWITCH_CHANNEL_LOG, /*SWITCH_LOG_DEBUG10*/ SWITCH_LOG_INFO,"Received a SR with %d report blocks, " \ "length in words = %d, " \ "SSRC = 0x%X, " \ "NTP MSW = %u, " \ @@ -4025,15 +4069,52 @@ static int rtp_common_write(switch_rtp_t *rtp_session, switch_test_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_RTCP_PASSTHRU) && rtp_session->rtcp_interval && (rtp_session->stats.outbound.packet_count % rtp_session->rtcp_interval) == 0) { struct switch_rtcp_senderinfo* sr = (struct switch_rtcp_senderinfo*)rtp_session->rtcp_send_msg.body; + const char* str_cname=NULL; sr->ssrc = send_msg->header.ssrc; - sr->ntp_msw = htonl((u_long)rtp_session->send_time / 1000000 + 2208988800UL); + sr->ntp_msw = htonl((u_long)(rtp_session->send_time / 1000000 + 2208988800UL)); + /* sr->ntp_lsw = htonl((u_long)(rtp_session->send_time % 1000000 * ((UINT_MAX * 1.0)/ 1000000.0))); + */ + sr->ntp_lsw = htonl((u_long)(rtp_session->send_time % 1000000 * 4294.967296)); sr->ts = send_msg->header.ts; sr->pc = htonl(rtp_session->stats.outbound.packet_count); sr->oc = htonl((rtp_session->stats.outbound.raw_bytes - rtp_session->stats.outbound.packet_count * sizeof(srtp_hdr_t))); - rtcp_bytes = sizeof(switch_rtcp_hdr_t) + sizeof(struct switch_rtcp_senderinfo); + + sr->sr_source.ssrc1 = htonl(rtp_session->stats.rtcp.peer_ssrc); + sr->sr_source.fraction_lost |= 0; + sr->sr_source.cumulative_lost |= 0; + sr->sr_source.hi_seq_recieved = htonl(rtp_session->last_seq); + sr->sr_source.interarrival_jitter = htonl(0); + sr->sr_source.lsr = htonl(0); + sr->sr_source.lsr_delay = htonl(0); + + sr->sr_desc_head.v = 0x02; + sr->sr_desc_head.padding = 0; + sr->sr_desc_head.sc = 1; + sr->sr_desc_head.pt = 202; + sr->sr_desc_head.length = htons(5); + + + sr->sr_desc_ssrc.ssrc = send_msg->header.ssrc; /*htonl(rtp_session->stats.rtcp.peer_ssrc); */ + sr->sr_desc_ssrc.cname = 0x1; + { + char bufa[30]; + str_cname = switch_get_addr(bufa, sizeof(bufa), rtp_session->rtcp_local_addr); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Setting RTCP src-1 to %s\n", str_cname); + sr->sr_desc_ssrc.length = strlen(str_cname); + memcpy ((char*)sr->sr_desc_ssrc.text, str_cname, strlen(str_cname)); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Setting RTCP src-1 LENGTH to %d (%d, %s)\n", sr->sr_desc_ssrc.length, sr->sr_desc_head.length, str_cname); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Setting msw = %d, lsw = %d \n", sr->ntp_msw, sr->ntp_lsw); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "now = %lld, now lo = %d, now hi = %d\n", (int64_t)now, (int32_t)(now&0xFFFFFFFF), (int32_t)((now>>32&0xFFFFFFFF))); + + + rtcp_bytes = sizeof(switch_rtcp_hdr_t) + sizeof(struct switch_rtcp_senderinfo) + sr->sr_desc_ssrc.length -1 ; + + #ifdef ENABLE_SRTP if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) { int sbytes = (int) rtcp_bytes; From 5bfc1473cb0878fb013ce9493df67b977d9d5dbe Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 3 Jul 2012 16:04:43 -0400 Subject: [PATCH 3/4] Added mod_rad_auth --- build/modules.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/build/modules.conf.in b/build/modules.conf.in index 2a73456541..559b06e8ea 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -13,3 +13,4 @@ xml_int/mod_xml_cdr event_handlers/mod_event_socket codecs/mod_sangoma_codec event_handlers/mod_radius_cdr +applications/mod_rad_auth From fff6a923fe77d4591f4c7f925aed6a526c1735af Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 3 Jul 2012 16:35:06 -0400 Subject: [PATCH 4/4] Added freeradius-client --- src/mod/applications/mod_rad_auth/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mod/applications/mod_rad_auth/Makefile b/src/mod/applications/mod_rad_auth/Makefile index d2e91c24b3..79021e86fe 100644 --- a/src/mod/applications/mod_rad_auth/Makefile +++ b/src/mod/applications/mod_rad_auth/Makefile @@ -10,5 +10,20 @@ RADCLIENT_LA=${RADCLIENT_LIBDIR}/libfreeradius-client.la LOCAL_CFLAGS=-I$(RADCLIENT_DIR)/include LOCAL_LIBADD=$(RADCLIENT_LA) + include $(switch_srcdir)/build/modmake.rules +$(RADCLIENT_DIR): + $(GETLIB) $(RADCLIENT).tar.gz + +$(RADCLIENT_BUILDDIR)/Makefile: $(RADCLIENT_DIR) + mkdir -p $(RADCLIENT_BUILDDIR) + cd $(RADCLIENT_BUILDDIR) && $(DEFAULT_VARS) $(RADCLIENT_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(RADCLIENT_DIR) + $(TOUCH_TARGET) + +$(RADCLIENT_LA): $(RADCLIENT_BUILDDIR)/Makefile + cd $(RADCLIENT_BUILDDIR) && CFLAGS="$(CFLAGS)" $(MAKE) + $(TOUCH_TARGET) + + +