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);
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;
}
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);
{
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;
}