mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 11:38:08 +00:00
improve network state monitor so that it can take into account IP address changes.
This commit is contained in:
parent
610f31c95f
commit
77ff00acbc
2 changed files with 16 additions and 6 deletions
|
|
@ -2089,23 +2089,32 @@ void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val){
|
|||
|
||||
|
||||
static void monitor_network_state(LinphoneCore *lc, time_t curtime){
|
||||
char result[LINPHONE_IPADDR_SIZE];
|
||||
bool_t new_status=lc->network_last_status;
|
||||
char newip[LINPHONE_IPADDR_SIZE];
|
||||
|
||||
/* 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(lc,AF_UNSPEC,result);
|
||||
if (strcmp(result,"::1")!=0 && strcmp(result,"127.0.0.1")!=0){
|
||||
linphone_core_get_local_ip(lc,AF_UNSPEC,newip);
|
||||
if (strcmp(newip,"::1")!=0 && strcmp(newip,"127.0.0.1")!=0){
|
||||
new_status=TRUE;
|
||||
}else new_status=FALSE;
|
||||
lc->network_last_check=curtime;
|
||||
}else new_status=FALSE; /*no network*/
|
||||
|
||||
if (new_status==lc->network_last_status && new_status==TRUE && strcmp(newip,lc->localip)!=0){
|
||||
/*IP address change detected*/
|
||||
ms_message("IP address change detected.");
|
||||
set_network_reachable(lc,FALSE,curtime);
|
||||
lc->network_last_status=FALSE;
|
||||
}
|
||||
strncpy(lc->localip,newip,sizeof(lc->localip));
|
||||
|
||||
if (new_status!=lc->network_last_status) {
|
||||
if (new_status){
|
||||
ms_message("New local ip address is %s",result);
|
||||
ms_message("New local ip address is %s",lc->localip);
|
||||
}
|
||||
set_network_reachable(lc,new_status, curtime);
|
||||
lc->network_last_status=new_status;
|
||||
}
|
||||
lc->network_last_check=curtime;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -682,6 +682,7 @@ struct _LinphoneCore
|
|||
bool_t network_last_status;
|
||||
bool_t ringstream_autorelease;
|
||||
bool_t pad[2];
|
||||
char localip[LINPHONE_IPADDR_SIZE];
|
||||
int device_rotation;
|
||||
int max_calls;
|
||||
LinphoneTunnel *tunnel;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue