OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr)); | 107 kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr)); |
108 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 108 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
109 } | 109 } |
110 | 110 |
111 void AddInterface(const SocketAddress& addr) { | 111 void AddInterface(const SocketAddress& addr) { |
112 network_manager_.AddInterface(addr); | 112 network_manager_.AddInterface(addr); |
113 } | 113 } |
114 void AddInterface(const SocketAddress& addr, const std::string& if_name) { | 114 void AddInterface(const SocketAddress& addr, const std::string& if_name) { |
115 network_manager_.AddInterface(addr, if_name); | 115 network_manager_.AddInterface(addr, if_name); |
116 } | 116 } |
| 117 // Default route is the public address that STUN server will observe when the |
| 118 // endpoint is sitting on the public internet and the local port is bound to a |
| 119 // wildcard address. This may be different from the default private address |
| 120 // which the endpoint observes. This can occur if the route to the public |
| 121 // endpoint like 8.8.8.8 (specified as the default private address) is |
| 122 // different from the route to the STUN server (the default route). |
117 void AddInterfaceAsDefaultRoute(const SocketAddress& addr) { | 123 void AddInterfaceAsDefaultRoute(const SocketAddress& addr) { |
118 AddInterface(addr); | 124 AddInterface(addr); |
119 // When a binding comes from the any address, the |addr| will be used as the | 125 // When a binding comes from the any address, the |addr| will be used as the |
120 // srflx address. | 126 // srflx address. |
121 vss_->SetDefaultRoute(addr.ipaddr()); | 127 vss_->SetDefaultRoute(addr.ipaddr()); |
122 } | 128 } |
123 void RemoveInterface(const SocketAddress& addr) { | 129 void RemoveInterface(const SocketAddress& addr) { |
124 network_manager_.RemoveInterface(addr); | 130 network_manager_.RemoveInterface(addr); |
125 } | 131 } |
126 bool SetPortRange(int min_port, int max_port) { | 132 bool SetPortRange(int min_port, int max_port) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // candidates as specified. When |expect_stun_candidate| is true, | 253 // candidates as specified. When |expect_stun_candidate| is true, |
248 // |stun_candidate_addr| carries the expected reflective address, which is | 254 // |stun_candidate_addr| carries the expected reflective address, which is |
249 // also the related address for TURN candidate if it is expected. Otherwise, | 255 // also the related address for TURN candidate if it is expected. Otherwise, |
250 // it should be ignore. | 256 // it should be ignore. |
251 void CheckDisableAdapterEnumeration( | 257 void CheckDisableAdapterEnumeration( |
252 uint32_t total_ports, | 258 uint32_t total_ports, |
253 const rtc::IPAddress& host_candidate_addr, | 259 const rtc::IPAddress& host_candidate_addr, |
254 const rtc::IPAddress& stun_candidate_addr, | 260 const rtc::IPAddress& stun_candidate_addr, |
255 const rtc::IPAddress& relay_candidate_udp_transport_addr, | 261 const rtc::IPAddress& relay_candidate_udp_transport_addr, |
256 const rtc::IPAddress& relay_candidate_tcp_transport_addr) { | 262 const rtc::IPAddress& relay_candidate_tcp_transport_addr) { |
| 263 network_manager_.set_default_private_address(kPrivateAddr.ipaddr()); |
257 if (!session_) { | 264 if (!session_) { |
258 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 265 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
259 } | 266 } |
260 session_->set_flags(session_->flags() | | 267 session_->set_flags(session_->flags() | |
261 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | | 268 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | |
262 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 269 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
263 allocator().set_allow_tcp_listen(false); | 270 allocator().set_allow_tcp_listen(false); |
264 session_->StartGettingPorts(); | 271 session_->StartGettingPorts(); |
265 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 272 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
266 | 273 |
267 uint32_t total_candidates = 0; | 274 uint32_t total_candidates = 0; |
268 if (!host_candidate_addr.IsNil()) { | 275 if (!host_candidate_addr.IsNil()) { |
269 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], | 276 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], |
270 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", | 277 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", |
271 rtc::SocketAddress(host_candidate_addr, 0)); | 278 rtc::SocketAddress(kPrivateAddr.ipaddr(), 0)); |
272 ++total_candidates; | 279 ++total_candidates; |
273 } | 280 } |
274 if (!stun_candidate_addr.IsNil()) { | 281 if (!stun_candidate_addr.IsNil()) { |
275 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], | 282 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], |
276 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", | 283 cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", |
277 rtc::SocketAddress(stun_candidate_addr, 0)); | 284 rtc::SocketAddress(stun_candidate_addr, 0)); |
278 EXPECT_EQ(rtc::EmptySocketAddressWithFamily( | 285 rtc::IPAddress related_address = host_candidate_addr; |
279 candidates_[total_candidates].address().family()), | 286 if (host_candidate_addr.IsNil()) { |
280 candidates_[total_candidates].related_address()); | 287 related_address = rtc::GetWildcardIP( |
| 288 candidates_[total_candidates].address().family()); |
| 289 } |
| 290 EXPECT_EQ(related_address, |
| 291 candidates_[total_candidates].related_address().ipaddr()); |
281 ++total_candidates; | 292 ++total_candidates; |
282 } | 293 } |
283 if (!relay_candidate_udp_transport_addr.IsNil()) { | 294 if (!relay_candidate_udp_transport_addr.IsNil()) { |
284 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], | 295 EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], |
285 cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", | 296 cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", |
286 rtc::SocketAddress(relay_candidate_udp_transport_addr, 0)); | 297 rtc::SocketAddress(relay_candidate_udp_transport_addr, 0)); |
287 EXPECT_EQ(stun_candidate_addr, | 298 EXPECT_EQ(stun_candidate_addr, |
288 candidates_[total_candidates].related_address().ipaddr()); | 299 candidates_[total_candidates].related_address().ipaddr()); |
289 ++total_candidates; | 300 ++total_candidates; |
290 } | 301 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 rtc::Thread::Current()->ProcessMessages(100); | 593 rtc::Thread::Current()->ProcessMessages(100); |
583 // Without network adapter, we should not get any candidate. | 594 // Without network adapter, we should not get any candidate. |
584 EXPECT_EQ(0U, candidates_.size()); | 595 EXPECT_EQ(0U, candidates_.size()); |
585 EXPECT_TRUE(candidate_allocation_done_); | 596 EXPECT_TRUE(candidate_allocation_done_); |
586 } | 597 } |
587 | 598 |
588 // Test that when enumeration is disabled, we should not have any ports when | 599 // Test that when enumeration is disabled, we should not have any ports when |
589 // candidate_filter() is set to CF_RELAY and no relay is specified. | 600 // candidate_filter() is set to CF_RELAY and no relay is specified. |
590 TEST_F(PortAllocatorTest, | 601 TEST_F(PortAllocatorTest, |
591 TestDisableAdapterEnumerationWithoutNatRelayTransportOnly) { | 602 TestDisableAdapterEnumerationWithoutNatRelayTransportOnly) { |
592 AddInterfaceAsDefaultRoute(kClientAddr); | |
593 ResetWithStunServerNoNat(kStunAddr); | 603 ResetWithStunServerNoNat(kStunAddr); |
594 allocator().set_candidate_filter(cricket::CF_RELAY); | 604 allocator().set_candidate_filter(cricket::CF_RELAY); |
595 // Expect to see no ports and no candidates. | 605 // Expect to see no ports and no candidates. |
596 CheckDisableAdapterEnumeration(0U, rtc::IPAddress(), rtc::IPAddress(), | 606 CheckDisableAdapterEnumeration(0U, rtc::IPAddress(), rtc::IPAddress(), |
597 rtc::IPAddress(), rtc::IPAddress()); | 607 rtc::IPAddress(), rtc::IPAddress()); |
598 } | 608 } |
599 | 609 |
600 // Test that we should only get STUN and TURN candidates when adapter | 610 // Test that even with multiple interfaces, the result should still be a single |
601 // enumeration is disabled. | 611 // default private, one STUN and one TURN candidate since we bind to any address |
602 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNat) { | 612 // (i.e. all 0s). |
603 AddInterface(kClientAddr); | |
604 // GTURN is not configured here. | |
605 ResetWithStunServerAndNat(kStunAddr); | |
606 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | |
607 // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and both STUN and | |
608 // TURN/UDP candidates. | |
609 CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kNatUdpAddr.ipaddr(), | |
610 kTurnUdpExtAddr.ipaddr(), rtc::IPAddress()); | |
611 } | |
612 | |
613 // Test that even with multiple interfaces, the result should still be one STUN | |
614 // and one TURN candidate since we bind to any address (i.e. all 0s). | |
615 TEST_F(PortAllocatorTest, | 613 TEST_F(PortAllocatorTest, |
616 TestDisableAdapterEnumerationBehindNatMultipleInterfaces) { | 614 TestDisableAdapterEnumerationBehindNatMultipleInterfaces) { |
617 AddInterface(kPrivateAddr); | 615 AddInterface(kPrivateAddr); |
618 AddInterface(kPrivateAddr2); | 616 AddInterface(kPrivateAddr2); |
619 ResetWithStunServerAndNat(kStunAddr); | 617 ResetWithStunServerAndNat(kStunAddr); |
620 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 618 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
621 // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and both STUN and | 619 // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, and a default private, |
622 // TURN/UDP candidates. | 620 // STUN and TURN/UDP candidates. |
623 CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kNatUdpAddr.ipaddr(), | 621 CheckDisableAdapterEnumeration(3U, kPrivateAddr.ipaddr(), |
624 kTurnUdpExtAddr.ipaddr(), rtc::IPAddress()); | 622 kNatUdpAddr.ipaddr(), kTurnUdpExtAddr.ipaddr(), |
| 623 rtc::IPAddress()); |
625 } | 624 } |
626 | 625 |
627 // Test that we should get STUN, TURN/UDP and TURN/TCP candidates when a | 626 // Test that we should get a default private, STUN, TURN/UDP and TURN/TCP |
628 // TURN/TCP server is specified. | 627 // candidates when both TURN/UDP and TURN/TCP servers are specified. |
629 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNatWithTcp) { | 628 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationBehindNatWithTcp) { |
630 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); | 629 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); |
631 AddInterface(kClientAddr); | 630 AddInterface(kPrivateAddr); |
632 // GTURN is not configured here. | |
633 ResetWithStunServerAndNat(kStunAddr); | 631 ResetWithStunServerAndNat(kStunAddr); |
634 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 632 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
635 // Expect to see 4 ports - STUN, TURN/UDP, TURN/TCP and TCP port. STUN, | 633 // Expect to see 4 ports - STUN, TURN/UDP, TURN/TCP and TCP port. A default |
636 // TURN/UDP, and TURN/TCP candidates. | 634 // private, STUN, TURN/UDP, and TURN/TCP candidates. |
637 CheckDisableAdapterEnumeration(4U, rtc::IPAddress(), kNatUdpAddr.ipaddr(), | 635 CheckDisableAdapterEnumeration(4U, kPrivateAddr.ipaddr(), |
638 kTurnUdpExtAddr.ipaddr(), | 636 kNatUdpAddr.ipaddr(), kTurnUdpExtAddr.ipaddr(), |
639 kTurnUdpExtAddr.ipaddr()); | 637 kTurnUdpExtAddr.ipaddr()); |
640 } | 638 } |
641 | 639 |
642 // Test that we should only get STUN and TURN candidates when adapter | 640 // Test that when adapter enumeration is disabled, for endpoints without |
643 // enumeration is disabled. Since the endpoint is not behind NAT, the srflx | 641 // STUN/TURN specified, a default private candidate is still generated. |
644 // address should be the public client interface. | 642 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNatOrServers) { |
645 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNat) { | 643 ResetWithNoServersOrNat(); |
646 AddInterfaceAsDefaultRoute(kClientAddr); | 644 // Expect to see 2 ports: STUN and TCP ports, one default private candidate. |
647 ResetWithStunServerNoNat(kStunAddr); | 645 CheckDisableAdapterEnumeration(2U, kPrivateAddr.ipaddr(), rtc::IPAddress(), |
648 AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 646 rtc::IPAddress(), rtc::IPAddress()); |
649 // Expect to see 3 ports: STUN, TURN/UDP and TCP ports, but only both STUN and | |
650 // TURN candidates. The STUN candidate should have kClientAddr as srflx | |
651 // address, and TURN candidate with kClientAddr as the related address. | |
652 CheckDisableAdapterEnumeration(3U, rtc::IPAddress(), kClientAddr.ipaddr(), | |
653 kTurnUdpExtAddr.ipaddr(), rtc::IPAddress()); | |
654 } | 647 } |
655 | 648 |
656 // Test that when adapter enumeration is disabled, for endpoints without | 649 // Test that when adapter enumeration is disabled, with |
657 // STUN/TURN specified, no candidate is generated. | 650 // PORTALLOCATOR_DISABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind |
658 TEST_F(PortAllocatorTest, TestDisableAdapterEnumerationWithoutNatOrServers) { | 651 // a NAT, there is no local candidate. |
659 AddInterfaceAsDefaultRoute(kClientAddr); | 652 TEST_F(PortAllocatorTest, |
660 ResetWithNoServersOrNat(); | 653 TestDisableAdapterEnumerationWithoutNatLocalhostCandidateDisabled) { |
661 // Expect to see 2 ports: STUN and TCP ports, but no candidate. | 654 ResetWithStunServerNoNat(kStunAddr); |
| 655 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 656 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_LOCAL_CANDIDATE); |
| 657 // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN |
| 658 // candidate. |
662 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), rtc::IPAddress(), | 659 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), rtc::IPAddress(), |
663 rtc::IPAddress(), rtc::IPAddress()); | 660 rtc::IPAddress(), rtc::IPAddress()); |
664 } | 661 } |
665 | 662 |
666 // Test that when adapter enumeration is disabled, with | 663 // Test that when adapter enumeration is disabled, with |
667 // PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind | 664 // PORTALLOCATOR_DISABLE_LOCALHOST_CANDIDATE specified, for endpoints not behind |
668 // a NAT, there are a localhost candidate in addition to a STUN candidate. | 665 // a NAT, there is no local candidate. However, this specified default route |
669 TEST_F(PortAllocatorTest, | 666 // (kClientAddr) which was discovered when sending STUN requests, will become |
670 TestDisableAdapterEnumerationWithoutNatLocalhostCandidateRequested) { | 667 // the srflx addresses. |
| 668 TEST_F( |
| 669 PortAllocatorTest, |
| 670 TestDisableAdapterEnumerationWithoutNatLocalhostCandidateDisabledWithDiffere
ntDefaultRoute) { |
| 671 ResetWithStunServerNoNat(kStunAddr); |
671 AddInterfaceAsDefaultRoute(kClientAddr); | 672 AddInterfaceAsDefaultRoute(kClientAddr); |
672 ResetWithStunServerNoNat(kStunAddr); | |
673 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 673 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
674 session_->set_flags(cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); | 674 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_LOCAL_CANDIDATE); |
675 // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN | 675 // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN |
676 // candidate. | 676 // candidate. |
677 CheckDisableAdapterEnumeration(2U, rtc::GetLoopbackIP(AF_INET), | 677 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), kClientAddr.ipaddr(), |
678 kClientAddr.ipaddr(), rtc::IPAddress(), | 678 rtc::IPAddress(), rtc::IPAddress()); |
679 rtc::IPAddress()); | 679 } |
| 680 |
| 681 // Test that when adapter enumeration is disabled, with |
| 682 // PORTALLOCATOR_DISABLE_LOCALHOST_CANDIDATE specified, for endpoints behind a |
| 683 // NAT, there is only one STUN candidate. |
| 684 TEST_F(PortAllocatorTest, |
| 685 TestDisableAdapterEnumerationWithNatLocalhostCandidateDisabled) { |
| 686 ResetWithStunServerAndNat(kStunAddr); |
| 687 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 688 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_LOCAL_CANDIDATE); |
| 689 // Expect to see 2 ports: STUN and TCP ports, and single STUN candidate. |
| 690 CheckDisableAdapterEnumeration(2U, rtc::IPAddress(), kNatUdpAddr.ipaddr(), |
| 691 rtc::IPAddress(), rtc::IPAddress()); |
680 } | 692 } |
681 | 693 |
682 // Test that we disable relay over UDP, and only TCP is used when connecting to | 694 // Test that we disable relay over UDP, and only TCP is used when connecting to |
683 // the relay server. | 695 // the relay server. |
684 TEST_F(PortAllocatorTest, TestDisableUdpTurn) { | 696 TEST_F(PortAllocatorTest, TestDisableUdpTurn) { |
685 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); | 697 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); |
686 AddInterface(kClientAddr); | 698 AddInterface(kClientAddr); |
687 ResetWithStunServerAndNat(kStunAddr); | 699 ResetWithStunServerAndNat(kStunAddr); |
688 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 700 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |
689 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 701 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); | 1249 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |
1238 // STUN timeout is 9sec. We need to wait to get candidate done signal. | 1250 // STUN timeout is 9sec. We need to wait to get candidate done signal. |
1239 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000); | 1251 EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000); |
1240 EXPECT_EQ(1U, candidates_.size()); | 1252 EXPECT_EQ(1U, candidates_.size()); |
1241 } | 1253 } |
1242 | 1254 |
1243 // Test that when the NetworkManager doesn't have permission to enumerate | 1255 // Test that when the NetworkManager doesn't have permission to enumerate |
1244 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified | 1256 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified |
1245 // automatically. | 1257 // automatically. |
1246 TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) { | 1258 TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) { |
1247 AddInterface(kClientAddr); | 1259 network_manager_.set_default_private_address(kPrivateAddr.ipaddr()); |
1248 network_manager_.set_enumeration_permission( | 1260 network_manager_.set_enumeration_permission( |
1249 rtc::NetworkManager::ENUMERATION_BLOCKED); | 1261 rtc::NetworkManager::ENUMERATION_BLOCKED); |
1250 allocator().set_flags(allocator().flags() | | 1262 allocator().set_flags(allocator().flags() | |
1251 cricket::PORTALLOCATOR_DISABLE_RELAY | | 1263 cricket::PORTALLOCATOR_DISABLE_RELAY | |
1252 cricket::PORTALLOCATOR_DISABLE_TCP | | 1264 cricket::PORTALLOCATOR_DISABLE_TCP | |
1253 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1265 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
1254 EXPECT_EQ(0U, allocator_->flags() & | 1266 EXPECT_EQ(0U, allocator_->flags() & |
1255 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 1267 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
1256 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 1268 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
1257 EXPECT_EQ(0U, session_->flags() & | 1269 EXPECT_EQ(0U, session_->flags() & |
1258 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); | 1270 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); |
1259 session_->StartGettingPorts(); | 1271 session_->StartGettingPorts(); |
1260 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); | 1272 EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); |
1261 EXPECT_EQ(0U, candidates_.size()); | 1273 EXPECT_EQ(1U, candidates_.size()); |
| 1274 EXPECT_PRED5(CheckCandidate, candidates_[0], |
| 1275 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", |
| 1276 kPrivateAddr); |
1262 EXPECT_TRUE((session_->flags() & | 1277 EXPECT_TRUE((session_->flags() & |
1263 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0); | 1278 cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0); |
1264 } | 1279 } |
1265 | 1280 |
1266 // This test verifies allocator can use IPv6 addresses along with IPv4. | 1281 // This test verifies allocator can use IPv6 addresses along with IPv4. |
1267 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) { | 1282 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) { |
1268 allocator().set_flags(allocator().flags() | | 1283 allocator().set_flags(allocator().flags() | |
1269 cricket::PORTALLOCATOR_DISABLE_RELAY | | 1284 cricket::PORTALLOCATOR_DISABLE_RELAY | |
1270 cricket::PORTALLOCATOR_ENABLE_IPV6 | | 1285 cricket::PORTALLOCATOR_ENABLE_IPV6 | |
1271 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 1286 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 | 1341 |
1327 // After clearing getting ports, adding a new interface will start getting | 1342 // After clearing getting ports, adding a new interface will start getting |
1328 // ports again. | 1343 // ports again. |
1329 candidates_.clear(); | 1344 candidates_.clear(); |
1330 ports_.clear(); | 1345 ports_.clear(); |
1331 candidate_allocation_done_ = false; | 1346 candidate_allocation_done_ = false; |
1332 network_manager_.AddInterface(kClientAddr2); | 1347 network_manager_.AddInterface(kClientAddr2); |
1333 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); | 1348 ASSERT_EQ_WAIT(2U, candidates_.size(), 1000); |
1334 EXPECT_EQ(2U, ports_.size()); | 1349 EXPECT_EQ(2U, ports_.size()); |
1335 } | 1350 } |
OLD | NEW |