mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/socket.c (sock_s_getnameinfo): use family_to_int.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
85d13f6165
commit
e924cabede
3 changed files with 12 additions and 8 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Thu Jan 1 21:26:05 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/socket.c (sock_s_getnameinfo): use family_to_int.
|
||||||
|
|
||||||
Thu Jan 1 21:08:34 2009 Tanaka Akira <akr@fsij.org>
|
Thu Jan 1 21:08:34 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/mkconstants.rb: check all alias possibility.
|
* ext/socket/mkconstants.rb: check all alias possibility.
|
||||||
|
|
|
@ -3369,14 +3369,10 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
||||||
hints.ai_family = FIX2INT(af);
|
hints.ai_family = FIX2INT(af);
|
||||||
}
|
}
|
||||||
else if ((ap = StringValuePtr(af)) != 0) {
|
else if ((ap = StringValuePtr(af)) != 0) {
|
||||||
if (strcmp(ap, "AF_INET") == 0) {
|
int family;
|
||||||
hints.ai_family = PF_INET;
|
if (family_to_int(ap, RSTRING_LEN(af), &family) == -1)
|
||||||
}
|
rb_raise(rb_eSocket, "unknown socket domain %s", ap);
|
||||||
#ifdef INET6
|
hints.ai_family = family;
|
||||||
else if (strcmp(ap, "AF_INET6") == 0) {
|
|
||||||
hints.ai_family = PF_INET6;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
error = getaddrinfo(hptr, pptr, &hints, &res);
|
error = getaddrinfo(hptr, pptr, &hints, &res);
|
||||||
if (error) goto error_exit_addr;
|
if (error) goto error_exit_addr;
|
||||||
|
|
|
@ -115,4 +115,8 @@ class TestSocket < Test::Unit::TestCase
|
||||||
# This should not send a DNS query because AF_UNIX.
|
# This should not send a DNS query because AF_UNIX.
|
||||||
assert_raise(SocketError) { Socket.getaddrinfo("www.kame.net", 80, "AF_UNIX") }
|
assert_raise(SocketError) { Socket.getaddrinfo("www.kame.net", 80, "AF_UNIX") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_getnameinfo
|
||||||
|
assert_raise(SocketError) { Socket.getnameinfo(["AF_UNIX", 80, "0.0.0.0"]) }
|
||||||
|
end
|
||||||
end if defined?(Socket)
|
end if defined?(Socket)
|
||||||
|
|
Loading…
Reference in a new issue