...
 
Commits (5)
......@@ -1409,6 +1409,13 @@ static void sip_config_read(LinphoneCore *lc) {
tmp=lp_config_get_int(lc->config,"sip","delayed_timeout",4);
linphone_core_set_delayed_timeout(lc,tmp);
/*In case of remote provisionning, function sip_config_read is initialy called in core_init, then in state ConfiguringSuccessfull*/
/*Accordingly, to avoid proxy_config to be added twice, it is mandatory to reset proxy config list from LinphoneCore*/
/*We assume, lc->config contains an accurate list of proxy_config, so no need to keep it from LinphoneCore */
/*Consequence in case of remote provisionning, linphone_core_add_proxy function should not be called before state GlobalOn*/
linphone_core_clear_proxy_config(lc);
/* get proxies config */
for(i=0;; i++){
LinphoneProxyConfig *cfg=linphone_proxy_config_new_from_config_file(lc,i);
......@@ -5693,7 +5700,7 @@ typedef enum{
LinphoneLocalPlayer
}LinphoneAudioResourceType;
static MSFilter *get_audio_resource(LinphoneCore *lc, LinphoneAudioResourceType rtype, MSSndCard *card) {
static MSFilter *get_audio_resource(LinphoneCore *lc, LinphoneAudioResourceType rtype, MSSndCard *card, bool_t create) {
LinphoneCall *call=linphone_core_get_current_call(lc);
AudioStream *stream=NULL;
RingStream *ringstream;
......@@ -5721,6 +5728,8 @@ static MSFilter *get_audio_resource(LinphoneCore *lc, LinphoneAudioResourceType
if (ringcard == NULL)
return NULL;
if (!create) return NULL;
ringstream=lc->ringstream=ring_start(lc->factory, NULL,0,ringcard);
ms_filter_call_method(lc->ringstream->gendtmf,MS_DTMF_GEN_SET_DEFAULT_AMPLITUDE,&amp);
......@@ -5736,7 +5745,7 @@ static MSFilter *get_audio_resource(LinphoneCore *lc, LinphoneAudioResourceType
}
static MSFilter *get_dtmf_gen(LinphoneCore *lc, MSSndCard *card) {
return get_audio_resource(lc,LinphoneToneGenerator, card);
return get_audio_resource(lc,LinphoneToneGenerator, card, TRUE);
}
void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms){
......@@ -5755,7 +5764,7 @@ void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms){
}
LinphoneStatus _linphone_core_play_local(LinphoneCore *lc, const char *audiofile, MSSndCard *card) {
MSFilter *f=get_audio_resource(lc,LinphoneLocalPlayer, card);
MSFilter *f=get_audio_resource(lc,LinphoneLocalPlayer, card, TRUE);
int loopms=-1;
if (!f) return -1;
ms_filter_call_method(f,MS_PLAYER_SET_LOOP,&loopms);
......@@ -5829,7 +5838,7 @@ void linphone_core_play_call_error_tone(LinphoneCore *lc, LinphoneReason reason)
}
void linphone_core_stop_dtmf(LinphoneCore *lc){
MSFilter *f=get_dtmf_gen(lc, NULL);
MSFilter *f=get_audio_resource(lc, LinphoneToneGenerator, NULL, FALSE);
if (f!=NULL)
ms_filter_call_method_noarg (f, MS_DTMF_GEN_STOP);
}
......
......@@ -185,6 +185,7 @@ static const char *_linphone_logging_service_log_domains[] = {
"ortp",
"mediastreamer",
"bzrtp",
"tunnel",
BCTBX_LOG_DOMAIN, /* which is "liblinphone", set from CMakeList.txt*/
NULL
};
......
......@@ -89,6 +89,7 @@ struct _LinphoneProxyConfig
char *reg_identity;
LinphoneAddress* identity_address;
LinphoneAddress *contact_address;
LinphoneAddress *service_route;
LinphoneAddress *contact_address_without_params;
bctbx_list_t *reg_routes;
char *quality_reporting_collector;
......
......@@ -265,6 +265,7 @@ void _linphone_proxy_config_destroy(LinphoneProxyConfig *cfg){
linphone_error_info_unref(cfg->ei);
}
if (cfg->service_route) linphone_address_unref(cfg->service_route);
if (cfg->contact_address) linphone_address_unref(cfg->contact_address);
if (cfg->contact_address_without_params)
linphone_address_unref(cfg->contact_address_without_params);
......@@ -1416,8 +1417,22 @@ const LinphoneErrorInfo *linphone_proxy_config_get_error_info(const LinphoneProx
}
const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphoneProxyConfig* cfg) {
return cfg->op?(const LinphoneAddress*) cfg->op->getServiceRoute():NULL;
if (!cfg->op)
return NULL;
const SalAddress *salAddr = cfg->op->getServiceRoute();
if (!salAddr)
return NULL;
if (cfg->service_route)
L_GET_PRIVATE_FROM_C_OBJECT(cfg->service_route)->setInternalAddress(const_cast<SalAddress *>(salAddr));
else {
char *buf = sal_address_as_string(salAddr);
const_cast<LinphoneProxyConfig *>(cfg)->service_route = linphone_address_new(buf);
ms_free(buf);
}
return cfg->service_route;
}
const char* linphone_proxy_config_get_transport(const LinphoneProxyConfig *cfg) {
const char* addr=NULL;
const char* ret="udp"; /*default value*/
......
......@@ -169,7 +169,6 @@ private:
SalMulticastRole getMulticastRole (SalStreamType type);
void joinMulticastGroup (int streamIndex, MediaStream *ms);
int findCryptoIndexFromTag (const SalSrtpCryptoAlgo crypto[], unsigned char tag);
void setDtlsFingerprint (MSMediaStreamSessions *sessions, const SalStreamDescription *sd, const SalStreamDescription *remote);
void setDtlsFingerprintOnAllStreams ();
void setupDtlsParams (MediaStream *ms);
......
......@@ -1710,14 +1710,6 @@ void MediaSessionPrivate::joinMulticastGroup (int streamIndex, MediaStream *ms)
// -----------------------------------------------------------------------------
int MediaSessionPrivate::findCryptoIndexFromTag (const SalSrtpCryptoAlgo crypto[], unsigned char tag) {
for (int i = 0; i < SAL_CRYPTO_ALGO_MAX; i++) {
if (crypto[i].tag == tag)
return i;
}
return -1;
}
void MediaSessionPrivate::setDtlsFingerprint (MSMediaStreamSessions *sessions, const SalStreamDescription *sd, const SalStreamDescription *remote) {
if (sal_stream_description_has_dtls(sd)) {
if (sd->dtls_role == SalDtlsRoleInvalid)
......@@ -1881,7 +1873,7 @@ void MediaSessionPrivate::updateCryptoParameters (SalMediaDescription *oldMd, Sa
}
bool MediaSessionPrivate::updateStreamCryptoParameters (const SalStreamDescription *localStreamDesc, SalStreamDescription *oldStream, SalStreamDescription *newStream, MediaStream *ms) {
int cryptoIdx = findCryptoIndexFromTag(localStreamDesc->crypto, static_cast<unsigned char>(newStream->crypto_local_tag));
int cryptoIdx = Sal::findCryptoIndexFromTag(localStreamDesc->crypto, static_cast<unsigned char>(newStream->crypto_local_tag));
if (cryptoIdx >= 0) {
if (localDescChanged & SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED)
ms_media_stream_sessions_set_srtp_send_key_b64(&ms->sessions, newStream->crypto[0].algo, localStreamDesc->crypto[cryptoIdx].master_key);
......@@ -2694,7 +2686,7 @@ void MediaSessionPrivate::startAudioStream (CallSession::State targetState, bool
// Valid local tags are > 0
if (sal_stream_description_has_srtp(stream)) {
const SalStreamDescription *localStreamDesc = sal_media_description_find_stream(localDesc, stream->proto, SalAudio);
int cryptoIdx = findCryptoIndexFromTag(localStreamDesc->crypto, static_cast<unsigned char>(stream->crypto_local_tag));
int cryptoIdx = Sal::findCryptoIndexFromTag(localStreamDesc->crypto, static_cast<unsigned char>(stream->crypto_local_tag));
if (cryptoIdx >= 0) {
ms_media_stream_sessions_set_srtp_recv_key_b64(&audioStream->ms.sessions, stream->crypto[0].algo, stream->crypto[0].master_key);
ms_media_stream_sessions_set_srtp_send_key_b64(&audioStream->ms.sessions, stream->crypto[0].algo, localStreamDesc->crypto[cryptoIdx].master_key);
......@@ -2874,7 +2866,7 @@ void MediaSessionPrivate::startTextStream () {
getCurrentParams()->getPrivate()->setUsedRealtimeTextCodec(rtp_profile_get_payload(textProfile, usedPt));
getCurrentParams()->enableRealtimeText(true);
if (sal_stream_description_has_srtp(tstream)) {
int cryptoIdx = findCryptoIndexFromTag(localStreamDesc->crypto, static_cast<unsigned char>(tstream->crypto_local_tag));
int cryptoIdx = Sal::findCryptoIndexFromTag(localStreamDesc->crypto, static_cast<unsigned char>(tstream->crypto_local_tag));
if (cryptoIdx >= 0) {
ms_media_stream_sessions_set_srtp_recv_key_b64(&textStream->ms.sessions, tstream->crypto[0].algo, tstream->crypto[0].master_key);
ms_media_stream_sessions_set_srtp_send_key_b64(&textStream->ms.sessions, tstream->crypto[0].algo, localStreamDesc->crypto[cryptoIdx].master_key);
......@@ -2967,7 +2959,7 @@ void MediaSessionPrivate::startVideoStream (CallSession::State targetState) {
if (isActive) {
if (sal_stream_description_has_srtp(vstream)) {
const SalStreamDescription *localStreamDesc = sal_media_description_find_stream(localDesc, vstream->proto, SalVideo);
int cryptoIdx = findCryptoIndexFromTag(localStreamDesc->crypto, static_cast<unsigned char>(vstream->crypto_local_tag));
int cryptoIdx = Sal::findCryptoIndexFromTag(localStreamDesc->crypto, static_cast<unsigned char>(vstream->crypto_local_tag));
if (cryptoIdx >= 0) {
ms_media_stream_sessions_set_srtp_recv_key_b64(&videoStream->ms.sessions, vstream->crypto[0].algo, vstream->crypto[0].master_key);
ms_media_stream_sessions_set_srtp_send_key_b64(&videoStream->ms.sessions, vstream->crypto[0].algo, localStreamDesc->crypto[cryptoIdx].master_key);
......
......@@ -339,9 +339,13 @@ void SalCallOp::sdpProcess(){
strcpy(mResult->streams[i].rtcp_addr,mRemoteMedia->streams[i].rtcp_addr);
mResult->streams[i].rtcp_port=mRemoteMedia->streams[i].rtcp_port;
if (sal_stream_description_has_srtp(&mResult->streams[i])) {
mResult->streams[i].crypto[0] = mRemoteMedia->streams[i].crypto[0];
}
if (sal_stream_description_has_srtp(&mResult->streams[i])) {
int cryptoIdx = Sal::findCryptoIndexFromTag( mRemoteMedia->streams[i].crypto, static_cast<unsigned char>(mResult->streams[i].crypto[0].tag));
if (cryptoIdx >= 0)
mResult->streams[i].crypto[0] = mRemoteMedia->streams[i].crypto[cryptoIdx];
else
lError() << "Failed to find crypto algo with tag: " << mResult->streams[i].crypto_local_tag << "from resulting description [" << mResult << "]";
}
}
}
}
......
......@@ -823,6 +823,13 @@ belle_sip_response_t* Sal::createResponseFromRequest (belle_sip_request_t* req,
return resp;
}
int Sal::findCryptoIndexFromTag (const SalSrtpCryptoAlgo crypto[], unsigned char tag) {
for (int i = 0; i < SAL_CRYPTO_ALGO_MAX; i++) {
if (crypto[i].tag == tag)
return i;
}
return -1;
}
......
......@@ -253,6 +253,8 @@ public:
belle_sip_source_t *createTimer (belle_sip_source_func_t func, void *data, unsigned int timeoutValueMs, const std::string &timerName);
void cancelTimer (belle_sip_source_t *timer);
//utils
static int findCryptoIndexFromTag (const SalSrtpCryptoAlgo crypto[], unsigned char tag);
private:
struct SalUuid {
......
......@@ -2665,6 +2665,13 @@ static void srtp_call(void) {
call_base(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE);
}
/*
*Purpose of this test is to check that even if caller and callee does not have exactly the same crypto suite configured, the matching crypto suite is used.
*/
static void srtp_call_with_different_crypto_suite(void) {
call_base_with_configfile(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "laure_tcp_rc", "marie_rc");
}
static void zrtp_call(void) {
call_base(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE);
}
......@@ -6542,6 +6549,7 @@ test_t call_tests[] = {
TEST_NO_TAG("Call paused resumed with loss", call_paused_resumed_with_loss),
TEST_NO_TAG("Call paused resumed from callee", call_paused_resumed_from_callee),
TEST_NO_TAG("SRTP call", srtp_call),
TEST_NO_TAG("SRTP call with different crypto suite", srtp_call_with_different_crypto_suite),
TEST_NO_TAG("ZRTP call", zrtp_call),
TEST_NO_TAG("ZRTP silent call", zrtp_silent_call),
TEST_NO_TAG("ZRTP SAS call", zrtp_sas_call),
......
......@@ -4,6 +4,7 @@ sip_tcp_port=-1
sip_tls_port=-1
default_proxy=0
ping_with_options=0
srtp_crypto_suites=AES_256_CM_HMAC_SHA1_80
[auth_info_0]
username=laure
......
......@@ -45,6 +45,8 @@ static void remote_provisioning_http(void) {
LinphoneCoreManager* marie = linphone_core_manager_new2("marie_remote_rc", FALSE);
BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneConfiguringSuccessful,1));
BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneRegistrationOk,1));
/*make sure proxy config is not added in double, one time at core init, next time at configuring successfull*/
BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_proxy_config_list(marie->lc)), 1, int,"%i");
linphone_core_manager_destroy(marie);
}
......