summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/extconf.rb18
-rw-r--r--ext/socket/getaddrinfo.c4
-rw-r--r--ext/socket/getnameinfo.c4
3 files changed, 26 insertions, 0 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 45e596700cd..357025cbbbc 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -321,6 +321,24 @@ $objs = ["socket.#{$OBJEXT}"]
if $getaddr_info_ok and have_func("getaddrinfo") and have_func("getnameinfo")
have_getaddrinfo = true
+else
+ if try_link(<<EOF)
+#include <sys/types.h>
+#include <netdb.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+int
+main()
+{
+ struct in6_addr addr;
+ unsigned char c;
+ c = addr.s6_addr8;
+ return 0;
+}
+EOF
+ $CFLAGS="-DHAVE_ADDR8 "+$CFLAGS
+ end
end
if have_getaddrinfo
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index a6c26a8f0f1..4f58a23d2d4 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -480,7 +480,11 @@ getaddrinfo(hostname, servname, hints, res)
break;
#ifdef INET6
case AF_INET6:
+#ifdef HAVE_ADDR8
pfx = ((struct in6_addr *)pton)->s6_addr8[0];
+#else
+ pfx = ((struct in6_addr *)pton)->s6_addr[0];
+#endif
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
pai->ai_flags &= ~AI_CANONNAME;
break;
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index a1fa5d79085..a75f233a815 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -208,7 +208,11 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
break;
#ifdef INET6
case AF_INET6:
+#ifdef HAVE_ADDR8
pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0];
+#else
+ pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[0];
+#endif
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
flags |= NI_NUMERICHOST;
break;