diff --git a/ChangeLog b/ChangeLog index 07c676fdeb..967f54bf3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Nov 3 00:16:37 2006 Yukihiro Matsumoto + + * ext/socket/socket.c (ruby_getnameinfo__aix): AF_INET6 workaround + for AIX. a patch from Yutaka Kanemoto . + [ruby-dev:29744] + Thu Nov 2 14:19:44 2006 Akinori MUSHA * lib/set.rb (Set#^): Fix XOR operation against a container that diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 1441dee4c0..0791714e49 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -141,6 +141,10 @@ main() if (ai->ai_addr == NULL) goto bad; #if defined(_AIX) + if (ai->ai_family == AF_INET6 && passive) { + inet6++; + continue; + } ai->ai_addr->sa_len = ai->ai_addrlen; ai->ai_addr->sa_family = ai->ai_family; #endif diff --git a/ext/socket/socket.c b/ext/socket/socket.c index acb8cdf7d4..419f08c6de 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -188,6 +188,34 @@ ruby_getaddrinfo__aix(char *nodename, char *servname, } #undef getaddrinfo #define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__aix((node),(serv),(hints),(res)) +static int +ruby_getnameinfo__aix(sa, salen, host, hostlen, serv, servlen, flags) + const struct sockaddr *sa; + size_t salen; + char *host; + size_t hostlen; + char *serv; + size_t servlen; + int flags; +{ + struct sockaddr_in6 *sa6; + u_int32_t *a6; + + if (sa->sa_family == AF_INET6) { + sa6 = (struct sockaddr_in6 *)sa; + a6 = sa6->sin6_addr.u6_addr.u6_addr32; + + if (a6[0] == 0 && a6[1] == 0 && a6[2] == 0 && a6[3] == 0) { + strncpy(host, "::", hostlen); + snprintf(serv, servlen, "%d", sa6->sin6_port); + return 0; + } + } + return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags); +} +#undef getnameinfo +#define getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) \ + ruby_getnameinfo__aix((sa), (salen), (host), (hostlen), (serv), (servlen), (flags)) #ifndef CMSG_SPACE # define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len)) #endif