| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 27 matching lines...) Expand all Loading... |
| 38 #include "webrtc/rtc_base/logging.h" | 38 #include "webrtc/rtc_base/logging.h" |
| 39 #include "webrtc/rtc_base/networkmonitor.h" | 39 #include "webrtc/rtc_base/networkmonitor.h" |
| 40 #include "webrtc/rtc_base/socket.h" // includes something that makes windows ha
ppy | 40 #include "webrtc/rtc_base/socket.h" // includes something that makes windows ha
ppy |
| 41 #include "webrtc/rtc_base/stream.h" | 41 #include "webrtc/rtc_base/stream.h" |
| 42 #include "webrtc/rtc_base/stringencode.h" | 42 #include "webrtc/rtc_base/stringencode.h" |
| 43 #include "webrtc/rtc_base/thread.h" | 43 #include "webrtc/rtc_base/thread.h" |
| 44 | 44 |
| 45 namespace rtc { | 45 namespace rtc { |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 // Turning on IPv6 could make many IPv6 interfaces available for connectivity |
| 49 // check and delay the call setup time. kMaxIPv6Networks is the default upper |
| 50 // limit of IPv6 networks but could be changed by set_max_ipv6_networks(). |
| 51 const int kMaxIPv6Networks = 5; |
| 52 |
| 48 const uint32_t kUpdateNetworksMessage = 1; | 53 const uint32_t kUpdateNetworksMessage = 1; |
| 49 const uint32_t kSignalNetworksMessage = 2; | 54 const uint32_t kSignalNetworksMessage = 2; |
| 50 | 55 |
| 51 // Fetch list of networks every two seconds. | 56 // Fetch list of networks every two seconds. |
| 52 const int kNetworksUpdateIntervalMs = 2000; | 57 const int kNetworksUpdateIntervalMs = 2000; |
| 53 | 58 |
| 54 const int kHighestNetworkPreference = 127; | 59 const int kHighestNetworkPreference = 127; |
| 55 | 60 |
| 56 typedef struct { | 61 typedef struct { |
| 57 Network* net; | 62 Network* net; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 81 | 86 |
| 82 // After type, networks are sorted by IP address precedence values | 87 // After type, networks are sorted by IP address precedence values |
| 83 // from RFC 3484-bis | 88 // from RFC 3484-bis |
| 84 if (IPAddressPrecedence(ip_a) != IPAddressPrecedence(ip_b)) { | 89 if (IPAddressPrecedence(ip_a) != IPAddressPrecedence(ip_b)) { |
| 85 return IPAddressPrecedence(ip_a) > IPAddressPrecedence(ip_b); | 90 return IPAddressPrecedence(ip_a) > IPAddressPrecedence(ip_b); |
| 86 } | 91 } |
| 87 | 92 |
| 88 // TODO(mallinath) - Add VPN and Link speed conditions while sorting. | 93 // TODO(mallinath) - Add VPN and Link speed conditions while sorting. |
| 89 | 94 |
| 90 // Networks are sorted last by key. | 95 // Networks are sorted last by key. |
| 91 return a->key() < b->key(); | 96 return a->key() > b->key(); |
| 92 } | 97 } |
| 93 | 98 |
| 94 std::string AdapterTypeToString(AdapterType type) { | 99 std::string AdapterTypeToString(AdapterType type) { |
| 95 switch (type) { | 100 switch (type) { |
| 96 case ADAPTER_TYPE_UNKNOWN: | 101 case ADAPTER_TYPE_UNKNOWN: |
| 97 return "Unknown"; | 102 return "Unknown"; |
| 98 case ADAPTER_TYPE_ETHERNET: | 103 case ADAPTER_TYPE_ETHERNET: |
| 99 return "Ethernet"; | 104 return "Ethernet"; |
| 100 case ADAPTER_TYPE_WIFI: | 105 case ADAPTER_TYPE_WIFI: |
| 101 return "Wifi"; | 106 return "Wifi"; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 const { | 168 const { |
| 164 return ENUMERATION_ALLOWED; | 169 return ENUMERATION_ALLOWED; |
| 165 } | 170 } |
| 166 | 171 |
| 167 bool NetworkManager::GetDefaultLocalAddress(int family, IPAddress* addr) const { | 172 bool NetworkManager::GetDefaultLocalAddress(int family, IPAddress* addr) const { |
| 168 return false; | 173 return false; |
| 169 } | 174 } |
| 170 | 175 |
| 171 NetworkManagerBase::NetworkManagerBase() | 176 NetworkManagerBase::NetworkManagerBase() |
| 172 : enumeration_permission_(NetworkManager::ENUMERATION_ALLOWED), | 177 : enumeration_permission_(NetworkManager::ENUMERATION_ALLOWED), |
| 178 max_ipv6_networks_(kMaxIPv6Networks), |
| 173 ipv6_enabled_(true) { | 179 ipv6_enabled_(true) { |
| 174 } | 180 } |
| 175 | 181 |
| 176 NetworkManagerBase::~NetworkManagerBase() { | 182 NetworkManagerBase::~NetworkManagerBase() { |
| 177 for (const auto& kv : networks_map_) { | 183 for (const auto& kv : networks_map_) { |
| 178 delete kv.second; | 184 delete kv.second; |
| 179 } | 185 } |
| 180 } | 186 } |
| 181 | 187 |
| 182 NetworkManager::EnumerationPermission | 188 NetworkManager::EnumerationPermission |
| (...skipping 17 matching lines...) Expand all Loading... |
| 200 ipv6_any_address_network_.reset( | 206 ipv6_any_address_network_.reset( |
| 201 new rtc::Network("any", "any", ipv6_any_address, 0)); | 207 new rtc::Network("any", "any", ipv6_any_address, 0)); |
| 202 ipv6_any_address_network_->set_default_local_address_provider(this); | 208 ipv6_any_address_network_->set_default_local_address_provider(this); |
| 203 ipv6_any_address_network_->AddIP(ipv6_any_address); | 209 ipv6_any_address_network_->AddIP(ipv6_any_address); |
| 204 } | 210 } |
| 205 networks->push_back(ipv6_any_address_network_.get()); | 211 networks->push_back(ipv6_any_address_network_.get()); |
| 206 } | 212 } |
| 207 } | 213 } |
| 208 | 214 |
| 209 void NetworkManagerBase::GetNetworks(NetworkList* result) const { | 215 void NetworkManagerBase::GetNetworks(NetworkList* result) const { |
| 216 int ipv6_networks = 0; |
| 210 result->clear(); | 217 result->clear(); |
| 211 result->insert(result->begin(), networks_.begin(), networks_.end()); | 218 for (Network* network : networks_) { |
| 219 // Keep the number of IPv6 networks under |max_ipv6_networks_|. |
| 220 if (network->prefix().family() == AF_INET6) { |
| 221 if (ipv6_networks >= max_ipv6_networks_) { |
| 222 continue; |
| 223 } |
| 224 ++ipv6_networks; |
| 225 } |
| 226 result->push_back(network); |
| 227 } |
| 212 } | 228 } |
| 213 | 229 |
| 214 void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks, | 230 void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks, |
| 215 bool* changed) { | 231 bool* changed) { |
| 216 NetworkManager::Stats stats; | 232 NetworkManager::Stats stats; |
| 217 MergeNetworkList(new_networks, changed, &stats); | 233 MergeNetworkList(new_networks, changed, &stats); |
| 218 } | 234 } |
| 219 | 235 |
| 220 void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks, | 236 void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks, |
| 221 bool* changed, | 237 bool* changed, |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 std::stringstream ss; | 983 std::stringstream ss; |
| 968 // Print out the first space-terminated token of the network desc, plus | 984 // Print out the first space-terminated token of the network desc, plus |
| 969 // the IP address. | 985 // the IP address. |
| 970 ss << "Net[" << description_.substr(0, description_.find(' ')) | 986 ss << "Net[" << description_.substr(0, description_.find(' ')) |
| 971 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ | 987 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ |
| 972 << ":" << AdapterTypeToString(type_) << "]"; | 988 << ":" << AdapterTypeToString(type_) << "]"; |
| 973 return ss.str(); | 989 return ss.str(); |
| 974 } | 990 } |
| 975 | 991 |
| 976 } // namespace rtc | 992 } // namespace rtc |
| OLD | NEW |