| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/base/nethelpers.h" | 11 #include "webrtc/base/nethelpers.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 | 14 |
| 15 #if defined(WEBRTC_WIN) | 15 #if defined(WEBRTC_WIN) |
| 16 #include <ws2spi.h> | 16 #include <ws2spi.h> |
| 17 #include <ws2tcpip.h> | 17 #include <ws2tcpip.h> |
| 18 #include "webrtc/base/win32.h" | 18 #include "webrtc/base/win32.h" |
| 19 #endif | 19 #endif |
| 20 #if defined(WEBRTC_LINUX) |
| 21 #include <sys/types.h> |
| 22 #include <ifaddrs.h> |
| 23 #endif |
| 20 | 24 |
| 21 #include "webrtc/base/byteorder.h" | 25 #include "webrtc/base/byteorder.h" |
| 22 #include "webrtc/base/logging.h" | 26 #include "webrtc/base/logging.h" |
| 23 #include "webrtc/base/signalthread.h" | 27 #include "webrtc/base/signalthread.h" |
| 24 | 28 |
| 25 namespace rtc { | 29 namespace rtc { |
| 26 | 30 |
| 27 int ResolveHostname(const std::string& hostname, int family, | 31 int ResolveHostname(const std::string& hostname, int family, |
| 28 std::vector<IPAddress>* addresses) { | 32 std::vector<IPAddress>* addresses) { |
| 29 #ifdef __native_client__ | 33 #ifdef __native_client__ |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 115 |
| 112 int inet_pton(int af, const char* src, void *dst) { | 116 int inet_pton(int af, const char* src, void *dst) { |
| 113 #if defined(WEBRTC_WIN) | 117 #if defined(WEBRTC_WIN) |
| 114 return win32_inet_pton(af, src, dst); | 118 return win32_inet_pton(af, src, dst); |
| 115 #else | 119 #else |
| 116 return ::inet_pton(af, src, dst); | 120 return ::inet_pton(af, src, dst); |
| 117 #endif | 121 #endif |
| 118 } | 122 } |
| 119 | 123 |
| 120 bool HasIPv6Enabled() { | 124 bool HasIPv6Enabled() { |
| 121 #if !defined(WEBRTC_WIN) | 125 #if defined(WEBRTC_WIN) |
| 122 // We only need to check this for Windows XP (so far). | |
| 123 return true; | |
| 124 #else | |
| 125 if (IsWindowsVistaOrLater()) { | 126 if (IsWindowsVistaOrLater()) { |
| 126 return true; | 127 return true; |
| 127 } | 128 } |
| 128 if (!IsWindowsXpOrLater()) { | 129 if (!IsWindowsXpOrLater()) { |
| 129 return false; | 130 return false; |
| 130 } | 131 } |
| 131 DWORD protbuff_size = 4096; | 132 DWORD protbuff_size = 4096; |
| 132 std::unique_ptr<char[]> protocols; | 133 std::unique_ptr<char[]> protocols; |
| 133 LPWSAPROTOCOL_INFOW protocol_infos = NULL; | 134 LPWSAPROTOCOL_INFOW protocol_infos = NULL; |
| 134 int requested_protocols[2] = {AF_INET6, 0}; | 135 int requested_protocols[2] = {AF_INET6, 0}; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 150 } | 151 } |
| 151 | 152 |
| 152 // Even if ret is positive, check specifically for IPv6. | 153 // Even if ret is positive, check specifically for IPv6. |
| 153 // Non-IPv6 enabled WinXP will still return a RAW protocol. | 154 // Non-IPv6 enabled WinXP will still return a RAW protocol. |
| 154 for (int i = 0; i < ret; ++i) { | 155 for (int i = 0; i < ret; ++i) { |
| 155 if (protocol_infos[i].iAddressFamily == AF_INET6) { | 156 if (protocol_infos[i].iAddressFamily == AF_INET6) { |
| 156 return true; | 157 return true; |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 return false; | 160 return false; |
| 161 #elif defined(WEBRTC_LINUX) |
| 162 bool has_ipv6 = false; |
| 163 struct ifaddrs* ifa; |
| 164 if (getifaddrs(&ifa) < 0) { |
| 165 return false; |
| 166 } |
| 167 for (struct ifaddrs* cur = ifa; cur != nullptr; cur = cur->ifa_next) { |
| 168 if (cur->ifa_addr->sa_family == AF_INET6) { |
| 169 has_ipv6 = true; |
| 170 break; |
| 171 } |
| 172 } |
| 173 freeifaddrs(ifa); |
| 174 return has_ipv6; |
| 175 #else |
| 176 return true; |
| 160 #endif | 177 #endif |
| 161 } | 178 } |
| 162 } // namespace rtc | 179 } // namespace rtc |
| OLD | NEW |