mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
fix(core): coding style, avoid spaces => use tabs instead, alignment...
This commit is contained in:
parent
b7d0db120f
commit
d41e2d5df5
8 changed files with 173 additions and 148 deletions
|
|
@ -43,30 +43,29 @@ BELLE_SIP_INSTANCIATE_VPTR(
|
|||
);
|
||||
|
||||
LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm, const char *domain){
|
||||
return linphone_auth_info_new_for_algorithm(username, userid, passwd, ha1, realm, domain, NULL);
|
||||
return linphone_auth_info_new_for_algorithm(username, userid, passwd, ha1, realm, domain, NULL);
|
||||
}
|
||||
|
||||
LinphoneAuthInfo *linphone_auth_info_new_for_algorithm(const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm, const char *domain, const char *algorithm){
|
||||
LinphoneAuthInfo *obj=belle_sip_object_new(LinphoneAuthInfo);
|
||||
if (username!=NULL && (strlen(username)>0) ) obj->username=ms_strdup(username);
|
||||
if (userid!=NULL && (strlen(userid)>0)) obj->userid=ms_strdup(userid);
|
||||
if (passwd!=NULL && (strlen(passwd)>0)) obj->passwd=ms_strdup(passwd);
|
||||
if (ha1!=NULL && (strlen(ha1)>0)) obj->ha1=ms_strdup(ha1);
|
||||
if (realm!=NULL && (strlen(realm)>0)) obj->realm=ms_strdup(realm);
|
||||
if (domain!=NULL && (strlen(domain)>0)) obj->domain=ms_strdup(domain);
|
||||
/* Default algorithm is MD5 if it's NULL*/
|
||||
if(algorithm==NULL)
|
||||
obj->algorithm = ms_strdup("MD5");
|
||||
/* If algorithm is neither MD5 or SHA-256, exit wit error*/
|
||||
if(algorithm && strcmp(algorithm, "MD5") && strcmp(algorithm, "SHA-256")){
|
||||
ms_error("Given algorithm %s is not correct.", algorithm);
|
||||
return NULL;
|
||||
}
|
||||
/*Else, set algorithm for obj */
|
||||
if(algorithm){
|
||||
obj->algorithm=ms_strdup(algorithm);
|
||||
}
|
||||
return obj;
|
||||
LinphoneAuthInfo *obj=belle_sip_object_new(LinphoneAuthInfo);
|
||||
if (username!=NULL && (strlen(username)>0) ) obj->username=ms_strdup(username);
|
||||
if (userid!=NULL && (strlen(userid)>0)) obj->userid=ms_strdup(userid);
|
||||
if (passwd!=NULL && (strlen(passwd)>0)) obj->passwd=ms_strdup(passwd);
|
||||
if (ha1!=NULL && (strlen(ha1)>0)) obj->ha1=ms_strdup(ha1);
|
||||
if (realm!=NULL && (strlen(realm)>0)) obj->realm=ms_strdup(realm);
|
||||
if (domain!=NULL && (strlen(domain)>0)) obj->domain=ms_strdup(domain);
|
||||
|
||||
if (!algorithm)
|
||||
obj->algorithm = ms_strdup("MD5");
|
||||
|
||||
if(algorithm && strcmp(algorithm, "MD5") && strcmp(algorithm, "SHA-256")){
|
||||
ms_error("Given algorithm %s is not correct.", algorithm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(algorithm)
|
||||
obj->algorithm=ms_strdup(algorithm);
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void _linphone_auth_info_copy(LinphoneAuthInfo *dst, const LinphoneAuthInfo *src) {
|
||||
|
|
@ -80,7 +79,7 @@ static void _linphone_auth_info_copy(LinphoneAuthInfo *dst, const LinphoneAuthIn
|
|||
if (src->tls_key) dst->tls_key = ms_strdup(src->tls_key);
|
||||
if (src->tls_cert_path) dst->tls_cert_path = ms_strdup(src->tls_cert_path);
|
||||
if (src->tls_key_path) dst->tls_key_path = ms_strdup(src->tls_key_path);
|
||||
if (src->algorithm) dst->algorithm = ms_strdup(src->algorithm);
|
||||
if (src->algorithm) dst->algorithm = ms_strdup(src->algorithm);
|
||||
}
|
||||
|
||||
LinphoneAuthInfo *linphone_auth_info_clone(const LinphoneAuthInfo *ai){
|
||||
|
|
@ -234,7 +233,7 @@ static void _linphone_auth_info_uninit(LinphoneAuthInfo *obj) {
|
|||
if (obj->tls_key != NULL) ms_free(obj->tls_key);
|
||||
if (obj->tls_cert_path != NULL) ms_free(obj->tls_cert_path);
|
||||
if (obj->tls_key_path != NULL) ms_free(obj->tls_key_path);
|
||||
if (obj->algorithm != NULL) ms_free(obj->algorithm);
|
||||
if (obj->algorithm != NULL) ms_free(obj->algorithm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -255,17 +254,16 @@ void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, in
|
|||
return;
|
||||
}
|
||||
if (!obj->ha1 && obj->realm && obj->passwd && (obj->username || obj->userid) && store_ha1_passwd) {
|
||||
/*compute ha1 to avoid storing clear text password*/
|
||||
/* Default algorithm is MD5 if it's NULL */
|
||||
if((obj->algorithm==NULL)||(!(strcmp(obj->algorithm, "MD5")))){
|
||||
obj->ha1 = reinterpret_cast<char *>(ms_malloc(33));
|
||||
sal_auth_compute_ha1(obj->userid ? obj->userid : obj->username, obj->realm, obj->passwd, obj->ha1);
|
||||
}
|
||||
/* If algorithm is SHA-256, calcul ha1 by sha256*/
|
||||
if((obj->algorithm)&&(!(strcmp(obj->algorithm, "SHA-256")))){
|
||||
obj->ha1 = reinterpret_cast<char *>(ms_malloc(65));
|
||||
sal_auth_compute_ha1_for_algorithm(obj->userid ? obj->userid : obj->username, obj->realm, obj->passwd, obj->ha1,65, obj->algorithm);
|
||||
}
|
||||
/* Default algorithm is MD5 if it's NULL */
|
||||
if((obj->algorithm==NULL)||(!(strcmp(obj->algorithm, "MD5")))){
|
||||
obj->ha1 = reinterpret_cast<char *>(ms_malloc(33));
|
||||
sal_auth_compute_ha1(obj->userid ? obj->userid : obj->username, obj->realm, obj->passwd, obj->ha1);
|
||||
}
|
||||
/* If algorithm is SHA-256, calcul ha1 by sha256*/
|
||||
if((obj->algorithm)&&(!(strcmp(obj->algorithm, "SHA-256")))){
|
||||
obj->ha1 = reinterpret_cast<char *>(ms_malloc(65));
|
||||
sal_auth_compute_ha1_for_algorithm(obj->userid ? obj->userid : obj->username, obj->realm, obj->passwd, obj->ha1,65, obj->algorithm);
|
||||
}
|
||||
}
|
||||
if (obj->username != NULL) {
|
||||
lp_config_set_string(config, key, "username", obj->username);
|
||||
|
|
@ -297,9 +295,9 @@ void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, in
|
|||
if (obj->tls_key_path != NULL) {
|
||||
lp_config_set_string(config, key, "client_cert_key", obj->tls_key_path);
|
||||
}
|
||||
if (obj->algorithm != NULL) {
|
||||
lp_config_set_string(config, key, "algorithm", obj->algorithm);
|
||||
}
|
||||
if (obj->algorithm != NULL) {
|
||||
lp_config_set_string(config, key, "algorithm", obj->algorithm);
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneAuthInfo *linphone_auth_info_new_from_config_file(LpConfig * config, int pos)
|
||||
|
|
@ -484,7 +482,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
|
|||
sai.realm=ai->realm;
|
||||
sai.password=ai->passwd;
|
||||
sai.ha1=ai->ha1;
|
||||
sai.algorithm=ai->algorithm;
|
||||
sai.algorithm=ai->algorithm;
|
||||
if (ai->tls_cert && ai->tls_key) {
|
||||
sal_certificates_chain_parse(&sai, ai->tls_cert, SAL_CERTIFICATE_RAW_FORMAT_PEM);
|
||||
sal_signing_key_parse(&sai, ai->tls_key, "");
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ SalAuthInfo* sal_auth_info_create(belle_sip_auth_event_t* event) {
|
|||
auth_info->username = ms_strdup(belle_sip_auth_event_get_username(event));
|
||||
auth_info->domain = ms_strdup(belle_sip_auth_event_get_domain(event));
|
||||
auth_info->mode = (SalAuthMode)belle_sip_auth_event_get_mode(event);
|
||||
auth_info->algorithm = ms_strdup(belle_sip_auth_event_get_algorithm(event));
|
||||
auth_info->algorithm = ms_strdup(belle_sip_auth_event_get_algorithm(event));
|
||||
return auth_info;
|
||||
}
|
||||
|
||||
|
|
@ -84,9 +84,15 @@ int sal_auth_compute_ha1(const char* userid,const char* realm,const char* passwo
|
|||
return belle_sip_auth_helper_compute_ha1(userid, realm, password, ha1);
|
||||
}
|
||||
|
||||
int sal_auth_compute_ha1_for_algorithm(const char* userid,const char* realm,const char* password, char* ha1,
|
||||
size_t size, const char* algo) {
|
||||
return belle_sip_auth_helper_compute_ha1_for_algorithm(userid, realm, password, ha1, size, algo);
|
||||
int sal_auth_compute_ha1_for_algorithm(
|
||||
const char *userid,
|
||||
const char *realm,
|
||||
const char *password,
|
||||
char *ha1,
|
||||
size_t size,
|
||||
const char *algo
|
||||
) {
|
||||
return belle_sip_auth_helper_compute_ha1_for_algorithm(userid, realm, password, ha1, size, algo);
|
||||
}
|
||||
|
||||
SalCustomHeader *sal_custom_header_ref(SalCustomHeader *ch){
|
||||
|
|
|
|||
|
|
@ -526,15 +526,18 @@ static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) {
|
|||
}
|
||||
if (ai) {
|
||||
if (sai->mode == SalAuthModeHttpDigest) {
|
||||
/* Compare algorithm of server(sai) with algorithm of client(ai), if they are not correspondant,
|
||||
exit. The default algorithm is MD5 if it's NULL. */
|
||||
if(sai->algorithm && ai->algorithm) {
|
||||
if(strcmp(ai->algorithm, sai->algorithm))
|
||||
return TRUE;
|
||||
}
|
||||
else if((ai->algorithm && strcmp(ai->algorithm, "MD5")) ||
|
||||
(sai->algorithm && strcmp(sai->algorithm, "MD5")))
|
||||
return TRUE;
|
||||
/*
|
||||
* Compare algorithm of server(sai) with algorithm of client(ai), if they are not correspondant,
|
||||
* exit. The default algorithm is MD5 if it's NULL.
|
||||
*/
|
||||
if (sai->algorithm && ai->algorithm) {
|
||||
if (strcmp(ai->algorithm, sai->algorithm))
|
||||
return TRUE;
|
||||
} else if (
|
||||
(ai->algorithm && strcmp(ai->algorithm, "MD5")) ||
|
||||
(sai->algorithm && strcmp(sai->algorithm, "MD5"))
|
||||
)
|
||||
return TRUE;
|
||||
|
||||
sai->userid = ms_strdup(ai->userid ? ai->userid : ai->username);
|
||||
sai->password = ai->passwd?ms_strdup(ai->passwd) : NULL;
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ struct _LinphoneAuthInfo
|
|||
char *tls_key;
|
||||
char *tls_cert_path;
|
||||
char *tls_key_path;
|
||||
char *algorithm;
|
||||
char *algorithm;
|
||||
};
|
||||
|
||||
typedef enum _LinphoneIsComposingState {
|
||||
|
|
|
|||
|
|
@ -51,11 +51,25 @@ extern "C" {
|
|||
* @return A #LinphoneAuthInfo object. linphone_auth_info_destroy() must be used to destroy it when no longer needed. The LinphoneCore makes a copy of LinphoneAuthInfo
|
||||
* passed through linphone_core_add_auth_info().
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid,
|
||||
const char *passwd, const char *ha1,const char *realm, const char *domain);
|
||||
|
||||
LINPHONE_PUBLIC LinphoneAuthInfo *linphone_auth_info_new_for_algorithm(const char *username, const char *userid,
|
||||
const char *passwd, const char *ha1,const char *realm, const char *domain, const char *algorithm);
|
||||
LINPHONE_PUBLIC LinphoneAuthInfo *linphone_auth_info_new(
|
||||
const char *username,
|
||||
const char *userid,
|
||||
const char *passwd,
|
||||
const char *ha1,
|
||||
const char *rfealm,
|
||||
const char *domain
|
||||
);
|
||||
|
||||
LINPHONE_PUBLIC LinphoneAuthInfo *linphone_auth_info_new_for_algorithm(
|
||||
const char *username,
|
||||
const char *userid,
|
||||
const char *passwd,
|
||||
const char *ha1,
|
||||
const char *realm,
|
||||
const char *domain,
|
||||
const char *algorithm
|
||||
);
|
||||
|
||||
/**
|
||||
* Instantiates a new auth info with values from source.
|
||||
* @param[in] source The #LinphoneAuthInfo object to be cloned
|
||||
|
|
|
|||
|
|
@ -762,7 +762,7 @@ SalAuthInfo* sal_auth_info_clone(const SalAuthInfo* auth_info) {
|
|||
new_auth_info->realm=auth_info->realm?ms_strdup(auth_info->realm):NULL;
|
||||
new_auth_info->domain=auth_info->realm?ms_strdup(auth_info->domain):NULL;
|
||||
new_auth_info->password=auth_info->password?ms_strdup(auth_info->password):NULL;
|
||||
new_auth_info->algorithm=auth_info->algorithm?ms_strdup(auth_info->algorithm):NULL;
|
||||
new_auth_info->algorithm=auth_info->algorithm?ms_strdup(auth_info->algorithm):NULL;
|
||||
return new_auth_info;
|
||||
}
|
||||
|
||||
|
|
@ -775,7 +775,7 @@ void sal_auth_info_delete(SalAuthInfo* auth_info) {
|
|||
if (auth_info->ha1) ms_free(auth_info->ha1);
|
||||
if (auth_info->certificates) sal_certificates_chain_delete(auth_info->certificates);
|
||||
if (auth_info->key) sal_signing_key_delete(auth_info->key);
|
||||
if (auth_info->algorithm) ms_free(auth_info->algorithm);
|
||||
if (auth_info->algorithm) ms_free(auth_info->algorithm);
|
||||
ms_free(auth_info);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@
|
|||
protocols and implementations under linphone, for example SIP, JINGLE...
|
||||
**/
|
||||
|
||||
#ifndef sal_h
|
||||
#define sal_h
|
||||
#ifndef _C_SAL_H_
|
||||
#define _C_SAL_H_
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mediastreamer2/mediastream.h"
|
||||
|
|
@ -263,7 +263,7 @@ typedef struct SalStreamDescription{
|
|||
SalSrtpCryptoAlgo crypto[SAL_CRYPTO_ALGO_MAX];
|
||||
unsigned int crypto_local_tag;
|
||||
int max_rate;
|
||||
bool_t implicit_rtcp_fb;
|
||||
bool_t implicit_rtcp_fb;
|
||||
OrtpRtcpFbConfiguration rtcp_fb;
|
||||
OrtpRtcpXrConfiguration rtcp_xr;
|
||||
SalCustomSdpAttribute *custom_sdp_attributes;
|
||||
|
|
@ -474,7 +474,7 @@ typedef struct SalAuthInfo{
|
|||
char *realm;
|
||||
char *domain;
|
||||
char *ha1;
|
||||
char *algorithm;
|
||||
char *algorithm;
|
||||
SalAuthMode mode;
|
||||
belle_sip_signing_key_t *key;
|
||||
belle_sip_certificates_chain_t *certificates;
|
||||
|
|
@ -488,10 +488,8 @@ extern "C" {
|
|||
SalAuthInfo* sal_auth_info_new(void);
|
||||
SalAuthInfo* sal_auth_info_clone(const SalAuthInfo* auth_info);
|
||||
void sal_auth_info_delete(SalAuthInfo* auth_info);
|
||||
LINPHONE_PUBLIC int sal_auth_compute_ha1(const char* userid,const char* realm,const char* password, char ha1[33]);
|
||||
LINPHONE_PUBLIC int sal_auth_compute_ha1_for_algorithm(const char* userid,const char* realm,const char* password, char *ha1,size_t size,const char* algo);
|
||||
/*LINPHONE_PUBLIC int sal_auth_compute_ha1_for_algorithm(const char* userid,const char* realm,const char* password, char *ha1,
|
||||
size_t size, const char* algo);*/
|
||||
LINPHONE_PUBLIC int sal_auth_compute_ha1(const char *userid, const char *realm, const char *password, char ha1[33]);
|
||||
LINPHONE_PUBLIC int sal_auth_compute_ha1_for_algorithm(const char *userid, const char *realm, const char *password, char *ha1, size_t size, const char *algo);
|
||||
SalAuthMode sal_auth_info_get_mode(const SalAuthInfo* auth_info);
|
||||
belle_sip_signing_key_t *sal_auth_info_get_signing_key(const SalAuthInfo* auth_info);
|
||||
belle_sip_certificates_chain_t *sal_auth_info_get_certificates_chain(const SalAuthInfo* auth_info);
|
||||
|
|
@ -579,13 +577,13 @@ typedef enum _SalPrivacy {
|
|||
SalPrivacyCritical=0x10,
|
||||
SalPrivacyDefault=0x8000
|
||||
} SalPrivacy;
|
||||
typedef unsigned int SalPrivacyMask;
|
||||
typedef unsigned int SalPrivacyMask;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const char* sal_privacy_to_string(SalPrivacy privacy);
|
||||
const char* sal_privacy_to_string(SalPrivacy privacy);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
@ -593,8 +591,8 @@ const char* sal_privacy_to_string(SalPrivacy privacy);
|
|||
|
||||
|
||||
|
||||
#define payload_type_set_number(pt,n) (pt)->user_data=(void*)((intptr_t)n);
|
||||
#define payload_type_get_number(pt) ((int)(intptr_t)(pt)->user_data)
|
||||
#define payload_type_set_number(pt,n) (pt)->user_data=(void*)((intptr_t)n);
|
||||
#define payload_type_get_number(pt) ((int)(intptr_t)(pt)->user_data)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -64,14 +64,16 @@ void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *c
|
|||
}
|
||||
}
|
||||
|
||||
static void register_with_refresh_base_3_for_algo(LinphoneCore* lc
|
||||
, bool_t refresh
|
||||
,const char* domain
|
||||
,const char* route
|
||||
,bool_t late_auth_info
|
||||
,LinphoneTransports *transport
|
||||
,LinphoneRegistrationState expected_final_state
|
||||
,const char* username) {
|
||||
static void register_with_refresh_base_3_for_algo(
|
||||
LinphoneCore* lc,
|
||||
bool_t refresh,
|
||||
const char* domain,
|
||||
const char* route,
|
||||
bool_t late_auth_info,
|
||||
LinphoneTransports *transport,
|
||||
LinphoneRegistrationState expected_final_state,
|
||||
const char* username
|
||||
) {
|
||||
int retry=0;
|
||||
char* addr;
|
||||
LinphoneProxyConfig* proxy_cfg;
|
||||
|
|
@ -89,7 +91,7 @@ static void register_with_refresh_base_3_for_algo(LinphoneCore* lc
|
|||
|
||||
proxy_cfg = linphone_proxy_config_new();
|
||||
|
||||
from = create_linphone_address_for_algo(domain, username);
|
||||
from = create_linphone_address_for_algo(domain, username);
|
||||
|
||||
linphone_proxy_config_set_identity(proxy_cfg,addr=linphone_address_as_string(from));
|
||||
ms_free(addr);
|
||||
|
|
@ -114,7 +116,7 @@ static void register_with_refresh_base_3_for_algo(LinphoneCore* lc
|
|||
if (counters->number_of_auth_info_requested>0 && linphone_proxy_config_get_state(proxy_cfg) == LinphoneRegistrationFailed && late_auth_info) {
|
||||
if (!linphone_core_get_auth_info_list(lc)) {
|
||||
BC_ASSERT_EQUAL(linphone_proxy_config_get_error(proxy_cfg),LinphoneReasonUnauthorized, int, "%d");
|
||||
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
|
||||
linphone_auth_info_unref(info);
|
||||
}
|
||||
|
|
@ -137,55 +139,59 @@ static void register_with_refresh_base_3_for_algo(LinphoneCore* lc
|
|||
linphone_proxy_config_unref(proxy_cfg);
|
||||
}
|
||||
|
||||
static void register_with_refresh_base_3(LinphoneCore* lc
|
||||
, bool_t refresh
|
||||
,const char* domain
|
||||
,const char* route
|
||||
,bool_t late_auth_info
|
||||
,LinphoneTransports *transport
|
||||
,LinphoneRegistrationState expected_final_state) {
|
||||
register_with_refresh_base_3_for_algo(lc, refresh, domain, route, late_auth_info, transport, expected_final_state, NULL);
|
||||
static void register_with_refresh_base_3(
|
||||
LinphoneCore* lc,
|
||||
bool_t refresh,
|
||||
const char *domain,
|
||||
const char *route,
|
||||
bool_t late_auth_info,
|
||||
LinphoneTransports *transport,
|
||||
LinphoneRegistrationState expected_final_state
|
||||
) {
|
||||
register_with_refresh_base_3_for_algo(lc, refresh, domain, route, late_auth_info, transport, expected_final_state, NULL);
|
||||
}
|
||||
|
||||
static void register_with_refresh_base_2(LinphoneCore* lc
|
||||
, bool_t refresh
|
||||
,const char* domain
|
||||
,const char* route
|
||||
,bool_t late_auth_info
|
||||
,LinphoneTransports *transport) {
|
||||
register_with_refresh_base_3(lc, refresh, domain, route, late_auth_info, transport,LinphoneRegistrationOk );
|
||||
static void register_with_refresh_base_2(
|
||||
LinphoneCore* lc,
|
||||
bool_t refresh,
|
||||
const char *domain,
|
||||
const char *route,
|
||||
bool_t late_auth_info,
|
||||
LinphoneTransports *transport
|
||||
) {
|
||||
register_with_refresh_base_3(lc, refresh, domain, route, late_auth_info, transport,LinphoneRegistrationOk);
|
||||
}
|
||||
|
||||
static void register_with_refresh_base_for_algo(LinphoneCore* lc, bool_t refresh,const char* domain,const char* route, const char* username) {
|
||||
LinphoneTransports *transport = linphone_factory_create_transports(linphone_factory_get());
|
||||
linphone_transports_set_udp_port(transport, 5070);
|
||||
linphone_transports_set_tcp_port(transport, 5070);
|
||||
linphone_transports_set_tls_port(transport, 5071);
|
||||
linphone_transports_set_dtls_port(transport, 0);
|
||||
register_with_refresh_base_3_for_algo(lc,refresh,domain,route,FALSE,transport,LinphoneRegistrationOk,username);
|
||||
linphone_transports_unref(transport);
|
||||
static void register_with_refresh_base_for_algo(LinphoneCore* lc, bool_t refresh, const char *domain,const char *route, const char *username) {
|
||||
LinphoneTransports *transport = linphone_factory_create_transports(linphone_factory_get());
|
||||
linphone_transports_set_udp_port(transport, 5070);
|
||||
linphone_transports_set_tcp_port(transport, 5070);
|
||||
linphone_transports_set_tls_port(transport, 5071);
|
||||
linphone_transports_set_dtls_port(transport, 0);
|
||||
register_with_refresh_base_3_for_algo(lc,refresh,domain,route,FALSE,transport,LinphoneRegistrationOk,username);
|
||||
linphone_transports_unref(transport);
|
||||
}
|
||||
|
||||
static void register_with_refresh_base(LinphoneCore* lc, bool_t refresh,const char* domain,const char* route) {
|
||||
register_with_refresh_base_for_algo(lc, refresh, domain, route, NULL);
|
||||
static void register_with_refresh_base(LinphoneCore *lc, bool_t refresh, const char *domain, const char *route) {
|
||||
register_with_refresh_base_for_algo(lc, refresh, domain, route, NULL);
|
||||
}
|
||||
|
||||
static void register_with_refresh_for_algo(LinphoneCoreManager* lcm, bool_t refresh,const char* domain,const char* route,const char* username) {
|
||||
stats* counters = &lcm->stat;
|
||||
register_with_refresh_base_for_algo(lcm->lc,refresh,domain,route,username);
|
||||
linphone_core_manager_stop(lcm);
|
||||
BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,1, int, "%d");
|
||||
static void register_with_refresh_for_algo(LinphoneCoreManager *lcm, bool_t refresh, const char *domain, const char*route, const char *username) {
|
||||
stats* counters = &lcm->stat;
|
||||
register_with_refresh_base_for_algo(lcm->lc,refresh,domain,route,username);
|
||||
linphone_core_manager_stop(lcm);
|
||||
BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,1, int, "%d");
|
||||
}
|
||||
|
||||
static void register_with_refresh(LinphoneCoreManager* lcm, bool_t refresh,const char* domain,const char* route) {
|
||||
register_with_refresh_for_algo(lcm, refresh, domain, route, NULL);
|
||||
register_with_refresh_for_algo(lcm, refresh, domain, route, NULL);
|
||||
}
|
||||
|
||||
static void register_with_refresh_with_send_error(void) {
|
||||
int retry=0;
|
||||
LinphoneCoreManager* lcm = create_lcm_with_auth(1);
|
||||
stats* counters = &lcm->stat;
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
|
||||
char route[256];
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
|
|
@ -330,7 +336,7 @@ static void simple_tls_register(void){
|
|||
static void simple_authenticated_register(void){
|
||||
stats* counters;
|
||||
LinphoneCoreManager* lcm = create_lcm();
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new_for_algorithm(test_username,NULL,test_password,NULL,auth_domain,NULL,NULL); /*create authentication structure from identity*/
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new_for_algorithm(test_username,NULL,test_password,NULL,auth_domain,NULL,NULL); /*create authentication structure from identity*/
|
||||
char route[256];
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
|
|
@ -342,17 +348,17 @@ static void simple_authenticated_register(void){
|
|||
}
|
||||
|
||||
static void simple_authenticated_register_for_algorithm(void){
|
||||
stats* counters;
|
||||
LinphoneCoreManager* lcm = create_lcm();
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new_for_algorithm(test_sha_username,NULL,test_password,NULL,auth_domain,NULL,"SHA-256"); /*create authentication structure from identity*/
|
||||
char route[256];
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
linphone_auth_info_unref(info);
|
||||
counters = &lcm->stat;
|
||||
register_with_refresh_for_algo(lcm,FALSE,auth_domain,route,test_sha_username);
|
||||
BC_ASSERT_EQUAL(counters->number_of_auth_info_requested,0, int, "%d");
|
||||
linphone_core_manager_destroy(lcm);
|
||||
stats* counters;
|
||||
LinphoneCoreManager* lcm = create_lcm();
|
||||
LinphoneAuthInfo *info=linphone_auth_info_new_for_algorithm(test_sha_username,NULL,test_password,NULL,auth_domain,NULL,"SHA-256"); /*create authentication structure from identity*/
|
||||
char route[256];
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
linphone_auth_info_unref(info);
|
||||
counters = &lcm->stat;
|
||||
register_with_refresh_for_algo(lcm,FALSE,auth_domain,route,test_sha_username);
|
||||
BC_ASSERT_EQUAL(counters->number_of_auth_info_requested,0, int, "%d");
|
||||
linphone_core_manager_destroy(lcm);
|
||||
}
|
||||
|
||||
static void ha1_authenticated_register(void){
|
||||
|
|
@ -373,20 +379,20 @@ static void ha1_authenticated_register(void){
|
|||
}
|
||||
|
||||
static void ha1_authenticated_register_for_algorithm(void){
|
||||
stats* counters;
|
||||
LinphoneCoreManager* lcm = create_lcm();
|
||||
char ha1[65];
|
||||
LinphoneAuthInfo *info;
|
||||
char route[256];
|
||||
sal_auth_compute_ha1_for_algorithm(test_sha_username,auth_domain,test_password,ha1,65,"SHA-256");
|
||||
info=linphone_auth_info_new_for_algorithm(test_sha_username,NULL,NULL,ha1,auth_domain,NULL,"SHA-256"); /*create authentication structure from identity*/
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
linphone_auth_info_unref(info);
|
||||
counters = &lcm->stat;
|
||||
register_with_refresh_for_algo(lcm,FALSE,auth_domain,route,test_sha_username);
|
||||
BC_ASSERT_EQUAL(counters->number_of_auth_info_requested,0, int, "%d");
|
||||
linphone_core_manager_destroy(lcm);
|
||||
stats* counters;
|
||||
LinphoneCoreManager* lcm = create_lcm();
|
||||
char ha1[65];
|
||||
LinphoneAuthInfo *info;
|
||||
char route[256];
|
||||
sal_auth_compute_ha1_for_algorithm(test_sha_username,auth_domain,test_password,ha1,65,"SHA-256");
|
||||
info=linphone_auth_info_new_for_algorithm(test_sha_username,NULL,NULL,ha1,auth_domain,NULL,"SHA-256"); /*create authentication structure from identity*/
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
|
||||
linphone_auth_info_unref(info);
|
||||
counters = &lcm->stat;
|
||||
register_with_refresh_for_algo(lcm,FALSE,auth_domain,route,test_sha_username);
|
||||
BC_ASSERT_EQUAL(counters->number_of_auth_info_requested,0, int, "%d");
|
||||
linphone_core_manager_destroy(lcm);
|
||||
}
|
||||
|
||||
static void authenticated_register_with_no_initial_credentials(void){
|
||||
|
|
@ -419,7 +425,7 @@ static void authenticated_register_with_late_credentials(void){
|
|||
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
|
||||
lcm = linphone_core_manager_new(NULL);
|
||||
lcm = linphone_core_manager_new(NULL);
|
||||
transport = linphone_factory_create_transports(linphone_factory_get());
|
||||
linphone_transports_set_udp_port(transport, 5070);
|
||||
linphone_transports_set_tcp_port(transport, 5070);
|
||||
|
|
@ -443,7 +449,7 @@ static void authenticated_register_with_provided_credentials(void){
|
|||
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
|
||||
lcm = linphone_core_manager_new(NULL);
|
||||
lcm = linphone_core_manager_new(NULL);
|
||||
|
||||
counters = get_stats(lcm->lc);
|
||||
cfg = linphone_core_create_proxy_config(lcm->lc);
|
||||
|
|
@ -485,7 +491,7 @@ static void authenticated_register_with_wrong_late_credentials(void){
|
|||
|
||||
sprintf(route,"sip:%s",test_route);
|
||||
|
||||
lcm = linphone_core_manager_new(NULL);
|
||||
lcm = linphone_core_manager_new(NULL);
|
||||
transport = linphone_factory_create_transports(linphone_factory_get());
|
||||
linphone_transports_set_udp_port(transport, 5070);
|
||||
linphone_transports_set_tcp_port(transport, 5070);
|
||||
|
|
@ -738,8 +744,8 @@ static void proxy_transport_change(void){
|
|||
}
|
||||
/*
|
||||
* On ios, some firewal require to disable flow label (livebox with default firewall level).
|
||||
* sudo sysctl net.inet6.ip6.auto_flowlabel=0
|
||||
* It might be possible to found a sockopt for such purpose.
|
||||
* sudo sysctl net.inet6.ip6.auto_flowlabel=0
|
||||
* It might be possible to found a sockopt for such purpose.
|
||||
*/
|
||||
static void proxy_transport_change_with_wrong_port(void) {
|
||||
LinphoneCoreManager* lcm = create_lcm();
|
||||
|
|
@ -962,7 +968,7 @@ static void tls_certificate_failure(void){
|
|||
}
|
||||
|
||||
char *read_file(const char *path) {
|
||||
long numbytes = 0;
|
||||
long numbytes = 0;
|
||||
size_t readbytes;
|
||||
char *buffer = NULL;
|
||||
FILE *infile = fopen(path, "rb");
|
||||
|
|
@ -1294,9 +1300,9 @@ test_t register_tests[] = {
|
|||
TEST_NO_TAG("TLS certificate given by string instead of file",tls_certificate_data),
|
||||
TEST_NO_TAG("TLS with non tls server",tls_with_non_tls_server),
|
||||
TEST_NO_TAG("Simple authenticated register", simple_authenticated_register),
|
||||
TEST_NO_TAG("Simple authenticated register SHA-256", simple_authenticated_register_for_algorithm),
|
||||
TEST_NO_TAG("Simple authenticated register SHA-256", simple_authenticated_register_for_algorithm),
|
||||
TEST_NO_TAG("Ha1 authenticated register", ha1_authenticated_register),
|
||||
TEST_NO_TAG("Ha1 authenticated register SHA-256", ha1_authenticated_register_for_algorithm),
|
||||
TEST_NO_TAG("Ha1 authenticated register SHA-256", ha1_authenticated_register_for_algorithm),
|
||||
TEST_NO_TAG("Digest auth without initial credentials", authenticated_register_with_no_initial_credentials),
|
||||
TEST_NO_TAG("Digest auth with wrong credentials", authenticated_register_with_wrong_credentials),
|
||||
TEST_NO_TAG("Digest auth with wrong credentials, check if registration attempts are stopped", authenticated_register_with_wrong_credentials_2),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue