+2005-05-10 Yoann Vandoorselaere <yoann.v@prelude-ids.com>
+
+ * getaddrinfo.c: Don't fail when SOCK_STREAM or SOCK_DGRAM are
+ specified in ai_socktype. 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.
+
2005-05-09 Yoann Vandoorselaere <yoann.v@prelude-ids.com>
Bruno Haible <bruno@clisp.org>
/* 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 <simon@josefsson.org>.
This program is free software; you can redistribute it and/or modify
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. */
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);
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. */