mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 16:39:14 +00:00
FS-3165
This commit is contained in:
parent
26f5ebd47d
commit
fd6089014e
@ -2491,24 +2491,11 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
rtp_session->stats.inbound.packet_count++;
|
rtp_session->stats.inbound.packet_count++;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ((rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) ||
|
|
||||||
(*bytes < rtp_header_len && *bytes > 0) ||
|
|
||||||
switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
rtp_session->last_read_ts = ts;
|
|
||||||
|
|
||||||
|
|
||||||
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
|
|
||||||
|
|
||||||
|
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
|
||||||
#ifdef ENABLE_ZRTP
|
#ifdef ENABLE_ZRTP
|
||||||
/* ZRTP Recv */
|
/* ZRTP Recv */
|
||||||
if (*bytes) {
|
|
||||||
unsigned int sbytes = (int) *bytes;
|
unsigned int sbytes = (int) *bytes;
|
||||||
zrtp_status_t stat = 0;
|
zrtp_status_t stat = 0;
|
||||||
|
|
||||||
@ -2528,49 +2515,59 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (*bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV)) {
|
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV)) {
|
||||||
int sbytes = (int) *bytes;
|
int sbytes = (int) *bytes;
|
||||||
err_status_t stat = 0;
|
err_status_t stat = 0;
|
||||||
|
|
||||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV_RESET)) {
|
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV_RESET)) {
|
||||||
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV_RESET);
|
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV_RESET);
|
||||||
srtp_dealloc(rtp_session->recv_ctx);
|
srtp_dealloc(rtp_session->recv_ctx);
|
||||||
rtp_session->recv_ctx = NULL;
|
rtp_session->recv_ctx = NULL;
|
||||||
if ((stat = srtp_create(&rtp_session->recv_ctx, &rtp_session->recv_policy))) {
|
if ((stat = srtp_create(&rtp_session->recv_ctx, &rtp_session->recv_policy))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error! RE-Activating Secure RTP RECV\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error! RE-Activating Secure RTP RECV\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "RE-Activating Secure RTP RECV\n");
|
||||||
|
rtp_session->srtp_errs = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(*flags & SFF_PLC)) {
|
||||||
|
stat = srtp_unprotect(rtp_session->recv_ctx, &rtp_session->recv_msg.header, &sbytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat && rtp_session->recv_msg.header.pt != rtp_session->recv_te && rtp_session->recv_msg.header.pt != rtp_session->cng_pt) {
|
||||||
|
if (++rtp_session->srtp_errs >= MAX_SRTP_ERRS) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||||
|
"Error: SRTP unprotect failed with code %d%s\n", stat,
|
||||||
|
stat == err_status_replay_fail ? " (replay check failed)" : stat ==
|
||||||
|
err_status_auth_fail ? " (auth check failed)" : "");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
} else {
|
||||||
|
sbytes = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "RE-Activating Secure RTP RECV\n");
|
|
||||||
rtp_session->srtp_errs = 0;
|
rtp_session->srtp_errs = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!(*flags & SFF_PLC)) {
|
*bytes = sbytes;
|
||||||
stat = srtp_unprotect(rtp_session->recv_ctx, &rtp_session->recv_msg.header, &sbytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat && rtp_session->recv_msg.header.pt != rtp_session->recv_te && rtp_session->recv_msg.header.pt != rtp_session->cng_pt) {
|
|
||||||
if (++rtp_session->srtp_errs >= MAX_SRTP_ERRS) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
|
||||||
"Error: SRTP unprotect failed with code %d%s\n", stat,
|
|
||||||
stat == err_status_replay_fail ? " (replay check failed)" : stat ==
|
|
||||||
err_status_auth_fail ? " (auth check failed)" : "");
|
|
||||||
return SWITCH_STATUS_FALSE;
|
|
||||||
} else {
|
|
||||||
sbytes = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rtp_session->srtp_errs = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*bytes = sbytes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ((rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) ||
|
||||||
|
(*bytes < rtp_header_len && *bytes > 0) ||
|
||||||
|
switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL)) {
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rtp_session->last_read_ts = ts;
|
||||||
|
|
||||||
|
|
||||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BYTESWAP) && rtp_session->recv_msg.header.pt == rtp_session->rpayload) {
|
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BYTESWAP) && rtp_session->recv_msg.header.pt == rtp_session->rpayload) {
|
||||||
switch_swap_linear((int16_t *)rtp_session->recv_msg.body, (int) *bytes - rtp_header_len);
|
switch_swap_linear((int16_t *)rtp_session->recv_msg.body, (int) *bytes - rtp_header_len);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user