mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
ipv6 detection fix
This commit is contained in:
parent
eba52ef155
commit
fb2b7ee40d
2 changed files with 12 additions and 9 deletions
|
|
@ -1527,7 +1527,9 @@ void linphone_core_get_local_ip(LinphoneCore *lc, int af, char *result){
|
|||
strncpy(result,"::1",LINPHONE_IPADDR_SIZE);
|
||||
return;
|
||||
}
|
||||
}else af=AF_INET;
|
||||
}
|
||||
/*in all other cases use IPv4*/
|
||||
af=AF_INET;
|
||||
}
|
||||
if (linphone_core_get_local_ip_for(af,NULL,result)==0)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1000,12 +1000,12 @@ bool_t linphone_core_tone_indications_enabled(LinphoneCore*lc){
|
|||
#ifdef HAVE_GETIFADDRS
|
||||
|
||||
#include <ifaddrs.h>
|
||||
static int get_local_ip_with_getifaddrs(int type, char *address, int size)
|
||||
{
|
||||
static int get_local_ip_with_getifaddrs(int type, char *address, int size){
|
||||
struct ifaddrs *ifp;
|
||||
struct ifaddrs *ifpstart;
|
||||
int ret = 0;
|
||||
|
||||
char retaddr[LINPHONE_IPADDR_SIZE]={0};
|
||||
bool_t found=FALSE;
|
||||
|
||||
if (getifaddrs(&ifpstart) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1022,17 +1022,18 @@ static int get_local_ip_with_getifaddrs(int type, char *address, int size)
|
|||
if(getnameinfo(ifp->ifa_addr,
|
||||
(type == AF_INET6) ?
|
||||
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in),
|
||||
address, size, NULL, 0, NI_NUMERICHOST) == 0) {
|
||||
if (strchr(address, '%') == NULL) { /*avoid ipv6 link-local addresses */
|
||||
retaddr, size, NULL, 0, NI_NUMERICHOST) == 0) {
|
||||
if (strchr(retaddr, '%') == NULL) { /*avoid ipv6 link-local addresses */
|
||||
/*ms_message("getifaddrs() found %s",address);*/
|
||||
ret++;
|
||||
found=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifpstart);
|
||||
return ret;
|
||||
if (found) strncpy(address,retaddr,size);
|
||||
return found;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue