Commit 24af44ee authored by Simon Morlat's avatar Simon Morlat
Browse files

Fix issue where DTLS handshake cannot take place when the media path goes through a TURN server

parent a2ba6bcf
......@@ -66,6 +66,7 @@ void MediaSessionParamsPrivate::clone (const MediaSessionParamsPrivate *src) {
downPtime = src->downPtime;
upPtime = src->upPtime;
updateCallWhenIceCompleted = src->updateCallWhenIceCompleted;
updateCallWhenIceCompletedWithDTLS = src->updateCallWhenIceCompletedWithDTLS;
if (src->customSdpAttributes)
customSdpAttributes = sal_custom_sdp_attribute_clone(src->customSdpAttributes);
for (unsigned int i = 0; i < (unsigned int)LinphoneStreamTypeUnknown; i++) {
......@@ -202,6 +203,7 @@ void MediaSessionParamsPrivate::setCustomSdpMediaAttributes (LinphoneStreamType
bool MediaSessionParamsPrivate::getUpdateCallWhenIceCompleted() const{
if (encryption == LinphoneMediaEncryptionDTLS){
lInfo() << "DTLS used, reINVITE requested: " << updateCallWhenIceCompletedWithDTLS;
return updateCallWhenIceCompletedWithDTLS;
}
return updateCallWhenIceCompleted;
......
......@@ -150,7 +150,7 @@ static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t
bctbx_list_t *lcs = NULL;
IceCheckList *cl1 = NULL, *cl2 = NULL;
marie = linphone_core_manager_create("marie_rc");
marie = linphone_core_manager_create(transport_supported(LinphoneTransportTls) ? "marie_sips_rc" : "marie_rc");
lcs = bctbx_list_append(lcs, marie->lc);
pauline = linphone_core_manager_create(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
lcs = bctbx_list_append(lcs, pauline->lc);
......@@ -162,6 +162,9 @@ static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t
linphone_core_enable_ipv6(marie->lc, FALSE);
linphone_core_enable_ipv6(pauline->lc, FALSE);
}
linphone_config_set_int(linphone_core_get_config(marie->lc), "sip", "update_call_when_ice_completed_with_dtls", 1);
linphone_config_set_int(linphone_core_get_config(pauline->lc), "sip", "update_call_when_ice_completed_with_dtls", 1);
configure_nat_policy(marie->lc, caller_turn_enabled, turn_tcp, turn_tls);
configure_nat_policy(pauline->lc, callee_turn_enabled, turn_tcp, turn_tls);
......@@ -320,6 +323,10 @@ static void relayed_ice_turn_tls_to_ice_with_srtp(void){
ice_turn_call_base(FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, LinphoneMediaEncryptionSRTP);
}
static void relayed_ice_turn_to_ice_with_dtls_srtp(void){
ice_turn_call_base(FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, LinphoneMediaEncryptionDTLS);
}
test_t stun_tests[] = {
TEST_ONE_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip, "STUN"),
......@@ -339,7 +346,8 @@ test_t stun_tests[] = {
TEST_TWO_TAGS("Relayed ICE+TURN to ICE+STUN call", relayed_ice_turn_to_ice_stun_call, "ICE", "TURN"),
TEST_TWO_TAGS("Relayed ICE+TURN call with SRTP", relayed_ice_turn_call_with_srtp, "ICE", "TURN"),
TEST_TWO_TAGS("Relayed ICE+TURN TLS call with SRTP", relayed_ice_turn_tls_with_srtp, "ICE", "TURN"),
TEST_TWO_TAGS("Relayed ICE+TURN TLS call to ICE with SRTP", relayed_ice_turn_tls_to_ice_with_srtp, "ICE", "TURN")
TEST_TWO_TAGS("Relayed ICE+TURN TLS call to ICE with SRTP", relayed_ice_turn_tls_to_ice_with_srtp, "ICE", "TURN"),
TEST_TWO_TAGS("Relayed ICE+TURN call to ICE with DTLS-SRTP", relayed_ice_turn_to_ice_with_dtls_srtp, "ICE", "TURN")
};
test_suite_t stun_test_suite = {"Stun", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
......
......@@ -388,8 +388,7 @@ LinphoneCore *linphone_core_manager_configure_lc(LinphoneCoreManager *mgr) {
ms_fatal("Could not find file %s in path %s, did you configured resources directory correctly?", mgr->rc_path, bc_tester_get_resource_dir_prefix());
}
LinphoneConfig * config = linphone_factory_create_config_with_factory(linphone_factory_get(), mgr->rc_local, filepath);
// clean
if (filepath) bctbx_free(filepath);
linphone_config_set_string(config, "storage", "backend", "sqlite3");
linphone_config_set_string(config, "storage", "uri", mgr->database_path);
linphone_config_set_string(config, "storage", "call_logs_db_uri", mgr->call_logs_database_path);
......@@ -398,6 +397,7 @@ LinphoneCore *linphone_core_manager_configure_lc(LinphoneCoreManager *mgr) {
lc = configure_lc_from(mgr->cbs, bc_tester_get_resource_dir_prefix(), config, mgr);
linphone_config_unref(config);
if (filepath) bctbx_free(filepath);
return lc;
}
......@@ -2934,7 +2934,10 @@ bool_t call_with_params2(LinphoneCoreManager* caller_mgr
&& linphone_core_get_firewall_policy(callee_mgr->lc) == LinphonePolicyUseIce
&& linphone_config_get_int(linphone_core_get_config(callee_mgr->lc), "sip", "update_call_when_ice_completed", TRUE)
&& linphone_config_get_int(linphone_core_get_config(callee_mgr->lc), "sip", "update_call_when_ice_completed", TRUE)
&& linphone_core_get_media_encryption(caller_mgr->lc) != LinphoneMediaEncryptionDTLS /*no ice-reinvite with DTLS*/) {
&& ( linphone_core_get_media_encryption(caller_mgr->lc) != LinphoneMediaEncryptionDTLS
|| (linphone_config_get_int(linphone_core_get_config(callee_mgr->lc), "sip", "update_call_when_ice_completed_with_dtls", FALSE)
&& linphone_config_get_int(linphone_core_get_config(callee_mgr->lc), "sip", "update_call_when_ice_completed_with_dtls", FALSE)) )
) {
BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+2));
BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+2));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment