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 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 } | 134 } |
135 | 135 |
136 int inet_pton(int af, const char* src, void *dst) { | 136 int inet_pton(int af, const char* src, void *dst) { |
137 #if defined(WEBRTC_WIN) | 137 #if defined(WEBRTC_WIN) |
138 return win32_inet_pton(af, src, dst); | 138 return win32_inet_pton(af, src, dst); |
139 #else | 139 #else |
140 return ::inet_pton(af, src, dst); | 140 return ::inet_pton(af, src, dst); |
141 #endif | 141 #endif |
142 } | 142 } |
143 | 143 |
144 bool HasIPv4Enabled() { | |
145 #if defined(WEBRTC_POSIX) && !defined(__native_client__) | |
146 bool has_ipv4 = false; | |
147 struct ifaddrs* ifa; | |
148 if (getifaddrs(&ifa) < 0) { | |
149 return false; | |
150 } | |
151 for (struct ifaddrs* cur = ifa; cur != nullptr; cur = cur->ifa_next) { | |
152 if (cur->ifa_addr->sa_family == AF_INET) { | |
153 has_ipv4 = true; | |
154 break; | |
pthatcher1
2017/05/15 21:50:31
Why not just "freeifaddrs(ifa); return true;"?
| |
155 } | |
156 } | |
157 freeifaddrs(ifa); | |
158 return has_ipv4; | |
159 #else | |
160 return true; | |
161 #endif | |
162 } | |
163 | |
144 bool HasIPv6Enabled() { | 164 bool HasIPv6Enabled() { |
145 #if defined(WEBRTC_WIN) | 165 #if defined(WEBRTC_WIN) |
146 if (IsWindowsVistaOrLater()) { | 166 if (IsWindowsVistaOrLater()) { |
147 return true; | 167 return true; |
148 } | 168 } |
149 if (!IsWindowsXpOrLater()) { | 169 if (!IsWindowsXpOrLater()) { |
150 return false; | 170 return false; |
151 } | 171 } |
152 DWORD protbuff_size = 4096; | 172 DWORD protbuff_size = 4096; |
153 std::unique_ptr<char[]> protocols; | 173 std::unique_ptr<char[]> protocols; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 break; | 210 break; |
191 } | 211 } |
192 } | 212 } |
193 freeifaddrs(ifa); | 213 freeifaddrs(ifa); |
194 return has_ipv6; | 214 return has_ipv6; |
195 #else | 215 #else |
196 return true; | 216 return true; |
197 #endif | 217 #endif |
198 } | 218 } |
199 } // namespace rtc | 219 } // namespace rtc |
OLD | NEW |