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