Hi, Here is a patch that address several issues in the getaddrinfo GnuLib module implementation:
- getaddrinfo might be available from -lnls or -lsocket. Look that up. - Don't fail when SOCK_STREAM or SOCK_DGRAM are specified in ai_socktype (most getaddrinfo usage involve using it, this was making the module unusable). - Fix invalid ai_protocol check. ai_protocol is usually set to 0 or depending on ai_family/ai_socktype to IPPROTO_TCP / IPPROTO_UDP. Checking for SOCK_STREAM / SOCK_DGRAM in ai_protocol was invalid. - Set ai_socktype / ai_protocol in the returned addrinfo structure. I'm using this patch in Prelude for a while and it definitely fixed most of the bug experienced by people lacking a getaddrinfo() implementation. Regards, -- Yoann Vandoorselaere <[EMAIL PROTECTED]>
Index: m4/getaddrinfo.m4 =================================================================== RCS file: /cvsroot/gnulib/gnulib/m4/getaddrinfo.m4,v retrieving revision 1.2 diff -u -r1.2 getaddrinfo.m4 --- m4/getaddrinfo.m4 23 Jan 2005 08:06:57 -0000 1.2 +++ m4/getaddrinfo.m4 9 May 2005 22:34:21 -0000 @@ -6,6 +6,7 @@ AC_DEFUN([gl_GETADDRINFO], [ + AC_SEARCH_LIBS(getaddrinfo, nsl socket) AC_REPLACE_FUNCS(getaddrinfo) gl_PREREQ_GETADDRINFO ]) Index: lib/getaddrinfo.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/getaddrinfo.c,v retrieving revision 1.1 diff -u -r1.1 getaddrinfo.c --- lib/getaddrinfo.c 10 Nov 2004 14:53:00 -0000 1.1 +++ lib/getaddrinfo.c 9 May 2005 22:34:21 -0000 @@ -74,15 +74,11 @@ 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. */ return EAI_NONAME; @@ -90,7 +86,7 @@ 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 @@ 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. */
_______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib