X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetaddrinfo.c;h=54bfb45aef62c6fd34ecbe47044448aa8048cad1;hb=7ec881d86b09cad88b3999ee314c21abe78c7eb2;hp=145eac519bfc77de7193a9acfe9959b448d05f89;hpb=f34b5ec45f70109f4d3d321ea17f996ff4b1c14d;p=gnulib.git diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c index 145eac519..54bfb45ae 100644 --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -1,5 +1,5 @@ /* Get address information (partial implementation). - Copyright (C) 1997, 2001, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1997, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. Contributed by Simon Josefsson . This program is free software; you can redistribute it and/or modify @@ -14,7 +14,7 @@ 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-1307, USA. */ + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #if HAVE_CONFIG_H # include @@ -74,14 +74,10 @@ getaddrinfo (const char *restrict nodename, if (hints && !validate_family (hints->ai_family)) return EAI_FAMILY; - if (hints && hints->ai_socktype) - /* FIXME: Support more socket types. */ - return EAI_SOCKTYPE; - if (hints && - hints->ai_protocol != SOCK_STREAM && hints->ai_protocol != SOCK_DGRAM) - /* FIXME: Support other protocols. */ - return EAI_SERVICE; /* FIXME: Better return code? */ + hints->ai_socktype != SOCK_STREAM && hints->ai_socktype != SOCK_DGRAM) + /* FIXME: Support other socktype. */ + return EAI_SOCKTYPE; /* FIXME: Better return code? */ if (!nodename) /* FIXME: Support server bind mode. */ @@ -90,7 +86,7 @@ getaddrinfo (const char *restrict nodename, if (servname) { const char *proto = - (hints && hints->ai_protocol == SOCK_DGRAM) ? "udp" : "tcp"; + (hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp"; /* FIXME: Use getservbyname_r if available. */ se = getservbyname (servname, proto); @@ -171,6 +167,8 @@ getaddrinfo (const char *restrict nodename, return EAI_NODATA; } + tmp->ai_protocol = (hints) ? hints->ai_protocol : 0; + tmp->ai_socktype = (hints) ? hints->ai_socktype : 0; tmp->ai_addr->sa_family = he->h_addrtype; /* FIXME: If more than one address, create linked list of addrinfo's. */