Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
a6b336e4
提交
a6b336e4
authored
5月 02, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add option to disable srtp with --disble-srtp
上级
a1306410
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
30 行增加
和
3 行删除
+30
-3
switch_rtp.c
src/switch_rtp.c
+30
-3
没有找到文件。
src/switch_rtp.c
浏览文件 @
a6b336e4
...
@@ -81,6 +81,7 @@ static int zrtp_on = 0;
...
@@ -81,6 +81,7 @@ static int zrtp_on = 0;
#ifdef _MSC_VER
#ifdef _MSC_VER
#pragma pack()
#pragma pack()
#define ENABLE_SRTP
#endif
#endif
static
switch_hash_t
*
alloc_hash
=
NULL
;
static
switch_hash_t
*
alloc_hash
=
NULL
;
...
@@ -844,14 +845,20 @@ SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool)
...
@@ -844,14 +845,20 @@ SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool)
}
}
#endif
#endif
#ifdef ENABLE_SRTP
srtp_init
();
srtp_init
();
#endif
switch_mutex_init
(
&
port_lock
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
port_lock
,
SWITCH_MUTEX_NESTED
,
pool
);
global_init
=
1
;
global_init
=
1
;
}
}
SWITCH_DECLARE
(
void
)
switch_rtp_get_random
(
void
*
buf
,
uint32_t
len
)
SWITCH_DECLARE
(
void
)
switch_rtp_get_random
(
void
*
buf
,
uint32_t
len
)
{
{
#ifdef ENABLE_SRTP
crypto_get_random
(
buf
,
len
);
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)
...
@@ -888,7 +895,9 @@ SWITCH_DECLARE(void) switch_rtp_shutdown(void)
zrtp_down
(
zrtp_global
);
zrtp_down
(
zrtp_global
);
}
}
#endif
#endif
#ifdef ENABLE_SRTP
crypto_kernel_shutdown
();
crypto_kernel_shutdown
();
#endif
}
}
...
@@ -1357,6 +1366,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
...
@@ -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
,
switch_rtp_crypto_direction_t
direction
,
uint32_t
index
,
switch_rtp_crypto_key_type_t
type
,
unsigned
char
*
key
,
switch_size_t
keylen
)
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
;
switch_rtp_crypto_key_t
*
crypto_key
;
srtp_policy_t
*
policy
;
srtp_policy_t
*
policy
;
err_status_t
stat
;
err_status_t
stat
;
...
@@ -1471,6 +1484,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
...
@@ -1471,6 +1484,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
return
SWITCH_STATUS_SUCCESS
;
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_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)
...
@@ -2117,6 +2131,7 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
switch_rtp_disable_vad
(
*
rtp_session
);
switch_rtp_disable_vad
(
*
rtp_session
);
}
}
#ifdef ENABLE_SRTP
if
(
switch_test_flag
((
*
rtp_session
),
SWITCH_RTP_FLAG_SECURE_SEND
))
{
if
(
switch_test_flag
((
*
rtp_session
),
SWITCH_RTP_FLAG_SECURE_SEND
))
{
srtp_dealloc
((
*
rtp_session
)
->
send_ctx
);
srtp_dealloc
((
*
rtp_session
)
->
send_ctx
);
(
*
rtp_session
)
->
send_ctx
=
NULL
;
(
*
rtp_session
)
->
send_ctx
=
NULL
;
...
@@ -2128,6 +2143,8 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
...
@@ -2128,6 +2143,8 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
(
*
rtp_session
)
->
recv_ctx
=
NULL
;
(
*
rtp_session
)
->
recv_ctx
=
NULL
;
switch_clear_flag
((
*
rtp_session
),
SWITCH_RTP_FLAG_SECURE_RECV
);
switch_clear_flag
((
*
rtp_session
),
SWITCH_RTP_FLAG_SECURE_RECV
);
}
}
#endif
#ifdef ENABLE_ZRTP
#ifdef ENABLE_ZRTP
/* ZRTP */
/* ZRTP */
if
(
zrtp_on
)
{
if
(
zrtp_on
)
{
...
@@ -2515,7 +2532,8 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
...
@@ -2515,7 +2532,8 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
break
;
break
;
}
}
#endif
#endif
#ifdef ENABLE_SRTP
if
(
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
;
...
@@ -2553,6 +2571,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
...
@@ -2553,6 +2571,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
*
bytes
=
sbytes
;
*
bytes
=
sbytes
;
}
}
#endif
}
}
}
}
...
@@ -2630,6 +2649,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
...
@@ -2630,6 +2649,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
*
bytes
=
0
;
*
bytes
=
0
;
}
}
#ifdef ENABLE_SRTP
if
(
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
;
...
@@ -2653,6 +2673,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
...
@@ -2653,6 +2673,7 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
*
bytes
=
sbytes
;
*
bytes
=
sbytes
;
}
}
#endif
#ifdef ENABLE_ZRTP
#ifdef ENABLE_ZRTP
...
@@ -2894,6 +2915,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
...
@@ -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
))
{
switch_test_flag
(
other_rtp_session
,
SWITCH_RTP_FLAG_ENABLE_RTCP
))
{
*
other_rtp_session
->
rtcp_send_msg
.
body
=
*
rtp_session
->
rtcp_recv_msg
.
body
;
*
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
))
{
if
(
switch_test_flag
(
other_rtp_session
,
SWITCH_RTP_FLAG_SECURE_SEND
))
{
int
sbytes
=
(
int
)
rtcp_bytes
;
int
sbytes
=
(
int
)
rtcp_bytes
;
int
stat
=
srtp_protect_rtcp
(
other_rtp_session
->
send_ctx
,
&
other_rtp_session
->
rtcp_send_msg
.
header
,
&
sbytes
);
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_
...
@@ -2902,6 +2924,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
}
}
rtcp_bytes
=
sbytes
;
rtcp_bytes
=
sbytes
;
}
}
#endif
#ifdef ENABLE_ZRTP
#ifdef ENABLE_ZRTP
/* ZRTP Send */
/* ZRTP Send */
...
@@ -3713,7 +3736,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
...
@@ -3713,7 +3736,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
switch_swap_linear
((
int16_t
*
)
send_msg
->
body
,
(
int
)
datalen
);
switch_swap_linear
((
int16_t
*
)
send_msg
->
body
,
(
int
)
datalen
);
}
}
#ifdef ENABLE_SRTP
if
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_SECURE_SEND
))
{
if
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_SECURE_SEND
))
{
int
sbytes
=
(
int
)
bytes
;
int
sbytes
=
(
int
)
bytes
;
err_status_t
stat
;
err_status_t
stat
;
...
@@ -3740,6 +3763,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
...
@@ -3740,6 +3763,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
bytes
=
sbytes
;
bytes
=
sbytes
;
}
}
#endif
#ifdef ENABLE_ZRTP
#ifdef ENABLE_ZRTP
/* ZRTP Send */
/* ZRTP Send */
if
(
1
)
{
if
(
1
)
{
...
@@ -3844,7 +3868,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
...
@@ -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
)));
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
);
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
))
{
if
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_SECURE_SEND
))
{
int
sbytes
=
(
int
)
rtcp_bytes
;
int
sbytes
=
(
int
)
rtcp_bytes
;
int
stat
=
srtp_protect_rtcp
(
rtp_session
->
send_ctx
,
&
rtp_session
->
rtcp_send_msg
.
header
,
&
sbytes
);
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,
...
@@ -3853,6 +3877,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
}
}
rtcp_bytes
=
sbytes
;
rtcp_bytes
=
sbytes
;
}
}
#endif
#ifdef ENABLE_ZRTP
#ifdef ENABLE_ZRTP
/* ZRTP Send */
/* ZRTP Send */
...
@@ -4137,6 +4162,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
...
@@ -4137,6 +4162,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
bytes
=
rtp_header_len
+
datalen
;
bytes
=
rtp_header_len
+
datalen
;
#ifdef ENABLE_SRTP
if
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_SECURE_SEND
))
{
if
(
switch_test_flag
(
rtp_session
,
SWITCH_RTP_FLAG_SECURE_SEND
))
{
int
sbytes
=
(
int
)
bytes
;
int
sbytes
=
(
int
)
bytes
;
err_status_t
stat
;
err_status_t
stat
;
...
@@ -4160,6 +4186,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
...
@@ -4160,6 +4186,7 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
}
}
bytes
=
sbytes
;
bytes
=
sbytes
;
}
}
#endif
#ifdef ENABLE_ZRTP
#ifdef ENABLE_ZRTP
/* ZRTP Send */
/* ZRTP Send */
if
(
1
)
{
if
(
1
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论