>From a848436eecb14fe91b22fbe38f65358e80753bbd Mon Sep 17 00:00:00 2001 From: Ben Sartor Date: Thu, 5 Feb 2015 08:27:16 +0100 Subject: [PATCH 3/3] configfile now supports setting zrtps key agreements --- coreapi/linphonecall.c | 2 ++ coreapi/misc.c | 35 +++++++++++++++++++++++++++++++++++ coreapi/private.h | 1 + 3 files changed, 38 insertions(+) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index fbeaf00..f413435 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2606,6 +2606,8 @@ static void setZrtpCryptoTypesParameters(MSZrtpParams *params, LinphoneCore *lc) } } } + + params->keyAgreementsCount = linphone_core_get_zrtp_key_agreements(lc, params->keyAgreements); } void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_muted, bool_t send_ringbacktone){ diff --git a/coreapi/misc.c b/coreapi/misc.c index d8c7cba..c75a728 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1581,6 +1581,41 @@ const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc){ return result; } +static char * seperate_string_list(char **str) { + char *ret; + + if (str == NULL) return NULL; + if (*str == NULL) return NULL; + if (**str == '\0') return NULL; + + ret = *str; + for ( ; **str!='\0' && **str!=' ' && **str!=','; (*str)++); + if (**str == '\0') { + return ret; + } else { + **str = '\0'; + do { (*str)++; } while (**str!='\0' && (**str==' ' || **str==',')); + return ret; + } +} + +MsZrtpCryptoTypesCount linphone_core_get_zrtp_key_agreements(LinphoneCore *lc, MSZrtpKeyAgreement keyAgreements[MS_MAX_ZRTP_CRYPTO_TYPES]){ + char *config=strdup(lp_config_get_string(lc->config, "sip", "zrtp_key_agreements_suites", "MS_ZRTP_KEY_AGREEMENT_DH3K, MS_ZRTP_KEY_AGREEMENT_DH2K")); + char *entry; + MsZrtpCryptoTypesCount key_agreements_count = 0; + + if (config == NULL) return 0; + + while ((entry = seperate_string_list(&config))) { + const MSZrtpKeyAgreement agreement = ms_zrtp_key_agreement_from_string(entry); + if (agreement != MS_ZRTP_KEY_AGREEMENT_INVALID) { + ms_message("Configured zrtp key agreement: '%s'", ms_zrtp_key_agreement_to_string(agreement)); + keyAgreements[key_agreements_count++] = agreement; + } + } + + return key_agreements_count; +} const char ** linphone_core_get_supported_file_formats(LinphoneCore *core){ diff --git a/coreapi/private.h b/coreapi/private.h index 1508394..5db26c0 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1043,6 +1043,7 @@ static MS2_INLINE bool_t payload_type_enabled(const PayloadType *pt) { bool_t is_payload_type_number_available(const MSList *l, int number, const PayloadType *ignore); const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc); +MsZrtpCryptoTypesCount linphone_core_get_zrtp_key_agreements(LinphoneCore *lc, MSZrtpKeyAgreement keyAgreements[MS_MAX_ZRTP_CRYPTO_TYPES]); /** Belle Sip-based objects need unique ids */ -- 2.1.4