| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 MAX_VALUE | 96 MAX_VALUE |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 const uint32_t kDefaultPortAllocatorFlags = 0; | 99 const uint32_t kDefaultPortAllocatorFlags = 0; |
| 100 | 100 |
| 101 const uint32_t kDefaultStepDelay = 1000; // 1 sec step delay. | 101 const uint32_t kDefaultStepDelay = 1000; // 1 sec step delay. |
| 102 // As per RFC 5245 Appendix B.1, STUN transactions need to be paced at certain | 102 // As per RFC 5245 Appendix B.1, STUN transactions need to be paced at certain |
| 103 // internal. Less than 20ms is not acceptable. We choose 50ms as our default. | 103 // internal. Less than 20ms is not acceptable. We choose 50ms as our default. |
| 104 const uint32_t kMinimumStepDelay = 50; | 104 const uint32_t kMinimumStepDelay = 50; |
| 105 | 105 |
| 106 // Turning on IPv6 could make many IPv6 interfaces available for connectivity | |
| 107 // check and delay the call setup time. kDefaultMaxIPv6Networks is the default | |
| 108 // upper limit of IPv6 networks but could be changed by | |
| 109 // set_max_ipv6_networks(). | |
| 110 constexpr int kDefaultMaxIPv6Networks = 5; | |
| 111 | |
| 112 // CF = CANDIDATE FILTER | 106 // CF = CANDIDATE FILTER |
| 113 enum { | 107 enum { |
| 114 CF_NONE = 0x0, | 108 CF_NONE = 0x0, |
| 115 CF_HOST = 0x1, | 109 CF_HOST = 0x1, |
| 116 CF_REFLEXIVE = 0x2, | 110 CF_REFLEXIVE = 0x2, |
| 117 CF_RELAY = 0x4, | 111 CF_RELAY = 0x4, |
| 118 CF_ALL = 0x7, | 112 CF_ALL = 0x7, |
| 119 }; | 113 }; |
| 120 | 114 |
| 121 // TLS certificate policy. | 115 // TLS certificate policy. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 }; | 317 }; |
| 324 | 318 |
| 325 // Every method of PortAllocator (including the destructor) must be called on | 319 // Every method of PortAllocator (including the destructor) must be called on |
| 326 // the same thread, except for the constructor which may be called on any | 320 // the same thread, except for the constructor which may be called on any |
| 327 // thread. | 321 // thread. |
| 328 // | 322 // |
| 329 // This allows constructing a PortAllocator subclass on one thread and | 323 // This allows constructing a PortAllocator subclass on one thread and |
| 330 // passing it into an object that uses it on a different thread. | 324 // passing it into an object that uses it on a different thread. |
| 331 class PortAllocator : public sigslot::has_slots<> { | 325 class PortAllocator : public sigslot::has_slots<> { |
| 332 public: | 326 public: |
| 333 PortAllocator() | 327 PortAllocator() : |
| 334 : flags_(kDefaultPortAllocatorFlags), | 328 flags_(kDefaultPortAllocatorFlags), |
| 335 min_port_(0), | 329 min_port_(0), |
| 336 max_port_(0), | 330 max_port_(0), |
| 337 max_ipv6_networks_(kDefaultMaxIPv6Networks), | 331 step_delay_(kDefaultStepDelay), |
| 338 step_delay_(kDefaultStepDelay), | 332 allow_tcp_listen_(true), |
| 339 allow_tcp_listen_(true), | 333 candidate_filter_(CF_ALL) { |
| 340 candidate_filter_(CF_ALL) {} | 334 } |
| 341 | 335 |
| 342 virtual ~PortAllocator() {} | 336 virtual ~PortAllocator() {} |
| 343 | 337 |
| 344 // This should be called on the PortAllocator's thread before the | 338 // This should be called on the PortAllocator's thread before the |
| 345 // PortAllocator is used. Subclasses may override this if necessary. | 339 // PortAllocator is used. Subclasses may override this if necessary. |
| 346 virtual void Initialize() {} | 340 virtual void Initialize() {} |
| 347 | 341 |
| 348 // Set STUN and TURN servers to be used in future sessions, and set | 342 // Set STUN and TURN servers to be used in future sessions, and set |
| 349 // candidate pool size, as described in JSEP. | 343 // candidate pool size, as described in JSEP. |
| 350 // | 344 // |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 bool SetPortRange(int min_port, int max_port) { | 422 bool SetPortRange(int min_port, int max_port) { |
| 429 if (min_port > max_port) { | 423 if (min_port > max_port) { |
| 430 return false; | 424 return false; |
| 431 } | 425 } |
| 432 | 426 |
| 433 min_port_ = min_port; | 427 min_port_ = min_port; |
| 434 max_port_ = max_port; | 428 max_port_ = max_port; |
| 435 return true; | 429 return true; |
| 436 } | 430 } |
| 437 | 431 |
| 438 // Can be used to change the default numer of IPv6 network interfaces used | |
| 439 // (5). Can set to INT_MAX to effectively disable the limit. | |
| 440 // | |
| 441 // TODO(deadbeef): Applications shouldn't have to arbitrarily limit the | |
| 442 // number of available IPv6 network interfaces just because they could slow | |
| 443 // ICE down. We should work on making our ICE logic smarter (for example, | |
| 444 // prioritizing pinging connections that are most likely to work) so that | |
| 445 // every network interface can be used without impacting ICE's speed. | |
| 446 void set_max_ipv6_networks(int networks) { max_ipv6_networks_ = networks; } | |
| 447 int max_ipv6_networks() { return max_ipv6_networks_; } | |
| 448 | |
| 449 uint32_t step_delay() const { return step_delay_; } | 432 uint32_t step_delay() const { return step_delay_; } |
| 450 void set_step_delay(uint32_t delay) { step_delay_ = delay; } | 433 void set_step_delay(uint32_t delay) { step_delay_ = delay; } |
| 451 | 434 |
| 452 bool allow_tcp_listen() const { return allow_tcp_listen_; } | 435 bool allow_tcp_listen() const { return allow_tcp_listen_; } |
| 453 void set_allow_tcp_listen(bool allow_tcp_listen) { | 436 void set_allow_tcp_listen(bool allow_tcp_listen) { |
| 454 allow_tcp_listen_ = allow_tcp_listen; | 437 allow_tcp_listen_ = allow_tcp_listen; |
| 455 } | 438 } |
| 456 | 439 |
| 457 uint32_t candidate_filter() { return candidate_filter_; } | 440 uint32_t candidate_filter() { return candidate_filter_; } |
| 458 void set_candidate_filter(uint32_t filter) { | 441 void set_candidate_filter(uint32_t filter) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 482 | 465 |
| 483 const std::deque<std::unique_ptr<PortAllocatorSession>>& pooled_sessions() { | 466 const std::deque<std::unique_ptr<PortAllocatorSession>>& pooled_sessions() { |
| 484 return pooled_sessions_; | 467 return pooled_sessions_; |
| 485 } | 468 } |
| 486 | 469 |
| 487 uint32_t flags_; | 470 uint32_t flags_; |
| 488 std::string agent_; | 471 std::string agent_; |
| 489 rtc::ProxyInfo proxy_; | 472 rtc::ProxyInfo proxy_; |
| 490 int min_port_; | 473 int min_port_; |
| 491 int max_port_; | 474 int max_port_; |
| 492 int max_ipv6_networks_; | |
| 493 uint32_t step_delay_; | 475 uint32_t step_delay_; |
| 494 bool allow_tcp_listen_; | 476 bool allow_tcp_listen_; |
| 495 uint32_t candidate_filter_; | 477 uint32_t candidate_filter_; |
| 496 std::string origin_; | 478 std::string origin_; |
| 497 | 479 |
| 498 private: | 480 private: |
| 499 ServerAddresses stun_servers_; | 481 ServerAddresses stun_servers_; |
| 500 std::vector<RelayServerConfig> turn_servers_; | 482 std::vector<RelayServerConfig> turn_servers_; |
| 501 int candidate_pool_size_ = 0; // Last value passed into SetConfiguration. | 483 int candidate_pool_size_ = 0; // Last value passed into SetConfiguration. |
| 502 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; | 484 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; |
| 503 bool candidate_pool_frozen_ = false; | 485 bool candidate_pool_frozen_ = false; |
| 504 bool prune_turn_ports_ = false; | 486 bool prune_turn_ports_ = false; |
| 505 | 487 |
| 506 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; | 488 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; |
| 507 }; | 489 }; |
| 508 | 490 |
| 509 } // namespace cricket | 491 } // namespace cricket |
| 510 | 492 |
| 511 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 493 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
| OLD | NEW |