Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
0a246d1c
提交
0a246d1c
authored
12月 19, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pull srtp negotiation stuff into the core stage 1
上级
330f68d9
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
323 行增加
和
208 行删除
+323
-208
switch_core_media.h
src/include/switch_core_media.h
+12
-1
switch_types.h
src/include/switch_types.h
+3
-0
mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.c
+2
-11
mod_sofia.h
src/mod/endpoints/mod_sofia/mod_sofia.h
+1
-12
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+3
-2
sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_glue.c
+11
-56
sofia_media.c
src/mod/endpoints/mod_sofia/sofia_media.c
+8
-125
switch_core_media.c
src/switch_core_media.c
+283
-1
没有找到文件。
src/include/switch_core_media.h
浏览文件 @
0a246d1c
...
@@ -39,7 +39,8 @@ SWITCH_BEGIN_EXTERN_C
...
@@ -39,7 +39,8 @@ SWITCH_BEGIN_EXTERN_C
typedef
enum
{
typedef
enum
{
SM_NDLB_ALLOW_BAD_IANANAME
=
(
1
<<
0
),
SM_NDLB_ALLOW_BAD_IANANAME
=
(
1
<<
0
),
SM_NDLB_ALLOW_NONDUP_SDP
=
(
1
<<
1
),
SM_NDLB_ALLOW_NONDUP_SDP
=
(
1
<<
1
),
SM_NDLB_ALLOW_CRYPTO_IN_AVP
=
(
1
<<
2
)
SM_NDLB_ALLOW_CRYPTO_IN_AVP
=
(
1
<<
2
),
SM_NDLB_DISABLE_SRTP_AUTH
=
(
1
<<
3
)
}
switch_core_media_NDLB_t
;
}
switch_core_media_NDLB_t
;
struct
switch_media_handle_s
;
struct
switch_media_handle_s
;
...
@@ -52,6 +53,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_media_handle_ready(switch_co
...
@@ -52,6 +53,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_media_handle_ready(switch_co
SWITCH_DECLARE
(
void
)
switch_media_handle_set_ndlb
(
switch_media_handle_t
*
smh
,
switch_core_media_NDLB_t
flag
);
SWITCH_DECLARE
(
void
)
switch_media_handle_set_ndlb
(
switch_media_handle_t
*
smh
,
switch_core_media_NDLB_t
flag
);
SWITCH_DECLARE
(
void
)
switch_media_handle_clear_ndlb
(
switch_media_handle_t
*
smh
,
switch_core_media_NDLB_t
flag
);
SWITCH_DECLARE
(
void
)
switch_media_handle_clear_ndlb
(
switch_media_handle_t
*
smh
,
switch_core_media_NDLB_t
flag
);
SWITCH_DECLARE
(
int32_t
)
switch_media_handle_test_ndlb
(
switch_media_handle_t
*
smh
,
switch_core_media_NDLB_t
flag
);
SWITCH_DECLARE
(
int32_t
)
switch_media_handle_test_ndlb
(
switch_media_handle_t
*
smh
,
switch_core_media_NDLB_t
flag
);
SWITCH_DECLARE
(
void
)
switch_core_session_check_outgoing_crypto
(
switch_core_session_t
*
session
,
const
char
*
sec_var
);
SWITCH_DECLARE
(
const
char
*
)
switch_core_sesson_local_crypto_key
(
switch_core_session_t
*
session
,
switch_media_type_t
type
);
SWITCH_DECLARE
(
int
)
switch_core_session_check_incoming_crypto
(
switch_core_session_t
*
session
,
const
char
*
varname
,
switch_media_type_t
type
,
const
char
*
crypto
,
int
crypto_tag
);
SWITCH_DECLARE
(
void
)
switch_core_session_apply_crypto
(
switch_core_session_t
*
session
,
switch_media_type_t
type
,
const
char
*
varname
);
SWITCH_DECLARE
(
void
)
switch_core_session_get_recovery_crypto_key
(
switch_core_session_t
*
session
,
switch_media_type_t
type
,
const
char
*
varname
);
SWITCH_DECLARE
(
void
)
switch_core_media_set_rtp_session
(
switch_core_session_t
*
session
,
switch_media_type_t
type
,
switch_rtp_t
*
rtp_session
);
SWITCH_END_EXTERN_C
SWITCH_END_EXTERN_C
#endif
#endif
...
...
src/include/switch_types.h
浏览文件 @
0a246d1c
...
@@ -1280,6 +1280,8 @@ typedef enum {
...
@@ -1280,6 +1280,8 @@ typedef enum {
CF_EARLY_OK
,
CF_EARLY_OK
,
CF_MEDIA_TRANS
,
CF_MEDIA_TRANS
,
CF_HOLD_ON_BRIDGE
,
CF_HOLD_ON_BRIDGE
,
CF_SECURE
,
CF_CRYPTO_RECOVER
,
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
CF_FLAG_MAX
CF_FLAG_MAX
...
@@ -1463,6 +1465,7 @@ typedef enum {
...
@@ -1463,6 +1465,7 @@ typedef enum {
SWITCH_MEDIA_TYPE_AUDIO
,
SWITCH_MEDIA_TYPE_AUDIO
,
SWITCH_MEDIA_TYPE_VIDEO
SWITCH_MEDIA_TYPE_VIDEO
}
switch_media_type_t
;
}
switch_media_type_t
;
#define SWITCH_MEDIA_TYPE_TOTAL 2
/*!
/*!
...
...
src/mod/endpoints/mod_sofia/mod_sofia.c
浏览文件 @
0a246d1c
...
@@ -93,17 +93,8 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
...
@@ -93,17 +93,8 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
}
}
if
(
sofia_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
)
||
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF_RECOVERING
))
{
if
(
sofia_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
)
||
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF_RECOVERING
))
{
const
char
*
var
;
if
((
var
=
switch_channel_get_variable
(
channel
,
SOFIA_SECURE_MEDIA_VARIABLE
))
&&
!
zstr
(
var
))
{
switch_core_session_check_outgoing_crypto
(
session
,
SOFIA_SECURE_MEDIA_VARIABLE
);
if
(
switch_true
(
var
)
||
!
strcasecmp
(
var
,
SWITCH_RTP_CRYPTO_KEY_32
))
{
sofia_set_flag_locked
(
tech_pvt
,
TFLAG_SECURE
);
sofia_glue_build_crypto
(
tech_pvt
,
1
,
AES_CM_128_HMAC_SHA1_32
,
SWITCH_RTP_CRYPTO_SEND
);
}
else
if
(
!
strcasecmp
(
var
,
SWITCH_RTP_CRYPTO_KEY_80
))
{
sofia_set_flag_locked
(
tech_pvt
,
TFLAG_SECURE
);
sofia_glue_build_crypto
(
tech_pvt
,
1
,
AES_CM_128_HMAC_SHA1_80
,
SWITCH_RTP_CRYPTO_SEND
);
}
}
if
(
sofia_glue_do_invite
(
session
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
sofia_glue_do_invite
(
session
)
!=
SWITCH_STATUS_SUCCESS
)
{
...
@@ -1871,7 +1862,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
...
@@ -1871,7 +1862,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if
((
var
=
switch_channel_get_variable
(
channel
,
SOFIA_SECURE_MEDIA_VARIABLE
))
&&
if
((
var
=
switch_channel_get_variable
(
channel
,
SOFIA_SECURE_MEDIA_VARIABLE
))
&&
(
switch_true
(
var
)
||
!
strcasecmp
(
var
,
SWITCH_RTP_CRYPTO_KEY_32
)
||
!
strcasecmp
(
var
,
SWITCH_RTP_CRYPTO_KEY_80
)))
{
(
switch_true
(
var
)
||
!
strcasecmp
(
var
,
SWITCH_RTP_CRYPTO_KEY_32
)
||
!
strcasecmp
(
var
,
SWITCH_RTP_CRYPTO_KEY_80
)))
{
s
ofia_set_flag_locked
(
tech_pvt
,
TFLAG
_SECURE
);
s
witch_channel_set_flag
(
tech_pvt
->
channel
,
CF
_SECURE
);
}
}
if
(
sofia_test_pflag
(
tech_pvt
->
profile
,
PFLAG_AUTOFIX_TIMING
))
{
if
(
sofia_test_pflag
(
tech_pvt
->
profile
,
PFLAG_AUTOFIX_TIMING
))
{
...
...
src/mod/endpoints/mod_sofia/mod_sofia.h
浏览文件 @
0a246d1c
...
@@ -224,7 +224,6 @@ typedef enum {
...
@@ -224,7 +224,6 @@ typedef enum {
PFLAG_RECIEVED_IN_NAT_REG_CONTACT
,
PFLAG_RECIEVED_IN_NAT_REG_CONTACT
,
PFLAG_3PCC
,
PFLAG_3PCC
,
PFLAG_DISABLE_RTP_AUTOADJ
,
PFLAG_DISABLE_RTP_AUTOADJ
,
PFLAG_DISABLE_SRTP_AUTH
,
PFLAG_FUNNY_STUN
,
PFLAG_FUNNY_STUN
,
PFLAG_STUN_ENABLED
,
PFLAG_STUN_ENABLED
,
PFLAG_STUN_AUTO_DISABLE
,
PFLAG_STUN_AUTO_DISABLE
,
...
@@ -309,7 +308,6 @@ typedef enum {
...
@@ -309,7 +308,6 @@ typedef enum {
TFLAG_BYE
,
TFLAG_BYE
,
TFLAG_ANS
,
TFLAG_ANS
,
TFLAG_EARLY_MEDIA
,
TFLAG_EARLY_MEDIA
,
TFLAG_SECURE
,
TFLAG_VAD_IN
,
TFLAG_VAD_IN
,
TFLAG_VAD_OUT
,
TFLAG_VAD_OUT
,
TFLAG_VAD
,
TFLAG_VAD
,
...
@@ -349,7 +347,6 @@ typedef enum {
...
@@ -349,7 +347,6 @@ typedef enum {
TFLAG_SLA_BARGE
,
TFLAG_SLA_BARGE
,
TFLAG_SLA_BARGING
,
TFLAG_SLA_BARGING
,
TFLAG_PASS_ACK
,
TFLAG_PASS_ACK
,
TFLAG_CRYPTO_RECOVER
,
TFLAG_DROP_DTMF
,
TFLAG_DROP_DTMF
,
/* No new flags below this line */
/* No new flags below this line */
TFLAG_MAX
TFLAG_MAX
...
@@ -754,12 +751,6 @@ struct private_object {
...
@@ -754,12 +751,6 @@ struct private_object {
char
*
rm_fmtp
;
char
*
rm_fmtp
;
char
*
fmtp_out
;
char
*
fmtp_out
;
char
*
remote_sdp_str
;
char
*
remote_sdp_str
;
int
crypto_tag
;
unsigned
char
local_raw_key
[
SWITCH_RTP_MAX_CRYPTO_LEN
];
unsigned
char
remote_raw_key
[
SWITCH_RTP_MAX_CRYPTO_LEN
];
switch_rtp_crypto_key_type_t
crypto_send_type
;
switch_rtp_crypto_key_type_t
crypto_recv_type
;
switch_rtp_crypto_key_type_t
crypto_type
;
char
*
early_sdp
;
char
*
early_sdp
;
char
*
local_sdp_str
;
char
*
local_sdp_str
;
char
*
last_sdp_str
;
char
*
last_sdp_str
;
...
@@ -777,8 +768,6 @@ struct private_object {
...
@@ -777,8 +768,6 @@ struct private_object {
char
*
invite_contact
;
char
*
invite_contact
;
char
*
local_url
;
char
*
local_url
;
char
*
gateway_name
;
char
*
gateway_name
;
char
*
local_crypto_key
;
char
*
remote_crypto_key
;
char
*
record_route
;
char
*
record_route
;
char
*
extrtpip
;
char
*
extrtpip
;
char
*
stun_ip
;
char
*
stun_ip
;
...
@@ -1125,7 +1114,7 @@ char *sofia_glue_strip_uri(const char *str);
...
@@ -1125,7 +1114,7 @@ char *sofia_glue_strip_uri(const char *str);
int
sofia_glue_check_nat
(
sofia_profile_t
*
profile
,
const
char
*
network_ip
);
int
sofia_glue_check_nat
(
sofia_profile_t
*
profile
,
const
char
*
network_ip
);
int
sofia_glue_transport_has_tls
(
const
sofia_transport_t
tp
);
int
sofia_glue_transport_has_tls
(
const
sofia_transport_t
tp
);
const
char
*
sofia_glue_get_unknown_header
(
sip_t
const
*
sip
,
const
char
*
name
);
const
char
*
sofia_glue_get_unknown_header
(
sip_t
const
*
sip
,
const
char
*
name
);
switch_status_t
sofia_
glue
_build_crypto
(
private_object_t
*
tech_pvt
,
int
index
,
switch_rtp_crypto_key_type_t
type
,
switch_rtp_crypto_direction_t
direction
);
switch_status_t
sofia_
media
_build_crypto
(
private_object_t
*
tech_pvt
,
int
index
,
switch_rtp_crypto_key_type_t
type
,
switch_rtp_crypto_direction_t
direction
);
void
sofia_glue_tech_patch_sdp
(
private_object_t
*
tech_pvt
);
void
sofia_glue_tech_patch_sdp
(
private_object_t
*
tech_pvt
);
switch_status_t
sofia_glue_tech_proxy_remote_addr
(
private_object_t
*
tech_pvt
,
const
char
*
sdp_str
);
switch_status_t
sofia_glue_tech_proxy_remote_addr
(
private_object_t
*
tech_pvt
,
const
char
*
sdp_str
);
void
sofia_presence_event_thread_start
(
void
);
void
sofia_presence_event_thread_start
(
void
);
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
0a246d1c
...
@@ -3923,7 +3923,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
...
@@ -3923,7 +3923,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
}
else
if
(
!
strcasecmp
(
var
,
"disable-rtp-auto-adjust"
)
&&
switch_true
(
val
))
{
}
else
if
(
!
strcasecmp
(
var
,
"disable-rtp-auto-adjust"
)
&&
switch_true
(
val
))
{
sofia_set_pflag
(
profile
,
PFLAG_DISABLE_RTP_AUTOADJ
);
sofia_set_pflag
(
profile
,
PFLAG_DISABLE_RTP_AUTOADJ
);
}
else
if
(
!
strcasecmp
(
var
,
"NDLB-support-asterisk-missing-srtp-auth"
)
&&
switch_true
(
val
))
{
}
else
if
(
!
strcasecmp
(
var
,
"NDLB-support-asterisk-missing-srtp-auth"
)
&&
switch_true
(
val
))
{
sofia_set_pflag
(
profile
,
PFLAG_DISABLE_SRTP_AUTH
)
;
profile
->
ndlb
|=
SM_NDLB_DISABLE_SRTP_AUTH
;
}
else
if
(
!
strcasecmp
(
var
,
"NDLB-funny-stun"
))
{
}
else
if
(
!
strcasecmp
(
var
,
"NDLB-funny-stun"
))
{
if
(
switch_true
(
val
))
{
if
(
switch_true
(
val
))
{
sofia_set_pflag
(
profile
,
PFLAG_FUNNY_STUN
);
sofia_set_pflag
(
profile
,
PFLAG_FUNNY_STUN
);
...
@@ -6187,7 +6187,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
...
@@ -6187,7 +6187,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if
(
is_ok
)
{
if
(
is_ok
)
{
if
(
tech_pvt
->
local_crypto_key
)
{
if
(
switch_core_sesson_local_crypto_key
(
tech_pvt
->
session
,
SWITCH_MEDIA_TYPE_AUDIO
))
{
sofia_glue_set_local_sdp
(
tech_pvt
,
NULL
,
0
,
NULL
,
0
);
sofia_glue_set_local_sdp
(
tech_pvt
,
NULL
,
0
,
NULL
,
0
);
}
}
if
(
sofia_use_soa
(
tech_pvt
))
{
if
(
sofia_use_soa
(
tech_pvt
))
{
...
...
src/mod/endpoints/mod_sofia/sofia_glue.c
浏览文件 @
0a246d1c
...
@@ -186,6 +186,7 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
...
@@ -186,6 +186,7 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
int
rate
;
int
rate
;
int
already_did
[
128
]
=
{
0
};
int
already_did
[
128
]
=
{
0
};
int
ptime
=
0
,
noptime
=
0
;
int
ptime
=
0
,
noptime
=
0
;
const
char
*
local_audio_crypto_key
=
switch_core_sesson_local_crypto_key
(
tech_pvt
->
session
,
SWITCH_MEDIA_TYPE_AUDIO
);
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"m=audio %d RTP/%sAVP"
,
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"m=audio %d RTP/%sAVP"
,
port
,
secure
?
"S"
:
""
);
port
,
secure
?
"S"
:
""
);
...
@@ -323,7 +324,7 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
...
@@ -323,7 +324,7 @@ static void generate_m(private_object_t *tech_pvt, char *buf, size_t buflen,
}
}
if
(
secure
)
{
if
(
secure
)
{
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=crypto:%s
\n
"
,
tech_pvt
->
local
_crypto_key
);
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=crypto:%s
\n
"
,
local_audio
_crypto_key
);
//switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=encryption:optional\n");
//switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=encryption:optional\n");
}
}
...
@@ -395,7 +396,8 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
...
@@ -395,7 +396,8 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
switch_event_t
*
map
=
NULL
,
*
ptmap
=
NULL
;
switch_event_t
*
map
=
NULL
,
*
ptmap
=
NULL
;
const
char
*
b_sdp
=
NULL
;
const
char
*
b_sdp
=
NULL
;
int
verbose_sdp
=
0
;
int
verbose_sdp
=
0
;
const
char
*
local_audio_crypto_key
=
switch_core_sesson_local_crypto_key
(
tech_pvt
->
session
,
SWITCH_MEDIA_TYPE_AUDIO
);
switch_zmalloc
(
buf
,
SDPBUFLEN
);
switch_zmalloc
(
buf
,
SDPBUFLEN
);
sofia_glue_check_dtmf_type
(
tech_pvt
);
sofia_glue_check_dtmf_type
(
tech_pvt
);
...
@@ -513,7 +515,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
...
@@ -513,7 +515,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
if
(
tech_pvt
->
rm_encoding
)
{
if
(
tech_pvt
->
rm_encoding
)
{
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"m=audio %d RTP/%sAVP"
,
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"m=audio %d RTP/%sAVP"
,
port
,
(
!
zstr
(
tech_pvt
->
local_crypto_key
)
&&
sofia_test_flag
(
tech_pvt
,
TFLAG
_SECURE
))
?
"S"
:
""
);
port
,
(
!
zstr
(
local_audio_crypto_key
)
&&
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF
_SECURE
))
?
"S"
:
""
);
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
" %d"
,
tech_pvt
->
pt
);
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
" %d"
,
tech_pvt
->
pt
);
...
@@ -571,8 +573,8 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
...
@@ -571,8 +573,8 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=%s
\n
"
,
sr
);
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=%s
\n
"
,
sr
);
}
}
if
(
!
zstr
(
tech_pvt
->
local_crypto_key
)
&&
sofia_test_flag
(
tech_pvt
,
TFLAG
_SECURE
))
{
if
(
!
zstr
(
local_audio_crypto_key
)
&&
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF
_SECURE
))
{
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=crypto:%s
\n
"
,
tech_pvt
->
local
_crypto_key
);
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=crypto:%s
\n
"
,
local_audio
_crypto_key
);
//switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=encryption:optional\n");
//switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=encryption:optional\n");
}
}
...
@@ -595,7 +597,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
...
@@ -595,7 +597,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
char
*
bp
=
buf
;
char
*
bp
=
buf
;
int
both
=
1
;
int
both
=
1
;
if
((
!
zstr
(
tech_pvt
->
local_crypto_key
)
&&
sofia_test_flag
(
tech_pvt
,
TFLAG
_SECURE
)))
{
if
((
!
zstr
(
local_audio_crypto_key
)
&&
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF
_SECURE
)))
{
generate_m
(
tech_pvt
,
buf
,
SDPBUFLEN
,
port
,
0
,
append_audio
,
sr
,
use_cng
,
cng_type
,
map
,
verbose_sdp
,
1
);
generate_m
(
tech_pvt
,
buf
,
SDPBUFLEN
,
port
,
0
,
append_audio
,
sr
,
use_cng
,
cng_type
,
map
,
verbose_sdp
,
1
);
bp
=
(
buf
+
strlen
(
buf
));
bp
=
(
buf
+
strlen
(
buf
));
...
@@ -631,7 +633,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
...
@@ -631,7 +633,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, switch
cur_ptime
=
this_ptime
;
cur_ptime
=
this_ptime
;
if
((
!
zstr
(
tech_pvt
->
local_crypto_key
)
&&
sofia_test_flag
(
tech_pvt
,
TFLAG
_SECURE
)))
{
if
((
!
zstr
(
local_audio_crypto_key
)
&&
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF
_SECURE
)))
{
generate_m
(
tech_pvt
,
bp
,
SDPBUFLEN
-
strlen
(
buf
),
port
,
cur_ptime
,
append_audio
,
sr
,
use_cng
,
cng_type
,
map
,
verbose_sdp
,
1
);
generate_m
(
tech_pvt
,
bp
,
SDPBUFLEN
-
strlen
(
buf
),
port
,
cur_ptime
,
append_audio
,
sr
,
use_cng
,
cng_type
,
map
,
verbose_sdp
,
1
);
bp
=
(
buf
+
strlen
(
buf
));
bp
=
(
buf
+
strlen
(
buf
));
...
@@ -3109,51 +3111,6 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
...
@@ -3109,51 +3111,6 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
}
}
switch_status_t
sofia_glue_build_crypto
(
private_object_t
*
tech_pvt
,
int
index
,
switch_rtp_crypto_key_type_t
type
,
switch_rtp_crypto_direction_t
direction
)
{
unsigned
char
b64_key
[
512
]
=
""
;
const
char
*
type_str
;
unsigned
char
*
key
;
const
char
*
val
;
char
*
p
;
if
(
type
==
AES_CM_128_HMAC_SHA1_80
)
{
type_str
=
SWITCH_RTP_CRYPTO_KEY_80
;
}
else
{
type_str
=
SWITCH_RTP_CRYPTO_KEY_32
;
}
if
(
direction
==
SWITCH_RTP_CRYPTO_SEND
)
{
key
=
tech_pvt
->
local_raw_key
;
}
else
{
key
=
tech_pvt
->
remote_raw_key
;
}
switch_rtp_get_random
(
key
,
SWITCH_RTP_KEY_LEN
);
switch_b64_encode
(
key
,
SWITCH_RTP_KEY_LEN
,
b64_key
,
sizeof
(
b64_key
));
p
=
strrchr
((
char
*
)
b64_key
,
'='
);
while
(
p
&&
*
p
&&
*
p
==
'='
)
{
*
p
--
=
'\0'
;
}
tech_pvt
->
local_crypto_key
=
switch_core_session_sprintf
(
tech_pvt
->
session
,
"%d %s inline:%s"
,
index
,
type_str
,
b64_key
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_DEBUG
,
"Set Local Key [%s]
\n
"
,
tech_pvt
->
local_crypto_key
);
if
(
!
sofia_test_pflag
(
tech_pvt
->
profile
,
PFLAG_DISABLE_SRTP_AUTH
)
&&
!
((
val
=
switch_channel_get_variable
(
tech_pvt
->
channel
,
"NDLB_support_asterisk_missing_srtp_auth"
))
&&
switch_true
(
val
)))
{
tech_pvt
->
crypto_type
=
type
;
}
else
{
tech_pvt
->
crypto_type
=
AES_CM_128_NULL_AUTH
;
}
return
SWITCH_STATUS_SUCCESS
;
}
static
void
add_audio_codec
(
sdp_rtpmap_t
*
map
,
int
ptime
,
char
*
buf
,
switch_size_t
buflen
)
static
void
add_audio_codec
(
sdp_rtpmap_t
*
map
,
int
ptime
,
char
*
buf
,
switch_size_t
buflen
)
{
{
int
codec_ms
=
ptime
;
int
codec_ms
=
ptime
;
...
@@ -4131,10 +4088,8 @@ int sofia_recover_callback(switch_core_session_t *session)
...
@@ -4131,10 +4088,8 @@ int sofia_recover_callback(switch_core_session_t *session)
sofia_glue_attach_private
(
session
,
profile
,
tech_pvt
,
NULL
);
sofia_glue_attach_private
(
session
,
profile
,
tech_pvt
,
NULL
);
switch_channel_set_name
(
tech_pvt
->
channel
,
switch_channel_get_variable
(
channel
,
"channel_name"
));
switch_channel_set_name
(
tech_pvt
->
channel
,
switch_channel_get_variable
(
channel
,
"channel_name"
));
if
((
tmp
=
switch_channel_get_variable
(
channel
,
"srtp_remote_audio_crypto_key"
)))
{
tech_pvt
->
remote_crypto_key
=
switch_core_session_strdup
(
session
,
tmp
);
switch_core_session_get_recovery_crypto_key
(
session
,
SWITCH_MEDIA_TYPE_AUDIO
,
"srtp_remote_audio_crypto_key"
);
sofia_set_flag
(
tech_pvt
,
TFLAG_CRYPTO_RECOVER
);
}
if
((
tmp
=
switch_channel_get_variable
(
channel
,
"sip_local_sdp_str"
)))
{
if
((
tmp
=
switch_channel_get_variable
(
channel
,
"sip_local_sdp_str"
)))
{
tech_pvt
->
local_sdp_str
=
switch_core_session_strdup
(
session
,
tmp
);
tech_pvt
->
local_sdp_str
=
switch_core_session_strdup
(
session
,
tmp
);
...
...
src/mod/endpoints/mod_sofia/sofia_media.c
浏览文件 @
0a246d1c
...
@@ -311,61 +311,6 @@ switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *sess
...
@@ -311,61 +311,6 @@ switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *sess
}
}
switch_status_t
sofia_glue_add_crypto
(
private_object_t
*
tech_pvt
,
const
char
*
key_str
,
switch_rtp_crypto_direction_t
direction
)
{
unsigned
char
key
[
SWITCH_RTP_MAX_CRYPTO_LEN
];
switch_rtp_crypto_key_type_t
type
;
char
*
p
;
if
(
!
switch_rtp_ready
(
tech_pvt
->
rtp_session
))
{
goto
bad
;
}
p
=
strchr
(
key_str
,
' '
);
if
(
p
&&
*
p
&&
*
(
p
+
1
))
{
p
++
;
if
(
!
strncasecmp
(
p
,
SWITCH_RTP_CRYPTO_KEY_32
,
strlen
(
SWITCH_RTP_CRYPTO_KEY_32
)))
{
type
=
AES_CM_128_HMAC_SHA1_32
;
}
else
if
(
!
strncasecmp
(
p
,
SWITCH_RTP_CRYPTO_KEY_80
,
strlen
(
SWITCH_RTP_CRYPTO_KEY_80
)))
{
type
=
AES_CM_128_HMAC_SHA1_80
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_ERROR
,
"Parse Error near [%s]
\n
"
,
p
);
goto
bad
;
}
p
=
strchr
(
p
,
' '
);
if
(
p
&&
*
p
&&
*
(
p
+
1
))
{
p
++
;
if
(
strncasecmp
(
p
,
"inline:"
,
7
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_ERROR
,
"Parse Error near [%s]
\n
"
,
p
);
goto
bad
;
}
p
+=
7
;
switch_b64_decode
(
p
,
(
char
*
)
key
,
sizeof
(
key
));
if
(
direction
==
SWITCH_RTP_CRYPTO_SEND
)
{
tech_pvt
->
crypto_send_type
=
type
;
memcpy
(
tech_pvt
->
local_raw_key
,
key
,
SWITCH_RTP_KEY_LEN
);
}
else
{
tech_pvt
->
crypto_recv_type
=
type
;
memcpy
(
tech_pvt
->
remote_raw_key
,
key
,
SWITCH_RTP_KEY_LEN
);
}
return
SWITCH_STATUS_SUCCESS
;
}
}
bad:
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_ERROR
,
"Error!
\n
"
);
return
SWITCH_STATUS_FALSE
;
}
uint8_t
sofia_glue_negotiate_sdp
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
)
uint8_t
sofia_glue_negotiate_sdp
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
)
{
{
...
@@ -676,67 +621,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
...
@@ -676,67 +621,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
crypto
=
attr
->
a_value
;
crypto
=
attr
->
a_value
;
crypto_tag
=
atoi
(
crypto
);
crypto_tag
=
atoi
(
crypto
);
if
(
tech_pvt
->
remote_crypto_key
&&
switch_rtp_ready
(
tech_pvt
->
rtp_session
))
{
got_crypto
=
switch_core_session_check_incoming_crypto
(
tech_pvt
->
session
,
/* Compare all the key. The tag may remain the same even if key changed */
SOFIA_HAS_CRYPTO_VARIABLE
,
SWITCH_MEDIA_TYPE_AUDIO
,
crypto
,
crypto_tag
);
if
(
crypto
&&
!
strcmp
(
crypto
,
tech_pvt
->
remote_crypto_key
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Existing key is still valid.
\n
"
);
}
else
{
const
char
*
a
=
switch_stristr
(
"AES"
,
tech_pvt
->
remote_crypto_key
);
const
char
*
b
=
switch_stristr
(
"AES"
,
crypto
);
/* Change our key every time we can */
if
(
sofia_test_flag
(
tech_pvt
,
TFLAG_CRYPTO_RECOVER
))
{
sofia_clear_flag
(
tech_pvt
,
TFLAG_CRYPTO_RECOVER
);
}
else
if
(
switch_stristr
(
SWITCH_RTP_CRYPTO_KEY_32
,
crypto
))
{
switch_channel_set_variable
(
tech_pvt
->
channel
,
SOFIA_HAS_CRYPTO_VARIABLE
,
SWITCH_RTP_CRYPTO_KEY_32
);
sofia_glue_build_crypto
(
tech_pvt
,
atoi
(
crypto
),
AES_CM_128_HMAC_SHA1_32
,
SWITCH_RTP_CRYPTO_SEND
);
switch_rtp_add_crypto_key
(
tech_pvt
->
rtp_session
,
SWITCH_RTP_CRYPTO_SEND
,
atoi
(
crypto
),
tech_pvt
->
crypto_type
,
tech_pvt
->
local_raw_key
,
SWITCH_RTP_KEY_LEN
);
}
else
if
(
switch_stristr
(
SWITCH_RTP_CRYPTO_KEY_80
,
crypto
))
{
switch_channel_set_variable
(
tech_pvt
->
channel
,
SOFIA_HAS_CRYPTO_VARIABLE
,
SWITCH_RTP_CRYPTO_KEY_80
);
sofia_glue_build_crypto
(
tech_pvt
,
atoi
(
crypto
),
AES_CM_128_HMAC_SHA1_80
,
SWITCH_RTP_CRYPTO_SEND
);
switch_rtp_add_crypto_key
(
tech_pvt
->
rtp_session
,
SWITCH_RTP_CRYPTO_SEND
,
atoi
(
crypto
),
tech_pvt
->
crypto_type
,
tech_pvt
->
local_raw_key
,
SWITCH_RTP_KEY_LEN
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Crypto Setup Failed!.
\n
"
);
}
if
(
a
&&
b
&&
!
strncasecmp
(
a
,
b
,
23
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Change Remote key to [%s]
\n
"
,
crypto
);
tech_pvt
->
remote_crypto_key
=
switch_core_session_strdup
(
tech_pvt
->
session
,
crypto
);
switch_channel_set_variable
(
tech_pvt
->
channel
,
"srtp_remote_audio_crypto_key"
,
crypto
);
tech_pvt
->
crypto_tag
=
crypto_tag
;
if
(
switch_rtp_ready
(
tech_pvt
->
rtp_session
)
&&
sofia_test_flag
(
tech_pvt
,
TFLAG_SECURE
))
{
sofia_glue_add_crypto
(
tech_pvt
,
tech_pvt
->
remote_crypto_key
,
SWITCH_RTP_CRYPTO_RECV
);
switch_rtp_add_crypto_key
(
tech_pvt
->
rtp_session
,
SWITCH_RTP_CRYPTO_RECV
,
tech_pvt
->
crypto_tag
,
tech_pvt
->
crypto_type
,
tech_pvt
->
remote_raw_key
,
SWITCH_RTP_KEY_LEN
);
}
got_crypto
++
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Ignoring unacceptable key
\n
"
);
}
}
}
else
if
(
!
switch_rtp_ready
(
tech_pvt
->
rtp_session
))
{
tech_pvt
->
remote_crypto_key
=
switch_core_session_strdup
(
tech_pvt
->
session
,
crypto
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Set Remote Key [%s]
\n
"
,
tech_pvt
->
remote_crypto_key
);
switch_channel_set_variable
(
tech_pvt
->
channel
,
"srtp_remote_audio_crypto_key"
,
crypto
);
tech_pvt
->
crypto_tag
=
crypto_tag
;
got_crypto
++
;
if
(
zstr
(
tech_pvt
->
local_crypto_key
))
{
if
(
switch_stristr
(
SWITCH_RTP_CRYPTO_KEY_32
,
crypto
))
{
switch_channel_set_variable
(
tech_pvt
->
channel
,
SOFIA_HAS_CRYPTO_VARIABLE
,
SWITCH_RTP_CRYPTO_KEY_32
);
sofia_glue_build_crypto
(
tech_pvt
,
atoi
(
crypto
),
AES_CM_128_HMAC_SHA1_32
,
SWITCH_RTP_CRYPTO_SEND
);
}
else
if
(
switch_stristr
(
SWITCH_RTP_CRYPTO_KEY_80
,
crypto
))
{
switch_channel_set_variable
(
tech_pvt
->
channel
,
SOFIA_HAS_CRYPTO_VARIABLE
,
SWITCH_RTP_CRYPTO_KEY_80
);
sofia_glue_build_crypto
(
tech_pvt
,
atoi
(
crypto
),
AES_CM_128_HMAC_SHA1_80
,
SWITCH_RTP_CRYPTO_SEND
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Crypto Setup Failed!.
\n
"
);
}
}
}
}
}
}
}
...
@@ -1171,7 +1058,7 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
...
@@ -1171,7 +1058,7 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
}
}
if
((
var
=
switch_channel_get_variable
(
tech_pvt
->
channel
,
SOFIA_SECURE_MEDIA_VARIABLE
))
&&
switch_true
(
var
))
{
if
((
var
=
switch_channel_get_variable
(
tech_pvt
->
channel
,
SOFIA_SECURE_MEDIA_VARIABLE
))
&&
switch_true
(
var
))
{
s
ofia_set_flag_locked
(
tech_pvt
,
TFLAG
_SECURE
);
s
witch_channel_set_flag
(
tech_pvt
->
channel
,
CF
_SECURE
);
}
}
if
(
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF_PROXY_MODE
))
{
if
(
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF_PROXY_MODE
))
{
...
@@ -1376,6 +1263,9 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
...
@@ -1376,6 +1263,9 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
uint32_t
stun_ping
=
0
;
uint32_t
stun_ping
=
0
;
const
char
*
ssrc
;
const
char
*
ssrc
;
switch_core_media_set_rtp_session
(
tech_pvt
->
session
,
SWITCH_MEDIA_TYPE_AUDIO
,
tech_pvt
->
rtp_session
);
if
((
ssrc
=
switch_channel_get_variable
(
tech_pvt
->
channel
,
"rtp_use_ssrc"
)))
{
if
((
ssrc
=
switch_channel_get_variable
(
tech_pvt
->
channel
,
"rtp_use_ssrc"
)))
{
uint32_t
ssrc_ul
=
(
uint32_t
)
strtoul
(
ssrc
,
NULL
,
10
);
uint32_t
ssrc_ul
=
(
uint32_t
)
strtoul
(
ssrc
,
NULL
,
10
);
switch_rtp_set_ssrc
(
tech_pvt
->
rtp_session
,
ssrc_ul
);
switch_rtp_set_ssrc
(
tech_pvt
->
rtp_session
,
ssrc_ul
);
...
@@ -1582,15 +1472,7 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
...
@@ -1582,15 +1472,7 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
switch_rtp_set_cng_pt
(
tech_pvt
->
rtp_session
,
tech_pvt
->
cng_pt
);
switch_rtp_set_cng_pt
(
tech_pvt
->
rtp_session
,
tech_pvt
->
cng_pt
);
}
}
if
(
tech_pvt
->
remote_crypto_key
&&
sofia_test_flag
(
tech_pvt
,
TFLAG_SECURE
))
{
switch_core_session_apply_crypto
(
tech_pvt
->
session
,
SWITCH_MEDIA_TYPE_AUDIO
,
SOFIA_SECURE_MEDIA_CONFIRMED_VARIABLE
);
sofia_glue_add_crypto
(
tech_pvt
,
tech_pvt
->
remote_crypto_key
,
SWITCH_RTP_CRYPTO_RECV
);
switch_rtp_add_crypto_key
(
tech_pvt
->
rtp_session
,
SWITCH_RTP_CRYPTO_SEND
,
1
,
tech_pvt
->
crypto_type
,
tech_pvt
->
local_raw_key
,
SWITCH_RTP_KEY_LEN
);
switch_rtp_add_crypto_key
(
tech_pvt
->
rtp_session
,
SWITCH_RTP_CRYPTO_RECV
,
tech_pvt
->
crypto_tag
,
tech_pvt
->
crypto_type
,
tech_pvt
->
remote_raw_key
,
SWITCH_RTP_KEY_LEN
);
switch_channel_set_variable
(
tech_pvt
->
channel
,
SOFIA_SECURE_MEDIA_CONFIRMED_VARIABLE
,
"true"
);
}
switch_snprintf
(
tmp
,
sizeof
(
tmp
),
"%d"
,
tech_pvt
->
remote_sdp_audio_port
);
switch_snprintf
(
tmp
,
sizeof
(
tmp
),
"%d"
,
tech_pvt
->
remote_sdp_audio_port
);
switch_channel_set_variable
(
tech_pvt
->
channel
,
SWITCH_REMOTE_MEDIA_IP_VARIABLE
,
tech_pvt
->
remote_sdp_audio_ip
);
switch_channel_set_variable
(
tech_pvt
->
channel
,
SWITCH_REMOTE_MEDIA_IP_VARIABLE
,
tech_pvt
->
remote_sdp_audio_ip
);
...
@@ -1754,6 +1636,7 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
...
@@ -1754,6 +1636,7 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
if
(
switch_rtp_ready
(
tech_pvt
->
video_rtp_session
))
{
if
(
switch_rtp_ready
(
tech_pvt
->
video_rtp_session
))
{
switch_rtp_set_default_payload
(
tech_pvt
->
video_rtp_session
,
tech_pvt
->
video_agreed_pt
);
switch_rtp_set_default_payload
(
tech_pvt
->
video_rtp_session
,
tech_pvt
->
video_agreed_pt
);
switch_core_media_set_rtp_session
(
tech_pvt
->
session
,
SWITCH_MEDIA_TYPE_VIDEO
,
tech_pvt
->
video_rtp_session
);
}
}
if
(
switch_rtp_ready
(
tech_pvt
->
video_rtp_session
))
{
if
(
switch_rtp_ready
(
tech_pvt
->
video_rtp_session
))
{
...
...
src/switch_core_media.c
浏览文件 @
0a246d1c
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论