MSDKDns/Network/msdkdns_local_ip_stack.cpp
/*
 * The following functions determine whether IPv4 or IPv6 connectivity is
 * available in order to implement AI_ADDRCONFIG.
 *
 * Strictly speaking, AI_ADDRCONFIG should not look at whether connectivity is
 * available, but whether addresses of the specified family are "configured
 * on the local system". However, bionic doesn't currently support getifaddrs,
 * so checking for connectivity is the next best thing.
 */
The following functions determine whether IPv4 or IPv6 connectivity is
available in order to implement AI_ADDRCONFIG.

Strictly speaking, AI_ADDRCONFIG should not look at whether connectivity is
available, but whether addresses of the specified family are "configured
on the local system". However, bionic doesn't currently support getifaddrs,
so checking for connectivity is the next best thing.
The following functions determine whether IPv4 or IPv6 connectivity is available in order to implement AI_ADDRCONFIG . Strictly speaking AI_ADDRCONFIG should not look at whether connectivity is available but whether addresses of the specified family are " configured on the local system " . However bionic doesn ' t currently support getifaddrs so checking for connectivity is the next best thing .
static int msdkdns_have_ipv6() {
    static struct sockaddr_in6 sin6_test = {0};
    sin6_test.sin6_family = AF_INET6;
    sin6_test.sin6_port = 80;
    sin6_test.sin6_flowinfo = 0;
    sin6_test.sin6_scope_id = 0;
    bzero(sin6_test.sin6_addr.s6_addr, sizeof(sin6_test.sin6_addr.s6_addr));
    sin6_test.sin6_addr.s6_addr[0] = 0x20;
    msdkdns::msdkdns_sockaddr_union addr = {.msdkdns_in6 = sin6_test};
    return msdkdns_test_connect(PF_INET6, &addr.msdkdns_generic, sizeof(addr.msdkdns_in6));
}
static int msdkdns_have_ipv6 ( ) { static struct sockaddr_in6 sin6_test = { 0 } ; sin6_test . sin6_family = AF_INET6 ; sin6_test . sin6_port = 80 ; sin6_test . sin6_flowinfo = 0 ; sin6_test . sin6_scope_id = 0 ; bzero ( sin6_test . sin6_addr . s6_addr , sizeof ( sin6_test . sin6_addr . s6_addr ) ) ; sin6_test . sin6_addr . s6_addr [ 0 ] = 0x20 ; msdkdns :: msdkdns_sockaddr_union addr = { . msdkdns_in6 = sin6_test } ; return msdkdns_test_connect ( PF_INET6 , & addr . msdkdns_generic , sizeof ( addr . msdkdns_in6 ) ) ; }
The following functions determine whether IPv4 or IPv6 connectivity is
 available in order to implement AI_ADDRCONFIG.
The following functions determine whether IPv4 or IPv6 connectivity is available in order to implement AI_ADDRCONFIG .
// union