#ifdef _MSC_VER
#pragma pack()
+#define ENABLE_SRTP
#endif
static switch_hash_t *alloc_hash = NULL;
}
#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
}
zrtp_down(zrtp_global);
}
#endif
+#ifdef ENABLE_SRTP
crypto_kernel_shutdown();
+#endif
}
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;
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)
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;
(*rtp_session)->recv_ctx = NULL;
switch_clear_flag((*rtp_session), SWITCH_RTP_FLAG_SECURE_RECV);
}
+#endif
+
#ifdef ENABLE_ZRTP
/* ZRTP */
if (zrtp_on) {
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;
*bytes = sbytes;
}
+#endif
}
}
*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;
*bytes = sbytes;
}
+#endif
#ifdef ENABLE_ZRTP
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);
}
rtcp_bytes = sbytes;
}
+#endif
#ifdef ENABLE_ZRTP
/* ZRTP Send */
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;
bytes = sbytes;
}
+#endif
#ifdef ENABLE_ZRTP
/* ZRTP Send */
if (1) {
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);
}
rtcp_bytes = sbytes;
}
+#endif
#ifdef ENABLE_ZRTP
/* ZRTP Send */
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;
}
bytes = sbytes;
}
+#endif
#ifdef ENABLE_ZRTP
/* ZRTP Send */
if (1) {