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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 int max_ipv6_networks_; | 166 int max_ipv6_networks_; |
167 | 167 |
168 NetworkMap networks_map_; | 168 NetworkMap networks_map_; |
169 bool ipv6_enabled_; | 169 bool ipv6_enabled_; |
170 | 170 |
171 rtc::scoped_ptr<rtc::Network> ipv4_any_address_network_; | 171 rtc::scoped_ptr<rtc::Network> ipv4_any_address_network_; |
172 rtc::scoped_ptr<rtc::Network> ipv6_any_address_network_; | 172 rtc::scoped_ptr<rtc::Network> ipv6_any_address_network_; |
173 | 173 |
174 IPAddress default_local_ipv4_address_; | 174 IPAddress default_local_ipv4_address_; |
175 IPAddress default_local_ipv6_address_; | 175 IPAddress default_local_ipv6_address_; |
| 176 // We use 16 bits to save the bandwidth consumption when sending the network |
| 177 // id over the Internet. It is OK that the 16-bit integer overflows to get a |
| 178 // network id 0 because we only compare the network ids in the old and the new |
| 179 // best connections in the transport channel. |
| 180 uint16_t next_available_network_id_ = 1; |
176 }; | 181 }; |
177 | 182 |
178 // Basic implementation of the NetworkManager interface that gets list | 183 // Basic implementation of the NetworkManager interface that gets list |
179 // of networks using OS APIs. | 184 // of networks using OS APIs. |
180 class BasicNetworkManager : public NetworkManagerBase, | 185 class BasicNetworkManager : public NetworkManagerBase, |
181 public MessageHandler, | 186 public MessageHandler, |
182 public sigslot::has_slots<> { | 187 public sigslot::has_slots<> { |
183 public: | 188 public: |
184 BasicNetworkManager(); | 189 BasicNetworkManager(); |
185 ~BasicNetworkManager() override; | 190 ~BasicNetworkManager() override; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 void set_scope_id(int id) { scope_id_ = id; } | 337 void set_scope_id(int id) { scope_id_ = id; } |
333 | 338 |
334 // Indicates whether this network should be ignored, perhaps because | 339 // Indicates whether this network should be ignored, perhaps because |
335 // the IP is 0, or the interface is one we know is invalid. | 340 // the IP is 0, or the interface is one we know is invalid. |
336 bool ignored() const { return ignored_; } | 341 bool ignored() const { return ignored_; } |
337 void set_ignored(bool ignored) { ignored_ = ignored; } | 342 void set_ignored(bool ignored) { ignored_ = ignored; } |
338 | 343 |
339 AdapterType type() const { return type_; } | 344 AdapterType type() const { return type_; } |
340 void set_type(AdapterType type) { type_ = type; } | 345 void set_type(AdapterType type) { type_ = type; } |
341 | 346 |
| 347 // A unique id assigned by the network manager, which may be signaled |
| 348 // to the remote side in the candidate. |
| 349 uint16_t id() const { return id_; } |
| 350 void set_id(uint16_t id) { id_ = id; } |
| 351 |
342 int preference() const { return preference_; } | 352 int preference() const { return preference_; } |
343 void set_preference(int preference) { preference_ = preference; } | 353 void set_preference(int preference) { preference_ = preference; } |
344 | 354 |
345 // When we enumerate networks and find a previously-seen network is missing, | 355 // When we enumerate networks and find a previously-seen network is missing, |
346 // we do not remove it (because it may be used elsewhere). Instead, we mark | 356 // we do not remove it (because it may be used elsewhere). Instead, we mark |
347 // it inactive, so that we can detect network changes properly. | 357 // it inactive, so that we can detect network changes properly. |
348 bool active() const { return active_; } | 358 bool active() const { return active_; } |
349 void set_active(bool active) { | 359 void set_active(bool active) { |
350 if (active_ == active) { | 360 if (active_ == active) { |
351 return; | 361 return; |
(...skipping 13 matching lines...) Expand all Loading... |
365 std::string description_; | 375 std::string description_; |
366 IPAddress prefix_; | 376 IPAddress prefix_; |
367 int prefix_length_; | 377 int prefix_length_; |
368 std::string key_; | 378 std::string key_; |
369 std::vector<InterfaceAddress> ips_; | 379 std::vector<InterfaceAddress> ips_; |
370 int scope_id_; | 380 int scope_id_; |
371 bool ignored_; | 381 bool ignored_; |
372 AdapterType type_; | 382 AdapterType type_; |
373 int preference_; | 383 int preference_; |
374 bool active_ = true; | 384 bool active_ = true; |
| 385 uint16_t id_ = 0; |
375 | 386 |
376 friend class NetworkManager; | 387 friend class NetworkManager; |
377 }; | 388 }; |
378 | 389 |
379 } // namespace rtc | 390 } // namespace rtc |
380 | 391 |
381 #endif // WEBRTC_BASE_NETWORK_H_ | 392 #endif // WEBRTC_BASE_NETWORK_H_ |
OLD | NEW |