Index: webrtc/rtc_base/network.cc |
diff --git a/webrtc/rtc_base/network.cc b/webrtc/rtc_base/network.cc |
index 26d6520e22b20712ef3f0cfe76b5053a84296f04..1f4a705db030e5b689e46b5fc460e7571e24e609 100644 |
--- a/webrtc/rtc_base/network.cc |
+++ b/webrtc/rtc_base/network.cc |
@@ -45,6 +45,11 @@ |
namespace rtc { |
namespace { |
+// Turning on IPv6 could make many IPv6 interfaces available for connectivity |
+// check and delay the call setup time. kMaxIPv6Networks is the default upper |
+// limit of IPv6 networks but could be changed by set_max_ipv6_networks(). |
+const int kMaxIPv6Networks = 5; |
+ |
const uint32_t kUpdateNetworksMessage = 1; |
const uint32_t kSignalNetworksMessage = 2; |
@@ -88,7 +93,7 @@ |
// TODO(mallinath) - Add VPN and Link speed conditions while sorting. |
// Networks are sorted last by key. |
- return a->key() < b->key(); |
+ return a->key() > b->key(); |
} |
std::string AdapterTypeToString(AdapterType type) { |
@@ -170,6 +175,7 @@ |
NetworkManagerBase::NetworkManagerBase() |
: enumeration_permission_(NetworkManager::ENUMERATION_ALLOWED), |
+ max_ipv6_networks_(kMaxIPv6Networks), |
ipv6_enabled_(true) { |
} |
@@ -207,8 +213,18 @@ |
} |
void NetworkManagerBase::GetNetworks(NetworkList* result) const { |
+ int ipv6_networks = 0; |
result->clear(); |
- result->insert(result->begin(), networks_.begin(), networks_.end()); |
+ for (Network* network : networks_) { |
+ // Keep the number of IPv6 networks under |max_ipv6_networks_|. |
+ if (network->prefix().family() == AF_INET6) { |
+ if (ipv6_networks >= max_ipv6_networks_) { |
+ continue; |
+ } |
+ ++ipv6_networks; |
+ } |
+ result->push_back(network); |
+ } |
} |
void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks, |