| 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 |
| 106 // CF = CANDIDATE FILTER | 112 // CF = CANDIDATE FILTER |
| 107 enum { | 113 enum { |
| 108 CF_NONE = 0x0, | 114 CF_NONE = 0x0, |
| 109 CF_HOST = 0x1, | 115 CF_HOST = 0x1, |
| 110 CF_REFLEXIVE = 0x2, | 116 CF_REFLEXIVE = 0x2, |
| 111 CF_RELAY = 0x4, | 117 CF_RELAY = 0x4, |
| 112 CF_ALL = 0x7, | 118 CF_ALL = 0x7, |
| 113 }; | 119 }; |
| 114 | 120 |
| 115 // TLS certificate policy. | 121 // TLS certificate policy. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 }; | 323 }; |
| 318 | 324 |
| 319 // Every method of PortAllocator (including the destructor) must be called on | 325 // Every method of PortAllocator (including the destructor) must be called on |
| 320 // the same thread, except for the constructor which may be called on any | 326 // the same thread, except for the constructor which may be called on any |
| 321 // thread. | 327 // thread. |
| 322 // | 328 // |
| 323 // This allows constructing a PortAllocator subclass on one thread and | 329 // This allows constructing a PortAllocator subclass on one thread and |
| 324 // passing it into an object that uses it on a different thread. | 330 // passing it into an object that uses it on a different thread. |
| 325 class PortAllocator : public sigslot::has_slots<> { | 331 class PortAllocator : public sigslot::has_slots<> { |
| 326 public: | 332 public: |
| 327 PortAllocator() : | 333 PortAllocator() |
| 328 flags_(kDefaultPortAllocatorFlags), | 334 : flags_(kDefaultPortAllocatorFlags), |
| 329 min_port_(0), | 335 min_port_(0), |
| 330 max_port_(0), | 336 max_port_(0), |
| 331 step_delay_(kDefaultStepDelay), | 337 max_ipv6_networks_(kDefaultMaxIPv6Networks), |
| 332 allow_tcp_listen_(true), | 338 step_delay_(kDefaultStepDelay), |
| 333 candidate_filter_(CF_ALL) { | 339 allow_tcp_listen_(true), |
| 334 } | 340 candidate_filter_(CF_ALL) {} |
| 335 | 341 |
| 336 virtual ~PortAllocator() {} | 342 virtual ~PortAllocator() {} |
| 337 | 343 |
| 338 // This should be called on the PortAllocator's thread before the | 344 // This should be called on the PortAllocator's thread before the |
| 339 // PortAllocator is used. Subclasses may override this if necessary. | 345 // PortAllocator is used. Subclasses may override this if necessary. |
| 340 virtual void Initialize() {} | 346 virtual void Initialize() {} |
| 341 | 347 |
| 342 // Set STUN and TURN servers to be used in future sessions, and set | 348 // Set STUN and TURN servers to be used in future sessions, and set |
| 343 // candidate pool size, as described in JSEP. | 349 // candidate pool size, as described in JSEP. |
| 344 // | 350 // |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 bool SetPortRange(int min_port, int max_port) { | 428 bool SetPortRange(int min_port, int max_port) { |
| 423 if (min_port > max_port) { | 429 if (min_port > max_port) { |
| 424 return false; | 430 return false; |
| 425 } | 431 } |
| 426 | 432 |
| 427 min_port_ = min_port; | 433 min_port_ = min_port; |
| 428 max_port_ = max_port; | 434 max_port_ = max_port; |
| 429 return true; | 435 return true; |
| 430 } | 436 } |
| 431 | 437 |
| 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 |
| 432 uint32_t step_delay() const { return step_delay_; } | 449 uint32_t step_delay() const { return step_delay_; } |
| 433 void set_step_delay(uint32_t delay) { step_delay_ = delay; } | 450 void set_step_delay(uint32_t delay) { step_delay_ = delay; } |
| 434 | 451 |
| 435 bool allow_tcp_listen() const { return allow_tcp_listen_; } | 452 bool allow_tcp_listen() const { return allow_tcp_listen_; } |
| 436 void set_allow_tcp_listen(bool allow_tcp_listen) { | 453 void set_allow_tcp_listen(bool allow_tcp_listen) { |
| 437 allow_tcp_listen_ = allow_tcp_listen; | 454 allow_tcp_listen_ = allow_tcp_listen; |
| 438 } | 455 } |
| 439 | 456 |
| 440 uint32_t candidate_filter() { return candidate_filter_; } | 457 uint32_t candidate_filter() { return candidate_filter_; } |
| 441 void set_candidate_filter(uint32_t filter) { | 458 void set_candidate_filter(uint32_t filter) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 465 | 482 |
| 466 const std::deque<std::unique_ptr<PortAllocatorSession>>& pooled_sessions() { | 483 const std::deque<std::unique_ptr<PortAllocatorSession>>& pooled_sessions() { |
| 467 return pooled_sessions_; | 484 return pooled_sessions_; |
| 468 } | 485 } |
| 469 | 486 |
| 470 uint32_t flags_; | 487 uint32_t flags_; |
| 471 std::string agent_; | 488 std::string agent_; |
| 472 rtc::ProxyInfo proxy_; | 489 rtc::ProxyInfo proxy_; |
| 473 int min_port_; | 490 int min_port_; |
| 474 int max_port_; | 491 int max_port_; |
| 492 int max_ipv6_networks_; |
| 475 uint32_t step_delay_; | 493 uint32_t step_delay_; |
| 476 bool allow_tcp_listen_; | 494 bool allow_tcp_listen_; |
| 477 uint32_t candidate_filter_; | 495 uint32_t candidate_filter_; |
| 478 std::string origin_; | 496 std::string origin_; |
| 479 | 497 |
| 480 private: | 498 private: |
| 481 ServerAddresses stun_servers_; | 499 ServerAddresses stun_servers_; |
| 482 std::vector<RelayServerConfig> turn_servers_; | 500 std::vector<RelayServerConfig> turn_servers_; |
| 483 int candidate_pool_size_ = 0; // Last value passed into SetConfiguration. | 501 int candidate_pool_size_ = 0; // Last value passed into SetConfiguration. |
| 484 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; | 502 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; |
| 485 bool candidate_pool_frozen_ = false; | 503 bool candidate_pool_frozen_ = false; |
| 486 bool prune_turn_ports_ = false; | 504 bool prune_turn_ports_ = false; |
| 487 | 505 |
| 488 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; | 506 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; |
| 489 }; | 507 }; |
| 490 | 508 |
| 491 } // namespace cricket | 509 } // namespace cricket |
| 492 | 510 |
| 493 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 511 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
| OLD | NEW |