add option to disable srtp with --disble-srtp
This commit is contained in:
parent
a13064101f
commit
a6b336e4cb
|
@ -81,6 +81,7 @@ static int zrtp_on = 0;
|
|||
|
||||
#ifdef _MSC_VER
|
||||
#pragma pack()
|
||||
#define ENABLE_SRTP
|
||||
#endif
|
||||
|
||||
static switch_hash_t *alloc_hash = NULL;
|
||||
|
@ -844,14 +845,20 @@ SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool)
|
|||
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_SRTP
|
||||
srtp_init();
|
||||
#endif
|
||||
switch_mutex_init(&port_lock, SWITCH_MUTEX_NESTED, pool);
|
||||
global_init = 1;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_rtp_get_random(void *buf, uint32_t len)
|
||||
{
|
||||
#ifdef ENABLE_SRTP
|
||||
crypto_get_random(buf, len);
|
||||
#else
|
||||
switch_stun_random_string(buf, len, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -888,7 +895,9 @@ SWITCH_DECLARE(void) switch_rtp_shutdown(void)
|
|||
zrtp_down(zrtp_global);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_SRTP
|
||||
crypto_kernel_shutdown();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -1357,6 +1366,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
|
|||
switch_rtp_crypto_direction_t direction,
|
||||
uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen)
|
||||
{
|
||||
#ifndef ENABLE_SRTP
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SRTP NOT SUPPORTED IN THIS BUILD!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
#else
|
||||
switch_rtp_crypto_key_t *crypto_key;
|
||||
srtp_policy_t *policy;
|
||||
err_status_t stat;
|
||||
|
@ -1471,6 +1484,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
|
|||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_set_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval)
|
||||
|
@ -2117,6 +2131,7 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
|
|||
switch_rtp_disable_vad(*rtp_session);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SRTP
|
||||
if (switch_test_flag((*rtp_session), SWITCH_RTP_FLAG_SECURE_SEND)) {
|
||||
srtp_dealloc((*rtp_session)->send_ctx);
|
||||
(*rtp_session)->send_ctx = NULL;
|
||||
|
@ -2128,6 +2143,8 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
|
|||
(*rtp_session)->recv_ctx = NULL;
|
||||
switch_clear_flag((*rtp_session), SWITCH_RTP_FLAG_SECURE_RECV);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ZRTP
|
||||
/* ZRTP */
|
||||
if (zrtp_on) {
|
||||
|
@ -2515,7 +2532,8 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ENABLE_SRTP
|
||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV)) {
|
||||
int sbytes = (int) *bytes;
|
||||
err_status_t stat = 0;
|
||||
|
@ -2553,6 +2571,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
|
|||
|
||||
*bytes = sbytes;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2630,6 +2649,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
|
|||
*bytes = 0;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SRTP
|
||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV)) {
|
||||
int sbytes = (int) *bytes;
|
||||
err_status_t stat = 0;
|
||||
|
@ -2653,6 +2673,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
|
|||
*bytes = sbytes;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ENABLE_ZRTP
|
||||
|
@ -2894,6 +2915,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
|||
switch_test_flag(other_rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP)) {
|
||||
*other_rtp_session->rtcp_send_msg.body = *rtp_session->rtcp_recv_msg.body;
|
||||
|
||||
#ifdef ENABLE_SRTP
|
||||
if (switch_test_flag(other_rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) {
|
||||
int sbytes = (int) rtcp_bytes;
|
||||
int stat = srtp_protect_rtcp(other_rtp_session->send_ctx, &other_rtp_session->rtcp_send_msg.header, &sbytes);
|
||||
|
@ -2902,6 +2924,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
|||
}
|
||||
rtcp_bytes = sbytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ZRTP
|
||||
/* ZRTP Send */
|
||||
|
@ -3713,7 +3736,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
|||
switch_swap_linear((int16_t *)send_msg->body, (int) datalen);
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_SRTP
|
||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) {
|
||||
int sbytes = (int) bytes;
|
||||
err_status_t stat;
|
||||
|
@ -3740,6 +3763,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
|||
|
||||
bytes = sbytes;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_ZRTP
|
||||
/* ZRTP Send */
|
||||
if (1) {
|
||||
|
@ -3844,7 +3868,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
|||
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);
|
||||
|
||||
#ifdef ENABLE_SRTP
|
||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) {
|
||||
int sbytes = (int) rtcp_bytes;
|
||||
int stat = srtp_protect_rtcp(rtp_session->send_ctx, &rtp_session->rtcp_send_msg.header, &sbytes);
|
||||
|
@ -3853,6 +3877,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
|
|||
}
|
||||
rtcp_bytes = sbytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ZRTP
|
||||
/* ZRTP Send */
|
||||
|
@ -4137,6 +4162,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
|
|||
|
||||
bytes = rtp_header_len + datalen;
|
||||
|
||||
#ifdef ENABLE_SRTP
|
||||
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) {
|
||||
int sbytes = (int) bytes;
|
||||
err_status_t stat;
|
||||
|
@ -4160,6 +4186,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
|
|||
}
|
||||
bytes = sbytes;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_ZRTP
|
||||
/* ZRTP Send */
|
||||
if (1) {
|
||||
|
|
Loading…
Reference in New Issue