summaryrefslogtreecommitdiffstats
path: root/net/base/net_util.cc
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 03:32:11 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 03:32:11 +0000
commit23330db782cd3bb9fc8dc40894436c39eea8c30f (patch)
tree69eaec5c5470a70019f4dd659d0548492c875b9f /net/base/net_util.cc
parent00fdd17f17c0d9a602b077b85630dd3d76634a4b (diff)
downloadchromium_src-23330db782cd3bb9fc8dc40894436c39eea8c30f.zip
chromium_src-23330db782cd3bb9fc8dc40894436c39eea8c30f.tar.gz
chromium_src-23330db782cd3bb9fc8dc40894436c39eea8c30f.tar.bz2
Remove interface probing for IPv6 support from HostResolverImpl
Since r195406 the probe is not used. It is now safe to remove this code completely. BUG=260750 Review URL: https://chromiumcodereview.appspot.com/19286002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212224 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.cc')
-rw-r--r--net/base/net_util.cc173
1 files changed, 0 insertions, 173 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index fe1d0f0..db9251b 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -1795,179 +1795,6 @@ ScopedPortException::~ScopedPortException() {
NOTREACHED();
}
-namespace {
-
-const char* kFinalStatusNames[] = {
- "Cannot create sockets",
- "Can create sockets",
- "Can't get addresses",
- "Global ipv6 address missing",
- "Global ipv6 address present",
- "Interface array too short",
- "Probing not supported", // IPV6_SUPPORT_MAX
-};
-COMPILE_ASSERT(arraysize(kFinalStatusNames) == IPV6_SUPPORT_MAX + 1,
- IPv6SupportStatus_name_count_mismatch);
-
-// TODO(jar): The following is a simple estimate of IPv6 support. We may need
-// to do a test resolution, and a test connection, to REALLY verify support.
-IPv6SupportResult TestIPv6SupportInternal() {
-#if defined(OS_ANDROID)
- // TODO: We should fully implement IPv6 probe once 'getifaddrs' API available;
- // Another approach is implementing the similar feature by
- // java.net.NetworkInterface through JNI.
- NOTIMPLEMENTED();
- return IPv6SupportResult(true, IPV6_SUPPORT_MAX, 0);
-#elif defined(OS_POSIX)
- int test_socket = socket(AF_INET6, SOCK_STREAM, 0);
- if (test_socket == -1)
- return IPv6SupportResult(false, IPV6_CANNOT_CREATE_SOCKETS, errno);
- close(test_socket);
-
- // Check to see if any interface has a IPv6 address.
- struct ifaddrs* interface_addr = NULL;
- int rv = getifaddrs(&interface_addr);
- if (rv != 0) {
- // Don't yet block IPv6.
- return IPv6SupportResult(true, IPV6_GETIFADDRS_FAILED, errno);
- }
-
- bool found_ipv6 = false;
- for (struct ifaddrs* interface = interface_addr;
- interface != NULL;
- interface = interface->ifa_next) {
- if (!(IFF_UP & interface->ifa_flags))
- continue;
- if (IFF_LOOPBACK & interface->ifa_flags)
- continue;
- struct sockaddr* addr = interface->ifa_addr;
- if (!addr)
- continue;
- if (addr->sa_family != AF_INET6)
- continue;
- // Safe cast since this is AF_INET6.
- struct sockaddr_in6* addr_in6 =
- reinterpret_cast<struct sockaddr_in6*>(addr);
- struct in6_addr* sin6_addr = &addr_in6->sin6_addr;
- if (IN6_IS_ADDR_LOOPBACK(sin6_addr) || IN6_IS_ADDR_LINKLOCAL(sin6_addr))
- continue;
- found_ipv6 = true;
- break;
- }
- freeifaddrs(interface_addr);
- if (!found_ipv6)
- return IPv6SupportResult(false, IPV6_GLOBAL_ADDRESS_MISSING, 0);
-
- return IPv6SupportResult(true, IPV6_GLOBAL_ADDRESS_PRESENT, 0);
-#elif defined(OS_WIN)
- EnsureWinsockInit();
- SOCKET test_socket = socket(AF_INET6, SOCK_STREAM, 0);
- if (test_socket == INVALID_SOCKET) {
- return IPv6SupportResult(false,
- IPV6_CANNOT_CREATE_SOCKETS,
- WSAGetLastError());
- }
- closesocket(test_socket);
-
- // Check to see if any interface has a IPv6 address.
- // The GetAdaptersAddresses MSDN page recommends using a size of 15000 to
- // avoid reallocation.
- ULONG adapters_size = 15000;
- scoped_ptr_malloc<IP_ADAPTER_ADDRESSES> adapters;
- ULONG error;
- int num_tries = 0;
- do {
- adapters.reset(
- reinterpret_cast<PIP_ADAPTER_ADDRESSES>(malloc(adapters_size)));
- // Return only unicast addresses.
- error = GetAdaptersAddresses(AF_UNSPEC,
- GAA_FLAG_SKIP_ANYCAST |
- GAA_FLAG_SKIP_MULTICAST |
- GAA_FLAG_SKIP_DNS_SERVER |
- GAA_FLAG_SKIP_FRIENDLY_NAME,
- NULL, adapters.get(), &adapters_size);
- num_tries++;
- } while (error == ERROR_BUFFER_OVERFLOW && num_tries <= 3);
- if (error == ERROR_NO_DATA)
- return IPv6SupportResult(false, IPV6_GLOBAL_ADDRESS_MISSING, error);
- if (error != ERROR_SUCCESS) {
- // Don't yet block IPv6.
- return IPv6SupportResult(true, IPV6_GETIFADDRS_FAILED, error);
- }
-
- PIP_ADAPTER_ADDRESSES adapter;
- for (adapter = adapters.get(); adapter; adapter = adapter->Next) {
- if (adapter->OperStatus != IfOperStatusUp)
- continue;
- if (adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK)
- continue;
- PIP_ADAPTER_UNICAST_ADDRESS unicast_address;
- for (unicast_address = adapter->FirstUnicastAddress;
- unicast_address;
- unicast_address = unicast_address->Next) {
- if (unicast_address->Address.lpSockaddr->sa_family != AF_INET6)
- continue;
- // Safe cast since this is AF_INET6.
- struct sockaddr_in6* addr_in6 = reinterpret_cast<struct sockaddr_in6*>(
- unicast_address->Address.lpSockaddr);
- struct in6_addr* sin6_addr = &addr_in6->sin6_addr;
- if (IN6_IS_ADDR_LOOPBACK(sin6_addr) || IN6_IS_ADDR_LINKLOCAL(sin6_addr))
- continue;
- const uint8 kTeredoPrefix[] = { 0x20, 0x01, 0, 0 };
- if (!memcmp(sin6_addr->s6_addr, kTeredoPrefix, arraysize(kTeredoPrefix)))
- continue;
- return IPv6SupportResult(true, IPV6_GLOBAL_ADDRESS_PRESENT, 0);
- }
- }
-
- return IPv6SupportResult(false, IPV6_GLOBAL_ADDRESS_MISSING, 0);
-#else
- NOTIMPLEMENTED();
- return IPv6SupportResult(true, IPV6_SUPPORT_MAX, 0);
-#endif // defined(various platforms)
-}
-
-} // namespace
-
-IPv6SupportResult::IPv6SupportResult(bool ipv6_supported,
- IPv6SupportStatus ipv6_support_status,
- int os_error)
- : ipv6_supported(ipv6_supported),
- ipv6_support_status(ipv6_support_status),
- os_error(os_error) {
-}
-
-base::Value* IPv6SupportResult::ToNetLogValue(
- NetLog::LogLevel /* log_level */) const {
- base::DictionaryValue* dict = new base::DictionaryValue();
- dict->SetBoolean("ipv6_supported", ipv6_supported);
- dict->SetString("ipv6_support_status",
- kFinalStatusNames[ipv6_support_status]);
- if (os_error)
- dict->SetInteger("os_error", os_error);
- return dict;
-}
-
-IPv6SupportResult TestIPv6Support() {
- IPv6SupportResult result = TestIPv6SupportInternal();
-
- // Record UMA.
- if (result.ipv6_support_status != IPV6_SUPPORT_MAX) {
- static bool run_once = false;
- if (!run_once) {
- run_once = true;
- UMA_HISTOGRAM_ENUMERATION("Net.IPv6Status",
- result.ipv6_support_status,
- IPV6_SUPPORT_MAX);
- } else {
- UMA_HISTOGRAM_ENUMERATION("Net.IPv6Status_retest",
- result.ipv6_support_status,
- IPV6_SUPPORT_MAX);
- }
- }
- return result;
-}
-
bool HaveOnlyLoopbackAddresses() {
#if defined(OS_ANDROID)
return android::HaveOnlyLoopbackAddresses();