summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-19 02:00:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-19 02:00:52 +0000
commitfb4bea8aaff84adedc4674758ac503d28d30ed0b (patch)
tree1c45a55e234fe38fbd3e2f4f5bb94ce77e884e07 /ext/socket
parent7d431933b65252109bde705391398126fb5930b9 (diff)
* ext/socket/raddrinfo.c (addrinfo_ip_port): use AF_INET6 only when
defined, as well as addrinfo_ipv6_p(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/raddrinfo.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index e9785d448b2..05cd2b2138c 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -1592,8 +1592,14 @@ addrinfo_ip_port(VALUE self)
int family = ai_get_afamily(rai);
int port;
- if (!IS_IP_FAMILY(family))
+ if (!IS_IP_FAMILY(family)) {
+ bad_family:
+#ifdef AF_INET6
rb_raise(rb_eSocket, "need IPv4 or IPv6 address");
+#else
+ rb_raise(rb_eSocket, "need IPv4 address");
+#endif
+ }
switch (family) {
case AF_INET:
@@ -1602,14 +1608,16 @@ addrinfo_ip_port(VALUE self)
port = ntohs(((struct sockaddr_in *)&rai->addr)->sin_port);
break;
+#ifdef AF_INET6
case AF_INET6:
if (rai->sockaddr_len != sizeof(struct sockaddr_in6))
rb_raise(rb_eSocket, "unexpected sockaddr size for IPv6");
port = ntohs(((struct sockaddr_in6 *)&rai->addr)->sin6_port);
break;
+#endif
default:
- rb_raise(rb_eSocket, "need IPv4 or IPv6 address");
+ goto bad_family;
}
return INT2NUM(port);