From e28a9ee83b296617f02e087cd9641eec1cb5547e Mon Sep 17 00:00:00 2001 From: Brian West Date: Mon, 10 Apr 2006 18:09:02 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1107 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_exosip/mod_exosip.c | 5 ++++- src/switch_rtp.c | 27 +++++++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/mod/endpoints/mod_exosip/mod_exosip.c b/src/mod/endpoints/mod_exosip/mod_exosip.c index 598da364ee..fc32fc0a4a 100644 --- a/src/mod/endpoints/mod_exosip/mod_exosip.c +++ b/src/mod/endpoints/mod_exosip/mod_exosip.c @@ -585,7 +585,10 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram now = switch_time_now(); tech_pvt->read_frame.flags = 0; tech_pvt->read_frame.datalen = switch_rtp_zerocopy_read(tech_pvt->rtp_session, &tech_pvt->read_frame.data, &payload, &tech_pvt->read_frame.flags); - + + if (tech_pvt->read_frame.datalen < 0) { + return SWITCH_STATUS_FALSE; + } if (timeout > -1) { elapsed = (unsigned int)((switch_time_now() - started) / 1000); diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 7049ef924f..26b80cb0c6 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -465,9 +465,22 @@ static int rtp_common_read(switch_rtp *rtp_session, void *data, int *payload_typ bytes = sizeof(rtp_msg_t); status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes); - if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE) && bytes > 0) { + if (bytes < 0) { + return bytes; + } + + if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE)) { int sbytes = (int)bytes; - srtp_unprotect(rtp_session->recv_ctx, &rtp_session->send_msg, &sbytes); + err_status_t stat; + + stat = srtp_unprotect(rtp_session->recv_ctx, &rtp_session->recv_msg, &sbytes); + if (stat) { + switch_console_printf(SWITCH_CHANNEL_CONSOLE, + "error: srtp unprotection failed with code %d%s\n", stat, + stat == err_status_replay_fail ? " (replay check failed)" : + stat == err_status_auth_fail ? " (auth check failed)" : ""); + return -1; + } bytes = sbytes; } @@ -496,11 +509,6 @@ static int rtp_common_read(switch_rtp *rtp_session, void *data, int *payload_typ return 0; } - if (bytes < 0) { - return bytes; - } - - if (rtp_session->recv_msg.header.version != 2) { if (rtp_session->recv_msg.header.version == 0 && rtp_session->ice_user) { handle_ice(rtp_session, (void *) &rtp_session->recv_msg, bytes); @@ -542,11 +550,12 @@ SWITCH_DECLARE(int) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **dat { int bytes = rtp_common_read(rtp_session, data, payload_type, flags); - *data = NULL; + *data = rtp_session->recv_msg.body; + if (bytes <= 0) { return bytes; } - *data = rtp_session->recv_msg.body; + return bytes; }