Index: ext/socket/raddrinfo.c =================================================================== --- ext/socket/raddrinfo.c (revision 36348) +++ ext/socket/raddrinfo.c (working copy) @@ -1793,6 +1793,18 @@ addrinfo_ipv6_sitelocal_p(VALUE self) } /* + * 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); Index: test/socket/test_addrinfo.rb =================================================================== --- test/socket/test_addrinfo.rb (revision 36348) +++ test/socket/test_addrinfo.rb (working copy) @@ -512,7 +512,8 @@ class TestSocketAddrinfo < Test::Unit::T [: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::"], Index: test/socket/test_socket.rb =================================================================== --- test/socket/test_socket.rb (revision 36348) +++ test/socket/test_socket.rb (working copy) @@ -334,6 +334,8 @@ class TestSocket < Test::Unit::TestCase end when /darwin/ if !ai.ipv6? + elsif ai.ipv6_unique_local? + next true # iCloud addresses do not work, see Bug 6692 elsif ifr_name = ai.ip_address[/%(.*)/, 1] # Mac OS X may sets IFDISABLED as FreeBSD does ulSIOCGIFFLAGS = 3223349521