From 820eaf86ed98aefbc303132bce2821674b840f3a Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 22 Oct 2010 09:56:47 +0200 Subject: [PATCH] fix linphone_core_get_local_ip_for(): don't use getifaddrs() when a destination address is supplied --- coreapi/misc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index ced4f3396..cc5aa5512 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -754,14 +754,10 @@ static int get_local_ip_for_with_connect(int type, const char *dest, char *resul } int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ - if (dest==NULL) { - if (type==AF_INET) - dest="87.98.157.38"; /*a public IP address*/ - else dest="2a00:1450:8002::68"; - } strcpy(result,type==AF_INET ? "127.0.0.1" : "::1"); #ifdef HAVE_GETIFADDRS - { + if (dest==NULL) { + /*we use getifaddrs for lookup of default interface */ int found_ifs; found_ifs=get_local_ip_with_getifaddrs(type,result,LINPHONE_IPADDR_SIZE); @@ -774,5 +770,8 @@ 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 */ + if (type==AF_INET) + dest="87.98.157.38"; /*a public IP address*/ + else dest="2a00:1450:8002::68"; return get_local_ip_for_with_connect(type,dest,result); }