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 19 matching lines...) Expand all Loading... | |
30 namespace rtc { | 30 namespace rtc { |
31 | 31 |
32 extern const char kPublicIPv4Host[]; | 32 extern const char kPublicIPv4Host[]; |
33 extern const char kPublicIPv6Host[]; | 33 extern const char kPublicIPv6Host[]; |
34 | 34 |
35 class IfAddrsConverter; | 35 class IfAddrsConverter; |
36 class Network; | 36 class Network; |
37 class NetworkMonitorInterface; | 37 class NetworkMonitorInterface; |
38 class Thread; | 38 class Thread; |
39 | 39 |
40 static const uint16_t kMaxNetworkCost = 999; | |
41 static const uint16_t kNetworkCostForUnknownType = 10; | |
pthatcher1
2016/05/17 20:44:28
I think kNetworkCostMax and kNetworkCostUnknown w
honghaiz3
2016/05/18 05:55:02
Done.
| |
40 | 42 |
41 // By default, ignore loopback interfaces on the host. | 43 // By default, ignore loopback interfaces on the host. |
42 const int kDefaultNetworkIgnoreMask = ADAPTER_TYPE_LOOPBACK; | 44 const int kDefaultNetworkIgnoreMask = ADAPTER_TYPE_LOOPBACK; |
43 | 45 |
44 // Makes a string key for this network. Used in the network manager's maps. | 46 // Makes a string key for this network. Used in the network manager's maps. |
45 // Network objects are keyed on interface name, network prefix and the | 47 // Network objects are keyed on interface name, network prefix and the |
46 // length of that prefix. | 48 // length of that prefix. |
47 std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix, | 49 std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix, |
48 int prefix_length); | 50 int prefix_length); |
49 | 51 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 void set_scope_id(int id) { scope_id_ = id; } | 341 void set_scope_id(int id) { scope_id_ = id; } |
340 | 342 |
341 // Indicates whether this network should be ignored, perhaps because | 343 // Indicates whether this network should be ignored, perhaps because |
342 // the IP is 0, or the interface is one we know is invalid. | 344 // the IP is 0, or the interface is one we know is invalid. |
343 bool ignored() const { return ignored_; } | 345 bool ignored() const { return ignored_; } |
344 void set_ignored(bool ignored) { ignored_ = ignored; } | 346 void set_ignored(bool ignored) { ignored_ = ignored; } |
345 | 347 |
346 AdapterType type() const { return type_; } | 348 AdapterType type() const { return type_; } |
347 void set_type(AdapterType type) { type_ = type; } | 349 void set_type(AdapterType type) { type_ = type; } |
348 | 350 |
351 uint16_t GetCost() const { | |
352 switch (type_) { | |
353 case rtc::ADAPTER_TYPE_UNKNOWN: | |
354 return kNetworkCostForUnknownType; | |
355 case rtc::ADAPTER_TYPE_CELLULAR: | |
356 return kMaxNetworkCost; | |
pthatcher1
2016/05/17 20:44:28
Should we use kNetworkCostHigh == 900 or so just i
honghaiz3
2016/05/18 05:55:02
Done.
I initially chose cellular network cost to b
honghaiz3
2016/05/18 05:55:02
Done.
| |
357 default: | |
358 return 0; | |
pthatcher1
2016/05/17 20:44:28
Would a kNetworkCostMin be a good constant?
pthatcher1
2016/05/17 20:44:28
Wouldn't it be better to have the default be "unkn
honghaiz3
2016/05/18 05:55:02
Done. I just listed all types we may have now.
honghaiz3
2016/05/18 05:55:02
Done.
| |
359 } | |
pthatcher1
2016/05/17 20:44:28
Would it make sense to make WiFi kNetworkCostLow =
honghaiz3
2016/05/18 05:55:02
I choose Wifi cost to be 10 to have slightly more
| |
360 } | |
361 | |
349 // A unique id assigned by the network manager, which may be signaled | 362 // A unique id assigned by the network manager, which may be signaled |
350 // to the remote side in the candidate. | 363 // to the remote side in the candidate. |
351 uint16_t id() const { return id_; } | 364 uint16_t id() const { return id_; } |
352 void set_id(uint16_t id) { id_ = id; } | 365 void set_id(uint16_t id) { id_ = id; } |
353 | 366 |
354 int preference() const { return preference_; } | 367 int preference() const { return preference_; } |
355 void set_preference(int preference) { preference_ = preference; } | 368 void set_preference(int preference) { preference_ = preference; } |
356 | 369 |
357 // When we enumerate networks and find a previously-seen network is missing, | 370 // When we enumerate networks and find a previously-seen network is missing, |
358 // we do not remove it (because it may be used elsewhere). Instead, we mark | 371 // we do not remove it (because it may be used elsewhere). Instead, we mark |
(...skipping 26 matching lines...) Expand all Loading... | |
385 int preference_; | 398 int preference_; |
386 bool active_ = true; | 399 bool active_ = true; |
387 uint16_t id_ = 0; | 400 uint16_t id_ = 0; |
388 | 401 |
389 friend class NetworkManager; | 402 friend class NetworkManager; |
390 }; | 403 }; |
391 | 404 |
392 } // namespace rtc | 405 } // namespace rtc |
393 | 406 |
394 #endif // WEBRTC_BASE_NETWORK_H_ | 407 #endif // WEBRTC_BASE_NETWORK_H_ |
OLD | NEW |