X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fnetwork%2Fgetaddrinfo.c;h=d5514d2d6c4cc0e3cbc78faf87cb070a6317440d;hb=6ee1e193fd896ab9a4729fde14f009d9ce629815;hp=08e31ca98f0d829dbc7d436fb61c25afa6338a96;hpb=3793ee13a2146356d38ed9e2069a6bdf056f0923;p=vlc diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c index 08e31ca98f..d5514d2d6c 100644 --- a/src/network/getaddrinfo.c +++ b/src/network/getaddrinfo.c @@ -2,7 +2,7 @@ * getaddrinfo.c: getaddrinfo/getnameinfo replacement functions ***************************************************************************** * Copyright (C) 2005 the VideoLAN team - * Copyright (C) 2002-2004 Rémi Denis-Courmont + * Copyright (C) 2002-2007 Rémi Denis-Courmont * $Id$ * * Author: Rémi Denis-Courmont @@ -19,13 +19,13 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #include #include /* size_t */ -#include /* strncpy(), strlen(), memcpy(), memset(), strchr() */ +#include /* strlen(), memcpy(), memset(), strchr() */ #include /* malloc(), free(), strtoul() */ #include @@ -42,7 +42,7 @@ # include #endif -#include "network.h" +#include #ifndef NO_ADDRESS # define NO_ADDRESS NO_DATA @@ -54,10 +54,6 @@ # define AF_UNSPEC 0 #endif -#define _NI_MASK (NI_NUMERICHOST|NI_NUMERICSERV|NI_NOFQDN|NI_NAMEREQD|\ - NI_DGRAM) -#define _AI_MASK (AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST) - #ifndef HAVE_GAI_STRERROR static struct @@ -77,6 +73,7 @@ static struct { EAI_SERVICE, "Incompatible service for socket type" }, { EAI_ADDRFAMILY, "Unavailable address family for host name" }, { EAI_MEMORY, "Memory allocation failure" }, + { EAI_OVERFLOW, "Buffer overflow" }, { EAI_SYSTEM, "System error" }, { 0, NULL } }; @@ -86,54 +83,24 @@ static const char *__gai_unknownerr = "Unrecognized error number"; /**************************************************************************** * Converts an EAI_* error code into human readable english text. ****************************************************************************/ -const char *vlc_gai_strerror( int errnum ) +const char *vlc_gai_strerror (int errnum) { - int i; - - for (i = 0; __gai_errlist[i].msg != NULL; i++) + for (unsigned i = 0; __gai_errlist[i].msg != NULL; i++) if (errnum == __gai_errlist[i].code) return __gai_errlist[i].msg; return __gai_unknownerr; } -# undef _EAI_POSITIVE_MAX #else /* ifndef HAVE_GAI_STRERROR */ -const char *vlc_gai_strerror( int errnum ) +const char *vlc_gai_strerror (int errnum) { - return gai_strerror( errnum ); + return gai_strerror (errnum); } #endif -#if !(defined (HAVE_GETNAMEINFO) && defined (HAVE_GETADDRINFO)) -/* - * Converts the current herrno error value into an EAI_* error code. - * That error code is normally returned by getnameinfo() or getaddrinfo(). - */ -static int -gai_error_from_herrno( void ) -{ - switch(h_errno) - { - case HOST_NOT_FOUND: - return EAI_NONAME; - - case NO_ADDRESS: -# if (NO_ADDRESS != NO_DATA) - case NO_DATA: -# endif - return EAI_NODATA; - - case NO_RECOVERY: - return EAI_FAIL; - - case TRY_AGAIN: - return EAI_AGAIN; - } - return EAI_SYSTEM; -} -#endif /* if !(HAVE_GETNAMEINFO && HAVE_GETADDRINFO) */ - #ifndef HAVE_GETNAMEINFO +#define _NI_MASK (NI_NUMERICHOST|NI_NUMERICSERV|NI_NOFQDN|NI_NAMEREQD|\ + NI_DGRAM) /* * getnameinfo() non-thread-safe IPv4-only implementation, * Address-family-independant address to hostname translation @@ -146,11 +113,17 @@ gai_error_from_herrno( void ) * GNU C library 2.0.x is known to lack this function, even though it defines * getaddrinfo(). */ +#ifdef WIN32 +static int WSAAPI +getnameinfo (const struct sockaddr *sa, socklen_t salen, + char *host, DWORD hostlen, char *serv, DWORD servlen, int flags) +#else static int -__getnameinfo( const struct sockaddr *sa, socklen_t salen, - char *host, int hostlen, char *serv, int servlen, int flags ) +getnameinfo (const struct sockaddr *sa, socklen_t salen, + char *host, int hostlen, char *serv, int servlen, int flags) +#endif { - if (((unsigned)salen < sizeof (struct sockaddr_in)) + if (((size_t)salen < sizeof (struct sockaddr_in)) || (sa->sa_family != AF_INET)) return EAI_FAMILY; else if (flags & (~_NI_MASK)) @@ -163,79 +136,27 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen, if (host != NULL) { - int solved = 0; - /* host name resolution */ if (!(flags & NI_NUMERICHOST)) { - struct hostent *hent; - - hent = gethostbyaddr ((const void*)&addr->sin_addr, - 4, AF_INET); - - if (hent != NULL) - { - strncpy (host, hent->h_name, hostlen); - host[hostlen - 1] = '\0'; - - /* - * only keep first part of hostname - * if user don't want fully qualified - * domain name - */ - if (flags & NI_NOFQDN) - { - char *ptr; - - ptr = strchr (host, '.'); - if (ptr != NULL) - *ptr = 0; - } - - solved = 1; - } - else if (flags & NI_NAMEREQD) - return gai_error_from_herrno (); + if (flags & NI_NAMEREQD) + return EAI_NONAME; } - if (!solved) - { - /* inet_ntoa() can't fail */ - strncpy (host, inet_ntoa (addr->sin_addr), hostlen); - host[hostlen - 1] = '\0'; - } + /* inet_ntoa() is not thread-safe, do not use it */ + uint32_t ipv4 = ntohl (addr->sin_addr.s_addr); + + if (snprintf (host, hostlen, "%u.%u.%u.%u", ipv4 >> 24, + (ipv4 >> 16) & 0xff, (ipv4 >> 8) & 0xff, + ipv4 & 0xff) >= (int)hostlen) + return EAI_OVERFLOW; } if (serv != NULL) { - struct servent *sent = NULL; - -#ifndef SYS_BEOS /* No getservbyport() */ - int solved = 0; - - /* service name resolution */ - if (!(flags & NI_NUMERICSERV)) - { - - sent = getservbyport(addr->sin_port, - (flags & NI_DGRAM) - ? "udp" : "tcp"); - if (sent != NULL) - { - strncpy (serv, sent->s_name, servlen); - serv[servlen - 1] = 0; - solved = 1; - } - } -#else - sent = NULL; -#endif - if (sent == NULL) - { - snprintf (serv, servlen, "%u", - (unsigned int)ntohs (addr->sin_port)); - serv[servlen - 1] = '\0'; - } + if (snprintf (serv, servlen, "%u", + (unsigned int)ntohs (addr->sin_port)) >= (int)servlen) + return EAI_OVERFLOW; } } return 0; @@ -243,13 +164,43 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen, #endif /* if !HAVE_GETNAMEINFO */ - #ifndef HAVE_GETADDRINFO +#define _AI_MASK (AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST) +/* + * Converts the current herrno error value into an EAI_* error code. + * That error code is normally returned by getnameinfo() or getaddrinfo(). + */ +static int +gai_error_from_herrno (void) +{ + switch (h_errno) + { + case HOST_NOT_FOUND: + return EAI_NONAME; + + case NO_ADDRESS: +# if (NO_ADDRESS != NO_DATA) + case NO_DATA: +# endif + return EAI_NODATA; + + case NO_RECOVERY: + return EAI_FAIL; + + case TRY_AGAIN: + return EAI_AGAIN; + } + return EAI_SYSTEM; +} + /* * This functions must be used to free the memory allocated by getaddrinfo(). */ -static void -__freeaddrinfo (struct addrinfo *res) +#ifdef WIN32 +static void WSAAPI freeaddrinfo (struct addrinfo *res) +#else +static void freeaddrinfo (struct addrinfo *res) +#endif { if (res != NULL) { @@ -333,9 +284,15 @@ makeipv4info (int type, int proto, u_long ip, u_short port, const char *name) * * Only UDP and TCP over IPv4 are supported here. */ +#ifdef WIN32 +static int WSAAPI +getaddrinfo (const char *node, const char *service, + const struct addrinfo *hints, struct addrinfo **res) +#else static int -__getaddrinfo (const char *node, const char *service, - const struct addrinfo *hints, struct addrinfo **res) +getaddrinfo (const char *node, const char *service, + const struct addrinfo *hints, struct addrinfo **res) +#endif { struct addrinfo *info; u_long ip; @@ -343,6 +300,31 @@ __getaddrinfo (const char *node, const char *service, int protocol = 0, flags = 0; const char *name = NULL; +#ifdef WIN32 + /* + * Maybe you knew already that Winsock does not handle TCP/RST packets + * properly, so that when a TCP connection fails, it will wait until it + * times out even if the remote host did return a TCP/RST. However, it + * still sees the TCP/RST as the error code is 10061 instead of 10060. + * Basically, we have the stupid brainfucked behavior with DNS queries... + * When the recursive DNS server returns an error, Winsock waits about + * 2 seconds before it returns to the callers, even though it should know + * that is pointless. I'd like to know how come this hasn't been fixed + * for the past decade, or maybe not. + * + * Anyway, this is causing a severe delay when the SAP listener tries + * to resolve more than ten IPv6 numeric addresses. Modern systems will + * eventually realize that it is an IPv6 address, and won't try to resolve + * it as a IPv4 address via the Domain Name Service. Old systems + * (including Windows XP without the IPv6 stack) will not. It is normally + * not an issue as the DNS server usually returns an error very quickly. + * But it IS a severe issue on Windows, given the bug explained above. + * So here comes one more bug-to-bug Windows compatibility fix. + */ + if ((node != NULL) && (strchr (node, ':') != NULL)) + return EAI_NONAME; +#endif + if (hints != NULL) { flags = hints->ai_flags; @@ -364,7 +346,7 @@ __getaddrinfo (const char *node, const char *service, protocol = IPPROTO_UDP; break; -#ifndef SYS_BEOS +#ifndef SOCK_RAW case SOCK_RAW: #endif case 0: @@ -398,7 +380,7 @@ __getaddrinfo (const char *node, const char *service, entry = gethostbyname (node); if (entry == NULL) - return EAI_NONAME; + return gai_error_from_herrno (); if ((entry->h_length != 4) || (entry->h_addrtype != AF_INET)) return EAI_FAMILY; @@ -416,38 +398,14 @@ __getaddrinfo (const char *node, const char *service, port = 0; else { - long d; + unsigned long d; char *end; d = strtoul (service, &end, 0); - if (end[0] /* service is not a number */ - || (d > 65535)) - { - struct servent *entry; - const char *protoname; - - switch (protocol) - { - case IPPROTO_TCP: - protoname = "tcp"; - break; - - case IPPROTO_UDP: - protoname = "udp"; - break; - - default: - protoname = NULL; - } - - entry = getservbyname (service, protoname); - if (entry == NULL) - return EAI_SERVICE; + if (end[0] || (d > 65535u)) + return EAI_SERVICE; - port = entry->s_port; - } - else - port = htons ((u_short)d); + port = htons ((u_short)d); } /* building results... */ @@ -481,23 +439,105 @@ __getaddrinfo (const char *node, const char *service, } #endif /* if !HAVE_GETADDRINFO */ - -int vlc_getnameinfo( const struct sockaddr *sa, int salen, - char *host, int hostlen, int *portnum, int flags ) -{ - char psz_servbuf[6], *psz_serv; - int i_servlen, i_val; #if defined( WIN32 ) && !defined( UNDER_CE ) /* * Here is the kind of kludge you need to keep binary compatibility among * varying OS versions... */ - typedef int (CALLBACK * GETNAMEINFO) ( const struct sockaddr*, socklen_t, - char*, DWORD, char*, DWORD, int ); - HINSTANCE wship6_module; - GETNAMEINFO ws2_getnameinfo; +typedef int (WSAAPI * GETNAMEINFO) ( const struct sockaddr FAR *, socklen_t, + char FAR *, DWORD, char FAR *, DWORD, int ); +typedef int (WSAAPI * GETADDRINFO) (const char FAR *, const char FAR *, + const struct addrinfo FAR *, + struct addrinfo FAR * FAR *); + +typedef void (WSAAPI * FREEADDRINFO) ( struct addrinfo FAR * ); + +static int WSAAPI _ws2_getnameinfo_bind ( const struct sockaddr FAR *, socklen_t, + char FAR *, DWORD, char FAR *, DWORD, int ); +static int WSAAPI _ws2_getaddrinfo_bind (const char FAR *, const char FAR *, + const struct addrinfo FAR *, + struct addrinfo FAR * FAR *); + +static GETNAMEINFO ws2_getnameinfo = _ws2_getnameinfo_bind; +static GETADDRINFO ws2_getaddrinfo = _ws2_getaddrinfo_bind; +static FREEADDRINFO ws2_freeaddrinfo; + +static FARPROC ws2_find_api (LPCTSTR name) +{ + FARPROC f = NULL; + + HMODULE m = GetModuleHandle (TEXT("WS2_32")); + if (m != NULL) + f = GetProcAddress (m, name); + + if (f == NULL) + { + /* Windows 2K IPv6 preview */ + m = LoadLibrary (TEXT("WSHIP6")); + if (m != NULL) + f = GetProcAddress (m, name); + } + + return f; +} + +static WSAAPI int _ws2_getnameinfo_bind( const struct sockaddr FAR * sa, socklen_t salen, + char FAR *host, DWORD hostlen, char FAR *serv, DWORD servlen, int flags ) +{ + GETNAMEINFO entry = (GETNAMEINFO)ws2_find_api (TEXT("getnameinfo")); + int result; + + if (entry == NULL) + { + /* not found, use replacement API instead */ + entry = getnameinfo; + + } + /* call API before replacing function pointer to avoid crash */ + result = entry (sa, salen, host, hostlen, serv, servlen, flags); + ws2_getnameinfo = entry; + return result; +} +#undef getnameinfo +#define getnameinfo ws2_getnameinfo + +static WSAAPI int _ws2_getaddrinfo_bind(const char FAR *node, const char FAR *service, + const struct addrinfo FAR *hints, struct addrinfo FAR * FAR *res) +{ + GETADDRINFO entry; + FREEADDRINFO freentry; + int result; + + entry = (GETADDRINFO)ws2_find_api (TEXT("getaddrinfo")); + freentry = (FREEADDRINFO)ws2_find_api (TEXT("freeaddrinfo")); + + if ((entry == NULL) || (freentry == NULL)) + { + /* not found, use replacement API instead */ + entry = getaddrinfo; + freentry = freeaddrinfo; + } + /* call API before replacing function pointer to avoid crash */ + result = entry (node, service, hints, res); + ws2_freeaddrinfo = freentry; + ws2_getaddrinfo = entry; + return result; +} +#undef getaddrinfo +#undef freeaddrinfo +#define getaddrinfo ws2_getaddrinfo +#define freeaddrinfo ws2_freeaddrinfo +#define HAVE_GETADDRINFO #endif + + +int vlc_getnameinfo( const struct sockaddr *sa, int salen, + char *host, int hostlen, int *portnum, int flags ) +{ + char psz_servbuf[6], *psz_serv; + int i_servlen, i_val; + flags |= NI_NUMERICSERV; if( portnum != NULL ) { @@ -509,47 +549,8 @@ int vlc_getnameinfo( const struct sockaddr *sa, int salen, psz_serv = NULL; i_servlen = 0; } -#if defined( WIN32 ) && !defined( UNDER_CE ) - wship6_module = LoadLibrary( "wship6.dll" ); - if( wship6_module != NULL ) - { - ws2_getnameinfo = (GETNAMEINFO)GetProcAddress( wship6_module, - "getnameinfo" ); - if( ws2_getnameinfo != NULL ) - { - i_val = ws2_getnameinfo( sa, salen, host, hostlen, psz_serv, - i_servlen, flags ); - FreeLibrary( wship6_module ); - - if( portnum != NULL ) - *portnum = atoi( psz_serv ); - return i_val; - } - - FreeLibrary( wship6_module ); - } -#endif -#if defined( HAVE_GETNAMEINFO ) || defined( UNDER_CE ) i_val = getnameinfo(sa, salen, host, hostlen, psz_serv, i_servlen, flags); -#else - { -# ifdef HAVE_USABLE_MUTEX_THAT_DONT_NEED_LIBVLC_POINTER - static vlc_value_t lock; - - /* my getnameinfo implementation is not thread-safe as it uses - * gethostbyaddr and the likes */ - vlc_mutex_lock( lock.p_address ); -#else -//# warning FIXME : This is not thread-safe! -#endif - i_val = __getnameinfo( sa, salen, host, hostlen, psz_serv, i_servlen, - flags ); -# ifdef HAVE_USABLE_MUTEX_THAT_DONT_NEED_LIBVLC_POINTER - vlc_mutex_unlock( lock.p_address ); -# endif - } -#endif if( portnum != NULL ) *portnum = atoi( psz_serv ); @@ -558,7 +559,6 @@ int vlc_getnameinfo( const struct sockaddr *sa, int salen, } -/* TODO: support for setting sin6_scope_id */ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, int i_port, const struct addrinfo *p_hints, struct addrinfo **res ) @@ -580,10 +580,41 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, snprintf( psz_service, 6, "%d", i_port ); /* Check if we have to force ipv4 or ipv6 */ - if( p_hints == NULL ) - memset( &hints, 0, sizeof( hints ) ); - else - memcpy( &hints, p_hints, sizeof( hints ) ); + memset (&hints, 0, sizeof (hints)); + if (p_hints != NULL) + { + const int safe_flags = + AI_PASSIVE | + AI_CANONNAME | + AI_NUMERICHOST | +#ifdef AI_NUMERICSERV + AI_NUMERICSERV | +#endif +#ifdef AI_ALL + AI_ALL | +#endif +#ifdef AI_ADDRCONFIG + AI_ADDRCONFIG | +#endif +#ifdef AI_V4MAPPED + AI_V4MAPPED | +#endif + 0; + + hints.ai_family = p_hints->ai_family; + hints.ai_socktype = p_hints->ai_socktype; + hints.ai_protocol = p_hints->ai_protocol; + /* Unfortunately, some flags chang the layout of struct addrinfo, so + * they cannot be copied blindly from p_hints to &hints. Therefore, we + * only copy flags that we know for sure are "safe". + */ + hints.ai_flags = p_hints->ai_flags & safe_flags; + } + +#ifdef AI_NUMERICSERV + /* We only ever use port *numbers* */ + hints.ai_flags |= AI_NUMERICSERV; +#endif if( hints.ai_family == AF_UNSPEC ) { @@ -602,7 +633,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, #endif } - /* + /* * VLC extensions : * - accept "" as NULL * - ignore square brackets @@ -613,8 +644,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, } else { - strncpy( psz_buf, node, NI_MAXHOST ); - psz_buf[NI_MAXHOST - 1] = '\0'; + strlcpy( psz_buf, node, NI_MAXHOST ); psz_node = psz_buf; @@ -631,107 +661,57 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node, } } -#if defined( WIN32 ) && !defined( UNDER_CE ) +#ifdef WIN32 + /* + * Winsock tries to resolve numerical IPv4 addresses as AAAA + * and IPv6 addresses as A... There comes the bug-to-bug fix. + */ + if ((hints.ai_flags & AI_NUMERICHOST) == 0) { - typedef int (CALLBACK * GETADDRINFO) ( const char *, const char *, - const struct addrinfo *, - struct addrinfo ** ); - HINSTANCE wship6_module; - GETADDRINFO ws2_getaddrinfo; - - wship6_module = LoadLibrary( "wship6.dll" ); - if( wship6_module != NULL ) - { - ws2_getaddrinfo = (GETADDRINFO)GetProcAddress( wship6_module, - "getaddrinfo" ); - - if( ws2_getaddrinfo != NULL ) - { - int i_ret; + hints.ai_flags |= AI_NUMERICHOST; - i_ret = ws2_getaddrinfo( psz_node, psz_service, &hints, res ); - FreeLibrary( wship6_module ); /* is this wise ? */ - return i_ret; - } + if (getaddrinfo (psz_node, psz_service, &hints, res) == 0) + return 0; - FreeLibrary( wship6_module ); - } + hints.ai_flags &= ~AI_NUMERICHOST; } #endif -#if defined( HAVE_GETADDRINFO ) || defined( UNDER_CE ) +#if defined (HAVE_GETADDRINFO) # ifdef AI_IDN /* Run-time I18n Domain Names support */ - { - static vlc_bool_t i_idn = VLC_TRUE; /* beware of thread-safety */ - - if( i_idn ) - { - int i_ret; + static vlc_bool_t b_idn = VLC_TRUE; /* beware of thread-safety */ - hints.ai_flags |= AI_IDN; - i_ret = getaddrinfo( psz_node, psz_service, &hints, res ); - - if( i_ret != EAI_BADFLAGS ) - return i_ret; + if (b_idn) + { + hints.ai_flags |= AI_IDN; + int ret = getaddrinfo (psz_node, psz_service, &hints, res); - /* libidn not available: disable and retry without it */ + if (ret != EAI_BADFLAGS) + return ret; - /* NOTE: Using i_idn here would not be thread-safe */ - hints.ai_flags &= ~AI_IDN; - i_idn = VLC_FALSE; - msg_Dbg( p_this, "I18n Domain Names not supported - disabled" ); - } + /* IDN not available: disable and retry without it */ + hints.ai_flags &= ~AI_IDN; + b_idn = VLC_FALSE; + msg_Info (p_this, "International Domain Names not supported"); } # endif - return getaddrinfo( psz_node, psz_service, &hints, res ); + return getaddrinfo (psz_node, psz_service, &hints, res); #else -{ - int i_ret; - + int ret; vlc_value_t lock; - var_Create( p_this->p_libvlc, "getaddrinfo_mutex", VLC_VAR_MUTEX ); - var_Get( p_this->p_libvlc, "getaddrinfo_mutex", &lock ); - vlc_mutex_lock( lock.p_address ); + var_Create (p_this->p_libvlc, "getaddrinfo_mutex", VLC_VAR_MUTEX); + var_Get (p_this->p_libvlc, "getaddrinfo_mutex", &lock); + vlc_mutex_lock (lock.p_address); - i_ret = __getaddrinfo( psz_node, psz_service, &hints, res ); - vlc_mutex_unlock( lock.p_address ); - return i_ret; -} + ret = getaddrinfo (psz_node, psz_service, &hints, res); + vlc_mutex_unlock (lock.p_address); + return ret; #endif } void vlc_freeaddrinfo( struct addrinfo *infos ) { -#if defined( WIN32 ) && !defined( UNDER_CE ) - typedef void (CALLBACK * FREEADDRINFO) ( struct addrinfo * ); - HINSTANCE wship6_module; - FREEADDRINFO ws2_freeaddrinfo; - - wship6_module = LoadLibrary( "wship6.dll" ); - if( wship6_module != NULL ) - { - ws2_freeaddrinfo = (FREEADDRINFO)GetProcAddress( wship6_module, - "freeaddrinfo" ); - - /* - * NOTE: it is assumed that wship6.dll defines either both - * getaddrinfo and freeaddrinfo or none of them. - */ - if( ws2_freeaddrinfo != NULL ) - { - ws2_freeaddrinfo( infos ); - FreeLibrary( wship6_module ); - return; - } - - FreeLibrary( wship6_module ); - } -#endif -#if defined( HAVE_GETADDRINFO ) || defined( UNDER_CE ) - freeaddrinfo( infos ); -#else - __freeaddrinfo( infos ); -#endif + freeaddrinfo (infos); }