summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-11-02 15:23:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-11-02 15:23:08 +0000
commit89e7d586f4799246340c92bcb2b4dc0bf95b5798 (patch)
tree8d73b2964ae9c45082431998a7125273328bb094 /ext
parent82371d77eea74e091a4e9d5317f61e738171990f (diff)
* ext/socket/socket.c (ruby_getnameinfo__aix): AF_INET6 workaround
for AIX. a patch from Yutaka Kanemoto <kinpoco AT gmail.com>. [ruby-dev:29744] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/extconf.rb4
-rw-r--r--ext/socket/socket.c28
2 files changed, 32 insertions, 0 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 7a8c153..8a13ddb 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -156,6 +156,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 b09d5d4..57eb7a4 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -198,6 +198,34 @@ ruby_getaddrinfo__aix(nodename, servname, hints, res)
}
#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