• Andrea Gianarda's avatar
    In the call parameters, there are 2 ways of setting the from address · 2dc884fb
    Andrea Gianarda authored
    when initiating a call;
    - from header
    - account
    These 2 parameters are dependent from each other which makes tricky for
    the core to know exactly which account to use and the correct from
    address.
    In most scenarios, the from address is the account's identity address
    but it is not always the case such as in the case of a direct call.
    Moreover, the account cannot be always deduced in a straightforward
    matter such as if the core has no default account (but it is registered
    with one or more accounts) and the call parameters have not set one.
    
    The algorithm for choosing an account is the following:
    1) search in the call parameters
    2) get the default account
    3) look up for the best guessed account based on the from (if known) or
       to address
    
    The algorithm for known the from address is the following:
    1) look for the from header in the call parameters
    2) look up for the identity address of the account (if known)
    3) get the core primary account
    
    Set Ik SDP attribute based on the account used for a call
    
    Use account set in the call parameters before retrieving the NAT policy.
    It may happen that a call session is buuild without passing an account
    and in such a case, the SDK will do its best to get one
    2dc884fb
capability_negotiation_tester.cpp 173.94 KiB
/*
 * Copyright (c) 2010-2022 Belledonne Communications SARL.
 * This file is part of Liblinphone
 * (see https://gitlab.linphone.org/BC/public/liblinphone).
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <algorithm>
#include <list>
#include <string>
#include "bctoolbox/defs.h"
#include "c-wrapper/c-wrapper.h"
#include "c-wrapper/internal/c-tools.h"
#include "call/call.h"
#include "capability_negotiation_tester.h"
#include "conference/session/media-session-p.h"
#include "liblinphone_tester.h"
#include "linphone/core.h"
#include "sal/call-op.h"
#include "shared_tester_functions.h"
#include "tester_utils.h"
void get_expected_encryption_from_call_params(LinphoneCall *offererCall,
                                              LinphoneCall *answererCall,
                                              LinphoneMediaEncryption *expectedEncryption,
                                              bool *potentialConfigurationChosen) {
	const LinphoneCallParams *offerer_params = linphone_call_get_params(offererCall);
	const LinphoneCallParams *answerer_params = linphone_call_get_params(answererCall);
	bool_t offerer_enc_mandatory = linphone_call_params_mandatory_media_encryption_enabled(offerer_params);
	bool_t answerer_enc_mandatory = linphone_call_params_mandatory_media_encryption_enabled(answerer_params);
	const LinphoneMediaEncryption offerer_encryption = linphone_call_params_get_media_encryption(offerer_params);
	const LinphoneMediaEncryption answerer_encryption = linphone_call_params_get_media_encryption(answerer_params);
	const bool_t offerer_capability_negotiations = linphone_call_params_capability_negotiations_enabled(offerer_params);
	const bool_t answerer_capability_negotiations =
	    linphone_call_params_capability_negotiations_enabled(answerer_params);
	if (offerer_enc_mandatory) {
		*expectedEncryption = offerer_encryption;
		// reINVITE is not sent because the call should not offer potential configurations as it must enforce an
		// encryption that will be stored in the actual configuration
		*potentialConfigurationChosen = false;
	} else if (answerer_enc_mandatory) {
		*expectedEncryption = answerer_encryption;
		// reINVITE is only sent if offerer and answerer support capability negotiations enabled and the expected
		// encryption is listed in one potential configuration offered by the offerer
		*potentialConfigurationChosen =
		    (offerer_capability_negotiations && answerer_capability_negotiations &&
		     linphone_call_params_is_media_encryption_supported(answerer_params, *expectedEncryption));
	} else if (answerer_capability_negotiations && offerer_capability_negotiations) {
		bctbx_list_t *offerer_supported_encs = linphone_call_params_get_supported_encryptions(offerer_params);
		bool_t enc_check_result = FALSE;
		// Find first encryption listed in the list of supported encryptions of the offerer that is supported by the
		// answerer
		for (bctbx_list_t *enc = offerer_supported_encs; enc != NULL; enc = enc->next) {
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
*expectedEncryption = static_cast<LinphoneMediaEncryption>(LINPHONE_PTR_TO_INT(bctbx_list_get_data(enc))); enc_check_result |= (linphone_call_params_is_media_encryption_supported(answerer_params, *expectedEncryption) || (linphone_call_params_get_media_encryption(answerer_params) == *expectedEncryption)); if (enc_check_result) { break; } } if (!enc_check_result) { *expectedEncryption = linphone_call_params_get_media_encryption(offerer_params); } // reINVITE is always sent *potentialConfigurationChosen = linphone_call_params_is_media_encryption_supported(offerer_params, *expectedEncryption) && (linphone_call_params_get_media_encryption(offerer_params) != *expectedEncryption); if (offerer_supported_encs) { bctbx_list_free(offerer_supported_encs); } if (*potentialConfigurationChosen && (*expectedEncryption == LinphoneMediaEncryptionSRTP)) { const bool srtpSuiteMatch = search_matching_srtp_suite(get_manager(linphone_call_get_core(offererCall)), get_manager(linphone_call_get_core(answererCall))); if (!srtpSuiteMatch) { *potentialConfigurationChosen = false; *expectedEncryption = linphone_call_params_get_media_encryption(offerer_params); } } } else { *expectedEncryption = linphone_call_params_get_media_encryption(offerer_params); // reINVITE is not sent because either parts of the call doesn't support capability negotiations *potentialConfigurationChosen = false; } } std::list<LinphoneMediaEncryption> set_encryption_preference(const bool_t encryption_preferred) { std::list<LinphoneMediaEncryption> preferences; for (int idx = 0; idx <= LinphoneMediaEncryptionDTLS; idx++) { LinphoneMediaEncryption candidateEncryption = static_cast<LinphoneMediaEncryption>(idx); if (candidateEncryption != LinphoneMediaEncryptionNone) { preferences.push_back(candidateEncryption); } } if (encryption_preferred) { preferences.push_back(LinphoneMediaEncryptionNone); /**< No media encryption is used */ } else { preferences.push_front(LinphoneMediaEncryptionNone); /**< No media encryption is used */ } return preferences; } std::list<LinphoneMediaEncryption> set_encryption_preference_with_priority(const LinphoneMediaEncryption encryption, const bool append) { std::list<LinphoneMediaEncryption> preferences; for (int idx = 0; idx <= LinphoneMediaEncryptionDTLS; idx++) { LinphoneMediaEncryption candidateEncryption = static_cast<LinphoneMediaEncryption>(idx); if (candidateEncryption != encryption) { if (candidateEncryption == LinphoneMediaEncryptionNone) { // No encryption should be added last preferences.push_back(candidateEncryption); } else { preferences.push_front(candidateEncryption); } } } if (append) { preferences.push_back(encryption);
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
} else { preferences.push_front(encryption); } return preferences; } bctbx_list_t *create_confg_encryption_preference_list_except(const LinphoneMediaEncryption encryption) { bctbx_list_t *encryption_list = NULL; for (int idx = 0; idx <= LinphoneMediaEncryptionDTLS; idx++) { if (static_cast<LinphoneMediaEncryption>(idx) != encryption) { encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(idx)); } } return encryption_list; } bctbx_list_t * create_confg_encryption_preference_list_from_param_preferences(const std::list<LinphoneMediaEncryption> &preferences) { bctbx_list_t *encryption_list = NULL; for (const auto &enc : preferences) { encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(enc)); } return encryption_list; } LinphoneCoreManager *create_core_mgr_with_capability_negotiation_setup(const char *rc_file, const encryption_params enc_params, const bool_t enable_capability_negotiations, const bool_t enable_ice, const bool_t enable_video) { LinphoneCoreManager *mgr = linphone_core_manager_new(rc_file); linphone_core_enable_capability_negociation(mgr->lc, enable_capability_negotiations); const LinphoneMediaEncryption encryption = enc_params.encryption; if (linphone_core_media_encryption_supported(mgr->lc, encryption)) { linphone_core_set_media_encryption_mandatory(mgr->lc, (enc_params.level == E_MANDATORY)); if ((enc_params.level == E_MANDATORY) || (enc_params.level == E_OPTIONAL)) { linphone_core_set_media_encryption(mgr->lc, encryption); BC_ASSERT_EQUAL(linphone_core_get_media_encryption(mgr->lc), encryption, int, "%i"); } else { linphone_core_set_media_encryption(mgr->lc, LinphoneMediaEncryptionNone); BC_ASSERT_EQUAL(linphone_core_get_media_encryption(mgr->lc), LinphoneMediaEncryptionNone, int, "%i"); } if (!enc_params.preferences.empty()) { bctbx_list_t *cfg_enc = create_confg_encryption_preference_list_from_param_preferences(enc_params.preferences); linphone_core_set_supported_media_encryptions(mgr->lc, cfg_enc); bctbx_list_free(cfg_enc); } } if (enable_video) { #ifdef VIDEO_ENABLED // important: VP8 has really poor performances with the mire camera, at least // on iOS - so when ever h264 is available, let's use it instead if (linphone_core_get_payload_type(mgr->lc, "h264", -1, -1) != NULL) { disable_all_video_codecs_except_one(mgr->lc, "h264"); } linphone_core_set_video_device(mgr->lc, liblinphone_tester_mire_id); LinphoneVideoActivationPolicy *pol = linphone_factory_create_video_activation_policy(linphone_factory_get()); linphone_video_activation_policy_set_automatically_accept(pol, TRUE); linphone_core_set_video_activation_policy(mgr->lc, pol); linphone_video_activation_policy_unref(pol); linphone_core_set_video_device(mgr->lc, liblinphone_tester_mire_id);
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
linphone_core_enable_video_capture(mgr->lc, TRUE); linphone_core_enable_video_display(mgr->lc, TRUE); #endif // VIDEO_ENABLED } if (enable_ice) { // TODO: allow disabling ice or STUN at the core level and enabling in the account // Enable ICE at the account level but not at the core level // enable_stun_in_mgr(mgr, TRUE, enable_ice, FALSE, FALSE); enable_stun_in_mgr(mgr, TRUE, enable_ice, TRUE, enable_ice); } return mgr; } void encrypted_call_with_params_base(LinphoneCoreManager *caller, LinphoneCoreManager *callee, const LinphoneMediaEncryption encryption, const LinphoneCallParams *caller_params, LinphoneCallParams *callee_params, const bool_t enable_video) { reset_counters(&caller->stat); reset_counters(&callee->stat); linphone_core_reset_tone_manager_stats(caller->lc); linphone_core_reset_tone_manager_stats(callee->lc); bool_t caller_enc_mandatory = linphone_call_params_mandatory_media_encryption_enabled(caller_params); bool_t callee_enc_mandatory = linphone_call_params_mandatory_media_encryption_enabled(callee_params); const LinphoneMediaEncryption caller_encryption = linphone_call_params_get_media_encryption(caller_params); const LinphoneMediaEncryption callee_encryption = linphone_call_params_get_media_encryption(callee_params); if (caller_enc_mandatory && callee_enc_mandatory && (caller_encryption != callee_encryption)) { BC_ASSERT_FALSE(call_with_params(caller, callee, caller_params, callee_params)); } else { const bool_t caller_capability_negotiations = linphone_call_params_capability_negotiations_enabled(caller_params); const bool_t callee_capability_negotiations = linphone_call_params_capability_negotiations_enabled(callee_params); char *path = bc_tester_file("certificates-marie"); linphone_core_set_user_certificates_path(callee->lc, path); bc_free(path); path = bc_tester_file("certificates-pauline"); linphone_core_set_user_certificates_path(caller->lc, path); bc_free(path); bctbx_mkdir(linphone_core_get_user_certificates_path(callee->lc)); bctbx_mkdir(linphone_core_get_user_certificates_path(caller->lc)); stats caller_stat = caller->stat; stats callee_stat = callee->stat; BC_ASSERT_TRUE(call_with_params(caller, callee, caller_params, callee_params)); LinphoneCall *callerCall = linphone_core_get_current_call(caller->lc); BC_ASSERT_PTR_NOT_NULL(callerCall); LinphoneCall *calleeCall = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(calleeCall); // Find expected call encryption as well as if a reinvite following capability negotiation is required LinphoneMediaEncryption expectedEncryption = LinphoneMediaEncryptionNone; bool potentialConfigurationChosen = false; if (caller_enc_mandatory) { expectedEncryption = caller_encryption; // reINVITE is not sent because the call should not offer potential configurations as it must enforce an // encryption that will be stored in the actual configuration potentialConfigurationChosen = false; } else if (callee_enc_mandatory) { expectedEncryption = callee_encryption;
281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
// reINVITE is only sent if caller and callee support capability negotiations enabled and the expected // encryption is listed in one potential configuration offered by the caller potentialConfigurationChosen = (callee_capability_negotiations && caller_capability_negotiations && linphone_call_params_is_media_encryption_supported(caller_params, expectedEncryption) && (linphone_call_params_get_media_encryption(caller_params) != expectedEncryption)); } else if (callee_capability_negotiations && caller_capability_negotiations && (linphone_call_params_is_media_encryption_supported(caller_params, encryption)) && (linphone_call_params_is_media_encryption_supported(callee_params, encryption))) { expectedEncryption = encryption; // reINVITE is always sent potentialConfigurationChosen = linphone_call_params_is_media_encryption_supported(caller_params, encryption) && (linphone_call_params_get_media_encryption(caller_params) != encryption); if (potentialConfigurationChosen && (expectedEncryption == LinphoneMediaEncryptionSRTP)) { const bool srtpSuiteMatch = search_matching_srtp_suite(caller, callee); if (!srtpSuiteMatch) { potentialConfigurationChosen = false; BC_ASSERT_EQUAL(expectedEncryption, linphone_call_params_get_media_encryption(caller_params), int, "%i"); } } } else { expectedEncryption = linphone_call_params_get_media_encryption(caller_params); // reINVITE is not sent because either parts of the call doesn't support capability negotiations potentialConfigurationChosen = false; } LinphoneNatPolicy *caller_nat_policy = get_nat_policy_for_call(caller, callerCall); const bool_t caller_ice_enabled = linphone_nat_policy_ice_enabled(caller_nat_policy); LinphoneNatPolicy *callee_nat_policy = get_nat_policy_for_call(callee, calleeCall); const bool_t callee_ice_enabled = linphone_nat_policy_ice_enabled(callee_nat_policy); const bool_t capabilityNegotiationReinviteEnabled = linphone_core_sdp_200_ack_enabled(caller->lc) ? linphone_call_params_capability_negotiation_reinvite_enabled(callee_params) : linphone_call_params_capability_negotiation_reinvite_enabled(caller_params); bool sendReInvite = (potentialConfigurationChosen && capabilityNegotiationReinviteEnabled) || (caller_ice_enabled && callee_ice_enabled); const int expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); if (callee_ice_enabled && caller_ice_enabled) { BC_ASSERT_TRUE(check_ice(caller, callee, LinphoneIceStateHostConnection)); BC_ASSERT_TRUE(check_ice(callee, caller, LinphoneIceStateHostConnection)); } int dummy = 0; wait_for_until(caller->lc, callee->lc, &dummy, 1, 3000); /*just to sleep while iterating 1s*/ liblinphone_tester_check_rtcp(caller, callee); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(caller), 70, int, "%i"); LinphoneCallStats *calleeStats = linphone_call_get_audio_stats(linphone_core_get_current_call(callee->lc)); BC_ASSERT_GREATER((int)linphone_call_stats_get_download_bandwidth(calleeStats), 70, int, "%i"); linphone_call_stats_unref(calleeStats); calleeStats = NULL; // Check that no reINVITE is sent while checking streams BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%i"); BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%i"); if (callerCall) {
351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
check_stream_encryption(callerCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), expectedEncryption, int, "%i"); } if (calleeCall) { check_stream_encryption(calleeCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), expectedEncryption, int, "%i"); } if (!enable_video) { BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(calleeCall))); BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(callerCall))); BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(calleeCall))); BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callerCall))); } #ifdef VIDEO_ENABLED else { reset_counters(&caller->stat); reset_counters(&callee->stat); stats caller_stat = caller->stat; stats callee_stat = callee->stat; LinphoneCallParams *params = linphone_core_create_call_params(callee->lc, calleeCall); linphone_call_params_enable_video(params, TRUE); linphone_call_update(calleeCall, params); linphone_call_params_unref(params); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallUpdating, (callee_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallUpdatedByRemote, (caller_stat.number_of_LinphoneCallUpdatedByRemote + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + 1))); // Update expected encryption get_expected_encryption_from_call_params(calleeCall, callerCall, &expectedEncryption, &potentialConfigurationChosen); const bool_t capabilityNegotiationReinviteEnabledAfterUpdate = linphone_core_sdp_200_ack_enabled(callee->lc) ? linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(callerCall)) : linphone_call_params_capability_negotiation_reinvite_enabled( linphone_call_get_params(calleeCall)); bool sendReInviteAfterUpdate = (potentialConfigurationChosen && capabilityNegotiationReinviteEnabledAfterUpdate) || (caller_ice_enabled && callee_ice_enabled); const int expectedStreamsRunningAfterUpdate = 1 + ((sendReInviteAfterUpdate) ? 1 : 0); BC_ASSERT_TRUE( wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunningAfterUpdate))); BC_ASSERT_TRUE( wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunningAfterUpdate))); liblinphone_tester_set_next_video_frame_decoded_cb(callerCall); liblinphone_tester_set_next_video_frame_decoded_cb(calleeCall); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_IframeDecoded, (callee_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_IframeDecoded, (caller_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(calleeCall))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(callerCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(calleeCall)));
421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(callerCall))); int dummy = 0; wait_for_until(caller->lc, callee->lc, &dummy, 1, 3000); /*just to sleep while iterating 1s*/ liblinphone_tester_check_rtcp(caller, callee); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(caller), 70, int, "%i"); calleeStats = linphone_call_get_audio_stats(linphone_core_get_current_call(callee->lc)); BC_ASSERT_GREATER((int)linphone_call_stats_get_download_bandwidth(calleeStats), 70, int, "%i"); linphone_call_stats_unref(calleeStats); calleeStats = NULL; } #endif // VIDEO_ENABLED // Check that encryption has not changed after sending update if (callerCall) { check_stream_encryption(callerCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), expectedEncryption, int, "%i"); } if (calleeCall) { check_stream_encryption(calleeCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), expectedEncryption, int, "%i"); } } } void encrypted_call_base(LinphoneCoreManager *caller, LinphoneCoreManager *callee, const LinphoneMediaEncryption encryption, const bool_t enable_caller_capability_negotiations, const bool_t enable_callee_capability_negotiations, const bool_t enable_video) { LinphoneCallParams *caller_params = linphone_core_create_call_params(caller->lc, NULL); linphone_call_params_enable_capability_negotiations(caller_params, enable_caller_capability_negotiations); LinphoneCallParams *callee_params = linphone_core_create_call_params(callee->lc, NULL); linphone_call_params_enable_capability_negotiations(callee_params, enable_callee_capability_negotiations); encrypted_call_with_params_base(caller, callee, encryption, caller_params, callee_params, enable_video); linphone_call_params_unref(caller_params); linphone_call_params_unref(callee_params); } void pause_resume_calls(LinphoneCoreManager *caller, LinphoneCoreManager *callee) { LinphoneCall *callerCall = linphone_core_get_current_call(caller->lc); BC_ASSERT_PTR_NOT_NULL(callerCall); LinphoneCall *calleeCall = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(calleeCall); if (calleeCall && callerCall) { LinphoneMediaEncryption calleeEncryption = linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)); LinphoneMediaEncryption callerEncryption = linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)); // Pause callee call BC_ASSERT_TRUE(pause_call_1(callee, calleeCall, caller, callerCall)); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); // Resume callee call reset_counters(&caller->stat); reset_counters(&callee->stat); stats caller_stat = caller->stat; stats callee_stat = callee->stat; linphone_call_resume(calleeCall);
491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, callee_stat.number_of_LinphoneCallStreamsRunning + 1)); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, caller_stat.number_of_LinphoneCallStreamsRunning + 1)); // Verify that encryption didn't change BC_ASSERT_EQUAL(calleeEncryption, callerEncryption, int, "%i"); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), callerEncryption, int, "%i"); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), calleeEncryption, int, "%i"); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); liblinphone_tester_check_rtcp(caller, callee); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(caller), 70, int, "%i"); LinphoneCallStats *calleeStats = linphone_call_get_audio_stats(linphone_core_get_current_call(callee->lc)); BC_ASSERT_GREATER((int)linphone_call_stats_get_download_bandwidth(calleeStats), 70, int, "%i"); linphone_call_stats_unref(calleeStats); calleeStats = NULL; check_stream_encryption(callerCall); check_stream_encryption(calleeCall); // Pause caller call BC_ASSERT_TRUE(pause_call_1(caller, callerCall, callee, calleeCall)); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); // Resume caller call reset_counters(&caller->stat); reset_counters(&callee->stat); caller_stat = caller->stat; callee_stat = callee->stat; linphone_call_resume(callerCall); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, callee_stat.number_of_LinphoneCallStreamsRunning + 1)); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, caller_stat.number_of_LinphoneCallStreamsRunning + 1)); // Verify that encryption didn't change BC_ASSERT_EQUAL(calleeEncryption, callerEncryption, int, "%i"); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), callerEncryption, int, "%i"); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), calleeEncryption, int, "%i"); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); liblinphone_tester_check_rtcp(caller, callee); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(callee), 70, int, "%i"); LinphoneCallStats *callerStats = linphone_call_get_audio_stats(linphone_core_get_current_call(caller->lc)); BC_ASSERT_GREATER((int)linphone_call_stats_get_download_bandwidth(callerStats), 70, int, "%i"); linphone_call_stats_unref(callerStats); callerStats = NULL; check_stream_encryption(callerCall); check_stream_encryption(calleeCall); } } void call_with_update_and_incompatible_encs_in_call_params_base(const bool_t enable_ice) { const LinphoneMediaEncryption encryption = LinphoneMediaEncryptionSRTP; // Desired encryption std::list<LinphoneMediaEncryption> marie_enc_list; if (encryption != LinphoneMediaEncryptionZRTP) { marie_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (encryption != LinphoneMediaEncryptionDTLS) {
561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
marie_enc_list.push_back(LinphoneMediaEncryptionDTLS); } if (encryption != LinphoneMediaEncryptionSRTP) { marie_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (encryption != LinphoneMediaEncryptionNone) { marie_enc_list.push_back(LinphoneMediaEncryptionNone); } encryption_params marie_enc_mgr_params; marie_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; marie_enc_mgr_params.level = E_OPTIONAL; marie_enc_mgr_params.preferences = marie_enc_list; LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_mgr_params, TRUE, enable_ice, TRUE); std::list<LinphoneMediaEncryption> pauline_enc_list; if (encryption != LinphoneMediaEncryptionSRTP) { pauline_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (encryption != LinphoneMediaEncryptionZRTP) { pauline_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (encryption != LinphoneMediaEncryptionNone) { pauline_enc_list.push_back(LinphoneMediaEncryptionNone); } if (encryption != LinphoneMediaEncryptionDTLS) { pauline_enc_list.push_back(LinphoneMediaEncryptionDTLS); } encryption_params pauline_enc_mgr_params; pauline_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_mgr_params.level = E_OPTIONAL; pauline_enc_mgr_params.preferences = pauline_enc_list; LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_mgr_params, TRUE, enable_ice, TRUE); if (enable_ice) { linphone_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "rtcp_mux", 1); } bctbx_list_t *marie_call_enc = NULL; marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(encryption)); LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, 1); linphone_call_params_set_supported_encryptions(marie_params, marie_call_enc); linphone_call_params_set_media_encryption(marie_params, LinphoneMediaEncryptionDTLS); bctbx_list_free(marie_call_enc); bctbx_list_t *pauline_call_enc = NULL; pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); LinphoneCallParams *pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, 1); linphone_call_params_set_media_encryption(pauline_params, encryption); linphone_call_params_set_supported_encryptions(pauline_params, pauline_call_enc); bctbx_list_free(pauline_call_enc); // Offerer media description: // - actual configuration: DTLS // - potential configuration: SRTP // Answerer media description: // - actual configuration: SRTP // - potential configuration: ZRTP // Result: potential configuration is chosen (encryption SRTP) BC_ASSERT_TRUE(call_with_params(marie, pauline, marie_params, pauline_params));
631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
LinphoneCall *marieCall = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(marieCall); LinphoneCall *paulineCall = linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(paulineCall); liblinphone_tester_check_rtcp(marie, pauline); BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, 2, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, 2, int, "%d"); // Check that encryption has not changed after sending update if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), encryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), encryption, int, "%i"); } stats marie_stat = marie->stat; stats pauline_stat = pauline->stat; LinphoneCallParams *params = linphone_core_create_call_params(pauline->lc, paulineCall); linphone_call_params_enable_video(params, TRUE); // Offerer media description: // - actual configuration: SRTP // - potential configuration: ZRTP // Answerer media description: // - actual configuration: DTLS // - potential configuration: SRTP // Result: actual configuration is chosen (encryption SRTP) linphone_call_update(paulineCall, params); linphone_call_params_unref(params); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallUpdating, (pauline_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallUpdatedByRemote, (marie_stat.number_of_LinphoneCallUpdatedByRemote + 1))); LinphoneNatPolicy *marie_nat_policy = get_nat_policy_for_call(marie, marieCall); const bool_t marie_ice_enabled = linphone_nat_policy_ice_enabled(marie_nat_policy); LinphoneNatPolicy *pauline_nat_policy = get_nat_policy_for_call(pauline, paulineCall); const bool_t pauline_ice_enabled = linphone_nat_policy_ice_enabled(pauline_nat_policy); const int expectedStreamsRunning = 1 + ((pauline_ice_enabled && marie_ice_enabled) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); if (pauline_ice_enabled && marie_ice_enabled) { BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection)); BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); } liblinphone_tester_set_next_video_frame_decoded_cb(marieCall); liblinphone_tester_set_next_video_frame_decoded_cb(paulineCall); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_IframeDecoded, (pauline_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_IframeDecoded, (marie_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(paulineCall))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marieCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(paulineCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(marieCall)));
701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
liblinphone_tester_check_rtcp(marie, pauline); // Check that encryption has not changed after sending update if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), encryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), encryption, int, "%i"); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); end_call(pauline, marie); linphone_call_params_unref(marie_params); linphone_call_params_unref(pauline_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } void call_with_encryption_test_base(const encryption_params marie_enc_params, const bool_t enable_marie_capability_negotiations, const bool_t enable_marie_ice, const encryption_params pauline_enc_params, const bool_t enable_pauline_capability_negotiations, const bool_t enable_pauline_ice, const bool_t enable_video) { LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup( "marie_rc", marie_enc_params, enable_marie_capability_negotiations, enable_marie_ice, enable_video); LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_params, enable_pauline_capability_negotiations, enable_pauline_ice, enable_video); LinphoneMediaEncryption expectedEncryption = LinphoneMediaEncryptionNone; if (marie_enc_params.level == E_MANDATORY) { expectedEncryption = marie_enc_params.encryption; } else if (pauline_enc_params.level == E_MANDATORY) { expectedEncryption = pauline_enc_params.encryption; } else if ((enable_marie_capability_negotiations == TRUE) && (enable_pauline_capability_negotiations == TRUE)) { for (const auto &enc : marie_enc_params.preferences) { if ((std::find(pauline_enc_params.preferences.cbegin(), pauline_enc_params.preferences.cend(), enc) != pauline_enc_params.preferences.cend()) || (pauline_enc_params.encryption == enc)) { expectedEncryption = enc; break; } } } else if (enable_marie_capability_negotiations == TRUE) { expectedEncryption = pauline_enc_params.encryption; } else { expectedEncryption = marie_enc_params.encryption; } if (enable_marie_ice && enable_pauline_ice) { linphone_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "rtcp_mux", 1); } encrypted_call_base(marie, pauline, expectedEncryption, enable_marie_capability_negotiations, enable_pauline_capability_negotiations, enable_video); if (linphone_core_get_current_call(marie->lc) && linphone_core_get_current_call(pauline->lc)) {
771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
end_call(marie, pauline); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static bool_t call_with_params_and_encryption_negotiation_failure_base(LinphoneCoreManager *caller, LinphoneCoreManager *callee, LinphoneCallParams *caller_params, LinphoneCallParams *callee_params, bool_t expSdpSuccess) { const bctbx_list_t *initLogs = linphone_core_get_call_logs(callee->lc); int initLogsSize = (int)bctbx_list_size(initLogs); stats initial_callee = callee->stat; stats initial_caller = callee->stat; LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; caller_test_params.base = (LinphoneCallParams *)caller_params; callee_test_params.base = (LinphoneCallParams *)callee_params; callee_test_params.sdp_simulate_error = !expSdpSuccess; bool_t ret = call_with_params2(caller, callee, &caller_test_params, &callee_test_params, FALSE); LinphoneCall *callee_call = linphone_core_get_current_call(callee->lc); if (!expSdpSuccess) { BC_ASSERT_PTR_NULL(callee_call); BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallError, (initial_caller.number_of_LinphoneCallError + 1), int, "%d"); BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallReleased, (initial_caller.number_of_LinphoneCallReleased + 1), int, "%d"); // actually callee does not receive error because it replies to the INVITE with a 488 Not Acceptable Here BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallIncomingReceived, (initial_callee.number_of_LinphoneCallIncomingReceived), int, "%d"); const bctbx_list_t *logs = linphone_core_get_call_logs(callee->lc); BC_ASSERT_EQUAL((int)bctbx_list_size(logs), (initLogsSize + 1), int, "%i"); // Forward logs pointer to the element desired for (int i = 0; i < initLogsSize; i++) logs = logs->next; if (logs) { const LinphoneErrorInfo *ei; LinphoneCallLog *cl = (LinphoneCallLog *)logs->data; BC_ASSERT_TRUE(linphone_call_log_get_start_date(cl) != 0); ei = linphone_call_log_get_error_info(cl); BC_ASSERT_PTR_NOT_NULL(ei); if (ei) { BC_ASSERT_EQUAL(linphone_error_info_get_reason(ei), LinphoneReasonNotAcceptable, int, "%d"); } } BC_ASSERT_EQUAL(linphone_core_get_calls_nb(caller->lc), 0, int, "%d"); BC_ASSERT_EQUAL(linphone_core_get_calls_nb(callee->lc), 0, int, "%d"); return FALSE; } return ret; } static bool_t call_with_encryption_negotiation_failure_base(LinphoneCoreManager *caller, LinphoneCoreManager *callee, bool_t expSdpSuccess) { return call_with_params_and_encryption_negotiation_failure_base(caller, callee, NULL, NULL, expSdpSuccess); } static void call_from_enc_to_different_enc_base(const LinphoneMediaEncryption mandatory_encryption, const LinphoneMediaEncryption non_mandatory_encryption, const bool_t enable_mandatory_enc_mgr_capability_negotiations,
841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
const bool_t enable_non_mandatory_enc_mgr_capability_negotiations, bool_t mandatory_to_non_mandatory) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_capability_negociation(marie->lc, enable_non_mandatory_enc_mgr_capability_negotiations); linphone_core_set_media_encryption_mandatory(marie->lc, FALSE); linphone_core_set_media_encryption(marie->lc, non_mandatory_encryption); bctbx_list_t *cfg_enc = create_confg_encryption_preference_list_except(mandatory_encryption); linphone_core_set_supported_media_encryptions(marie->lc, cfg_enc); BC_ASSERT_FALSE(linphone_core_is_media_encryption_supported(marie->lc, mandatory_encryption)); bctbx_list_free(cfg_enc); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_enable_capability_negociation(pauline->lc, enable_mandatory_enc_mgr_capability_negotiations); if (linphone_core_media_encryption_supported(pauline->lc, mandatory_encryption)) { linphone_core_set_media_encryption_mandatory(pauline->lc, TRUE); linphone_core_set_media_encryption(pauline->lc, mandatory_encryption); } BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(pauline->lc, mandatory_encryption)); if (mandatory_to_non_mandatory) { ms_message("Core with mandatory encryption calls core with non mandatory encryption"); BC_ASSERT_FALSE(call_with_encryption_negotiation_failure_base(pauline, marie, FALSE)); } else { ms_message("Core with non mandatory encryption calls core with mandatory encryption"); BC_ASSERT_FALSE(call_with_encryption_negotiation_failure_base(marie, pauline, FALSE)); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } void call_from_enc_to_no_enc_base(const LinphoneMediaEncryption encryption, const bool_t enable_mandatory_enc_mgr_capability_negotiations, const bool_t enable_non_mandatory_enc_mgr_capability_negotiations, bool_t mandatory_to_non_mandatory) { call_from_enc_to_different_enc_base( encryption, LinphoneMediaEncryptionNone, enable_mandatory_enc_mgr_capability_negotiations, enable_non_mandatory_enc_mgr_capability_negotiations, mandatory_to_non_mandatory); } void call_from_enc_to_dtls_enc_base(const LinphoneMediaEncryption encryption, const bool_t enable_mandatory_enc_mgr_capability_negotiations, const bool_t enable_non_mandatory_enc_mgr_capability_negotiations, bool_t mandatory_to_non_mandatory) { call_from_enc_to_different_enc_base( encryption, LinphoneMediaEncryptionDTLS, enable_mandatory_enc_mgr_capability_negotiations, enable_non_mandatory_enc_mgr_capability_negotiations, mandatory_to_non_mandatory); } static void call_with_capability_negotiation_failure(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_capability_negociation(marie->lc, 1); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_enable_capability_negociation(pauline->lc, 1); const LinphoneMediaEncryption paulineOptionalEncryption = LinphoneMediaEncryptionSRTP; BC_ASSERT_TRUE(linphone_core_media_encryption_supported(pauline->lc, paulineOptionalEncryption)); if (linphone_core_media_encryption_supported(pauline->lc, paulineOptionalEncryption)) { bctbx_list_t *encryption_list = NULL; encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(paulineOptionalEncryption)); linphone_core_set_media_encryption_mandatory(pauline->lc, 0); linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(pauline->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(pauline->lc, paulineOptionalEncryption)); if (encryption_list) { bctbx_list_free(encryption_list); }
911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
} const LinphoneMediaEncryption marieOptionalEncryption = LinphoneMediaEncryptionDTLS; BC_ASSERT_TRUE(linphone_core_media_encryption_supported(marie->lc, marieOptionalEncryption)); if (linphone_core_media_encryption_supported(marie->lc, marieOptionalEncryption)) { bctbx_list_t *encryption_list = NULL; encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(marieOptionalEncryption)); linphone_core_set_media_encryption_mandatory(marie->lc, 0); linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(marie->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(marie->lc, marieOptionalEncryption)); if (encryption_list) { bctbx_list_free(encryption_list); } } BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(marie->lc, marieOptionalEncryption)); BC_ASSERT_FALSE(linphone_core_is_media_encryption_supported(pauline->lc, marieOptionalEncryption)); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(pauline->lc, paulineOptionalEncryption)); BC_ASSERT_FALSE(linphone_core_is_media_encryption_supported(pauline->lc, marieOptionalEncryption)); encrypted_call_base(marie, pauline, marieOptionalEncryption, TRUE, TRUE, FALSE); if (linphone_core_get_current_call(marie->lc) && linphone_core_get_current_call(pauline->lc)) { end_call(marie, pauline); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_capability_negotiation_failure_multiple_potential_configurations(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_capability_negociation(marie->lc, 1); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_enable_capability_negociation(pauline->lc, 1); const LinphoneMediaEncryption paulineOptionalEncryption = LinphoneMediaEncryptionSRTP; BC_ASSERT_TRUE(linphone_core_media_encryption_supported(pauline->lc, paulineOptionalEncryption)); if (linphone_core_media_encryption_supported(pauline->lc, paulineOptionalEncryption)) { bctbx_list_t *encryption_list = NULL; encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(paulineOptionalEncryption)); linphone_core_set_media_encryption_mandatory(pauline->lc, 0); linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(pauline->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(pauline->lc, paulineOptionalEncryption)); if (encryption_list) { bctbx_list_free(encryption_list); } } bctbx_list_t *encryption_list = NULL; const LinphoneMediaEncryption marieOptionalEncryption0 = LinphoneMediaEncryptionDTLS; BC_ASSERT_TRUE(linphone_core_media_encryption_supported(marie->lc, marieOptionalEncryption0)); if (linphone_core_media_encryption_supported(marie->lc, marieOptionalEncryption0)) { encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(marieOptionalEncryption0)); } const LinphoneMediaEncryption marieOptionalEncryption1 = LinphoneMediaEncryptionZRTP; BC_ASSERT_TRUE(linphone_core_media_encryption_supported(marie->lc, marieOptionalEncryption1)); if (linphone_core_media_encryption_supported(marie->lc, marieOptionalEncryption1)) { encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(marieOptionalEncryption1)); } linphone_core_set_media_encryption_mandatory(marie->lc, 0); linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(marie->lc, encryption_list); if (encryption_list) {
981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
bctbx_list_free(encryption_list); } BC_ASSERT_FALSE(linphone_core_is_media_encryption_supported(marie->lc, paulineOptionalEncryption)); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(marie->lc, marieOptionalEncryption0)); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(marie->lc, marieOptionalEncryption1)); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(pauline->lc, paulineOptionalEncryption)); BC_ASSERT_FALSE(linphone_core_is_media_encryption_supported(pauline->lc, marieOptionalEncryption0)); BC_ASSERT_FALSE(linphone_core_is_media_encryption_supported(pauline->lc, marieOptionalEncryption1)); encrypted_call_base(marie, pauline, marieOptionalEncryption0, TRUE, TRUE, FALSE); if (linphone_core_get_current_call(marie->lc) && linphone_core_get_current_call(pauline->lc)) { end_call(marie, pauline); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_capability_negotiation_disable_call_level(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_capability_negociation(marie->lc, 1); linphone_core_set_media_encryption_mandatory(marie->lc, 0); linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionNone); bctbx_list_t *cfg_enc = create_confg_encryption_preference_list_except(LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(marie->lc, cfg_enc); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_enable_capability_negociation(pauline->lc, 1); linphone_core_set_media_encryption_mandatory(pauline->lc, 0); linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(pauline->lc, cfg_enc); bctbx_list_free(cfg_enc); encrypted_call_base(marie, pauline, LinphoneMediaEncryptionNone, FALSE, FALSE, FALSE); if (linphone_core_get_current_call(marie->lc) && linphone_core_get_current_call(pauline->lc)) { end_call(marie, pauline); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_capability_negotiation_disable_core_level(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_capability_negociation(marie->lc, 0); linphone_core_set_media_encryption_mandatory(marie->lc, 0); linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionNone); bctbx_list_t *cfg_enc = create_confg_encryption_preference_list_except(LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(marie->lc, cfg_enc); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_enable_capability_negociation(pauline->lc, 0); linphone_core_set_media_encryption_mandatory(pauline->lc, 0); linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(pauline->lc, cfg_enc); LinphoneMediaEncryption chosenMediaEnc = static_cast<LinphoneMediaEncryption>(LINPHONE_PTR_TO_INT(bctbx_list_get_data(cfg_enc))); encrypted_call_base(marie, pauline, chosenMediaEnc, TRUE, TRUE, FALSE); bctbx_list_free(cfg_enc); if (linphone_core_get_current_call(marie->lc) && linphone_core_get_current_call(pauline->lc)) { end_call(marie, pauline); } linphone_core_manager_destroy(marie);
1051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
linphone_core_manager_destroy(pauline); } static void call_with_incompatible_encs_in_call_params(void) { const LinphoneMediaEncryption defaultEncryption = LinphoneMediaEncryptionNone; const LinphoneMediaEncryption marieEncryption = LinphoneMediaEncryptionDTLS; // Desired encryption const LinphoneMediaEncryption paulineEncryption = LinphoneMediaEncryptionSRTP; // Desired encryption std::list<LinphoneMediaEncryption> marie_enc_list; if ((paulineEncryption != LinphoneMediaEncryptionZRTP) && (marieEncryption != LinphoneMediaEncryptionZRTP)) { marie_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if ((paulineEncryption != LinphoneMediaEncryptionDTLS) && (marieEncryption != LinphoneMediaEncryptionDTLS)) { marie_enc_list.push_back(LinphoneMediaEncryptionDTLS); } if ((paulineEncryption != LinphoneMediaEncryptionSRTP) && (marieEncryption != LinphoneMediaEncryptionSRTP)) { marie_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if ((paulineEncryption != LinphoneMediaEncryptionNone) && (marieEncryption != LinphoneMediaEncryptionNone)) { marie_enc_list.push_back(LinphoneMediaEncryptionNone); } encryption_params marie_enc_mgr_params; marie_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; marie_enc_mgr_params.level = E_OPTIONAL; marie_enc_mgr_params.preferences = marie_enc_list; LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_mgr_params, TRUE, FALSE, FALSE); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(marie->lc, marieEncryption)); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(marie->lc, paulineEncryption)); std::list<LinphoneMediaEncryption> pauline_enc_list; if ((paulineEncryption != LinphoneMediaEncryptionSRTP) && (marieEncryption != LinphoneMediaEncryptionSRTP)) { pauline_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if ((paulineEncryption != LinphoneMediaEncryptionZRTP) && (marieEncryption != LinphoneMediaEncryptionZRTP)) { pauline_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if ((paulineEncryption != LinphoneMediaEncryptionNone) && (marieEncryption != LinphoneMediaEncryptionNone)) { pauline_enc_list.push_back(LinphoneMediaEncryptionNone); } if ((paulineEncryption != LinphoneMediaEncryptionDTLS) && (marieEncryption != LinphoneMediaEncryptionDTLS)) { pauline_enc_list.push_back(LinphoneMediaEncryptionDTLS); } encryption_params pauline_enc_mgr_params; pauline_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_mgr_params.level = E_OPTIONAL; pauline_enc_mgr_params.preferences = pauline_enc_list; LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_mgr_params, TRUE, FALSE, FALSE); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(pauline->lc, marieEncryption)); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(pauline->lc, paulineEncryption)); bctbx_list_t *marie_call_enc = NULL; marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(marieEncryption)); LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, 1); linphone_call_params_set_supported_encryptions(marie_params, marie_call_enc); bctbx_list_free(marie_call_enc); bctbx_list_t *pauline_call_enc = NULL; pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(paulineEncryption)); LinphoneCallParams *pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, 1); linphone_call_params_set_supported_encryptions(pauline_params, pauline_call_enc); bctbx_list_free(pauline_call_enc);
1121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
// Check requirements for this test: // - encryption of Marie and Pauline should be different // - Marie and Pauline encryption list in the call params must be equal to 1 BC_ASSERT_NOT_EQUAL(paulineEncryption, marieEncryption, int, "%i"); bctbx_list_t *pauline_supported_encs = linphone_call_params_get_supported_encryptions(pauline_params); BC_ASSERT_EQUAL((int)bctbx_list_size(pauline_supported_encs), 1, int, "%d"); if (pauline_supported_encs) { bctbx_list_free(pauline_supported_encs); } bctbx_list_t *marie_supported_encs = linphone_call_params_get_supported_encryptions(marie_params); BC_ASSERT_EQUAL((int)bctbx_list_size(marie_supported_encs), 1, int, "%d"); if (marie_supported_encs) { bctbx_list_free(marie_supported_encs); } BC_ASSERT_TRUE( call_with_params_and_encryption_negotiation_failure_base(marie, pauline, marie_params, pauline_params, TRUE)); LinphoneCall *marieCall = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(marieCall); LinphoneCall *paulineCall = linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(paulineCall); liblinphone_tester_check_rtcp(marie, pauline); if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), defaultEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), defaultEncryption, int, "%i"); } end_call(pauline, marie); linphone_call_params_unref(marie_params); linphone_call_params_unref(pauline_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } void call_with_video_and_capability_negotiation_base(const LinphoneMediaEncryption encryption) { std::list<LinphoneMediaEncryption> marie_enc_list; if (encryption != LinphoneMediaEncryptionZRTP) { marie_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (encryption != LinphoneMediaEncryptionDTLS) { marie_enc_list.push_back(LinphoneMediaEncryptionDTLS); } if (encryption != LinphoneMediaEncryptionSRTP) { marie_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (encryption != LinphoneMediaEncryptionNone) { marie_enc_list.push_back(LinphoneMediaEncryptionNone); } encryption_params marie_enc_mgr_params; marie_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; marie_enc_mgr_params.level = E_OPTIONAL; marie_enc_mgr_params.preferences = marie_enc_list; LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_mgr_params, TRUE, FALSE, TRUE);
1191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260
BC_ASSERT_FALSE(linphone_core_media_encryption_supported(marie->lc, encryption)); std::list<LinphoneMediaEncryption> pauline_enc_list; if (encryption != LinphoneMediaEncryptionSRTP) { pauline_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (encryption != LinphoneMediaEncryptionZRTP) { pauline_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (encryption != LinphoneMediaEncryptionNone) { pauline_enc_list.push_back(LinphoneMediaEncryptionNone); } if (encryption != LinphoneMediaEncryptionDTLS) { pauline_enc_list.push_back(LinphoneMediaEncryptionDTLS); } encryption_params pauline_enc_mgr_params; pauline_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_mgr_params.level = E_OPTIONAL; pauline_enc_mgr_params.preferences = pauline_enc_list; LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_mgr_params, TRUE, FALSE, TRUE); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(pauline->lc, encryption)); bctbx_list_t *call_enc = NULL; call_enc = bctbx_list_append(call_enc, LINPHONE_INT_TO_PTR(encryption)); LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_video(marie_params, 1); linphone_call_params_enable_capability_negotiations(marie_params, 1); linphone_call_params_set_supported_encryptions(marie_params, call_enc); LinphoneCallParams *pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_video(pauline_params, 1); linphone_call_params_enable_capability_negotiations(pauline_params, 1); linphone_call_params_set_supported_encryptions(pauline_params, call_enc); bctbx_list_free(call_enc); BC_ASSERT_TRUE(call_with_params(marie, pauline, marie_params, pauline_params)); LinphoneCall *marieCall = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(marieCall); LinphoneCall *paulineCall = linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(paulineCall); const int expectedStreamsRunning = 2; BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, expectedStreamsRunning, int, "%i"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, expectedStreamsRunning, int, "%i"); if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), encryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), encryption, int, "%i"); } if (marieCall && paulineCall) { BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(marieCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(paulineCall))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marieCall))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(paulineCall))); /*check video path*/
1261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
liblinphone_tester_set_next_video_frame_decoded_cb(paulineCall); liblinphone_tester_set_next_video_frame_decoded_cb(marieCall); linphone_call_send_vfu_request(paulineCall); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_IframeDecoded, 1)); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_IframeDecoded, 1)); } liblinphone_tester_check_rtcp(pauline, marie); end_call(pauline, marie); linphone_call_params_unref(marie_params); linphone_call_params_unref(pauline_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_cfg_lines_merge_base(const bool_t caller_cfg_merge, const bool_t callee_cfg_merge) { encryption_params caller_enc_mgr_params; caller_enc_mgr_params.encryption = LinphoneMediaEncryptionZRTP; caller_enc_mgr_params.level = E_OPTIONAL; caller_enc_mgr_params.preferences = set_encryption_preference(TRUE); encryption_params callee_enc_mgr_params; callee_enc_mgr_params.encryption = LinphoneMediaEncryptionDTLS; callee_enc_mgr_params.level = E_OPTIONAL; callee_enc_mgr_params.preferences = set_encryption_preference(FALSE); LinphoneCoreManager *caller = create_core_mgr_with_capability_negotiation_setup("marie_rc", caller_enc_mgr_params, TRUE, FALSE, TRUE); LinphoneCoreManager *callee = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), callee_enc_mgr_params, TRUE, FALSE, TRUE); // Caller call params: // - RFC5939 is supported // - Merge pcfg lines // - Default encryption SRTP // - No mandatory encryption // - Supported optional encryptions: DTLS, ZRTP LinphoneCallParams *caller_params = linphone_core_create_call_params(caller->lc, NULL); linphone_call_params_enable_capability_negotiations(caller_params, TRUE); bctbx_list_t *caller_cfg_enc = NULL; caller_cfg_enc = bctbx_list_append(caller_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionSRTP)); caller_cfg_enc = bctbx_list_append(caller_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionDTLS)); caller_cfg_enc = bctbx_list_append(caller_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); linphone_call_params_set_supported_encryptions(caller_params, caller_cfg_enc); bctbx_list_free(caller_cfg_enc); linphone_call_params_set_media_encryption(caller_params, LinphoneMediaEncryptionNone); linphone_call_params_enable_mandatory_media_encryption(caller_params, 0); linphone_call_params_enable_cfg_lines_merging(caller_params, caller_cfg_merge); // Callee call params: // - RFC5939 is supported // - Merge pcfg lines // - Default encryption SRTP // - No mandatory encryption // - Supported optional encryptions: SRTP, ZRTP, DTLS LinphoneCallParams *callee_params = linphone_core_create_call_params(callee->lc, NULL); linphone_call_params_enable_capability_negotiations(callee_params, TRUE); bctbx_list_t *callee_cfg_enc = NULL; callee_cfg_enc = bctbx_list_append(callee_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); callee_cfg_enc = bctbx_list_append(callee_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionSRTP)); linphone_call_params_set_supported_encryptions(callee_params, callee_cfg_enc); bctbx_list_free(callee_cfg_enc); linphone_call_params_set_media_encryption(callee_params, LinphoneMediaEncryptionDTLS); linphone_call_params_enable_mandatory_media_encryption(callee_params, 0); linphone_call_params_enable_cfg_lines_merging(callee_params, callee_cfg_merge);
1331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
const LinphoneMediaEncryption expectedEncryption = LinphoneMediaEncryptionSRTP; encrypted_call_with_params_base(caller, callee, expectedEncryption, caller_params, callee_params, TRUE); LinphoneCall *callee_call = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(callee_call); if (callee_call) { BC_ASSERT_TRUE(linphone_call_params_cfg_lines_merged(linphone_call_get_params(callee_call)) == callee_cfg_merge); } LinphoneCall *caller_call = linphone_core_get_current_call(caller->lc); BC_ASSERT_PTR_NOT_NULL(caller_call); if (caller_call) { BC_ASSERT_TRUE(linphone_call_params_cfg_lines_merged(linphone_call_get_params(caller_call)) == caller_cfg_merge); end_call(caller, callee); } linphone_call_params_unref(caller_params); linphone_call_params_unref(callee_params); linphone_core_manager_destroy(caller); linphone_core_manager_destroy(callee); } static void call_with_no_cfg_lines_merge(void) { call_with_cfg_lines_merge_base(FALSE, FALSE); } static void call_with_cfg_lines_merge_on_caller(void) { call_with_cfg_lines_merge_base(TRUE, FALSE); } static void call_with_cfg_lines_merge_on_callee(void) { call_with_cfg_lines_merge_base(FALSE, TRUE); } static void call_with_cfg_lines_merge_on_both_sides(void) { call_with_cfg_lines_merge_base(TRUE, TRUE); } static void call_with_tcap_line_merge_base(const bool_t caller_tcap_merge, const bool_t callee_tcap_merge) { encryption_params caller_enc_mgr_params; caller_enc_mgr_params.encryption = LinphoneMediaEncryptionZRTP; caller_enc_mgr_params.level = E_OPTIONAL; caller_enc_mgr_params.preferences = set_encryption_preference(TRUE); encryption_params callee_enc_mgr_params; callee_enc_mgr_params.encryption = LinphoneMediaEncryptionDTLS; callee_enc_mgr_params.level = E_OPTIONAL; callee_enc_mgr_params.preferences = set_encryption_preference(FALSE); LinphoneCoreManager *caller = create_core_mgr_with_capability_negotiation_setup("marie_rc", caller_enc_mgr_params, TRUE, FALSE, TRUE); LinphoneCoreManager *callee = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), callee_enc_mgr_params, TRUE, FALSE, TRUE); // Caller call params: // - RFC5939 is supported // - Merge tcap lines // - Default encryption SRTP // - No mandatory encryption // - Supported optional encryptions: DTLS, ZRTP LinphoneCallParams *caller_params = linphone_core_create_call_params(caller->lc, NULL); linphone_call_params_enable_capability_negotiations(caller_params, TRUE); bctbx_list_t *caller_cfg_enc = NULL; caller_cfg_enc = bctbx_list_append(caller_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionDTLS)); caller_cfg_enc = bctbx_list_append(caller_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); linphone_call_params_set_supported_encryptions(caller_params, caller_cfg_enc);
1401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
bctbx_list_free(caller_cfg_enc); linphone_call_params_set_media_encryption(caller_params, LinphoneMediaEncryptionSRTP); linphone_call_params_enable_mandatory_media_encryption(caller_params, 0); linphone_call_params_enable_tcap_line_merging(caller_params, caller_tcap_merge); // Callee call params: // - RFC5939 is supported // - Merge tcap lines // - Default encryption SRTP // - No mandatory encryption // - Supported optional encryptions: SRTP, ZRTP, DTLS LinphoneCallParams *callee_params = linphone_core_create_call_params(callee->lc, NULL); linphone_call_params_enable_capability_negotiations(callee_params, TRUE); bctbx_list_t *callee_cfg_enc = NULL; callee_cfg_enc = bctbx_list_append(callee_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionSRTP)); callee_cfg_enc = bctbx_list_append(callee_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); callee_cfg_enc = bctbx_list_append(callee_cfg_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionDTLS)); linphone_call_params_set_supported_encryptions(callee_params, callee_cfg_enc); bctbx_list_free(callee_cfg_enc); linphone_call_params_set_media_encryption(callee_params, LinphoneMediaEncryptionNone); linphone_call_params_enable_mandatory_media_encryption(callee_params, 0); linphone_call_params_enable_tcap_line_merging(callee_params, callee_tcap_merge); const LinphoneMediaEncryption expectedEncryption = LinphoneMediaEncryptionDTLS; encrypted_call_with_params_base(caller, callee, expectedEncryption, caller_params, callee_params, TRUE); LinphoneCall *callee_call = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(callee_call); if (callee_call) { BC_ASSERT_TRUE(linphone_call_params_tcap_lines_merged(linphone_call_get_params(callee_call)) == callee_tcap_merge); } LinphoneCall *caller_call = linphone_core_get_current_call(caller->lc); BC_ASSERT_PTR_NOT_NULL(caller_call); if (caller_call) { BC_ASSERT_TRUE(linphone_call_params_tcap_lines_merged(linphone_call_get_params(caller_call)) == caller_tcap_merge); end_call(caller, callee); } linphone_call_params_unref(caller_params); linphone_call_params_unref(callee_params); linphone_core_manager_destroy(caller); linphone_core_manager_destroy(callee); } static void call_with_tcap_line_merge_on_caller(void) { call_with_tcap_line_merge_base(TRUE, FALSE); } static void call_with_tcap_line_merge_on_callee(void) { call_with_tcap_line_merge_base(FALSE, TRUE); } static void call_with_tcap_line_merge_on_both_sides(void) { call_with_tcap_line_merge_base(TRUE, TRUE); } static void call_with_no_sdp_on_update_base(const bool_t caller_cap_neg, const bool_t callee_cap_neg, const bool_t caller_cap_neg_reinvite, const bool_t callee_cap_neg_reinvite) { const LinphoneMediaEncryption encryption = LinphoneMediaEncryptionSRTP; // Desired encryption const LinphoneMediaEncryption encryption1 = LinphoneMediaEncryptionNone; // Desired encryption after first update const LinphoneMediaEncryption encryption2 = LinphoneMediaEncryptionZRTP; // Desired encryption after Marie's update LinphoneMediaEncryption marieEncryption = LinphoneMediaEncryptionNone; if (caller_cap_neg && callee_cap_neg) {
1471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540
marieEncryption = LinphoneMediaEncryptionDTLS; } else { marieEncryption = encryption; } std::list<LinphoneMediaEncryption> marie_enc_list; if (!caller_cap_neg || (encryption != LinphoneMediaEncryptionZRTP)) { marie_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (!caller_cap_neg || (encryption != LinphoneMediaEncryptionDTLS)) { marie_enc_list.push_back(LinphoneMediaEncryptionDTLS); } if (!caller_cap_neg || (encryption != LinphoneMediaEncryptionSRTP)) { marie_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (!caller_cap_neg || (encryption != LinphoneMediaEncryptionNone)) { marie_enc_list.push_back(LinphoneMediaEncryptionNone); } encryption_params marie_enc_mgr_params; marie_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; marie_enc_mgr_params.level = E_OPTIONAL; marie_enc_mgr_params.preferences = marie_enc_list; LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_mgr_params, caller_cap_neg, FALSE, TRUE); linphone_core_enable_capability_negotiation_reinvite(marie->lc, caller_cap_neg_reinvite); std::list<LinphoneMediaEncryption> pauline_enc_list; if (!callee_cap_neg || (encryption != LinphoneMediaEncryptionSRTP)) { pauline_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (!callee_cap_neg || (encryption != LinphoneMediaEncryptionZRTP)) { pauline_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (!callee_cap_neg || (encryption != LinphoneMediaEncryptionNone)) { pauline_enc_list.push_back(LinphoneMediaEncryptionNone); } if (!callee_cap_neg || (encryption != LinphoneMediaEncryptionDTLS)) { pauline_enc_list.push_back(LinphoneMediaEncryptionDTLS); } encryption_params pauline_enc_mgr_params; pauline_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_mgr_params.level = E_OPTIONAL; pauline_enc_mgr_params.preferences = pauline_enc_list; LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_mgr_params, callee_cap_neg, FALSE, TRUE); linphone_core_enable_capability_negotiation_reinvite(pauline->lc, callee_cap_neg_reinvite); bctbx_list_t *marie_call_enc = NULL; marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(encryption)); marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(encryption1)); LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, caller_cap_neg); linphone_call_params_set_supported_encryptions(marie_params, marie_call_enc); linphone_call_params_set_media_encryption(marie_params, marieEncryption); bctbx_list_free(marie_call_enc); bctbx_list_t *pauline_call_enc = NULL; pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); LinphoneCallParams *pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, callee_cap_neg); linphone_call_params_set_media_encryption(pauline_params, encryption); linphone_call_params_set_supported_encryptions(pauline_params, pauline_call_enc);
1541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610
bctbx_list_free(pauline_call_enc); // Different scenarios: // ==================== OFFERER ===================== // If offerer and answerer supports capability negotiations: // - actual configuration: DTLS // - potential configuration: SRTP // If offerer only supports capability negotiations: // - actual configuration: SRTP // - potential configuration: SRTP // If offerer doesn't support capability negotiations: // - actual configuration: SRTP // ==================== ANSWERER ===================== // If answerer supports capability negotiations: // - actual configuration: SRTP // - potential configuration: ZRTP // If answerer doesn't support capability negotiations: // - actual configuration: SRTP // ==================== RESULT ===================== // Result: encryption SRTP is chosen BC_ASSERT_TRUE(call_with_params(marie, pauline, marie_params, pauline_params)); LinphoneCall *marieCall = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(marieCall); LinphoneCall *paulineCall = linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(paulineCall); liblinphone_tester_check_rtcp(marie, pauline); LinphoneNatPolicy *marie_nat_policy = get_nat_policy_for_call(marie, marieCall); const bool_t marie_ice_enabled = linphone_nat_policy_ice_enabled(marie_nat_policy); LinphoneNatPolicy *pauline_nat_policy = get_nat_policy_for_call(pauline, paulineCall); const bool_t pauline_ice_enabled = linphone_nat_policy_ice_enabled(pauline_nat_policy); bool potentialConfigurationChosen = (caller_cap_neg && callee_cap_neg); bool_t capabilityNegotiationReinviteEnabled = linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(marieCall)); bool sendReInvite = (potentialConfigurationChosen && capabilityNegotiationReinviteEnabled) || (marie_ice_enabled && pauline_ice_enabled); int expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, expectedStreamsRunning, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, expectedStreamsRunning, int, "%d"); // Check that encryption has not changed after sending update if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), encryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), encryption, int, "%i"); } ms_message("Pauline sends a reINVITE without SDP"); // Pauline send an empty SDP for the update linphone_core_enable_sdp_200_ack(pauline->lc, TRUE); stats marie_stat = marie->stat; stats pauline_stat = pauline->stat; LinphoneCallParams *params0 = linphone_core_create_call_params(pauline->lc, paulineCall); if (caller_cap_neg && callee_cap_neg) { linphone_call_params_set_media_encryption(params0, encryption1); } bctbx_list_t *encs0 = NULL; encs0 = bctbx_list_append(encs0, LINPHONE_INT_TO_PTR(encryption1)); encs0 = bctbx_list_append(encs0, LINPHONE_INT_TO_PTR(encryption2)); linphone_call_params_set_supported_encryptions(params0, encs0);
1611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
bctbx_list_free(encs0); BC_ASSERT_TRUE(linphone_core_sdp_200_ack_enabled(pauline->lc)); linphone_call_update(paulineCall, params0); linphone_call_params_unref(params0); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallUpdating, (pauline_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallUpdatedByRemote, (marie_stat.number_of_LinphoneCallUpdatedByRemote + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + 1))); LinphoneMediaEncryption encryptionAfterUpdate = (caller_cap_neg && callee_cap_neg) ? encryption1 : encryption; LinphoneMediaEncryption expectedEncryption = LinphoneMediaEncryptionNone; bool dummyPotentialConfigurationChosen = false; get_expected_encryption_from_call_params(paulineCall, marieCall, &expectedEncryption, &dummyPotentialConfigurationChosen); // As Pauline sends a reINVITE without SDP, Marie replies with the same SDP as she previously sent hence it has the // same capability negotiation flags as the previous answer to the INVITE. A reINVITE is sent again if capability // negotiations are sent capabilityNegotiationReinviteEnabled = linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(marieCall)); sendReInvite = (potentialConfigurationChosen && capabilityNegotiationReinviteEnabled) || (marie_ice_enabled && pauline_ice_enabled); expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); linphone_core_enable_sdp_200_ack(pauline->lc, FALSE); liblinphone_tester_check_rtcp(marie, pauline); wait_for_until(marie->lc, pauline->lc, NULL, 5, 2000); // Check that encryption has not changed after sending update BC_ASSERT_EQUAL(expectedEncryption, encryptionAfterUpdate, int, "%i"); if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), expectedEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), expectedEncryption, int, "%i"); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); marie_stat = marie->stat; pauline_stat = pauline->stat; LinphoneCallParams *params1 = linphone_core_create_call_params(pauline->lc, paulineCall); linphone_call_params_enable_video(params1, TRUE); BC_ASSERT_FALSE(linphone_core_sdp_200_ack_enabled(pauline->lc)); ms_message("Pauline enables video"); linphone_call_update(paulineCall, params1); linphone_call_params_unref(params1); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallUpdating, (pauline_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallUpdatedByRemote,
1681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750
(marie_stat.number_of_LinphoneCallUpdatedByRemote + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + 1))); get_expected_encryption_from_call_params(paulineCall, marieCall, &expectedEncryption, &potentialConfigurationChosen); capabilityNegotiationReinviteEnabled = linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(paulineCall)); sendReInvite = (potentialConfigurationChosen && capabilityNegotiationReinviteEnabled); expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); // wait for reINVITEs to complete BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); if (pauline_ice_enabled && marie_ice_enabled) { BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection)); BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); } liblinphone_tester_set_next_video_frame_decoded_cb(marieCall); liblinphone_tester_set_next_video_frame_decoded_cb(paulineCall); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_IframeDecoded, (pauline_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_IframeDecoded, (marie_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(paulineCall))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marieCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(paulineCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(marieCall))); liblinphone_tester_check_rtcp(marie, pauline); wait_for_until(marie->lc, pauline->lc, NULL, 5, 2000); // Check that encryption has not changed after sending update BC_ASSERT_EQUAL(expectedEncryption, encryptionAfterUpdate, int, "%i"); if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), expectedEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), expectedEncryption, int, "%i"); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); // Marie send an empty SDP for the update linphone_core_enable_sdp_200_ack(marie->lc, TRUE); marie_stat = marie->stat; pauline_stat = pauline->stat; LinphoneCallParams *params2 = linphone_core_create_call_params(marie->lc, marieCall); linphone_call_params_set_media_encryption(params2, marieEncryption); bctbx_list_t *encs2 = NULL; encs2 = bctbx_list_append(encs2, LINPHONE_INT_TO_PTR(encryption2));
1751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820
encs2 = bctbx_list_append(encs2, LINPHONE_INT_TO_PTR(encryption)); linphone_call_params_set_supported_encryptions(params2, encs2); bctbx_list_free(encs2); BC_ASSERT_TRUE(linphone_core_sdp_200_ack_enabled(marie->lc)); ms_message("Marie sends a reINVITE without SDP"); linphone_call_update(marieCall, params2); linphone_call_params_unref(params2); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallUpdating, (marie_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, (pauline_stat.number_of_LinphoneCallUpdatedByRemote + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + 1))); encryptionAfterUpdate = (caller_cap_neg && callee_cap_neg) ? encryption2 : encryption; get_expected_encryption_from_call_params(marieCall, paulineCall, &expectedEncryption, &potentialConfigurationChosen); capabilityNegotiationReinviteEnabled = linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(paulineCall)); sendReInvite = (potentialConfigurationChosen && capabilityNegotiationReinviteEnabled); expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); // wait for reINVITEs to complete BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); linphone_core_enable_sdp_200_ack(marie->lc, FALSE); liblinphone_tester_set_next_video_frame_decoded_cb(marieCall); liblinphone_tester_set_next_video_frame_decoded_cb(paulineCall); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_IframeDecoded, (pauline_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_IframeDecoded, (marie_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(paulineCall))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marieCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(paulineCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(marieCall))); liblinphone_tester_check_rtcp(marie, pauline); wait_for_until(marie->lc, pauline->lc, NULL, 5, 2000); // Check that encryption has not changed after sending update BC_ASSERT_EQUAL(expectedEncryption, encryptionAfterUpdate, int, "%i"); if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), expectedEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), expectedEncryption, int, "%i"); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); end_call(pauline, marie);
1821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890
linphone_call_params_unref(marie_params); linphone_call_params_unref(pauline_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_no_sdp_on_update_cap_neg_caller(void) { call_with_no_sdp_on_update_base(TRUE, FALSE, TRUE, TRUE); } static void call_with_no_sdp_on_update_cap_neg_callee(void) { call_with_no_sdp_on_update_base(FALSE, TRUE, TRUE, TRUE); } static void call_with_no_sdp_on_update_cap_neg_both_sides_with_reinvite(void) { call_with_no_sdp_on_update_base(TRUE, TRUE, TRUE, TRUE); } static void call_with_no_sdp_on_update_cap_neg_both_sides_without_reinvite_on_caller(void) { call_with_no_sdp_on_update_base(TRUE, TRUE, FALSE, TRUE); } static void call_with_no_sdp_on_update_cap_neg_both_sides_without_reinvite_on_callee(void) { call_with_no_sdp_on_update_base(TRUE, TRUE, TRUE, FALSE); } static void call_with_no_sdp_on_update_cap_neg_both_sides_without_reinvite(void) { call_with_no_sdp_on_update_base(TRUE, TRUE, FALSE, FALSE); } static void call_changes_enc_on_update_base(const bool_t caller_cap_neg, const bool_t callee_cap_neg, const bool_t caller_cap_neg_reinvite, const bool_t callee_cap_neg_reinvite) { const LinphoneMediaEncryption encryption = LinphoneMediaEncryptionSRTP; // Desired encryption LinphoneMediaEncryption expectedEncryption = encryption; // Expected encryption LinphoneMediaEncryption marieEncryption = LinphoneMediaEncryptionNone; if (caller_cap_neg && callee_cap_neg) { marieEncryption = LinphoneMediaEncryptionDTLS; } else { marieEncryption = encryption; } std::list<LinphoneMediaEncryption> marie_enc_list; if (!caller_cap_neg || (encryption != LinphoneMediaEncryptionZRTP)) { marie_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (!caller_cap_neg || (encryption != LinphoneMediaEncryptionDTLS)) { marie_enc_list.push_back(LinphoneMediaEncryptionDTLS); } if (!caller_cap_neg || (encryption != LinphoneMediaEncryptionSRTP)) { marie_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (!caller_cap_neg || (encryption != LinphoneMediaEncryptionNone)) { marie_enc_list.push_back(LinphoneMediaEncryptionNone); } encryption_params marie_enc_mgr_params; marie_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; marie_enc_mgr_params.level = E_OPTIONAL; marie_enc_mgr_params.preferences = marie_enc_list; LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_mgr_params, caller_cap_neg, FALSE, TRUE); linphone_core_enable_capability_negotiation_reinvite(marie->lc, caller_cap_neg_reinvite); std::list<LinphoneMediaEncryption> pauline_enc_list;
1891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960
if (!callee_cap_neg || (encryption != LinphoneMediaEncryptionSRTP)) { pauline_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (!callee_cap_neg || (encryption != LinphoneMediaEncryptionZRTP)) { pauline_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (!callee_cap_neg || (encryption != LinphoneMediaEncryptionNone)) { pauline_enc_list.push_back(LinphoneMediaEncryptionNone); } if (!callee_cap_neg || (encryption != LinphoneMediaEncryptionDTLS)) { pauline_enc_list.push_back(LinphoneMediaEncryptionDTLS); } encryption_params pauline_enc_mgr_params; pauline_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_mgr_params.level = E_OPTIONAL; pauline_enc_mgr_params.preferences = pauline_enc_list; LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_mgr_params, callee_cap_neg, FALSE, TRUE); linphone_core_enable_capability_negotiation_reinvite(pauline->lc, callee_cap_neg_reinvite); bctbx_list_t *marie_call_enc = NULL; marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(encryption)); marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionDTLS)); LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, caller_cap_neg); linphone_call_params_set_supported_encryptions(marie_params, marie_call_enc); bctbx_list_free(marie_call_enc); linphone_call_params_set_media_encryption(marie_params, marieEncryption); bctbx_list_t *pauline_call_enc = NULL; pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); LinphoneCallParams *pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, callee_cap_neg); linphone_call_params_set_media_encryption(pauline_params, encryption); linphone_call_params_set_supported_encryptions(pauline_params, pauline_call_enc); bctbx_list_free(pauline_call_enc); // Different scenarios: // ==================== OFFERER ===================== // If offerer and answerer supports capability negotiations: // - actual configuration: DTLS // - potential configuration: SRTP and DTLS // If offerer only supports capability negotiations: // - actual configuration: SRTP // - potential configuration: SRTP and DTLS // If offerer doesn't support capability negotiations: // - actual configuration: SRTP // ==================== ANSWERER ===================== // If answerer supports capability negotiations: // - actual configuration: SRTP // - potential configuration: ZRTP // If answerer doesn't support capability negotiations: // - actual configuration: SRTP // ==================== RESULT ===================== // Result: encryption SRTP is chosen ms_message("SRTP Call from Marie to Pauline"); BC_ASSERT_TRUE(call_with_params(marie, pauline, marie_params, pauline_params)); LinphoneCall *marieCall = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(marieCall); LinphoneCall *paulineCall = linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(paulineCall); liblinphone_tester_check_rtcp(marie, pauline);
1961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030
LinphoneNatPolicy *marie_nat_policy = get_nat_policy_for_call(marie, marieCall); const bool_t marie_ice_enabled = linphone_nat_policy_ice_enabled(marie_nat_policy); LinphoneNatPolicy *pauline_nat_policy = get_nat_policy_for_call(pauline, paulineCall); const bool_t pauline_ice_enabled = linphone_nat_policy_ice_enabled(pauline_nat_policy); bool capabilityNegotiationReinviteEnabled = linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(marieCall)); bool sendReInvite = ((caller_cap_neg && callee_cap_neg && capabilityNegotiationReinviteEnabled) || (marie_ice_enabled && pauline_ice_enabled)); int expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, expectedStreamsRunning, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, expectedStreamsRunning, int, "%d"); // Check that encryption has not changed after sending update if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), expectedEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), expectedEncryption, int, "%i"); } // If capability negotiation is enabled on both sides, DTLS is chosen // Callee: // Optional encryptions: DTLS and ZRTP // Default: SRTP // Caller: // Optional encryptions: SRTP and DTLS // Default: SRTP if capability negotiation is disabled, DTLS otherwise stats marie_stat = marie->stat; stats pauline_stat = pauline->stat; LinphoneCallParams *params0 = linphone_core_create_call_params(pauline->lc, paulineCall); linphone_call_params_set_media_encryption(params0, encryption); linphone_call_params_enable_video(params0, TRUE); bctbx_list_t *pauline_call_enc0 = NULL; if (caller_cap_neg && callee_cap_neg) { expectedEncryption = LinphoneMediaEncryptionDTLS; } ms_message("Pauline changes encryption to %s", linphone_media_encryption_to_string(expectedEncryption)); pauline_call_enc0 = bctbx_list_append(pauline_call_enc0, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionDTLS)); pauline_call_enc0 = bctbx_list_append(pauline_call_enc0, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); linphone_call_params_set_supported_encryptions(params0, pauline_call_enc0); bctbx_list_free(pauline_call_enc0); linphone_call_update(paulineCall, params0); linphone_call_params_unref(params0); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallUpdating, (pauline_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallUpdatedByRemote, (marie_stat.number_of_LinphoneCallUpdatedByRemote + 1))); capabilityNegotiationReinviteEnabled = linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(paulineCall)); sendReInvite = (caller_cap_neg && callee_cap_neg && capabilityNegotiationReinviteEnabled); expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); if (pauline_ice_enabled && marie_ice_enabled) { BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection)); BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); }
2031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100
liblinphone_tester_set_next_video_frame_decoded_cb(marieCall); liblinphone_tester_set_next_video_frame_decoded_cb(paulineCall); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_IframeDecoded, (pauline_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_IframeDecoded, (marie_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(paulineCall))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marieCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(paulineCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(marieCall))); liblinphone_tester_check_rtcp(marie, pauline); // Check that encryption has not changed after sending update if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), expectedEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), expectedEncryption, int, "%i"); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); // If capability negotiation is enabled on both sides, DTLS is chosen // Callee: // Optional encryptions: DTLS and ZRTP // Default: SRTP // Caller: // Optional encryptions: ZRTP and DTLS // Default: SRTP if capability negotiation is disabled, DTLS otherwise marie_stat = marie->stat; pauline_stat = pauline->stat; LinphoneCallParams *params1 = linphone_core_create_call_params(marie->lc, marieCall); linphone_call_params_set_media_encryption(params1, marieEncryption); bctbx_list_t *marie_call_enc1 = NULL; if (caller_cap_neg && callee_cap_neg) { expectedEncryption = LinphoneMediaEncryptionZRTP; } ms_message("Marie changes encryption to %s", linphone_media_encryption_to_string(expectedEncryption)); marie_call_enc1 = bctbx_list_append(marie_call_enc1, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); marie_call_enc1 = bctbx_list_append(marie_call_enc1, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionDTLS)); linphone_call_params_set_supported_encryptions(params1, marie_call_enc1); bctbx_list_free(marie_call_enc1); linphone_call_update(marieCall, params1); linphone_call_params_unref(params1); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallUpdating, (marie_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallUpdatedByRemote, (pauline_stat.number_of_LinphoneCallUpdatedByRemote + 1))); capabilityNegotiationReinviteEnabled = linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(marieCall)); sendReInvite = (caller_cap_neg && callee_cap_neg && capabilityNegotiationReinviteEnabled); expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning)));
2101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170
liblinphone_tester_set_next_video_frame_decoded_cb(marieCall); liblinphone_tester_set_next_video_frame_decoded_cb(paulineCall); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_IframeDecoded, (pauline_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_IframeDecoded, (marie_stat.number_of_IframeDecoded + 1))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(paulineCall))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marieCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(paulineCall))); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(marieCall))); if ((expectedEncryption == LinphoneMediaEncryptionDTLS) || (expectedEncryption == LinphoneMediaEncryptionZRTP)) { BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallEncryptedOn, marie_stat.number_of_LinphoneCallEncryptedOn + 1, 10000)); BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallEncryptedOn, pauline_stat.number_of_LinphoneCallEncryptedOn + 1, 10000)); } liblinphone_tester_check_rtcp(marie, pauline); // Check that encryption has not changed after sending update if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), expectedEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), expectedEncryption, int, "%i"); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); end_call(pauline, marie); linphone_call_params_unref(marie_params); linphone_call_params_unref(pauline_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_changes_enc_on_update_cap_neg_caller(void) { call_changes_enc_on_update_base(TRUE, FALSE, TRUE, TRUE); } static void call_changes_enc_on_update_cap_neg_callee(void) { call_changes_enc_on_update_base(FALSE, TRUE, TRUE, TRUE); } static void call_changes_enc_on_update_cap_neg_both_sides_with_reinvite(void) { call_changes_enc_on_update_base(TRUE, TRUE, TRUE, TRUE); } static void call_changes_enc_on_update_cap_neg_both_sides_without_reinvite(void) { call_changes_enc_on_update_base(TRUE, TRUE, FALSE, FALSE); } static void back_to_back_calls_cap_neg_base(bool_t enable_cap_neg_both_sides) { std::list<LinphoneMediaEncryption> marie_enc_list; marie_enc_list.push_back(LinphoneMediaEncryptionNone);
2171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240
encryption_params marie_enc_mgr_params; marie_enc_mgr_params.encryption = LinphoneMediaEncryptionZRTP; marie_enc_mgr_params.level = E_OPTIONAL; marie_enc_mgr_params.preferences = marie_enc_list; LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_mgr_params, TRUE, FALSE, TRUE); std::list<LinphoneMediaEncryption> pauline_enc_list; pauline_enc_list.push_back(LinphoneMediaEncryptionNone); encryption_params pauline_enc_mgr_params; pauline_enc_mgr_params.encryption = LinphoneMediaEncryptionSRTP; pauline_enc_mgr_params.level = E_OPTIONAL; pauline_enc_mgr_params.preferences = pauline_enc_list; LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_mgr_params, TRUE, FALSE, TRUE); LinphoneMediaEncryption encryption = LinphoneMediaEncryptionDTLS; // Expected encryption LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, 1); linphone_call_params_set_media_encryption(marie_params, encryption); bctbx_list_t *marie_call_enc = NULL; marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionSRTP)); marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(encryption)); linphone_call_params_set_supported_encryptions(marie_params, marie_call_enc); bctbx_list_free(marie_call_enc); marie_call_enc = NULL; LinphoneCallParams *pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, enable_cap_neg_both_sides); linphone_call_params_set_media_encryption(pauline_params, encryption); bctbx_list_t *pauline_call_enc = NULL; pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionNone)); pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(encryption)); linphone_call_params_set_supported_encryptions(pauline_params, pauline_call_enc); bctbx_list_free(pauline_call_enc); pauline_call_enc = NULL; // TODO: Delete the following 2 lines when relying only on call params to check validity of SDP linphone_core_set_media_encryption(pauline->lc, encryption); linphone_core_set_media_encryption(marie->lc, encryption); // Caller (Marie) supports SRTP and DTLS as potential configurations and DTLS as default one // Callee (Pauline) supports ZRTP, no encryption and DTLS as potential configurations and DTLS as default one // DTLS is expected to be chosen encrypted_call_with_params_base(marie, pauline, encryption, marie_params, pauline_params, TRUE); if (linphone_core_get_current_call(marie->lc)) { end_call(marie, pauline); } encryption = LinphoneMediaEncryptionSRTP; if (marie_params) { linphone_call_params_unref(marie_params); marie_params = NULL; } marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, 1); linphone_call_params_set_media_encryption(marie_params, encryption); if (marie_call_enc) { bctbx_list_free(marie_call_enc); marie_call_enc = NULL; } marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(encryption)); linphone_call_params_set_supported_encryptions(marie_params, marie_call_enc); bctbx_list_free(marie_call_enc);
2241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310
marie_call_enc = NULL; if (pauline_params) { linphone_call_params_unref(pauline_params); pauline_params = NULL; } pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, enable_cap_neg_both_sides); linphone_call_params_set_media_encryption(pauline_params, encryption); if (pauline_call_enc) { bctbx_list_free(pauline_call_enc); pauline_call_enc = NULL; } pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionDTLS)); pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionNone)); pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(encryption)); linphone_call_params_set_supported_encryptions(pauline_params, pauline_call_enc); bctbx_list_free(pauline_call_enc); pauline_call_enc = NULL; // TODO: Delete the following 2 lines when relying only on call params to check validity of SDP linphone_core_set_media_encryption(pauline->lc, encryption); linphone_core_set_media_encryption(marie->lc, encryption); // Caller (Pauline) supports DTLS, no encryption and SRTP as potential configurations and SRTP as default one // Callee (Marie) supports ZRTP and SRTP as potential configurations and SRTP as default one // DTLS is expected to be chosen encrypted_call_with_params_base(pauline, marie, encryption, marie_params, pauline_params, TRUE); if (linphone_core_get_current_call(pauline->lc)) { end_call(pauline, marie); } encryption = LinphoneMediaEncryptionZRTP; if (marie_params) { linphone_call_params_unref(marie_params); marie_params = NULL; } marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, 1); linphone_call_params_set_media_encryption(marie_params, encryption); if (marie_call_enc) { bctbx_list_free(marie_call_enc); marie_call_enc = NULL; } marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionNone)); marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionZRTP)); marie_call_enc = bctbx_list_append(marie_call_enc, LINPHONE_INT_TO_PTR(encryption)); linphone_call_params_set_supported_encryptions(marie_params, marie_call_enc); bctbx_list_free(marie_call_enc); marie_call_enc = NULL; if (pauline_params) { linphone_call_params_unref(pauline_params); pauline_params = NULL; } pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, enable_cap_neg_both_sides); linphone_call_params_set_media_encryption(pauline_params, encryption); if (pauline_call_enc) { bctbx_list_free(pauline_call_enc); pauline_call_enc = NULL; } pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionDTLS)); pauline_call_enc = bctbx_list_append(pauline_call_enc, LINPHONE_INT_TO_PTR(encryption)); linphone_call_params_set_supported_encryptions(pauline_params, pauline_call_enc); bctbx_list_free(pauline_call_enc); pauline_call_enc = NULL; // TODO: Delete the following 2 lines when relying only on call params to check validity of SDP linphone_core_set_media_encryption(pauline->lc, encryption);
2311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380
linphone_core_set_media_encryption(marie->lc, encryption); // Caller (Marie) supports SRTP, DTLS and ZRTP as potential configurations and ZRTP as default one // Callee (Pauline) supports no encryption and ZRTP as potential configurations and ZRTP as default one // DTLS is expected to be chosen encrypted_call_with_params_base(pauline, marie, encryption, marie_params, pauline_params, TRUE); if (linphone_core_get_current_call(pauline->lc)) { end_call(pauline, marie); } if (marie_call_enc) { bctbx_list_free(marie_call_enc); marie_call_enc = NULL; } if (pauline_call_enc) { bctbx_list_free(pauline_call_enc); pauline_call_enc = NULL; } if (marie_params) { linphone_call_params_unref(marie_params); marie_params = NULL; } if (pauline_params) { linphone_call_params_unref(pauline_params); pauline_params = NULL; } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void back_to_back_calls_cap_neg_one_side(void) { back_to_back_calls_cap_neg_base(FALSE); } static void back_to_back_calls_cap_neg_both_sides(void) { back_to_back_calls_cap_neg_base(TRUE); } static void call_with_update_and_incompatible_encs_in_call_params(void) { call_with_update_and_incompatible_encs_in_call_params_base(FALSE); } void call_with_encryption_supported_in_call_params_only_base(const LinphoneMediaEncryption encryption) { std::list<LinphoneMediaEncryption> marie_enc_list; if (encryption != LinphoneMediaEncryptionZRTP) { marie_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (encryption != LinphoneMediaEncryptionDTLS) { marie_enc_list.push_back(LinphoneMediaEncryptionDTLS); } if (encryption != LinphoneMediaEncryptionSRTP) { marie_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (encryption != LinphoneMediaEncryptionNone) { marie_enc_list.push_back(LinphoneMediaEncryptionNone); } encryption_params marie_enc_mgr_params; marie_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; marie_enc_mgr_params.level = E_OPTIONAL; marie_enc_mgr_params.preferences = marie_enc_list; LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_mgr_params, TRUE, FALSE, FALSE); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(marie->lc, encryption)); std::list<LinphoneMediaEncryption> pauline_enc_list; if (encryption != LinphoneMediaEncryptionSRTP) { pauline_enc_list.push_back(LinphoneMediaEncryptionSRTP);
2381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450
} if (encryption != LinphoneMediaEncryptionZRTP) { pauline_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (encryption != LinphoneMediaEncryptionNone) { pauline_enc_list.push_back(LinphoneMediaEncryptionNone); } if (encryption != LinphoneMediaEncryptionDTLS) { pauline_enc_list.push_back(LinphoneMediaEncryptionDTLS); } encryption_params pauline_enc_mgr_params; pauline_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_mgr_params.level = E_OPTIONAL; pauline_enc_mgr_params.preferences = pauline_enc_list; LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_mgr_params, TRUE, FALSE, FALSE); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(pauline->lc, encryption)); bctbx_list_t *call_enc = NULL; call_enc = bctbx_list_append(call_enc, LINPHONE_INT_TO_PTR(encryption)); LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, 1); linphone_call_params_set_supported_encryptions(marie_params, call_enc); LinphoneCallParams *pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, 1); linphone_call_params_set_supported_encryptions(pauline_params, call_enc); bctbx_list_free(call_enc); BC_ASSERT_TRUE(call_with_params(marie, pauline, marie_params, pauline_params)); LinphoneCall *marieCall = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(marieCall); LinphoneCall *paulineCall = linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(paulineCall); liblinphone_tester_check_rtcp(marie, pauline); const int expectedStreamsRunning = 2; BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, expectedStreamsRunning, int, "%i"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, expectedStreamsRunning, int, "%i"); if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), encryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), encryption, int, "%i"); } end_call(pauline, marie); linphone_call_params_unref(marie_params); linphone_call_params_unref(pauline_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } void call_with_default_encryption(const LinphoneMediaEncryption encryption) { std::list<LinphoneMediaEncryption> marie_enc_list; if (encryption != LinphoneMediaEncryptionZRTP) {
2451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520
marie_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (encryption != LinphoneMediaEncryptionDTLS) { marie_enc_list.push_back(LinphoneMediaEncryptionDTLS); } if (encryption != LinphoneMediaEncryptionSRTP) { marie_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (encryption != LinphoneMediaEncryptionNone) { marie_enc_list.push_back(LinphoneMediaEncryptionNone); } encryption_params marie_enc_mgr_params; marie_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; marie_enc_mgr_params.level = E_OPTIONAL; marie_enc_mgr_params.preferences = marie_enc_list; LinphoneCoreManager *marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_mgr_params, TRUE, FALSE, TRUE); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(marie->lc, encryption)); std::list<LinphoneMediaEncryption> pauline_enc_list; if (encryption != LinphoneMediaEncryptionSRTP) { pauline_enc_list.push_back(LinphoneMediaEncryptionSRTP); } if (encryption != LinphoneMediaEncryptionZRTP) { pauline_enc_list.push_back(LinphoneMediaEncryptionZRTP); } if (encryption != LinphoneMediaEncryptionNone) { pauline_enc_list.push_back(LinphoneMediaEncryptionNone); } if (encryption != LinphoneMediaEncryptionDTLS) { pauline_enc_list.push_back(LinphoneMediaEncryptionDTLS); } encryption_params pauline_enc_mgr_params; pauline_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_mgr_params.level = E_OPTIONAL; pauline_enc_mgr_params.preferences = pauline_enc_list; LinphoneCoreManager *pauline = create_core_mgr_with_capability_negotiation_setup( (transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_mgr_params, TRUE, FALSE, TRUE); BC_ASSERT_FALSE(linphone_core_media_encryption_supported(pauline->lc, encryption)); LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); linphone_call_params_enable_capability_negotiations(marie_params, 1); linphone_call_params_set_media_encryption(marie_params, encryption); LinphoneCallParams *pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_capability_negotiations(pauline_params, 1); linphone_call_params_set_media_encryption(pauline_params, encryption); encrypted_call_with_params_base(marie, pauline, marie_enc_list.front(), marie_params, pauline_params, TRUE); if (linphone_core_get_current_call(marie->lc)) { end_call(marie, pauline); } linphone_call_params_unref(marie_params); linphone_call_params_unref(pauline_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } void call_with_potential_configuration_same_as_actual_configuration_base(const LinphoneMediaEncryption encryption) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_capability_negociation(marie->lc, 1); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590
linphone_core_enable_capability_negociation(pauline->lc, 1); BC_ASSERT_TRUE(linphone_core_media_encryption_supported(pauline->lc, encryption)); if (linphone_core_media_encryption_supported(pauline->lc, encryption)) { bctbx_list_t *encryption_list = NULL; encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(encryption)); linphone_core_set_media_encryption_mandatory(pauline->lc, 0); linphone_core_set_media_encryption(pauline->lc, encryption); linphone_core_set_supported_media_encryptions(pauline->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(pauline->lc, encryption)); if (encryption_list) { bctbx_list_free(encryption_list); } } linphone_core_set_media_encryption_mandatory(marie->lc, 0); linphone_core_set_media_encryption(marie->lc, encryption); // Desired encryption is put last bctbx_list_t *encryption_list = create_confg_encryption_preference_list_from_param_preferences( set_encryption_preference_with_priority(encryption, true)); linphone_core_set_supported_media_encryptions(marie->lc, encryption_list); if (encryption_list) { bctbx_list_free(encryption_list); } BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(marie->lc, encryption)); BC_ASSERT_TRUE(linphone_core_get_media_encryption(marie->lc) == encryption); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(pauline->lc, encryption)); BC_ASSERT_TRUE(linphone_core_get_media_encryption(pauline->lc) == encryption); encrypted_call_base(marie, pauline, encryption, TRUE, TRUE, FALSE); if (linphone_core_get_current_call(marie->lc) && linphone_core_get_current_call(pauline->lc)) { end_call(marie, pauline); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void unencrypted_call_with_potential_configuration_same_as_actual_configuration(void) { call_with_potential_configuration_same_as_actual_configuration_base(LinphoneMediaEncryptionNone); } void simple_call_with_capability_negotiations_removed_after_update(LinphoneCoreManager *caller, LinphoneCoreManager *callee, const LinphoneMediaEncryption optionalEncryption) { linphone_core_enable_capability_negociation(caller->lc, 1); linphone_core_enable_capability_negociation(callee->lc, 1); bctbx_list_t *encryption_list = NULL; encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(optionalEncryption)); BC_ASSERT_TRUE(linphone_core_media_encryption_supported(callee->lc, optionalEncryption)); if (linphone_core_media_encryption_supported(callee->lc, optionalEncryption)) { linphone_core_set_media_encryption_mandatory(callee->lc, 0); linphone_core_set_media_encryption(callee->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(callee->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(callee->lc, optionalEncryption)); } BC_ASSERT_TRUE(linphone_core_media_encryption_supported(caller->lc, optionalEncryption)); if (linphone_core_media_encryption_supported(caller->lc, optionalEncryption)) { linphone_core_set_media_encryption_mandatory(caller->lc, 0); linphone_core_set_media_encryption(caller->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(caller->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(caller->lc, optionalEncryption)); } if (encryption_list) { bctbx_list_free(encryption_list); }
2591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660
encrypted_call_base(caller, callee, optionalEncryption, TRUE, TRUE, FALSE); LinphoneCall *callerCall = linphone_core_get_current_call(caller->lc); BC_ASSERT_PTR_NOT_NULL(callerCall); LinphoneCall *calleeCall = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(calleeCall); stats caller_stat = caller->stat; stats callee_stat = callee->stat; LinphoneCallParams *params0 = linphone_core_create_call_params(callee->lc, calleeCall); linphone_call_params_enable_capability_negotiations(params0, FALSE); linphone_call_update(calleeCall, params0); linphone_call_params_unref(params0); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallUpdating, (callee_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallUpdatedByRemote, (caller_stat.number_of_LinphoneCallUpdatedByRemote + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + 1))); LinphoneMediaEncryption encryptionAfterUpdate = LinphoneMediaEncryptionNone; LinphoneMediaEncryption expectedEncryption = LinphoneMediaEncryptionNone; bool dummyPotentialConfigurationChosen = false; get_expected_encryption_from_call_params(calleeCall, callerCall, &expectedEncryption, &dummyPotentialConfigurationChosen); int expectedStreamsRunning = 1; BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); liblinphone_tester_check_rtcp(caller, callee); // Check that encryption has not changed after sending update BC_ASSERT_EQUAL(expectedEncryption, encryptionAfterUpdate, int, "%i"); if (callerCall) { check_stream_encryption(callerCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), expectedEncryption, int, "%i"); } if (calleeCall) { check_stream_encryption(calleeCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), expectedEncryption, int, "%i"); } wait_for_until(callee->lc, caller->lc, NULL, 5, 2000); caller_stat = caller->stat; callee_stat = callee->stat; LinphoneCallParams *params1 = linphone_core_create_call_params(caller->lc, callerCall); linphone_call_update(callerCall, params1); linphone_call_params_unref(params1); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallUpdating, (caller_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallUpdatedByRemote, (callee_stat.number_of_LinphoneCallUpdatedByRemote + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + 1))); get_expected_encryption_from_call_params(calleeCall, callerCall, &expectedEncryption, &dummyPotentialConfigurationChosen);
2661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730
liblinphone_tester_check_rtcp(caller, callee); // Check that encryption has not changed after sending update BC_ASSERT_EQUAL(expectedEncryption, encryptionAfterUpdate, int, "%i"); if (callerCall) { check_stream_encryption(callerCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), expectedEncryption, int, "%i"); } if (calleeCall) { check_stream_encryption(calleeCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), expectedEncryption, int, "%i"); } wait_for_until(callee->lc, caller->lc, NULL, 5, 2000); BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning), int, "%d"); if (callerCall && calleeCall) { end_call(caller, callee); } } void simple_call_with_capability_negotiations(LinphoneCoreManager *caller, LinphoneCoreManager *callee, const LinphoneMediaEncryption optionalEncryption, const LinphoneMediaEncryption expectedEncryption) { linphone_core_enable_capability_negociation(caller->lc, 1); linphone_core_enable_capability_negociation(callee->lc, 1); bctbx_list_t *encryption_list = NULL; encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(optionalEncryption)); BC_ASSERT_TRUE(linphone_core_media_encryption_supported(callee->lc, optionalEncryption)); if (linphone_core_media_encryption_supported(callee->lc, optionalEncryption)) { linphone_core_set_media_encryption_mandatory(callee->lc, 0); linphone_core_set_media_encryption(callee->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(callee->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(callee->lc, optionalEncryption)); } BC_ASSERT_TRUE(linphone_core_media_encryption_supported(caller->lc, optionalEncryption)); if (linphone_core_media_encryption_supported(caller->lc, optionalEncryption)) { linphone_core_set_media_encryption_mandatory(caller->lc, 0); linphone_core_set_media_encryption(caller->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(caller->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(caller->lc, optionalEncryption)); } if (encryption_list) { bctbx_list_free(encryption_list); } encrypted_call_base(caller, callee, expectedEncryption, TRUE, TRUE, FALSE); pause_resume_calls(caller, callee); if (linphone_core_get_current_call(caller->lc) && linphone_core_get_current_call(callee->lc)) { end_call(caller, callee); } } static void call_with_no_sdp_cap_neg_on_caller(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_sdp_200_ack(marie->lc, TRUE); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
2731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800
simple_call_with_capability_negotiations(marie, pauline, LinphoneMediaEncryptionSRTP, LinphoneMediaEncryptionSRTP); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_no_sdp_cap_neg_on_callee(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_enable_sdp_200_ack(pauline->lc, TRUE); simple_call_with_capability_negotiations(marie, pauline, LinphoneMediaEncryptionSRTP, LinphoneMediaEncryptionSRTP); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_no_sdp_cap_neg_on_both_sides(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_sdp_200_ack(marie->lc, TRUE); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_enable_sdp_200_ack(pauline->lc, TRUE); simple_call_with_capability_negotiations(marie, pauline, LinphoneMediaEncryptionSRTP, LinphoneMediaEncryptionSRTP); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_avpf_and_cap_neg_on_caller(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_set_avpf_mode(marie->lc, LinphoneAVPFEnabled); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); simple_call_with_capability_negotiations(marie, pauline, LinphoneMediaEncryptionSRTP, LinphoneMediaEncryptionSRTP); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_avpf_and_cap_neg_on_callee(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_set_avpf_mode(pauline->lc, LinphoneAVPFEnabled); simple_call_with_capability_negotiations(marie, pauline, LinphoneMediaEncryptionSRTP, LinphoneMediaEncryptionSRTP); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_avpf_and_cap_neg_on_both_sides(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_set_avpf_mode(marie->lc, LinphoneAVPFEnabled); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_enable_sdp_200_ack(pauline->lc, TRUE); linphone_core_set_avpf_mode(pauline->lc, LinphoneAVPFEnabled); simple_call_with_capability_negotiations(marie, pauline, LinphoneMediaEncryptionSRTP, LinphoneMediaEncryptionSRTP); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } void simple_call_with_capability_negotiations_with_different_encryption_after_resume( LinphoneCoreManager *caller, LinphoneCoreManager *callee, const LinphoneMediaEncryption optionalEncryption, const LinphoneMediaEncryption encryptionAfterResume) { linphone_core_enable_capability_negociation(caller->lc, 1); linphone_core_enable_capability_negociation(callee->lc, 1); bctbx_list_t *encryption_list = NULL; encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(optionalEncryption)); BC_ASSERT_TRUE(linphone_core_media_encryption_supported(callee->lc, optionalEncryption)); if (linphone_core_media_encryption_supported(callee->lc, optionalEncryption)) {
2801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870
linphone_core_set_media_encryption_mandatory(callee->lc, 0); linphone_core_set_media_encryption(callee->lc, encryptionAfterResume); linphone_core_set_supported_media_encryptions(callee->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(callee->lc, optionalEncryption)); } BC_ASSERT_TRUE(linphone_core_media_encryption_supported(caller->lc, optionalEncryption)); if (linphone_core_media_encryption_supported(caller->lc, optionalEncryption)) { linphone_core_set_media_encryption_mandatory(caller->lc, 0); if (optionalEncryption == LinphoneMediaEncryptionZRTP) { linphone_core_set_media_encryption(caller->lc, (encryptionAfterResume == LinphoneMediaEncryptionDTLS) ? LinphoneMediaEncryptionSRTP : LinphoneMediaEncryptionDTLS); } else { linphone_core_set_media_encryption(caller->lc, LinphoneMediaEncryptionNone); } linphone_core_set_supported_media_encryptions(caller->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(caller->lc, optionalEncryption)); } if (encryption_list) { bctbx_list_free(encryption_list); encryption_list = NULL; } encrypted_call_base(caller, callee, optionalEncryption, TRUE, TRUE, FALSE); LinphoneCall *callerCall = linphone_core_get_current_call(caller->lc); BC_ASSERT_PTR_NOT_NULL(callerCall); LinphoneCall *calleeCall = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(calleeCall); if (calleeCall && callerCall) { // Pause callee call BC_ASSERT_TRUE(pause_call_1(callee, calleeCall, caller, callerCall)); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); // Resume callee call reset_counters(&caller->stat); reset_counters(&callee->stat); stats caller_stat = caller->stat; stats callee_stat = callee->stat; // Update call params before resuming call LinphoneCallParams *callerParams = linphone_core_create_call_params(caller->lc, callerCall); encryption_list = bctbx_list_append(NULL, LINPHONE_INT_TO_PTR(encryptionAfterResume)); linphone_call_params_set_supported_encryptions(callerParams, encryption_list); if (encryption_list) { bctbx_list_free(encryption_list); encryption_list = NULL; } L_GET_PRIVATE(std::static_pointer_cast<LinphonePrivate::MediaSession>( LinphonePrivate::Call::toCpp(callerCall)->getActiveSession())) ->setParams(new LinphonePrivate::MediaSessionParams(*L_GET_CPP_PTR_FROM_C_OBJECT(callerParams))); linphone_call_params_unref(callerParams); linphone_call_resume(calleeCall); LinphoneMediaEncryption encryption = LinphoneMediaEncryptionNone; BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallResuming, callee_stat.number_of_LinphoneCallResuming + 1)); if (encryptionAfterResume == optionalEncryption) { BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, callee_stat.number_of_LinphoneCallStreamsRunning + 1)); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, caller_stat.number_of_LinphoneCallStreamsRunning + 1)); bool potentialConfigurationChosen = false; get_expected_encryption_from_call_params(calleeCall, callerCall, &encryption, &potentialConfigurationChosen);
2871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940
int expectedStreamsRunning = 1 + ((potentialConfigurationChosen) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_EQUAL(encryptionAfterResume, encryption, int, "%i"); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); liblinphone_tester_check_rtcp(caller, callee); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(caller), 70, int, "%i"); LinphoneCallStats *calleeStats = linphone_call_get_audio_stats(linphone_core_get_current_call(callee->lc)); BC_ASSERT_GREATER((int)linphone_call_stats_get_download_bandwidth(calleeStats), 70, int, "%i"); linphone_call_stats_unref(calleeStats); calleeStats = NULL; if ((encryption == LinphoneMediaEncryptionDTLS) || (encryption == LinphoneMediaEncryptionZRTP)) { BC_ASSERT_TRUE(wait_for_until(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallEncryptedOn, caller_stat.number_of_LinphoneCallEncryptedOn + 1, 10000)); BC_ASSERT_TRUE(wait_for_until(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallEncryptedOn, callee_stat.number_of_LinphoneCallEncryptedOn + 1, 10000)); } } else { encryption = optionalEncryption; // Resume fails because requested encryption is not supported BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallPaused, callee_stat.number_of_LinphoneCallPaused + 1)); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); BC_ASSERT_LOWER(caller->stat.number_of_rtcp_received, 5, int, "%d"); BC_ASSERT_LOWER(callee->stat.number_of_rtcp_received, 5, int, "%d"); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(caller), 0, int, "%i"); LinphoneCall *calleeCall2 = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(calleeCall2); if (calleeCall2) { LinphoneCallStats *calleeStats = linphone_call_get_audio_stats(calleeCall2); BC_ASSERT_EQUAL((int)linphone_call_stats_get_download_bandwidth(calleeStats), 0, int, "%d"); linphone_call_stats_unref(calleeStats); calleeStats = NULL; } } if (calleeCall) { check_stream_encryption(calleeCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), encryption, int, "%i"); } if (callerCall) { check_stream_encryption(callerCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), encryption, int, "%i"); } /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/ const rtp_stats_t *stats = rtp_session_get_stats(linphone_call_get_stream(calleeCall, LinphoneStreamTypeAudio)->sessions.rtp_session); BC_ASSERT_LOWER((int)stats->cum_packet_loss, 10, int, "%d"); end_call(caller, callee); } } void simple_call_with_capability_negotiations_with_resume_and_media_change_base(
2941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010
LinphoneCoreManager *caller, LinphoneCoreManager *callee, const LinphoneMediaEncryption optionalEncryption, const LinphoneMediaEncryption encryptionAfterResume) { linphone_core_enable_capability_negociation(caller->lc, 1); linphone_core_enable_capability_negociation(callee->lc, 1); bctbx_list_t *encryption_list = NULL; encryption_list = bctbx_list_append(encryption_list, LINPHONE_INT_TO_PTR(optionalEncryption)); BC_ASSERT_TRUE(linphone_core_media_encryption_supported(callee->lc, optionalEncryption)); if (linphone_core_media_encryption_supported(callee->lc, optionalEncryption)) { linphone_core_set_media_encryption_mandatory(callee->lc, 0); linphone_core_set_media_encryption(callee->lc, encryptionAfterResume); linphone_core_set_supported_media_encryptions(callee->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(callee->lc, optionalEncryption)); } BC_ASSERT_TRUE(linphone_core_media_encryption_supported(caller->lc, optionalEncryption)); if (linphone_core_media_encryption_supported(caller->lc, optionalEncryption)) { linphone_core_set_media_encryption_mandatory(caller->lc, 0); linphone_core_set_media_encryption(caller->lc, LinphoneMediaEncryptionNone); linphone_core_set_supported_media_encryptions(caller->lc, encryption_list); BC_ASSERT_TRUE(linphone_core_is_media_encryption_supported(caller->lc, optionalEncryption)); } if (encryption_list) { bctbx_list_free(encryption_list); encryption_list = NULL; } encrypted_call_base(caller, callee, optionalEncryption, TRUE, TRUE, FALSE); LinphoneCall *callerCall = linphone_core_get_current_call(caller->lc); BC_ASSERT_PTR_NOT_NULL(callerCall); LinphoneCall *calleeCall = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(calleeCall); if (calleeCall && callerCall) { // Pause callee call BC_ASSERT_TRUE(pause_call_1(callee, calleeCall, caller, callerCall)); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); // Resume callee call reset_counters(&caller->stat); reset_counters(&callee->stat); stats caller_stat = caller->stat; stats callee_stat = callee->stat; linphone_call_resume(calleeCall); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallResuming, callee_stat.number_of_LinphoneCallResuming + 1)); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, callee_stat.number_of_LinphoneCallStreamsRunning + 1)); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, caller_stat.number_of_LinphoneCallStreamsRunning + 1)); caller_stat = caller->stat; callee_stat = callee->stat; LinphoneCallParams *callerParams = linphone_core_create_call_params(caller->lc, callerCall); encryption_list = bctbx_list_append(NULL, LINPHONE_INT_TO_PTR(encryptionAfterResume)); linphone_call_params_set_supported_encryptions(callerParams, encryption_list); if (encryption_list) { bctbx_list_free(encryption_list); encryption_list = NULL; } linphone_call_update(callerCall, callerParams); linphone_call_params_unref(callerParams); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallUpdating,
3011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080
(caller_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallUpdatedByRemote, (callee_stat.number_of_LinphoneCallUpdatedByRemote + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + 1))); if (optionalEncryption == LinphoneMediaEncryptionZRTP) { BC_ASSERT_TRUE(wait_for_until(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallGoClearAckSent, callee_stat.number_of_LinphoneCallGoClearAckSent + 1, 10000)); } bool potentialConfigurationChosen = false; LinphoneMediaEncryption encryption = LinphoneMediaEncryptionNone; get_expected_encryption_from_call_params(calleeCall, callerCall, &encryption, &potentialConfigurationChosen); int expectedStreamsRunning = 1 + ((potentialConfigurationChosen) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_EQUAL(encryptionAfterResume, encryption, int, "%i"); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); liblinphone_tester_check_rtcp(caller, callee); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(caller), 70, int, "%i"); LinphoneCallStats *calleeStats = linphone_call_get_audio_stats(linphone_core_get_current_call(callee->lc)); BC_ASSERT_GREATER((int)linphone_call_stats_get_download_bandwidth(calleeStats), 70, int, "%i"); linphone_call_stats_unref(calleeStats); calleeStats = NULL; if (calleeCall) { check_stream_encryption(calleeCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), encryption, int, "%i"); } if (callerCall) { check_stream_encryption(callerCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), encryption, int, "%i"); } /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/ const rtp_stats_t *stats = rtp_session_get_stats(linphone_call_get_stream(calleeCall, LinphoneStreamTypeAudio)->sessions.rtp_session); BC_ASSERT_LOWER((int)stats->cum_packet_loss, 10, int, "%d"); callerParams = linphone_core_create_call_params(caller->lc, callerCall); encryption_list = bctbx_list_append(NULL, LINPHONE_INT_TO_PTR(optionalEncryption)); linphone_call_params_set_supported_encryptions(callerParams, encryption_list); if (encryption_list) { bctbx_list_free(encryption_list); encryption_list = NULL; } linphone_call_update(callerCall, callerParams); linphone_call_params_unref(callerParams); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallUpdating, (caller_stat.number_of_LinphoneCallUpdating + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallUpdatedByRemote, (callee_stat.number_of_LinphoneCallUpdatedByRemote + 1))); BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + 1)));
3081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150
BC_ASSERT_TRUE(wait_for(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + 1))); potentialConfigurationChosen = false; encryption = LinphoneMediaEncryptionNone; get_expected_encryption_from_call_params(callerCall, calleeCall, &encryption, &potentialConfigurationChosen); expectedStreamsRunning = 1 + ((potentialConfigurationChosen) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, (caller_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, (callee_stat.number_of_LinphoneCallStreamsRunning + expectedStreamsRunning))); if ((encryptionAfterResume == LinphoneMediaEncryptionNone) && ((encryption == LinphoneMediaEncryptionDTLS) || (encryption == LinphoneMediaEncryptionZRTP))) { BC_ASSERT_TRUE(wait_for_until(callee->lc, caller->lc, &caller->stat.number_of_LinphoneCallEncryptedOn, caller_stat.number_of_LinphoneCallEncryptedOn + 1, 10000)); BC_ASSERT_TRUE(wait_for_until(callee->lc, caller->lc, &callee->stat.number_of_LinphoneCallEncryptedOn, callee_stat.number_of_LinphoneCallEncryptedOn + 1, 10000)); } BC_ASSERT_EQUAL(optionalEncryption, encryption, int, "%i"); wait_for_until(callee->lc, caller->lc, NULL, 5, 10000); liblinphone_tester_check_rtcp(caller, callee); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(caller), 70, int, "%i"); calleeStats = linphone_call_get_audio_stats(linphone_core_get_current_call(callee->lc)); BC_ASSERT_GREATER((int)linphone_call_stats_get_download_bandwidth(calleeStats), 70, int, "%i"); linphone_call_stats_unref(calleeStats); calleeStats = NULL; if (calleeCall) { check_stream_encryption(calleeCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(calleeCall)), encryption, int, "%i"); } if (callerCall) { check_stream_encryption(callerCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(callerCall)), encryption, int, "%i"); } /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/ stats = rtp_session_get_stats(linphone_call_get_stream(calleeCall, LinphoneStreamTypeAudio)->sessions.rtp_session); BC_ASSERT_LOWER((int)stats->cum_packet_loss, 10, int, "%d"); end_call(caller, callee); } } static void call_with_no_encryption(void) { encryption_params marie_enc_params; marie_enc_params.encryption = LinphoneMediaEncryptionNone; marie_enc_params.level = E_DISABLED; encryption_params pauline_enc_params; pauline_enc_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_params.level = E_DISABLED; call_with_encryption_test_base(marie_enc_params, FALSE, FALSE, pauline_enc_params, FALSE, FALSE, FALSE); } void call_with_mandatory_encryption_base(const LinphoneMediaEncryption encryption, const bool_t caller_capability_negotiation, const bool_t callee_capability_negotiation) { encryption_params marie_enc_params; marie_enc_params.encryption = encryption;
3151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220
marie_enc_params.level = E_MANDATORY; encryption_params pauline_enc_params; pauline_enc_params.encryption = encryption; pauline_enc_params.level = E_MANDATORY; call_with_encryption_test_base(marie_enc_params, caller_capability_negotiation, FALSE, pauline_enc_params, callee_capability_negotiation, FALSE, FALSE); } void call_from_opt_enc_to_enc_base(const LinphoneMediaEncryption encryption, bool_t opt_enc_to_enc) { encryption_params optional_enc_mgr_params; // Avoid setting the actual configuration with the same encryption as the desired one if (encryption == LinphoneMediaEncryptionSRTP) { optional_enc_mgr_params.encryption = LinphoneMediaEncryptionDTLS; } else { optional_enc_mgr_params.encryption = LinphoneMediaEncryptionSRTP; } optional_enc_mgr_params.level = E_OPTIONAL; optional_enc_mgr_params.preferences = set_encryption_preference(TRUE); encryption_params mandatory_enc_mgr_params; mandatory_enc_mgr_params.encryption = encryption; mandatory_enc_mgr_params.level = E_MANDATORY; if (opt_enc_to_enc) { call_with_encryption_test_base(optional_enc_mgr_params, TRUE, FALSE, mandatory_enc_mgr_params, TRUE, FALSE, FALSE); } else { call_with_encryption_test_base(mandatory_enc_mgr_params, TRUE, FALSE, optional_enc_mgr_params, TRUE, FALSE, FALSE); } } void call_from_opt_enc_to_none_base(const LinphoneMediaEncryption encryption, bool_t opt_enc_to_none, const bool_t enable_video) { encryption_params no_enc_mgr_params; no_enc_mgr_params.encryption = LinphoneMediaEncryptionNone; no_enc_mgr_params.level = E_DISABLED; encryption_params enc_mgr_params; enc_mgr_params.encryption = LinphoneMediaEncryptionNone; enc_mgr_params.level = E_OPTIONAL; enc_mgr_params.preferences = set_encryption_preference_with_priority(encryption, false); if (opt_enc_to_none) { call_with_encryption_test_base(enc_mgr_params, TRUE, FALSE, no_enc_mgr_params, FALSE, FALSE, enable_video); } else { call_with_encryption_test_base(no_enc_mgr_params, FALSE, FALSE, enc_mgr_params, TRUE, FALSE, enable_video); } } void call_with_optional_encryption_on_both_sides_base(const LinphoneMediaEncryption encryption, const bool_t enable_video) { encryption_params marie_enc_params; // Avoid setting the actual configuration with the same encryption as the desired one if (encryption == LinphoneMediaEncryptionSRTP) { marie_enc_params.encryption = LinphoneMediaEncryptionDTLS; } else { marie_enc_params.encryption = LinphoneMediaEncryptionSRTP; } marie_enc_params.level = E_OPTIONAL; marie_enc_params.preferences = set_encryption_preference_with_priority(encryption, false); encryption_params pauline_enc_params; pauline_enc_params.encryption = encryption; pauline_enc_params.level = E_OPTIONAL; pauline_enc_params.preferences = set_encryption_preference_with_priority(encryption, true); call_with_encryption_test_base(marie_enc_params, TRUE, FALSE, pauline_enc_params, TRUE, FALSE, enable_video); }
3221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290
void call_with_toggling_encryption_base(BCTBX_UNUSED(const LinphoneMediaEncryption encryption)) { #if 0 std::list<LinphoneMediaEncryption> enc_list {encryption}; encryption_params marie_enc_params; marie_enc_params.encryption = LinphoneMediaEncryptionNone; marie_enc_params.level = E_OPTIONAL; marie_enc_params.preferences = enc_list; encryption_params pauline_enc_params; pauline_enc_params.encryption = LinphoneMediaEncryptionNone; pauline_enc_params.level = E_OPTIONAL; pauline_enc_params.preferences = enc_list; LinphoneCoreManager * marie = create_core_mgr_with_capability_negotiation_setup("marie_rc", marie_enc_params, TRUE, FALSE, TRUE); LinphoneCoreManager * pauline = create_core_mgr_with_capability_negotiation_setup((transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"), pauline_enc_params, TRUE, FALSE, TRUE); encrypted_call_base(marie, pauline, encryption, TRUE, TRUE, TRUE); LinphoneCall *marieCall = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(marieCall); LinphoneCall *paulineCall = linphone_core_get_current_call(pauline->lc); BC_ASSERT_PTR_NOT_NULL(paulineCall); if (marieCall && paulineCall) { stats marie_stat = marie->stat; stats pauline_stat = pauline->stat; LinphoneCallParams * params0 = linphone_core_create_call_params(pauline->lc, paulineCall); bctbx_list_t * encs0 = NULL; encs0 = bctbx_list_append(encs0, LINPHONE_INT_TO_PTR(LinphoneMediaEncryptionNone)); linphone_call_params_set_supported_encryptions (params0, encs0); bctbx_list_free(encs0); linphone_call_update(paulineCall, params0); linphone_call_params_unref(params0); BC_ASSERT_TRUE( wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdating,(pauline_stat.number_of_LinphoneCallUpdating+1))); BC_ASSERT_TRUE( wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallUpdatedByRemote,(marie_stat.number_of_LinphoneCallUpdatedByRemote+1))); BC_ASSERT_TRUE( wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,(pauline_stat.number_of_LinphoneCallStreamsRunning+1))); BC_ASSERT_TRUE( wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,(marie_stat.number_of_LinphoneCallStreamsRunning+1))); LinphoneMediaEncryption encryptionAfterUpdate = LinphoneMediaEncryptionNone; LinphoneMediaEncryption expectedEncryption = LinphoneMediaEncryptionNone; bool potentialConfigurationChosen = false; get_expected_encryption_from_call_params(paulineCall, marieCall, &expectedEncryption, &potentialConfigurationChosen); BC_ASSERT_FALSE(potentialConfigurationChosen); int expectedStreamsRunning = 1; /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,(pauline_stat.number_of_LinphoneCallStreamsRunning+expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,(marie_stat.number_of_LinphoneCallStreamsRunning+expectedStreamsRunning))); liblinphone_tester_check_rtcp(marie, pauline); wait_for_until(marie->lc, pauline->lc, NULL, 5, 2000); // Check that encryption has not changed after sending update BC_ASSERT_EQUAL(expectedEncryption, encryptionAfterUpdate, int, "%i"); if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), expectedEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), expectedEncryption, int, "%i"); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning+expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning+expectedStreamsRunning), int, "%d");
3291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360
pause_resume_calls(marie, pauline); marie_stat = marie->stat; pauline_stat = pauline->stat; LinphoneCallParams * params1 = linphone_core_create_call_params(pauline->lc, paulineCall); bctbx_list_t * encs1 = NULL; encs1 = bctbx_list_append(encs1, LINPHONE_INT_TO_PTR(encryption)); linphone_call_params_set_supported_encryptions (params1, encs1); bctbx_list_free(encs1); linphone_call_update(paulineCall, params1); linphone_call_params_unref(params1); BC_ASSERT_TRUE( wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdating,(pauline_stat.number_of_LinphoneCallUpdating+1))); BC_ASSERT_TRUE( wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallUpdatedByRemote,(marie_stat.number_of_LinphoneCallUpdatedByRemote+1))); BC_ASSERT_TRUE( wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,(pauline_stat.number_of_LinphoneCallStreamsRunning+1))); BC_ASSERT_TRUE( wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,(marie_stat.number_of_LinphoneCallStreamsRunning+1))); encryptionAfterUpdate = encryption; get_expected_encryption_from_call_params(paulineCall, marieCall, &expectedEncryption, &potentialConfigurationChosen); BC_ASSERT_TRUE(potentialConfigurationChosen); bool_t capabilityNegotiationReinviteEnabled = linphone_call_params_capability_negotiation_reinvite_enabled(linphone_call_get_params(paulineCall)); bool sendReInvite = (potentialConfigurationChosen && capabilityNegotiationReinviteEnabled); expectedStreamsRunning = 1 + ((sendReInvite) ? 1 : 0); /*wait for reINVITEs to complete*/ BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,(pauline_stat.number_of_LinphoneCallStreamsRunning+expectedStreamsRunning))); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,(marie_stat.number_of_LinphoneCallStreamsRunning+expectedStreamsRunning))); liblinphone_tester_check_rtcp(marie, pauline); wait_for_until(marie->lc, pauline->lc, NULL, 5, 2000); // Check that encryption has not changed after sending update BC_ASSERT_EQUAL(expectedEncryption, encryptionAfterUpdate, int, "%i"); if ((expectedEncryption == LinphoneMediaEncryptionDTLS) || (expectedEncryption == LinphoneMediaEncryptionZRTP)) { BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallEncryptedOn,marie_stat.number_of_LinphoneCallEncryptedOn+1,10000)); BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallEncryptedOn,pauline_stat.number_of_LinphoneCallEncryptedOn+1,10000)); } if (marieCall) { check_stream_encryption(marieCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(marieCall)), expectedEncryption, int, "%i"); } if (paulineCall) { check_stream_encryption(paulineCall); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(paulineCall)), expectedEncryption, int, "%i"); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, (pauline_stat.number_of_LinphoneCallStreamsRunning+expectedStreamsRunning), int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallStreamsRunning, (marie_stat.number_of_LinphoneCallStreamsRunning+expectedStreamsRunning), int, "%d"); pause_resume_calls(marie, pauline); end_call(marie, pauline); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); #endif BC_PASS("Test temporarely disabled"); } static void call_with_200ok_lost(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_capability_negociation(marie->lc, TRUE); LinphoneCoreManager *pauline =
3361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430
linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionSRTP); linphone_core_set_nortp_timeout(marie->lc, 100); LinphoneCall *in_call = NULL; LinphoneCall *out_call = linphone_core_invite_address(pauline->lc, marie->identity); BC_ASSERT_PTR_NOT_NULL(out_call); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallOutgoingInit, 1)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallOutgoingProgress, 1)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallIncomingReceived, 1)); BC_ASSERT_PTR_NOT_NULL(in_call = linphone_core_get_current_call(marie->lc)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallOutgoingRinging, 1)); BC_ASSERT_PTR_NOT_NULL(in_call = linphone_core_get_current_call(marie->lc)); linphone_call_accept(in_call); // Pauline goes offline so that it cannot send the ACK linphone_core_set_network_reachable(pauline->lc, FALSE); BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1, 5000)); BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallEnd, 1, 90000)); check_media_stream(in_call, TRUE); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(in_call)), LinphoneMediaEncryptionSRTP, int, "%i"); // Pauline comes back online to answer the BYE linphone_core_set_network_reachable(pauline->lc, TRUE); const LinphoneErrorInfo *ei = linphone_call_get_error_info(in_call); if (BC_ASSERT_PTR_NOT_NULL(ei)) { BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei), 408, int, "%d"); } // Check that Pauline never went to the streams running state BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallStreamsRunning, 0, int, "%d"); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallReleased, 1)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallReleased, 1)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void call_with_ack_not_sent(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); linphone_core_enable_capability_negociation(marie->lc, TRUE); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionSRTP); linphone_core_set_nortp_timeout(marie->lc, 100); LinphoneCall *in_call = NULL; LinphoneCall *out_call = linphone_core_invite_address(pauline->lc, marie->identity); BC_ASSERT_PTR_NOT_NULL(out_call); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallOutgoingInit, 1)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallOutgoingProgress, 1)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallIncomingReceived, 1)); BC_ASSERT_PTR_NOT_NULL(in_call = linphone_core_get_current_call(marie->lc)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallOutgoingRinging, 1)); BC_ASSERT_PTR_NOT_NULL(in_call = linphone_core_get_current_call(marie->lc));
3431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500
// Tell the dialog to loose all ACK LinphonePrivate::SalCallOp *op = LinphonePrivate::Call::toCpp(in_call)->getOp(); op->simulateLostAckOnDialog(true); linphone_call_accept(in_call); BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1, 5000)); BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallEnd, 1, 90000)); check_media_stream(in_call, TRUE); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(linphone_call_get_current_params(in_call)), LinphoneMediaEncryptionSRTP, int, "%i"); const LinphoneErrorInfo *ei = linphone_call_get_error_info(in_call); if (BC_ASSERT_PTR_NOT_NULL(ei)) { BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei), 408, int, "%d"); } BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallReleased, 1)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallReleased, 1)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } test_t capability_negotiation_tests[] = { TEST_NO_TAG("Call with no encryption", call_with_no_encryption), TEST_NO_TAG("Call with 200Ok lost", call_with_200ok_lost), TEST_NO_TAG("Call with ACK not sent", call_with_ack_not_sent), TEST_NO_TAG("Call with capability negotiation failure", call_with_capability_negotiation_failure), TEST_NO_TAG("Call with capability negotiation failure and multiple potential configurations", call_with_capability_negotiation_failure_multiple_potential_configurations), TEST_NO_TAG("Call with capability negotiation disabled at call level", call_with_capability_negotiation_disable_call_level), TEST_NO_TAG("Call with capability negotiation disabled at core level", call_with_capability_negotiation_disable_core_level), TEST_NO_TAG("Call with incompatible encryptions in call params", call_with_incompatible_encs_in_call_params), TEST_NO_TAG("Call with update and incompatible encryptions in call params", call_with_update_and_incompatible_encs_in_call_params), TEST_NO_TAG("Call changes encryption with update and capability negotiations on caller", call_changes_enc_on_update_cap_neg_caller), TEST_NO_TAG("Call changes encryption with update and capability negotiations on callee", call_changes_enc_on_update_cap_neg_callee), TEST_NO_TAG("Call changes encryption with update and capability negotiations on both sides with reINVITE", call_changes_enc_on_update_cap_neg_both_sides_with_reinvite), TEST_NO_TAG("Call changes encryption with update and capability negotiations on both sides without reINVITE", call_changes_enc_on_update_cap_neg_both_sides_without_reinvite), TEST_NO_TAG("Unencrypted call with potential configuration same as actual one", unencrypted_call_with_potential_configuration_same_as_actual_configuration), TEST_NO_TAG("Back to back call with capability negotiations on one side", back_to_back_calls_cap_neg_one_side), TEST_NO_TAG("Back to back call with capability negotiations on both sides", back_to_back_calls_cap_neg_both_sides)}; test_t capability_negotiation_parameters_tests[] = { TEST_NO_TAG("Call with tcap line merge on caller", call_with_tcap_line_merge_on_caller), TEST_NO_TAG("Call with tcap line merge on callee", call_with_tcap_line_merge_on_callee), TEST_NO_TAG("Call with tcap line merge on both sides", call_with_tcap_line_merge_on_both_sides), TEST_NO_TAG("Call with no cfg line merge", call_with_no_cfg_lines_merge), TEST_NO_TAG("Call with cfg line merge on caller", call_with_cfg_lines_merge_on_caller), TEST_NO_TAG("Call with cfg line merge on callee", call_with_cfg_lines_merge_on_callee), TEST_NO_TAG("Call with cfg line merge on both sides", call_with_cfg_lines_merge_on_both_sides), TEST_NO_TAG("Call with AVPF and capability negotiations on caller", call_with_avpf_and_cap_neg_on_caller), TEST_NO_TAG("Call with AVPF and capability negotiations on callee", call_with_avpf_and_cap_neg_on_callee), TEST_NO_TAG("Call with AVPF and capability negotiations on both sides", call_with_avpf_and_cap_neg_on_both_sides)}; test_t capability_negotiation_tests_no_sdp[] = { TEST_NO_TAG("Call with no SDP and capability negotiations on caller", call_with_no_sdp_cap_neg_on_caller), TEST_NO_TAG("Call with no SDP and capability negotiations on callee", call_with_no_sdp_cap_neg_on_callee), TEST_NO_TAG("Call with no SDP and capability negotiations on both sides", call_with_no_sdp_cap_neg_on_both_sides), TEST_NO_TAG("Call with no SDP on update and capability negotiations on caller", call_with_no_sdp_on_update_cap_neg_caller),
35013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541
TEST_NO_TAG("Call with no SDP on update and capability negotiations on callee", call_with_no_sdp_on_update_cap_neg_callee), TEST_NO_TAG("Call with no SDP on update and capability negotiations on both sides with reINVITE", call_with_no_sdp_on_update_cap_neg_both_sides_with_reinvite), TEST_NO_TAG("Call with no SDP on update and capability negotiations on both sides without reINVITE on caller", call_with_no_sdp_on_update_cap_neg_both_sides_without_reinvite_on_caller), TEST_NO_TAG("Call with no SDP on update and capability negotiations on both sides without reINVITE on callee", call_with_no_sdp_on_update_cap_neg_both_sides_without_reinvite_on_callee), TEST_NO_TAG("Call with no SDP on update and capability negotiations on both sides without reINVITE", call_with_no_sdp_on_update_cap_neg_both_sides_without_reinvite)}; test_suite_t capability_negotiation_test_suite = {"Capability Negotiation (SDP)", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, sizeof(capability_negotiation_tests) / sizeof(capability_negotiation_tests[0]), capability_negotiation_tests, 0}; test_suite_t capability_negotiation_parameters_test_suite = {"Capability Negotiation (Parameters)", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, sizeof(capability_negotiation_parameters_tests) / sizeof(capability_negotiation_parameters_tests[0]), capability_negotiation_parameters_tests, 0}; test_suite_t capability_negotiation_no_sdp_test_suite = {"Capability Negotiation (No SDP)", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, sizeof(capability_negotiation_tests_no_sdp) / sizeof(capability_negotiation_tests_no_sdp[0]), capability_negotiation_tests_no_sdp, 0};