зеркало из https://github.com/github/ruby.git
* ext/socket/raddrinfo.c (addrinfo_ipv6_unique_local_p): Added
Addrinfo#ipv6_unique_local? to detect RFC 4193 unique local addresses. Part of #6692 * ext/socket/rubysocket.h: Add IN6_IS_ADDR_UNIQUE_LOCAL macro if missing. * test/socket/test_addrinfo.rb: Test for ipv6_unqiue_local? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b1a0509b54
Коммит
3efea48a70
|
@ -1,3 +1,12 @@
|
|||
Fri Jul 20 09:32:14 2012 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* ext/socket/raddrinfo.c (addrinfo_ipv6_unique_local_p): Added
|
||||
Addrinfo#ipv6_unique_local? to detect RFC 4193 unique local
|
||||
addresses. Part of #6692
|
||||
* ext/socket/rubysocket.h: Add IN6_IS_ADDR_UNIQUE_LOCAL macro if
|
||||
missing.
|
||||
* test/socket/test_addrinfo.rb: Test for ipv6_unqiue_local?
|
||||
|
||||
Fri Jul 20 07:40:32 2012 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/net/http/response.rb: Automatically inflate gzip and
|
||||
|
|
|
@ -1792,6 +1792,18 @@ addrinfo_ipv6_sitelocal_p(VALUE self)
|
|||
return Qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true for IPv6 unique local address (fc00::/7, RFC4193).
|
||||
* It returns false otherwise.
|
||||
*/
|
||||
static VALUE
|
||||
addrinfo_ipv6_unique_local_p(VALUE self)
|
||||
{
|
||||
struct in6_addr *addr = extract_in6_addr(self);
|
||||
if (addr && IN6_IS_ADDR_UNIQUE_LOCAL(addr)) return Qtrue;
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80).
|
||||
* It returns false otherwise.
|
||||
|
@ -2207,6 +2219,7 @@ rsock_init_addrinfo(void)
|
|||
rb_define_method(rb_cAddrinfo, "ipv6_multicast?", addrinfo_ipv6_multicast_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_linklocal?", addrinfo_ipv6_linklocal_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_sitelocal?", addrinfo_ipv6_sitelocal_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_unique_local?", addrinfo_ipv6_unique_local_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_v4mapped?", addrinfo_ipv6_v4mapped_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_v4compat?", addrinfo_ipv6_v4compat_p, 0);
|
||||
rb_define_method(rb_cAddrinfo, "ipv6_mc_nodelocal?", addrinfo_ipv6_mc_nodelocal_p, 0);
|
||||
|
|
|
@ -117,6 +117,10 @@
|
|||
# define IS_IP_FAMILY(af) ((af) == AF_INET)
|
||||
#endif
|
||||
|
||||
#ifndef IN6_IS_ADDR_UNIQUE_LOCAL
|
||||
# define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] == 0xfc) || ((a)->s6_addr[0] == 0xfd))
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SOCKADDR_STORAGE
|
||||
/*
|
||||
* RFC 2553: protocol-independent placeholder for socket addresses
|
||||
|
|
|
@ -512,7 +512,8 @@ class TestSocketAddrinfo < Test::Unit::TestCase
|
|||
[:ipv6_v4mapped?, "::ffff:0.0.0.0", "::ffff:255.255.255.255"],
|
||||
[:ipv6_linklocal?, "fe80::", "febf::"],
|
||||
[:ipv6_sitelocal?, "fec0::", "feef::"],
|
||||
[:ipv6_multicast?, "ff00::", "ffff::"]
|
||||
[:ipv6_multicast?, "ff00::", "ffff::"],
|
||||
[:ipv6_unique_local?, "fc00::", "fd00::"],
|
||||
]
|
||||
mlist = [
|
||||
[:ipv6_mc_nodelocal?, "ff01::", "ff11::"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче