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()) { |