Commit 3d512a01 authored by Ghislain MARY's avatar Ghislain MARY

Fix update of primary contact.

parent aa5f676d
......@@ -679,25 +679,7 @@ static void linphone_call_get_local_ip(LinphoneCall *call, const LinphoneAddress
return;
}
#endif //BUILD_UPNP
if (af==AF_UNSPEC){
if (linphone_core_ipv6_enabled(call->core)){
bool_t has_ipv6;
has_ipv6=linphone_core_get_local_ip_for(AF_INET6,dest,call->localip)==0;
if (strcmp(call->localip,"::1")!=0)
return; /*this machine has real ipv6 connectivity*/
if (linphone_core_get_local_ip_for(AF_INET,dest,call->localip)==0 && strcmp(call->localip,"127.0.0.1")!=0)
return; /*this machine has only ipv4 connectivity*/
if (has_ipv6){
/*this machine has only local loopback for both ipv4 and ipv6, so prefer ipv6*/
strncpy(call->localip,"::1",LINPHONE_IPADDR_SIZE);
return;
}
}
/*in all other cases use IPv4*/
af=AF_INET;
}
if (linphone_core_get_local_ip_for(af,dest,call->localip)==0)
return;
linphone_core_get_local_ip(call->core, af, dest, call->localip);
}
static void linphone_call_destroy(LinphoneCall *obj);
......
......@@ -1536,7 +1536,7 @@ static void update_primary_contact(LinphoneCore *lc){
ms_error("Could not parse identity contact !");
url=linphone_address_new("sip:unknown@unkwownhost");
}
linphone_core_get_local_ip_for(AF_UNSPEC, NULL, tmp);
linphone_core_get_local_ip(lc, AF_UNSPEC, NULL, tmp);
if (strcmp(tmp,"127.0.0.1")==0 || strcmp(tmp,"::1")==0 ){
ms_warning("Local loopback network only !");
lc->sip_conf.loopback_only=TRUE;
......@@ -2132,7 +2132,7 @@ static void monitor_network_state(LinphoneCore *lc, time_t curtime){
/* only do the network up checking every five seconds */
if (lc->network_last_check==0 || (curtime-lc->network_last_check)>=5){
linphone_core_get_local_ip_for(AF_UNSPEC,NULL,newip);
linphone_core_get_local_ip(lc,AF_UNSPEC,NULL,newip);
if (strcmp(newip,"::1")!=0 && strcmp(newip,"127.0.0.1")!=0){
new_status=TRUE;
}else new_status=FALSE; /*no network*/
......
......@@ -1125,6 +1125,26 @@ int linphone_core_get_local_ip_for(int type, const char *dest, char *result){
return 0;
}
void linphone_core_get_local_ip(LinphoneCore *lc, int af, const char *dest, char *result) {
if (af == AF_UNSPEC) {
if (linphone_core_ipv6_enabled(lc)) {
bool_t has_ipv6 = linphone_core_get_local_ip_for(AF_INET6, dest, result) == 0;
if (strcmp(result, "::1") != 0)
return; /*this machine has real ipv6 connectivity*/
if ((linphone_core_get_local_ip_for(AF_INET, dest, result) == 0) && (strcmp(result, "127.0.0.1") != 0))
return; /*this machine has only ipv4 connectivity*/
if (has_ipv6) {
/*this machine has only local loopback for both ipv4 and ipv6, so prefer ipv6*/
strncpy(result, "::1", LINPHONE_IPADDR_SIZE);
return;
}
}
/*in all other cases use IPv4*/
af = AF_INET;
}
linphone_core_get_local_ip_for(af, dest, result);
}
SalReason linphone_reason_to_sal(LinphoneReason reason){
switch(reason){
case LinphoneReasonNone:
......
......@@ -360,6 +360,7 @@ void linphone_proxy_config_get_contact(LinphoneProxyConfig *cfg, const char **ip
LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri);
const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAddress *to);
int linphone_core_get_local_ip_for(int type, const char *dest, char *result);
void linphone_core_get_local_ip(LinphoneCore *lc, int af, const char *dest, char *result);
LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore *lc, int index);
void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,LinphoneProxyConfig *obj, int index);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment