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

Unified Diff: webrtc/base/nethelpers.cc

Issue 2881973002: Get tests working on systems that only support IPv6. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/nethelpers.h ('k') | webrtc/base/physicalsocketserver_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/nethelpers.cc
diff --git a/webrtc/base/nethelpers.cc b/webrtc/base/nethelpers.cc
index 6c2ef9c5f6bb28eb5745efaa8eb74050866d8ba2..6c11ef8c38fa04800df834bc8fa0f0f8939b3b89 100644
--- a/webrtc/base/nethelpers.cc
+++ b/webrtc/base/nethelpers.cc
@@ -141,6 +141,26 @@ int inet_pton(int af, const char* src, void *dst) {
#endif
}
+bool HasIPv4Enabled() {
+#if defined(WEBRTC_POSIX) && !defined(__native_client__)
+ bool has_ipv4 = false;
+ struct ifaddrs* ifa;
+ if (getifaddrs(&ifa) < 0) {
+ return false;
+ }
+ for (struct ifaddrs* cur = ifa; cur != nullptr; cur = cur->ifa_next) {
+ if (cur->ifa_addr->sa_family == AF_INET) {
+ has_ipv4 = true;
+ break;
pthatcher1 2017/05/15 21:50:31 Why not just "freeifaddrs(ifa); return true;"?
+ }
+ }
+ freeifaddrs(ifa);
+ return has_ipv4;
+#else
+ return true;
+#endif
+}
+
bool HasIPv6Enabled() {
#if defined(WEBRTC_WIN)
if (IsWindowsVistaOrLater()) {
« no previous file with comments | « webrtc/base/nethelpers.h ('k') | webrtc/base/physicalsocketserver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698