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

Unified 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: Removing debug logging and adding IPv6 check for more tests 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/base/nethelpers.cc
diff --git a/webrtc/base/nethelpers.cc b/webrtc/base/nethelpers.cc
index d9015283b0baef98f2a370acdf334f9603a8765d..d3d24c2c971d39d7410f39e433f5f24d7732d442 100644
--- a/webrtc/base/nethelpers.cc
+++ b/webrtc/base/nethelpers.cc
@@ -17,6 +17,10 @@
#include <ws2tcpip.h>
#include "webrtc/base/win32.h"
#endif
+#if defined(WEBRTC_LINUX)
+#include <sys/types.h>
+#include <ifaddrs.h>
+#endif
#include "webrtc/base/byteorder.h"
#include "webrtc/base/logging.h"
@@ -118,10 +122,7 @@ int inet_pton(int af, const char* src, void *dst) {
}
bool HasIPv6Enabled() {
-#if !defined(WEBRTC_WIN)
- // We only need to check this for Windows XP (so far).
- return true;
-#else
+#if defined(WEBRTC_WIN)
if (IsWindowsVistaOrLater()) {
return true;
}
@@ -157,6 +158,22 @@ bool HasIPv6Enabled() {
}
}
return false;
+#elif defined(WEBRTC_LINUX)
+ bool has_ipv6 = 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_INET6) {
+ has_ipv6 = true;
+ break;
+ }
+ }
+ freeifaddrs(ifa);
+ return has_ipv6;
+#else
+ return true;
#endif
}
} // namespace rtc

Powered by Google App Engine
This is Rietveld 408576698