mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 16:49:20 +00:00
change encryption state management
This commit is contained in:
parent
f9c8c72c01
commit
43aa6ef34f
9 changed files with 210 additions and 132 deletions
|
|
@ -149,22 +149,22 @@ static void stream_description_to_sdp ( belle_sdp_session_description_t *session
|
|||
const char *enc_name=NULL;
|
||||
|
||||
switch ( stream->crypto[j].algo ) {
|
||||
case AES_128_SHA1_80:
|
||||
case MS_AES_128_SHA1_80:
|
||||
enc_name="AES_CM_128_HMAC_SHA1_80";
|
||||
break;
|
||||
case AES_128_SHA1_32:
|
||||
case MS_AES_128_SHA1_32:
|
||||
enc_name="AES_CM_128_HMAC_SHA1_32";
|
||||
break;
|
||||
case AES_256_SHA1_32:
|
||||
case MS_AES_256_SHA1_32:
|
||||
enc_name="AES_CM_256_HMAC_SHA1_32";
|
||||
break;
|
||||
case AES_256_SHA1_80:
|
||||
case MS_AES_256_SHA1_80:
|
||||
enc_name="AES_CM_256_HMAC_SHA1_32";
|
||||
break;
|
||||
case AES_128_NO_AUTH:
|
||||
case MS_AES_128_NO_AUTH:
|
||||
ms_warning ( "Unsupported crypto suite: AES_128_NO_AUTH" );
|
||||
break;
|
||||
case NO_CIPHER_SHA1_80:
|
||||
case MS_NO_CIPHER_SHA1_80:
|
||||
ms_warning ( "Unsupported crypto suite: NO_CIPHER_SHA1_80" );
|
||||
break;
|
||||
default:
|
||||
|
|
@ -351,13 +351,13 @@ static void sdp_parse_media_crypto_parameters(belle_sdp_media_description_t *med
|
|||
tmp2 );
|
||||
if ( nb == 3 ) {
|
||||
if ( keywordcmp ( "AES_CM_128_HMAC_SHA1_80",tmp ) == 0 ){
|
||||
stream->crypto[valid_count].algo = AES_128_SHA1_80;
|
||||
stream->crypto[valid_count].algo = MS_AES_128_SHA1_80;
|
||||
}else if ( keywordcmp ( "AES_CM_128_HMAC_SHA1_32",tmp ) == 0 ){
|
||||
stream->crypto[valid_count].algo = AES_128_SHA1_32;
|
||||
stream->crypto[valid_count].algo = MS_AES_128_SHA1_32;
|
||||
}else if ( keywordcmp ( "AES_CM_256_HMAC_SHA1_32",tmp ) == 0 ){
|
||||
stream->crypto[valid_count].algo = AES_256_SHA1_32;
|
||||
stream->crypto[valid_count].algo = MS_AES_256_SHA1_32;
|
||||
}else if ( keywordcmp ( "AES_CM_256_HMAC_SHA1_80",tmp ) == 0 ){
|
||||
stream->crypto[valid_count].algo = AES_256_SHA1_80;
|
||||
stream->crypto[valid_count].algo = MS_AES_256_SHA1_80;
|
||||
}else {
|
||||
ms_warning ( "Failed to parse crypto-algo: '%s'", tmp );
|
||||
stream->crypto[valid_count].algo = 0;
|
||||
|
|
|
|||
|
|
@ -95,22 +95,21 @@ bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call){
|
|||
}
|
||||
|
||||
static bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call) {
|
||||
// Check ZRTP encryption in audiostream
|
||||
if (!call->audiostream_encrypted) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef VIDEO_ENABLED
|
||||
// If video enabled, check ZRTP encryption in videostream
|
||||
{
|
||||
const LinphoneCallParams *params=linphone_call_get_current_params(call);
|
||||
if (params->has_video && !call->videostream_encrypted) {
|
||||
return FALSE;
|
||||
int number_of_encrypted_stream = 0;
|
||||
int number_of_active_stream = 0;
|
||||
if (call) {
|
||||
if (call->audiostream && media_stream_get_state((MediaStream *)call->audiostream) == MSStreamStarted) {
|
||||
number_of_active_stream++;
|
||||
if(media_stream_is_secured((MediaStream *)call->audiostream))
|
||||
number_of_encrypted_stream++;
|
||||
}
|
||||
if (call->videostream && media_stream_get_state((MediaStream *)call->videostream) == MSStreamStarted) {
|
||||
number_of_active_stream++;
|
||||
if (media_stream_is_secured((MediaStream *)call->videostream))
|
||||
number_of_encrypted_stream++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return number_of_active_stream>0 & number_of_active_stream==number_of_encrypted_stream;
|
||||
}
|
||||
|
||||
void propagate_encryption_changed(LinphoneCall *call){
|
||||
|
|
@ -131,9 +130,6 @@ void propagate_encryption_changed(LinphoneCall *call){
|
|||
#ifdef VIDEO_ENABLED
|
||||
static void linphone_call_videostream_encryption_changed(void *data, bool_t encrypted){
|
||||
LinphoneCall *call = (LinphoneCall *)data;
|
||||
|
||||
ms_message("Video stream is %s", encrypted ? "encrypted" : "not encrypted");
|
||||
call->videostream_encrypted=encrypted;
|
||||
propagate_encryption_changed(call);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -141,10 +137,8 @@ static void linphone_call_videostream_encryption_changed(void *data, bool_t encr
|
|||
static void linphone_call_audiostream_encryption_changed(void *data, bool_t encrypted) {
|
||||
char status[255]={0};
|
||||
LinphoneCall *call;
|
||||
ms_message("Audio stream is %s ", encrypted ? "encrypted" : "not encrypted");
|
||||
|
||||
call = (LinphoneCall *)data;
|
||||
call->audiostream_encrypted=encrypted;
|
||||
|
||||
if (encrypted && call->core->vtable.display_status != NULL) {
|
||||
snprintf(status,sizeof(status)-1,_("Authentication token is %s"),call->auth_token);
|
||||
|
|
@ -260,11 +254,11 @@ static void setup_encryption_keys(LinphoneCall *call, SalMediaDescription *md){
|
|||
}
|
||||
}else{
|
||||
md->streams[i].crypto[0].tag = 1;
|
||||
md->streams[i].crypto[0].algo = AES_128_SHA1_80;
|
||||
md->streams[i].crypto[0].algo = MS_AES_128_SHA1_80;
|
||||
if (!generate_b64_crypto_key(30, md->streams[i].crypto[0].master_key, SAL_SRTP_KEY_SIZE))
|
||||
md->streams[i].crypto[0].algo = 0;
|
||||
md->streams[i].crypto[1].tag = 2;
|
||||
md->streams[i].crypto[1].algo = AES_128_SHA1_32;
|
||||
md->streams[i].crypto[1].algo = MS_AES_128_SHA1_32;
|
||||
if (!generate_b64_crypto_key(30, md->streams[i].crypto[1].master_key, SAL_SRTP_KEY_SIZE))
|
||||
md->streams[i].crypto[1].algo = 0;
|
||||
md->streams[i].crypto[2].algo = 0;
|
||||
|
|
@ -482,6 +476,7 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from,
|
|||
call->log=linphone_call_log_new(call, from, to);
|
||||
call->owns_call_log=TRUE;
|
||||
call->camera_enabled=TRUE;
|
||||
call->current_params.media_encryption=LinphoneMediaEncryptionNone;
|
||||
|
||||
linphone_core_get_audio_port_range(call->core, &min_port, &max_port);
|
||||
port_config_set(call,0,min_port,max_port);
|
||||
|
|
@ -916,6 +911,16 @@ const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call){
|
|||
}
|
||||
#endif
|
||||
|
||||
if (linphone_call_are_all_streams_encrypted(call)) {
|
||||
if (linphone_call_get_authentication_token(call)) {
|
||||
call->current_params.media_encryption=LinphoneMediaEncryptionZRTP;
|
||||
} else {
|
||||
call->current_params.media_encryption=LinphoneMediaEncryptionSRTP;
|
||||
}
|
||||
} else {
|
||||
call->current_params.media_encryption=LinphoneMediaEncryptionNone;
|
||||
}
|
||||
|
||||
return &call->current_params;
|
||||
}
|
||||
|
||||
|
|
@ -1903,12 +1908,10 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna
|
|||
if (crypto_idx >= 0) {
|
||||
media_stream_set_srtp_recv_key(&call->audiostream->ms,stream->crypto[0].algo,stream->crypto[0].master_key);
|
||||
media_stream_set_srtp_send_key(&call->audiostream->ms,stream->crypto[0].algo,local_st_desc->crypto[crypto_idx].master_key);
|
||||
call->audiostream_encrypted=TRUE;
|
||||
} else {
|
||||
ms_warning("Failed to find local crypto algo with tag: %d", stream->crypto_local_tag);
|
||||
call->audiostream_encrypted=FALSE;
|
||||
}
|
||||
}else call->audiostream_encrypted=FALSE;
|
||||
}
|
||||
configure_rtp_session_for_rtcp_xr(lc, call, SalAudio);
|
||||
audio_stream_start_full(
|
||||
call->audiostream,
|
||||
|
|
@ -2022,14 +2025,10 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna
|
|||
if (!is_inactive){
|
||||
if (vstream->proto == SalProtoRtpSavp) {
|
||||
int crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, vstream->crypto_local_tag);
|
||||
|
||||
if (crypto_idx >= 0) {
|
||||
media_stream_set_srtp_recv_key(&call->videostream->ms,vstream->crypto[0].algo,vstream->crypto[0].master_key);
|
||||
media_stream_set_srtp_send_key(&call->videostream->ms,vstream->crypto[0].algo,local_st_desc->crypto[crypto_idx].master_key);
|
||||
call->videostream_encrypted=TRUE;
|
||||
}else call->videostream_encrypted=FALSE;
|
||||
}else{
|
||||
call->videostream_encrypted=FALSE;
|
||||
}
|
||||
}
|
||||
configure_rtp_session_for_rtcp_xr(lc, call, SalVideo);
|
||||
|
||||
|
|
@ -2090,11 +2089,17 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut
|
|||
|
||||
if (call->params.media_encryption==LinphoneMediaEncryptionZRTP) {
|
||||
OrtpZrtpParams params;
|
||||
/*will be set later when zrtp is activated*/
|
||||
call->current_params.media_encryption=LinphoneMediaEncryptionNone;
|
||||
|
||||
memset(¶ms,0,sizeof(OrtpZrtpParams));
|
||||
/*call->current_params.media_encryption will be set later when zrtp is activated*/
|
||||
params.zid_file=lc->zrtp_secrets_cache;
|
||||
audio_stream_enable_zrtp(call->audiostream,¶ms);
|
||||
#if VIDEO_ENABLED
|
||||
if (media_stream_is_secured((MediaStream *)call->audiostream) && media_stream_get_state((MediaStream *)call->videostream) == MSStreamStarted) {
|
||||
/*audio stream is already encrypted and video stream is active*/
|
||||
memset(¶ms,0,sizeof(OrtpZrtpParams));
|
||||
video_stream_enable_zrtp(call->videostream,call->audiostream,¶ms);
|
||||
}
|
||||
#endif
|
||||
}else{
|
||||
call->current_params.media_encryption=linphone_call_are_all_streams_encrypted(call) ?
|
||||
LinphoneMediaEncryptionSRTP : LinphoneMediaEncryptionNone;
|
||||
|
|
@ -2144,8 +2149,7 @@ void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescript
|
|||
new_stream = sal_media_description_find_stream(new_md, SalProtoRtpSavp, SalAudio);
|
||||
if (call->audiostream && local_st_desc && old_stream && new_stream &&
|
||||
update_stream_crypto_params(call,local_st_desc,old_stream,new_stream,&call->audiostream->ms)){
|
||||
call->audiostream_encrypted = TRUE;
|
||||
}else call->audiostream_encrypted = FALSE;
|
||||
}
|
||||
|
||||
#ifdef VIDEO_ENABLED
|
||||
local_st_desc = sal_media_description_find_stream(call->localdesc, SalProtoRtpSavp, SalVideo);
|
||||
|
|
@ -2153,9 +2157,7 @@ void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescript
|
|||
new_stream = sal_media_description_find_stream(new_md, SalProtoRtpSavp, SalVideo);
|
||||
if (call->videostream && local_st_desc && old_stream && new_stream &&
|
||||
update_stream_crypto_params(call,local_st_desc,old_stream,new_stream,&call->videostream->ms)){
|
||||
call->videostream_encrypted = TRUE;
|
||||
}
|
||||
call->videostream_encrypted = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,8 +224,6 @@ struct _LinphoneCall
|
|||
bool_t owns_call_log;
|
||||
bool_t ringing_beep; /* whether this call is ringing through an already existent current call*/
|
||||
|
||||
bool_t videostream_encrypted;
|
||||
bool_t audiostream_encrypted;
|
||||
bool_t auth_token_verified;
|
||||
bool_t defer_update;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mediastreamer2/mscommon.h"
|
||||
#include "mediastreamer2/mediastream.h"
|
||||
#include "ortp/rtpsession.h"
|
||||
#include "ortp/ortp_srtp.h"
|
||||
#include "belle-sip/belle-sip.h"
|
||||
|
||||
#ifndef LINPHONE_PUBLIC
|
||||
|
|
@ -171,7 +170,7 @@ typedef struct SalIceRemoteCandidate {
|
|||
|
||||
typedef struct SalSrtpCryptoAlgo {
|
||||
unsigned int tag;
|
||||
enum ortp_srtp_crypto_suite_t algo;
|
||||
MSCryptoSuite algo;
|
||||
char master_key[SAL_SRTP_KEY_SIZE];
|
||||
} SalSrtpCryptoAlgo;
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 41db9323be6a6d136949ee5fdba1198c38a7d787
|
||||
Subproject commit 5363f6d6487f44c0fa898647b7b859857db13283
|
||||
2
oRTP
2
oRTP
|
|
@ -1 +1 @@
|
|||
Subproject commit beee1f20d69af3d04cd27fcc00b3830620066367
|
||||
Subproject commit 891f3da6817e30b606493840f305250f81a254bd
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include "private.h"
|
||||
#include "liblinphone_tester.h"
|
||||
|
||||
static void call_base(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy);
|
||||
|
||||
void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){
|
||||
char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to);
|
||||
|
|
@ -59,7 +60,22 @@ void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState
|
|||
CU_FAIL("unexpected event");break;
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token) {
|
||||
char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to);
|
||||
char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from);
|
||||
stats* counters;
|
||||
ms_message(" %s call from [%s] to [%s], is now [%s]",linphone_call_get_call_log(call)->dir==LinphoneCallIncoming?"Incoming":"Outgoing"
|
||||
,from
|
||||
,to
|
||||
,(on?"encrypted":"unencrypted"));
|
||||
ms_free(to);
|
||||
ms_free(from);
|
||||
counters = get_stats(lc);
|
||||
if (on)
|
||||
counters->number_of_LinphoneCallEncryptedOn++;
|
||||
else
|
||||
counters->number_of_LinphoneCallEncryptedOff++;
|
||||
}
|
||||
void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state) {
|
||||
char* to=linphone_address_as_string(linphone_call_get_call_log(transfered)->to);
|
||||
char* from=linphone_address_as_string(linphone_call_get_call_log(transfered)->from);
|
||||
|
|
@ -198,12 +214,19 @@ bool_t call_with_params(LinphoneCoreManager* caller_mgr
|
|||
&&
|
||||
wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+1);
|
||||
|
||||
if (linphone_core_get_media_encryption(caller_mgr->lc)
|
||||
&& linphone_core_get_media_encryption(callee_mgr->lc)) {
|
||||
if (linphone_core_get_media_encryption(caller_mgr->lc) != LinphoneMediaEncryptionNone
|
||||
&& linphone_core_get_media_encryption(callee_mgr->lc) != LinphoneMediaEncryptionNone) {
|
||||
/*wait for encryption to be on, in case of zrtp, it can take a few seconds*/
|
||||
if (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionZRTP)
|
||||
wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallEncryptedOn,initial_caller.number_of_LinphoneCallEncryptedOn+1);
|
||||
if (linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionZRTP)
|
||||
wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallEncryptedOn,initial_callee.number_of_LinphoneCallEncryptedOn+1);
|
||||
{
|
||||
const LinphoneCallParams* call_param = linphone_call_get_current_params(linphone_core_get_current_call(callee_mgr->lc));
|
||||
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller_mgr->lc));
|
||||
call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller_mgr->lc));
|
||||
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller_mgr->lc));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -516,6 +539,17 @@ static bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee
|
|||
}
|
||||
ms_usleep(50000);
|
||||
}
|
||||
|
||||
/*make sure encryption mode are preserved*/
|
||||
if (c1) {
|
||||
const LinphoneCallParams* call_param = linphone_call_get_current_params(c1);
|
||||
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc));
|
||||
}
|
||||
if (c2) {
|
||||
const LinphoneCallParams* call_param = linphone_call_get_current_params(c2);
|
||||
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(callee->lc));
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
@ -703,6 +737,15 @@ static bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee)
|
|||
LinphoneVideoPolicy caller_policy;
|
||||
LinphoneCallParams* callee_params;
|
||||
LinphoneCall* call_obj;
|
||||
stats initial_caller_stat=caller->stat;
|
||||
stats initial_callee_stat=callee->stat;
|
||||
|
||||
if (linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning
|
||||
|| linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning ) {
|
||||
ms_warning("bad state for adding video");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
caller_policy.automatically_accept=TRUE;
|
||||
caller_policy.automatically_initiate=TRUE;
|
||||
linphone_core_enable_video_capture(callee->lc, TRUE);
|
||||
|
|
@ -710,8 +753,8 @@ static bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee)
|
|||
linphone_core_enable_video_capture(caller->lc, TRUE);
|
||||
linphone_core_enable_video_display(caller->lc, FALSE);
|
||||
linphone_core_set_video_policy(caller->lc,&caller_policy);
|
||||
stats initial_caller_stat=caller->stat;
|
||||
stats initial_callee_stat=callee->stat;
|
||||
|
||||
|
||||
|
||||
if ((call_obj = linphone_core_get_current_call(callee->lc))) {
|
||||
callee_params = linphone_call_params_copy(linphone_call_get_current_params(call_obj));
|
||||
|
|
@ -726,6 +769,21 @@ static bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee)
|
|||
|
||||
CU_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc))));
|
||||
CU_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc))));
|
||||
if (linphone_core_get_media_encryption(caller->lc) != LinphoneMediaEncryptionNone
|
||||
&& linphone_core_get_media_encryption(callee->lc) != LinphoneMediaEncryptionNone) {
|
||||
/*wait for encryption to be on, in case of zrtp, it can take a few seconds*/
|
||||
if (linphone_core_get_media_encryption(caller->lc) == LinphoneMediaEncryptionZRTP)
|
||||
wait_for(callee->lc,caller->lc,&caller->stat.number_of_LinphoneCallEncryptedOn,initial_caller_stat.number_of_LinphoneCallEncryptedOn+1);
|
||||
if (linphone_core_get_media_encryption(callee->lc) == LinphoneMediaEncryptionZRTP)
|
||||
wait_for(callee->lc,caller->lc,&callee->stat.number_of_LinphoneCallEncryptedOn,initial_callee_stat.number_of_LinphoneCallEncryptedOn+1);
|
||||
|
||||
{
|
||||
const LinphoneCallParams* call_param = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc));
|
||||
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc));
|
||||
call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc));
|
||||
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc));
|
||||
}
|
||||
}
|
||||
|
||||
linphone_call_set_next_video_frame_decoded_callback(call_obj,linphone_call_cb,callee->lc);
|
||||
/*send vfu*/
|
||||
|
|
@ -824,19 +882,21 @@ static void video_call(void) {
|
|||
marie_call=linphone_core_get_current_call(marie->lc);
|
||||
pauline_call=linphone_core_get_current_call(pauline->lc);
|
||||
|
||||
CU_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call)));
|
||||
CU_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call)));
|
||||
if (marie_call && pauline_call ) {
|
||||
CU_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call)));
|
||||
CU_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call)));
|
||||
|
||||
/*check video path*/
|
||||
linphone_call_set_next_video_frame_decoded_callback(marie_call,linphone_call_cb,marie->lc);
|
||||
linphone_call_send_vfu_request(marie_call);
|
||||
CU_ASSERT_TRUE( wait_for(marie->lc,pauline->lc,&marie->stat.number_of_IframeDecoded,1));
|
||||
/*check video path*/
|
||||
linphone_call_set_next_video_frame_decoded_callback(marie_call,linphone_call_cb,marie->lc);
|
||||
linphone_call_send_vfu_request(marie_call);
|
||||
CU_ASSERT_TRUE( wait_for(marie->lc,pauline->lc,&marie->stat.number_of_IframeDecoded,1));
|
||||
|
||||
liblinphone_tester_check_rtcp(marie,pauline);
|
||||
liblinphone_tester_check_rtcp(marie,pauline);
|
||||
|
||||
linphone_core_terminate_all_calls(pauline->lc);
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
|
||||
linphone_core_terminate_all_calls(pauline->lc);
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
|
||||
}
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
|
|
@ -1139,45 +1199,17 @@ static void simple_conference(void) {
|
|||
}
|
||||
|
||||
|
||||
static void encrypted_call(LinphoneMediaEncryption mode) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
|
||||
if (linphone_core_media_encryption_supported(marie->lc,mode)) {
|
||||
linphone_core_set_media_encryption(marie->lc,mode);
|
||||
linphone_core_set_media_encryption(pauline->lc,mode);
|
||||
|
||||
CU_ASSERT_TRUE(call(pauline,marie));
|
||||
|
||||
CU_ASSERT_EQUAL(linphone_core_get_media_encryption(marie->lc),mode);
|
||||
CU_ASSERT_EQUAL(linphone_core_get_media_encryption(pauline->lc),mode);
|
||||
if (linphone_core_get_media_encryption(pauline->lc) == LinphoneMediaEncryptionZRTP
|
||||
&& linphone_core_get_media_encryption(pauline->lc) == LinphoneMediaEncryptionZRTP) {
|
||||
/*check SAS*/
|
||||
CU_ASSERT_STRING_EQUAL(linphone_call_get_authentication_token(linphone_core_get_current_call(pauline->lc))
|
||||
,linphone_call_get_authentication_token(linphone_core_get_current_call(marie->lc)));
|
||||
}
|
||||
liblinphone_tester_check_rtcp(pauline,marie);
|
||||
/*just to sleep*/
|
||||
linphone_core_terminate_all_calls(marie->lc);
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
|
||||
} else {
|
||||
ms_warning ("Not tested because %s not available", linphone_media_encryption_to_string(mode));
|
||||
}
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void srtp_call() {
|
||||
encrypted_call(LinphoneMediaEncryptionSRTP);
|
||||
call_base(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyNoFirewall);
|
||||
}
|
||||
|
||||
/*
|
||||
* future work
|
||||
static void zrtp_call() {
|
||||
encrypted_call(LinphoneMediaEncryptionZRTP);
|
||||
}*/
|
||||
call_base(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall);
|
||||
}
|
||||
static void zrtp_video_call() {
|
||||
call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyNoFirewall);
|
||||
}
|
||||
|
||||
static void call_with_declined_srtp(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
|
|
@ -1197,43 +1229,70 @@ static void call_with_declined_srtp(void) {
|
|||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
#ifdef VIDEO_ENABLED
|
||||
static void srtp_video_ice_call(void) {
|
||||
|
||||
static void call_base(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy) {
|
||||
int i=0;
|
||||
#else
|
||||
static void srtp_ice_call(void) {
|
||||
#endif
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
if (enable_relay) {
|
||||
linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL);
|
||||
linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL);
|
||||
}
|
||||
if (linphone_core_media_encryption_supported(marie->lc,mode)) {
|
||||
linphone_core_set_media_encryption(marie->lc,mode);
|
||||
linphone_core_set_media_encryption(pauline->lc,mode);
|
||||
|
||||
if (linphone_core_media_encryption_supported(marie->lc,LinphoneMediaEncryptionSRTP)) {
|
||||
linphone_core_set_media_encryption(marie->lc,LinphoneMediaEncryptionSRTP);
|
||||
linphone_core_set_media_encryption(pauline->lc,LinphoneMediaEncryptionSRTP);
|
||||
|
||||
linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
|
||||
linphone_core_set_firewall_policy(marie->lc,policy);
|
||||
linphone_core_set_stun_server(marie->lc,"stun.linphone.org");
|
||||
linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
|
||||
linphone_core_set_firewall_policy(pauline->lc,policy);
|
||||
linphone_core_set_stun_server(pauline->lc,"stun.linphone.org");
|
||||
|
||||
|
||||
CU_ASSERT_TRUE(call(pauline,marie));
|
||||
if (linphone_core_get_media_encryption(pauline->lc) == LinphoneMediaEncryptionZRTP
|
||||
&& linphone_core_get_media_encryption(pauline->lc) == LinphoneMediaEncryptionZRTP) {
|
||||
/*wait for SAS*/
|
||||
int i;
|
||||
for (i=0;i<10;i++) {
|
||||
if (linphone_call_get_authentication_token(linphone_core_get_current_call(pauline->lc))
|
||||
&&
|
||||
linphone_call_get_authentication_token(linphone_core_get_current_call(marie->lc))) {
|
||||
/*check SAS*/
|
||||
CU_ASSERT_STRING_EQUAL(linphone_call_get_authentication_token(linphone_core_get_current_call(pauline->lc))
|
||||
,linphone_call_get_authentication_token(linphone_core_get_current_call(marie->lc)));
|
||||
liblinphone_tester_check_rtcp(pauline,marie);
|
||||
break;
|
||||
}
|
||||
linphone_core_iterate(marie->lc);
|
||||
linphone_core_iterate(pauline->lc);
|
||||
ms_usleep(200000);
|
||||
}
|
||||
|
||||
CU_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
|
||||
#ifdef VIDEO_ENABLED
|
||||
for (i=0;i<100;i++) { /*fixme to workaround a crash*/
|
||||
ms_usleep(20000);
|
||||
linphone_core_iterate(marie->lc);
|
||||
linphone_core_iterate(pauline->lc);
|
||||
}
|
||||
|
||||
add_video(pauline,marie);
|
||||
if (policy == LinphonePolicyUseIce)
|
||||
CU_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
|
||||
if (enable_video) {
|
||||
if (linphone_core_video_supported(marie->lc)) {
|
||||
for (i=0;i<100;i++) { /*fixme to workaround a crash*/
|
||||
ms_usleep(20000);
|
||||
linphone_core_iterate(marie->lc);
|
||||
linphone_core_iterate(pauline->lc);
|
||||
}
|
||||
|
||||
add_video(pauline,marie);
|
||||
if (policy == LinphonePolicyUseIce)
|
||||
CU_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
|
||||
|
||||
liblinphone_tester_check_rtcp(marie,pauline);
|
||||
/*wait for ice to found the direct path*/
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_IframeDecoded,1));
|
||||
} else {
|
||||
ms_warning ("not tested because video not available");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CU_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
|
||||
liblinphone_tester_check_rtcp(marie,pauline);
|
||||
/*wait for ice to found the direct path*/
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_IframeDecoded,1));
|
||||
#endif
|
||||
|
||||
|
||||
/*just to sleep*/
|
||||
linphone_core_terminate_all_calls(marie->lc);
|
||||
|
|
@ -1246,9 +1305,21 @@ static void srtp_ice_call(void) {
|
|||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void srtp_video_ice_call(void) {
|
||||
call_base(LinphoneMediaEncryptionSRTP,TRUE,FALSE,LinphonePolicyUseIce);
|
||||
}
|
||||
static void srtp_ice_call(void) {
|
||||
call_base(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyUseIce);
|
||||
}
|
||||
static void zrtp_video_ice_call(void) {
|
||||
/*encrypted_ice_call(LinphoneMediaEncryptionZRTP,TRUE,FALSE);*/
|
||||
}
|
||||
static void zrtp_ice_call(void) {
|
||||
/*encrypted_ice_call(LinphoneMediaEncryptionZRTP,FALSE,FALSE);*/
|
||||
}
|
||||
static void zrtp_ice_call_with_relay(void) {
|
||||
/*encrypted_ice_call(LinphoneMediaEncryptionZRTP,FALSE,TRUE);*/
|
||||
}
|
||||
|
||||
static void early_media_call(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_early_rc");
|
||||
|
|
@ -1901,17 +1972,20 @@ test_t call_tests[] = {
|
|||
{ "Call paused resumed", call_paused_resumed },
|
||||
{ "Call paused resumed from callee", call_paused_resumed_from_callee },
|
||||
{ "SRTP call", srtp_call },
|
||||
/*{ "ZRTP call",zrtp_call}, futur work*/
|
||||
{ "ZRTP call",zrtp_call},
|
||||
{ "ZRTP video call",zrtp_video_call},
|
||||
{ "SRTP call with declined srtp", call_with_declined_srtp },
|
||||
#ifdef VIDEO_ENABLED
|
||||
{ "Simple video call",video_call},
|
||||
{ "SRTP ice video call", srtp_video_ice_call },
|
||||
{ "ZRTP ice video call", zrtp_video_ice_call },
|
||||
{ "Call with video added", call_with_video_added },
|
||||
{ "Call with video added (random ports)", call_with_video_added_random_ports },
|
||||
{ "Call with video declined",call_with_declined_video},
|
||||
#else
|
||||
{ "SRTP ice call", srtp_ice_call },
|
||||
#endif
|
||||
{ "SRTP ice call", srtp_ice_call },
|
||||
{ "ZRTP ice call", zrtp_ice_call },
|
||||
{ "ZRTP ice call with relay", zrtp_ice_call_with_relay},
|
||||
{ "Call with privacy", call_with_privacy },
|
||||
{ "Call with privacy 2", call_with_privacy2 },
|
||||
{ "Call rejected because of wrong credential", call_rejected_because_wrong_credentials},
|
||||
|
|
|
|||
|
|
@ -181,6 +181,9 @@ typedef struct _stats {
|
|||
int number_of_LinphoneConfiguringSkipped;
|
||||
int number_of_LinphoneConfiguringFailed;
|
||||
int number_of_LinphoneConfiguringSuccessful;
|
||||
|
||||
int number_of_LinphoneCallEncryptedOn;
|
||||
int number_of_LinphoneCallEncryptedOff;
|
||||
}stats;
|
||||
|
||||
typedef struct _LinphoneCoreManager {
|
||||
|
|
@ -212,6 +215,7 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *ev, Lin
|
|||
void linphone_publish_state_changed(LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state);
|
||||
void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *eventname, const LinphoneContent *content);
|
||||
void linphone_configuration_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message);
|
||||
void linphone_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token);
|
||||
|
||||
LinphoneAddress * create_linphone_address(const char * domain);
|
||||
bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value);
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_f
|
|||
mgr->v_table.notify_received=linphone_notify_received;
|
||||
mgr->v_table.publish_state_changed=linphone_publish_state_changed;
|
||||
mgr->v_table.configuring_status=linphone_configuration_status;
|
||||
mgr->v_table.call_encryption_changed=linphone_call_encryption_changed;
|
||||
|
||||
reset_counters(&mgr->stat);
|
||||
if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue