From 737997cb208b9ce4a3388cbaa64c1dd38c8d028a Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 26 Apr 2010 22:18:54 +0200 Subject: [PATCH] fix debian-reported bug around resolution of local interface for host that have both ipv4 and ipv6 addresses. --- coreapi/misc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index ae5414de6..86b527e94 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -684,7 +684,7 @@ static int get_local_ip_with_getifaddrs(int type, char *address, int size) #endif -static int get_local_ip_for_with_connect(const char *dest, char *result){ +static int get_local_ip_for_with_connect(int type, const char *dest, char *result){ int err,tmp; struct addrinfo hints; struct addrinfo *res=NULL; @@ -694,7 +694,7 @@ static int get_local_ip_for_with_connect(const char *dest, char *result){ socklen_t s; memset(&hints,0,sizeof(hints)); - hints.ai_family=PF_UNSPEC; + hints.ai_family=(type==AF_INET6) ? PF_INET6 : PF_INET; hints.ai_socktype=SOCK_DGRAM; /*hints.ai_flags=AI_NUMERICHOST|AI_CANONNAME;*/ err=getaddrinfo(dest,"5060",&hints,&res); @@ -765,5 +765,5 @@ int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ } #endif /*else use connect to find the best local ip address */ - return get_local_ip_for_with_connect(dest,result); + return get_local_ip_for_with_connect(type,dest,result); }