From 71cdb52799220f8d9052643baf1d3e9836a9c755 Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Thu, 15 Jan 2009 04:22:57 -0500 Subject: Sync with gnulib --- gl/getaddrinfo.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'gl/getaddrinfo.c') diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c index 04f0ac2e..f09cf9ee 100644 --- a/gl/getaddrinfo.c +++ b/gl/getaddrinfo.c @@ -1,5 +1,5 @@ /* Get address information (partial implementation). - Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007 Free Software + Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Contributed by Simon Josefsson . @@ -19,12 +19,15 @@ #include -#include "getaddrinfo.h" +#include #if HAVE_NETINET_IN_H # include #endif +/* Get inet_ntop. */ +#include + /* Get calloc. */ #include @@ -40,8 +43,6 @@ #define _(String) gettext (String) #define N_(String) String -#include "inet_ntop.h" - /* BeOS has AF_INET, but not PF_INET. */ #ifndef PF_INET # define PF_INET AF_INET @@ -300,6 +301,22 @@ getaddrinfo (const char *restrict nodename, tmp->ai_addr->sa_family = he->h_addrtype; tmp->ai_family = he->h_addrtype; +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN + switch (he->h_addrtype) + { +#if HAVE_IPV4 + case AF_INET: + tmp->ai_addr->sa_len = sizeof (struct sockaddr_in); + break; +#endif +#if HAVE_IPV6 + case AF_INET6: + tmp->ai_addr->sa_len = sizeof (struct sockaddr_in6); + break; +#endif + } +#endif + /* FIXME: If more than one address, create linked list of addrinfo's. */ *res = tmp; @@ -326,7 +343,7 @@ freeaddrinfo (struct addrinfo *ai) cur = ai; ai = ai->ai_next; - if (cur->ai_canonname) free (cur->ai_canonname); + free (cur->ai_canonname); free (cur); } } -- cgit v1.2.3