Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: webrtc/base/nethelpers.cc

Issue 1982733002: Re-enabling socket tests that were previously flaky. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing ifdefs. Using same logic as network.cc. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/messagequeue.cc ('k') | webrtc/base/physicalsocketserver_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_POSIX) && !defined(__native_client__)
21 #if defined(WEBRTC_ANDROID)
22 #include "webrtc/base/ifaddrs-android.h"
23 #else
24 #include <ifaddrs.h>
25 #endif
26 #endif // defined(WEBRTC_POSIX) && !defined(__native_client__)
20 27
21 #include "webrtc/base/byteorder.h" 28 #include "webrtc/base/byteorder.h"
22 #include "webrtc/base/logging.h" 29 #include "webrtc/base/logging.h"
23 #include "webrtc/base/signalthread.h" 30 #include "webrtc/base/signalthread.h"
24 31
25 namespace rtc { 32 namespace rtc {
26 33
27 int ResolveHostname(const std::string& hostname, int family, 34 int ResolveHostname(const std::string& hostname, int family,
28 std::vector<IPAddress>* addresses) { 35 std::vector<IPAddress>* addresses) {
29 #ifdef __native_client__ 36 #ifdef __native_client__
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 118
112 int inet_pton(int af, const char* src, void *dst) { 119 int inet_pton(int af, const char* src, void *dst) {
113 #if defined(WEBRTC_WIN) 120 #if defined(WEBRTC_WIN)
114 return win32_inet_pton(af, src, dst); 121 return win32_inet_pton(af, src, dst);
115 #else 122 #else
116 return ::inet_pton(af, src, dst); 123 return ::inet_pton(af, src, dst);
117 #endif 124 #endif
118 } 125 }
119 126
120 bool HasIPv6Enabled() { 127 bool HasIPv6Enabled() {
121 #if !defined(WEBRTC_WIN) 128 #if defined(WEBRTC_WIN)
122 // We only need to check this for Windows XP (so far).
123 return true;
124 #else
125 if (IsWindowsVistaOrLater()) { 129 if (IsWindowsVistaOrLater()) {
126 return true; 130 return true;
127 } 131 }
128 if (!IsWindowsXpOrLater()) { 132 if (!IsWindowsXpOrLater()) {
129 return false; 133 return false;
130 } 134 }
131 DWORD protbuff_size = 4096; 135 DWORD protbuff_size = 4096;
132 std::unique_ptr<char[]> protocols; 136 std::unique_ptr<char[]> protocols;
133 LPWSAPROTOCOL_INFOW protocol_infos = NULL; 137 LPWSAPROTOCOL_INFOW protocol_infos = NULL;
134 int requested_protocols[2] = {AF_INET6, 0}; 138 int requested_protocols[2] = {AF_INET6, 0};
(...skipping 15 matching lines...) Expand all
150 } 154 }
151 155
152 // Even if ret is positive, check specifically for IPv6. 156 // Even if ret is positive, check specifically for IPv6.
153 // Non-IPv6 enabled WinXP will still return a RAW protocol. 157 // Non-IPv6 enabled WinXP will still return a RAW protocol.
154 for (int i = 0; i < ret; ++i) { 158 for (int i = 0; i < ret; ++i) {
155 if (protocol_infos[i].iAddressFamily == AF_INET6) { 159 if (protocol_infos[i].iAddressFamily == AF_INET6) {
156 return true; 160 return true;
157 } 161 }
158 } 162 }
159 return false; 163 return false;
164 #elif defined(WEBRTC_POSIX) && !defined(__native_client__)
165 bool has_ipv6 = false;
166 struct ifaddrs* ifa;
167 if (getifaddrs(&ifa) < 0) {
168 return false;
169 }
170 for (struct ifaddrs* cur = ifa; cur != nullptr; cur = cur->ifa_next) {
171 if (cur->ifa_addr->sa_family == AF_INET6) {
172 has_ipv6 = true;
173 break;
174 }
175 }
176 freeifaddrs(ifa);
177 return has_ipv6;
178 #else
179 return true;
160 #endif 180 #endif
161 } 181 }
162 } // namespace rtc 182 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/messagequeue.cc ('k') | webrtc/base/physicalsocketserver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698