| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   241   // |stun_candidate_addr| carries the expected reflective address, which is |   241   // |stun_candidate_addr| carries the expected reflective address, which is | 
|   242   // also the related address for TURN candidate if it is expected. Otherwise, |   242   // also the related address for TURN candidate if it is expected. Otherwise, | 
|   243   // it should be ignore. |   243   // it should be ignore. | 
|   244   void CheckDisableAdapterEnumeration( |   244   void CheckDisableAdapterEnumeration( | 
|   245       uint32 total_ports, |   245       uint32 total_ports, | 
|   246       const rtc::IPAddress& stun_candidate_addr, |   246       const rtc::IPAddress& stun_candidate_addr, | 
|   247       const rtc::IPAddress& relay_candidate_udp_transport_addr, |   247       const rtc::IPAddress& relay_candidate_udp_transport_addr, | 
|   248       const rtc::IPAddress& relay_candidate_tcp_transport_addr) { |   248       const rtc::IPAddress& relay_candidate_tcp_transport_addr) { | 
|   249     EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   249     EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   250     session_->set_flags(cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | |   250     session_->set_flags(cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION | | 
|   251                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|   252                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |   251                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|   253     allocator().set_allow_tcp_listen(false); |   252     allocator().set_allow_tcp_listen(false); | 
|   254     session_->StartGettingPorts(); |   253     session_->StartGettingPorts(); | 
|   255     EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |   254     EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 
|   256  |   255  | 
|   257     uint32 total_candidates = 0; |   256     uint32 total_candidates = 0; | 
|   258     if (!stun_candidate_addr.IsNil()) { |   257     if (!stun_candidate_addr.IsNil()) { | 
|   259       ++total_candidates; |   258       ++total_candidates; | 
|   260       EXPECT_PRED5(CheckCandidate, candidates_[0], |   259       EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|   261                    cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", |   260                    cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", | 
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   729   for (size_t i = 0; i < candidates_.size(); ++i) { |   728   for (size_t i = 0; i < candidates_.size(); ++i) { | 
|   730     EXPECT_EQ(std::string(cricket::RELAY_PORT_TYPE), candidates_[i].type()); |   729     EXPECT_EQ(std::string(cricket::RELAY_PORT_TYPE), candidates_[i].type()); | 
|   731     EXPECT_EQ( |   730     EXPECT_EQ( | 
|   732         candidates_[0].related_address(), |   731         candidates_[0].related_address(), | 
|   733         rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); |   732         rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); | 
|   734   } |   733   } | 
|   735 } |   734 } | 
|   736  |   735  | 
|   737 TEST_F(PortAllocatorTest, TestCandidateFilterWithHostOnly) { |   736 TEST_F(PortAllocatorTest, TestCandidateFilterWithHostOnly) { | 
|   738   AddInterface(kClientAddr); |   737   AddInterface(kClientAddr); | 
|   739   allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |   738   allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|   740                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |  | 
|   741   allocator().set_candidate_filter(cricket::CF_HOST); |   739   allocator().set_candidate_filter(cricket::CF_HOST); | 
|   742   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   740   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   743   session_->StartGettingPorts(); |   741   session_->StartGettingPorts(); | 
|   744   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |   742   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 
|   745   EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only. |   743   EXPECT_EQ(2U, candidates_.size()); // Host UDP/TCP candidates only. | 
|   746   EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only. |   744   EXPECT_EQ(2U, ports_.size()); // UDP/TCP ports only. | 
|   747   for (size_t i = 0; i < candidates_.size(); ++i) { |   745   for (size_t i = 0; i < candidates_.size(); ++i) { | 
|   748     EXPECT_EQ(std::string(cricket::LOCAL_PORT_TYPE), candidates_[i].type()); |   746     EXPECT_EQ(std::string(cricket::LOCAL_PORT_TYPE), candidates_[i].type()); | 
|   749   } |   747   } | 
|   750 } |   748 } | 
|   751  |   749  | 
|   752 // Host is behind the NAT. |   750 // Host is behind the NAT. | 
|   753 TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { |   751 TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { | 
|   754   AddInterface(kPrivateAddr); |   752   AddInterface(kPrivateAddr); | 
|   755   ResetWithStunServerAndNat(kStunAddr); |   753   ResetWithStunServerAndNat(kStunAddr); | 
|   756  |   754  | 
|   757   allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |   755   allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|   758                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |  | 
|   759   allocator().set_candidate_filter(cricket::CF_REFLEXIVE); |   756   allocator().set_candidate_filter(cricket::CF_REFLEXIVE); | 
|   760   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   757   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   761   session_->StartGettingPorts(); |   758   session_->StartGettingPorts(); | 
|   762   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |   759   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 
|   763   // Host is behind NAT, no private address will be exposed. Hence only UDP |   760   // Host is behind NAT, no private address will be exposed. Hence only UDP | 
|   764   // port with STUN candidate will be sent outside. |   761   // port with STUN candidate will be sent outside. | 
|   765   EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate. |   762   EXPECT_EQ(1U, candidates_.size()); // Only STUN candidate. | 
|   766   EXPECT_EQ(1U, ports_.size());  // Only UDP port will be in ready state. |   763   EXPECT_EQ(1U, ports_.size());  // Only UDP port will be in ready state. | 
|   767   for (size_t i = 0; i < candidates_.size(); ++i) { |   764   for (size_t i = 0; i < candidates_.size(); ++i) { | 
|   768     EXPECT_EQ(std::string(cricket::STUN_PORT_TYPE), candidates_[i].type()); |   765     EXPECT_EQ(std::string(cricket::STUN_PORT_TYPE), candidates_[i].type()); | 
|   769     EXPECT_EQ( |   766     EXPECT_EQ( | 
|   770         candidates_[0].related_address(), |   767         candidates_[0].related_address(), | 
|   771         rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); |   768         rtc::EmptySocketAddressWithFamily(candidates_[0].address().family())); | 
|   772   } |   769   } | 
|   773 } |   770 } | 
|   774  |   771  | 
|   775 // Host is not behind the NAT. |   772 // Host is not behind the NAT. | 
|   776 TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { |   773 TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { | 
|   777   AddInterface(kClientAddr); |   774   AddInterface(kClientAddr); | 
|   778   allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |   775   allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|   779                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |  | 
|   780   allocator().set_candidate_filter(cricket::CF_REFLEXIVE); |   776   allocator().set_candidate_filter(cricket::CF_REFLEXIVE); | 
|   781   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   777   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   782   session_->StartGettingPorts(); |   778   session_->StartGettingPorts(); | 
|   783   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |   779   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 
|   784   // Host has a public address, both UDP and TCP candidates will be exposed. |   780   // Host has a public address, both UDP and TCP candidates will be exposed. | 
|   785   EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate. |   781   EXPECT_EQ(2U, candidates_.size()); // Local UDP + TCP candidate. | 
|   786   EXPECT_EQ(2U, ports_.size());  //  UDP and TCP ports will be in ready state. |   782   EXPECT_EQ(2U, ports_.size());  //  UDP and TCP ports will be in ready state. | 
|   787   for (size_t i = 0; i < candidates_.size(); ++i) { |   783   for (size_t i = 0; i < candidates_.size(); ++i) { | 
|   788     EXPECT_EQ(std::string(cricket::LOCAL_PORT_TYPE), candidates_[i].type()); |   784     EXPECT_EQ(std::string(cricket::LOCAL_PORT_TYPE), candidates_[i].type()); | 
|   789   } |   785   } | 
|   790 } |   786 } | 
|   791  |   787  | 
|   792 // Test that when the PORTALLOCATOR_ENABLE_SHARED_UFRAG is enabled we got same |   788 // Test that we get the same ufrag and pwd for all candidates. | 
|   793 // ufrag and pwd for the collected candidates. |  | 
|   794 TEST_F(PortAllocatorTest, TestEnableSharedUfrag) { |   789 TEST_F(PortAllocatorTest, TestEnableSharedUfrag) { | 
|   795   allocator().set_flags(allocator().flags() | |  | 
|   796                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |  | 
|   797   AddInterface(kClientAddr); |   790   AddInterface(kClientAddr); | 
|   798   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   791   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   799   session_->StartGettingPorts(); |   792   session_->StartGettingPorts(); | 
|   800   ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); |   793   ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); | 
|   801   EXPECT_PRED5(CheckCandidate, candidates_[0], |   794   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|   802       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |   795       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); | 
|   803   EXPECT_PRED5(CheckCandidate, candidates_[1], |   796   EXPECT_PRED5(CheckCandidate, candidates_[1], | 
|   804       cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", kClientAddr); |   797       cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", kClientAddr); | 
|   805   EXPECT_PRED5(CheckCandidate, candidates_[5], |   798   EXPECT_PRED5(CheckCandidate, candidates_[5], | 
|   806       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp", kClientAddr); |   799       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp", kClientAddr); | 
|   807   EXPECT_EQ(4U, ports_.size()); |   800   EXPECT_EQ(4U, ports_.size()); | 
|   808   EXPECT_EQ(kIceUfrag0, candidates_[0].username()); |   801   EXPECT_EQ(kIceUfrag0, candidates_[0].username()); | 
|   809   EXPECT_EQ(kIceUfrag0, candidates_[1].username()); |   802   EXPECT_EQ(kIceUfrag0, candidates_[1].username()); | 
|   810   EXPECT_EQ(kIceUfrag0, candidates_[2].username()); |   803   EXPECT_EQ(kIceUfrag0, candidates_[2].username()); | 
|   811   EXPECT_EQ(kIcePwd0, candidates_[0].password()); |   804   EXPECT_EQ(kIcePwd0, candidates_[0].password()); | 
|   812   EXPECT_EQ(kIcePwd0, candidates_[1].password()); |   805   EXPECT_EQ(kIcePwd0, candidates_[1].password()); | 
|   813   EXPECT_TRUE(candidate_allocation_done_); |   806   EXPECT_TRUE(candidate_allocation_done_); | 
|   814 } |   807 } | 
|   815  |   808  | 
|   816 // Test that when the PORTALLOCATOR_ENABLE_SHARED_UFRAG isn't enabled we got |  | 
|   817 // different ufrag and pwd for the collected candidates. |  | 
|   818 TEST_F(PortAllocatorTest, TestDisableSharedUfrag) { |  | 
|   819   allocator().set_flags(allocator().flags() & |  | 
|   820                         ~cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |  | 
|   821   AddInterface(kClientAddr); |  | 
|   822   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |  | 
|   823   session_->StartGettingPorts(); |  | 
|   824   ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); |  | 
|   825   EXPECT_PRED5(CheckCandidate, candidates_[0], |  | 
|   826       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |  | 
|   827   EXPECT_PRED5(CheckCandidate, candidates_[1], |  | 
|   828       cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", kClientAddr); |  | 
|   829   EXPECT_EQ(4U, ports_.size()); |  | 
|   830   // Port should generate random ufrag and pwd. |  | 
|   831   EXPECT_NE(kIceUfrag0, candidates_[0].username()); |  | 
|   832   EXPECT_NE(kIceUfrag0, candidates_[1].username()); |  | 
|   833   EXPECT_NE(candidates_[0].username(), candidates_[1].username()); |  | 
|   834   EXPECT_NE(kIcePwd0, candidates_[0].password()); |  | 
|   835   EXPECT_NE(kIcePwd0, candidates_[1].password()); |  | 
|   836   EXPECT_NE(candidates_[0].password(), candidates_[1].password()); |  | 
|   837   EXPECT_TRUE(candidate_allocation_done_); |  | 
|   838 } |  | 
|   839  |  | 
|   840 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |   809 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port | 
|   841 // is allocated for udp and stun. Also verify there is only one candidate |   810 // is allocated for udp and stun. Also verify there is only one candidate | 
|   842 // (local) if stun candidate is same as local candidate, which will be the case |   811 // (local) if stun candidate is same as local candidate, which will be the case | 
|   843 // in a public network like the below test. |   812 // in a public network like the below test. | 
|   844 TEST_F(PortAllocatorTest, TestSharedSocketWithoutNat) { |   813 TEST_F(PortAllocatorTest, TestSharedSocketWithoutNat) { | 
|   845   AddInterface(kClientAddr); |   814   AddInterface(kClientAddr); | 
|   846   allocator_->set_flags(allocator().flags() | |   815   allocator_->set_flags(allocator().flags() | | 
|   847                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|   848                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |   816                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|   849   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   817   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   850   session_->StartGettingPorts(); |   818   session_->StartGettingPorts(); | 
|   851   ASSERT_EQ_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout); |   819   ASSERT_EQ_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout); | 
|   852   EXPECT_EQ(3U, ports_.size()); |   820   EXPECT_EQ(3U, ports_.size()); | 
|   853   EXPECT_PRED5(CheckCandidate, candidates_[0], |   821   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|   854       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |   822       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); | 
|   855   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |   823   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 
|   856 } |   824 } | 
|   857  |   825  | 
|   858 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |   826 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port | 
|   859 // is allocated for udp and stun. In this test we should expect both stun and |   827 // is allocated for udp and stun. In this test we should expect both stun and | 
|   860 // local candidates as client behind a nat. |   828 // local candidates as client behind a nat. | 
|   861 TEST_F(PortAllocatorTest, TestSharedSocketWithNat) { |   829 TEST_F(PortAllocatorTest, TestSharedSocketWithNat) { | 
|   862   AddInterface(kClientAddr); |   830   AddInterface(kClientAddr); | 
|   863   ResetWithStunServerAndNat(kStunAddr); |   831   ResetWithStunServerAndNat(kStunAddr); | 
|   864  |   832  | 
|   865   allocator_->set_flags(allocator().flags() | |   833   allocator_->set_flags(allocator().flags() | | 
|   866                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|   867                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |   834                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|   868   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   835   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   869   session_->StartGettingPorts(); |   836   session_->StartGettingPorts(); | 
|   870   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |   837   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 
|   871   ASSERT_EQ(2U, ports_.size()); |   838   ASSERT_EQ(2U, ports_.size()); | 
|   872   EXPECT_PRED5(CheckCandidate, candidates_[0], |   839   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|   873       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |   840       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); | 
|   874   EXPECT_PRED5(CheckCandidate, candidates_[1], |   841   EXPECT_PRED5(CheckCandidate, candidates_[1], | 
|   875       cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", |   842       cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", | 
|   876       rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); |   843       rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | 
|   877   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |   844   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 
|   878   EXPECT_EQ(3U, candidates_.size()); |   845   EXPECT_EQ(3U, candidates_.size()); | 
|   879 } |   846 } | 
|   880  |   847  | 
|   881 // Test TURN port in shared socket mode with UDP and TCP TURN server addresses. |   848 // Test TURN port in shared socket mode with UDP and TCP TURN server addresses. | 
|   882 TEST_F(PortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { |   849 TEST_F(PortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { | 
|   883   turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); |   850   turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); | 
|   884   AddInterface(kClientAddr); |   851   AddInterface(kClientAddr); | 
|   885   allocator_.reset(new cricket::BasicPortAllocator(&network_manager_)); |   852   allocator_.reset(new cricket::BasicPortAllocator(&network_manager_)); | 
|   886  |   853  | 
|   887   AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); |   854   AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); | 
|   888  |   855  | 
|   889   allocator_->set_step_delay(cricket::kMinimumStepDelay); |   856   allocator_->set_step_delay(cricket::kMinimumStepDelay); | 
|   890   allocator_->set_flags(allocator().flags() | |   857   allocator_->set_flags(allocator().flags() | | 
|   891                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|   892                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |   858                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 
|   893                         cricket::PORTALLOCATOR_DISABLE_TCP); |   859                         cricket::PORTALLOCATOR_DISABLE_TCP); | 
|   894  |   860  | 
|   895   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   861   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   896   session_->StartGettingPorts(); |   862   session_->StartGettingPorts(); | 
|   897  |   863  | 
|   898   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |   864   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 
|   899   ASSERT_EQ(3U, ports_.size()); |   865   ASSERT_EQ(3U, ports_.size()); | 
|   900   EXPECT_PRED5(CheckCandidate, candidates_[0], |   866   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|   901       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |   867       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|   919   cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); |   885   cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | 
|   920   cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); |   886   cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); | 
|   921   relay_server.credentials = credentials; |   887   relay_server.credentials = credentials; | 
|   922   relay_server.ports.push_back(cricket::ProtocolAddress( |   888   relay_server.ports.push_back(cricket::ProtocolAddress( | 
|   923       rtc::SocketAddress("localhost", 3478), |   889       rtc::SocketAddress("localhost", 3478), | 
|   924       cricket::PROTO_UDP, false)); |   890       cricket::PROTO_UDP, false)); | 
|   925   allocator_->AddRelay(relay_server); |   891   allocator_->AddRelay(relay_server); | 
|   926  |   892  | 
|   927   allocator_->set_step_delay(cricket::kMinimumStepDelay); |   893   allocator_->set_step_delay(cricket::kMinimumStepDelay); | 
|   928   allocator_->set_flags(allocator().flags() | |   894   allocator_->set_flags(allocator().flags() | | 
|   929                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|   930                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |   895                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 
|   931                         cricket::PORTALLOCATOR_DISABLE_TCP); |   896                         cricket::PORTALLOCATOR_DISABLE_TCP); | 
|   932  |   897  | 
|   933   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   898   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   934   session_->StartGettingPorts(); |   899   session_->StartGettingPorts(); | 
|   935  |   900  | 
|   936   EXPECT_EQ_WAIT(2U, ports_.size(), kDefaultAllocationTimeout); |   901   EXPECT_EQ_WAIT(2U, ports_.size(), kDefaultAllocationTimeout); | 
|   937 } |   902 } | 
|   938  |   903  | 
|   939 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |   904 // Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port | 
|   940 // is allocated for udp/stun/turn. In this test we should expect all local, |   905 // is allocated for udp/stun/turn. In this test we should expect all local, | 
|   941 // stun and turn candidates. |   906 // stun and turn candidates. | 
|   942 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) { |   907 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) { | 
|   943   AddInterface(kClientAddr); |   908   AddInterface(kClientAddr); | 
|   944   ResetWithStunServerAndNat(kStunAddr); |   909   ResetWithStunServerAndNat(kStunAddr); | 
|   945  |   910  | 
|   946   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |   911   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 
|   947  |   912  | 
|   948   allocator_->set_flags(allocator().flags() | |   913   allocator_->set_flags(allocator().flags() | | 
|   949                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|   950                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |   914                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 
|   951                         cricket::PORTALLOCATOR_DISABLE_TCP); |   915                         cricket::PORTALLOCATOR_DISABLE_TCP); | 
|   952  |   916  | 
|   953   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   917   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   954   session_->StartGettingPorts(); |   918   session_->StartGettingPorts(); | 
|   955  |   919  | 
|   956   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |   920   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 
|   957   ASSERT_EQ(2U, ports_.size()); |   921   ASSERT_EQ(2U, ports_.size()); | 
|   958   EXPECT_PRED5(CheckCandidate, candidates_[0], |   922   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|   959       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |   923       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|   978   // Use an empty SocketAddress to add a NAT without STUN server. |   942   // Use an empty SocketAddress to add a NAT without STUN server. | 
|   979   ResetWithStunServerAndNat(SocketAddress()); |   943   ResetWithStunServerAndNat(SocketAddress()); | 
|   980   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |   944   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 
|   981  |   945  | 
|   982   // Must set the step delay to 0 to make sure the relay allocation phase is |   946   // Must set the step delay to 0 to make sure the relay allocation phase is | 
|   983   // started before the STUN candidates are obtained, so that the STUN binding |   947   // started before the STUN candidates are obtained, so that the STUN binding | 
|   984   // response is processed when both StunPort and TurnPort exist to reproduce |   948   // response is processed when both StunPort and TurnPort exist to reproduce | 
|   985   // webrtc issue 3537. |   949   // webrtc issue 3537. | 
|   986   allocator_->set_step_delay(0); |   950   allocator_->set_step_delay(0); | 
|   987   allocator_->set_flags(allocator().flags() | |   951   allocator_->set_flags(allocator().flags() | | 
|   988                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|   989                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |   952                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 
|   990                         cricket::PORTALLOCATOR_DISABLE_TCP); |   953                         cricket::PORTALLOCATOR_DISABLE_TCP); | 
|   991  |   954  | 
|   992   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   955   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|   993   session_->StartGettingPorts(); |   956   session_->StartGettingPorts(); | 
|   994  |   957  | 
|   995   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |   958   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 
|   996   EXPECT_PRED5(CheckCandidate, candidates_[0], |   959   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|   997       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |   960       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); | 
|   998   EXPECT_PRED5(CheckCandidate, candidates_[1], |   961   EXPECT_PRED5(CheckCandidate, candidates_[1], | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  1013 // Test that when only a TCP TURN server is available, we do NOT use it as |   976 // Test that when only a TCP TURN server is available, we do NOT use it as | 
|  1014 // a UDP STUN server, as this could leak our IP address. Thus we should only |   977 // a UDP STUN server, as this could leak our IP address. Thus we should only | 
|  1015 // expect two ports, a UDPPort and TurnPort. |   978 // expect two ports, a UDPPort and TurnPort. | 
|  1016 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { |   979 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { | 
|  1017   turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); |   980   turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); | 
|  1018   AddInterface(kClientAddr); |   981   AddInterface(kClientAddr); | 
|  1019   ResetWithStunServerAndNat(rtc::SocketAddress()); |   982   ResetWithStunServerAndNat(rtc::SocketAddress()); | 
|  1020   AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr); |   983   AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr); | 
|  1021  |   984  | 
|  1022   allocator_->set_flags(allocator().flags() | |   985   allocator_->set_flags(allocator().flags() | | 
|  1023                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|  1024                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |   986                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 
|  1025                         cricket::PORTALLOCATOR_DISABLE_TCP); |   987                         cricket::PORTALLOCATOR_DISABLE_TCP); | 
|  1026  |   988  | 
|  1027   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |   989   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|  1028   session_->StartGettingPorts(); |   990   session_->StartGettingPorts(); | 
|  1029  |   991  | 
|  1030   ASSERT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); |   992   ASSERT_EQ_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout); | 
|  1031   ASSERT_EQ(2U, ports_.size()); |   993   ASSERT_EQ(2U, ports_.size()); | 
|  1032   EXPECT_PRED5(CheckCandidate, candidates_[0], |   994   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|  1033                cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", |   995                cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  1046 // 'relay' candidates. |  1008 // 'relay' candidates. | 
|  1047 // TODO(deadbeef): Remove this test when support for non-shared socket mode |  1009 // TODO(deadbeef): Remove this test when support for non-shared socket mode | 
|  1048 // is removed. |  1010 // is removed. | 
|  1049 TEST_F(PortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { |  1011 TEST_F(PortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { | 
|  1050   AddInterface(kClientAddr); |  1012   AddInterface(kClientAddr); | 
|  1051   // Use an empty SocketAddress to add a NAT without STUN server. |  1013   // Use an empty SocketAddress to add a NAT without STUN server. | 
|  1052   ResetWithStunServerAndNat(SocketAddress()); |  1014   ResetWithStunServerAndNat(SocketAddress()); | 
|  1053   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |  1015   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 
|  1054  |  1016  | 
|  1055   allocator_->set_flags(allocator().flags() | |  1017   allocator_->set_flags(allocator().flags() | | 
|  1056                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|  1057                         cricket::PORTALLOCATOR_DISABLE_TCP); |  1018                         cricket::PORTALLOCATOR_DISABLE_TCP); | 
|  1058  |  1019  | 
|  1059   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |  1020   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|  1060   session_->StartGettingPorts(); |  1021   session_->StartGettingPorts(); | 
|  1061  |  1022  | 
|  1062   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |  1023   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 
|  1063   ASSERT_EQ(3U, ports_.size()); |  1024   ASSERT_EQ(3U, ports_.size()); | 
|  1064   EXPECT_PRED5(CheckCandidate, candidates_[0], |  1025   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|  1065                cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", |  1026                cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", | 
|  1066                kClientAddr); |  1027                kClientAddr); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  1085 // server is used as a STUN server and we get a 'stun' candidate. |  1046 // server is used as a STUN server and we get a 'stun' candidate. | 
|  1086 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { |  1047 TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { | 
|  1087   AddInterface(kClientAddr); |  1048   AddInterface(kClientAddr); | 
|  1088   // Configure with STUN server but destroy it, so we can ensure that it's |  1049   // Configure with STUN server but destroy it, so we can ensure that it's | 
|  1089   // the TURN server actually being used as a STUN server. |  1050   // the TURN server actually being used as a STUN server. | 
|  1090   ResetWithStunServerAndNat(kStunAddr); |  1051   ResetWithStunServerAndNat(kStunAddr); | 
|  1091   stun_server_.reset(); |  1052   stun_server_.reset(); | 
|  1092   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |  1053   AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); | 
|  1093  |  1054  | 
|  1094   allocator_->set_flags(allocator().flags() | |  1055   allocator_->set_flags(allocator().flags() | | 
|  1095                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|  1096                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |  1056                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 
|  1097                         cricket::PORTALLOCATOR_DISABLE_TCP); |  1057                         cricket::PORTALLOCATOR_DISABLE_TCP); | 
|  1098  |  1058  | 
|  1099   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |  1059   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|  1100   session_->StartGettingPorts(); |  1060   session_->StartGettingPorts(); | 
|  1101  |  1061  | 
|  1102   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |  1062   ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); | 
|  1103   EXPECT_PRED5(CheckCandidate, candidates_[0], |  1063   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|  1104                cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", |  1064                cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", | 
|  1105                kClientAddr); |  1065                kClientAddr); | 
|  1106   EXPECT_PRED5(CheckCandidate, candidates_[1], |  1066   EXPECT_PRED5(CheckCandidate, candidates_[1], | 
|  1107                cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", |  1067                cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", | 
|  1108                rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); |  1068                rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); | 
|  1109   EXPECT_PRED5(CheckCandidate, candidates_[2], |  1069   EXPECT_PRED5(CheckCandidate, candidates_[2], | 
|  1110                cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", |  1070                cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", | 
|  1111                rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |  1071                rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); | 
|  1112   EXPECT_EQ(candidates_[2].related_address(), candidates_[1].address()); |  1072   EXPECT_EQ(candidates_[2].related_address(), candidates_[1].address()); | 
|  1113  |  1073  | 
|  1114   // Don't bother waiting for STUN timeout, since we already verified |  1074   // Don't bother waiting for STUN timeout, since we already verified | 
|  1115   // that we got a STUN candidate from the TURN server. |  1075   // that we got a STUN candidate from the TURN server. | 
|  1116 } |  1076 } | 
|  1117  |  1077  | 
|  1118 // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled |  1078 // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled | 
|  1119 // and fail to generate STUN candidate, local UDP candidate is generated |  1079 // and fail to generate STUN candidate, local UDP candidate is generated | 
|  1120 // properly. |  1080 // properly. | 
|  1121 TEST_F(PortAllocatorTest, TestSharedSocketNoUdpAllowed) { |  1081 TEST_F(PortAllocatorTest, TestSharedSocketNoUdpAllowed) { | 
|  1122   allocator().set_flags(allocator().flags() | |  1082   allocator().set_flags(allocator().flags() | | 
|  1123                         cricket::PORTALLOCATOR_DISABLE_RELAY | |  1083                         cricket::PORTALLOCATOR_DISABLE_RELAY | | 
|  1124                         cricket::PORTALLOCATOR_DISABLE_TCP | |  1084                         cricket::PORTALLOCATOR_DISABLE_TCP | | 
|  1125                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|  1126                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |  1085                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|  1127   fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); |  1086   fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); | 
|  1128   AddInterface(kClientAddr); |  1087   AddInterface(kClientAddr); | 
|  1129   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |  1088   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|  1130   session_->StartGettingPorts(); |  1089   session_->StartGettingPorts(); | 
|  1131   ASSERT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); |  1090   ASSERT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); | 
|  1132   EXPECT_EQ(1U, candidates_.size()); |  1091   EXPECT_EQ(1U, candidates_.size()); | 
|  1133   EXPECT_PRED5(CheckCandidate, candidates_[0], |  1092   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
|  1134       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |  1093       cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); | 
|  1135   // STUN timeout is 9sec. We need to wait to get candidate done signal. |  1094   // STUN timeout is 9sec. We need to wait to get candidate done signal. | 
|  1136   EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000); |  1095   EXPECT_TRUE_WAIT(candidate_allocation_done_, 10000); | 
|  1137   EXPECT_EQ(1U, candidates_.size()); |  1096   EXPECT_EQ(1U, candidates_.size()); | 
|  1138 } |  1097 } | 
|  1139  |  1098  | 
|  1140 // Test that when the NetworkManager doesn't have permission to enumerate |  1099 // Test that when the NetworkManager doesn't have permission to enumerate | 
|  1141 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified |  1100 // adapters, the PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION is specified | 
|  1142 // automatically. |  1101 // automatically. | 
|  1143 TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) { |  1102 TEST_F(PortAllocatorTest, TestNetworkPermissionBlocked) { | 
|  1144   AddInterface(kClientAddr); |  1103   AddInterface(kClientAddr); | 
|  1145   network_manager_.set_enumeration_permission( |  1104   network_manager_.set_enumeration_permission( | 
|  1146       rtc::NetworkManager::kEnumerationDisallowed); |  1105       rtc::NetworkManager::kEnumerationDisallowed); | 
|  1147   allocator().set_flags(allocator().flags() | |  1106   allocator().set_flags(allocator().flags() | | 
|  1148                         cricket::PORTALLOCATOR_DISABLE_RELAY | |  1107                         cricket::PORTALLOCATOR_DISABLE_RELAY | | 
|  1149                         cricket::PORTALLOCATOR_DISABLE_TCP | |  1108                         cricket::PORTALLOCATOR_DISABLE_TCP | | 
|  1150                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|  1151                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |  1109                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|  1152   EXPECT_EQ( |  1110   EXPECT_EQ( | 
|  1153       allocator_->flags() & cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION, |  1111       allocator_->flags() & cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION, | 
|  1154       0U); |  1112       0U); | 
|  1155   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |  1113   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|  1156   EXPECT_EQ( |  1114   EXPECT_EQ( | 
|  1157       session_->flags() & cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION, |  1115       session_->flags() & cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION, | 
|  1158       0U); |  1116       0U); | 
|  1159   session_->StartGettingPorts(); |  1117   session_->StartGettingPorts(); | 
|  1160   EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); |  1118   EXPECT_EQ_WAIT(1U, ports_.size(), kDefaultAllocationTimeout); | 
|  1161   EXPECT_EQ(0U, candidates_.size()); |  1119   EXPECT_EQ(0U, candidates_.size()); | 
|  1162   EXPECT_TRUE((session_->flags() & |  1120   EXPECT_TRUE((session_->flags() & | 
|  1163                cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0); |  1121                cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) != 0); | 
|  1164 } |  1122 } | 
|  1165  |  1123  | 
|  1166 // This test verifies allocator can use IPv6 addresses along with IPv4. |  1124 // This test verifies allocator can use IPv6 addresses along with IPv4. | 
|  1167 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) { |  1125 TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) { | 
|  1168   allocator().set_flags(allocator().flags() | |  1126   allocator().set_flags(allocator().flags() | | 
|  1169                         cricket::PORTALLOCATOR_DISABLE_RELAY | |  1127                         cricket::PORTALLOCATOR_DISABLE_RELAY | | 
|  1170                         cricket::PORTALLOCATOR_ENABLE_IPV6 | |  1128                         cricket::PORTALLOCATOR_ENABLE_IPV6 | | 
|  1171                         cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |  | 
|  1172                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |  1129                         cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); | 
|  1173   AddInterface(kClientIPv6Addr); |  1130   AddInterface(kClientIPv6Addr); | 
|  1174   AddInterface(kClientAddr); |  1131   AddInterface(kClientAddr); | 
|  1175   allocator_->set_step_delay(cricket::kMinimumStepDelay); |  1132   allocator_->set_step_delay(cricket::kMinimumStepDelay); | 
|  1176   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |  1133   EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 
|  1177   session_->StartGettingPorts(); |  1134   session_->StartGettingPorts(); | 
|  1178   ASSERT_EQ_WAIT(4U, ports_.size(), kDefaultAllocationTimeout); |  1135   ASSERT_EQ_WAIT(4U, ports_.size(), kDefaultAllocationTimeout); | 
|  1179   EXPECT_EQ(4U, candidates_.size()); |  1136   EXPECT_EQ(4U, candidates_.size()); | 
|  1180   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |  1137   EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); | 
|  1181   EXPECT_PRED5(CheckCandidate, candidates_[0], |  1138   EXPECT_PRED5(CheckCandidate, candidates_[0], | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1220   alloc.SetStunHosts(stun_servers); |  1177   alloc.SetStunHosts(stun_servers); | 
|  1221   EXPECT_EQ(2U, alloc.relay_hosts().size()); |  1178   EXPECT_EQ(2U, alloc.relay_hosts().size()); | 
|  1222   EXPECT_EQ(2U, alloc.stun_hosts().size()); |  1179   EXPECT_EQ(2U, alloc.stun_hosts().size()); | 
|  1223 } |  1180 } | 
|  1224  |  1181  | 
|  1225 // Test that the HttpPortAllocator uses correct URL to create sessions. |  1182 // Test that the HttpPortAllocator uses correct URL to create sessions. | 
|  1226 TEST(HttpPortAllocatorTest, TestSessionRequestUrl) { |  1183 TEST(HttpPortAllocatorTest, TestSessionRequestUrl) { | 
|  1227   rtc::FakeNetworkManager network_manager; |  1184   rtc::FakeNetworkManager network_manager; | 
|  1228   cricket::HttpPortAllocator alloc(&network_manager, "unit test agent"); |  1185   cricket::HttpPortAllocator alloc(&network_manager, "unit test agent"); | 
|  1229  |  1186  | 
|  1230   // Disable PORTALLOCATOR_ENABLE_SHARED_UFRAG. |  | 
|  1231   alloc.set_flags(alloc.flags() & ~cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |  | 
|  1232   rtc::scoped_ptr<cricket::HttpPortAllocatorSessionBase> session( |  1187   rtc::scoped_ptr<cricket::HttpPortAllocatorSessionBase> session( | 
|  1233       static_cast<cricket::HttpPortAllocatorSession*>( |  1188       static_cast<cricket::HttpPortAllocatorSession*>( | 
|  1234           alloc.CreateSessionInternal( |  1189           alloc.CreateSessionInternal( | 
|  1235               "test content", 0, kIceUfrag0, kIcePwd0))); |  1190               "test content", 0, kIceUfrag0, kIcePwd0))); | 
|  1236   std::string url = session->GetSessionRequestUrl(); |  1191   std::string url = session->GetSessionRequestUrl(); | 
|  1237   LOG(LS_INFO) << "url: " << url; |  1192   LOG(LS_INFO) << "url: " << url; | 
|  1238   EXPECT_EQ(std::string(cricket::HttpPortAllocator::kCreateSessionURL), url); |  | 
|  1239  |  | 
|  1240   // Enable PORTALLOCATOR_ENABLE_SHARED_UFRAG. |  | 
|  1241   alloc.set_flags(alloc.flags() | cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |  | 
|  1242   session.reset(static_cast<cricket::HttpPortAllocatorSession*>( |  | 
|  1243       alloc.CreateSessionInternal("test content", 0, kIceUfrag0, kIcePwd0))); |  | 
|  1244   url = session->GetSessionRequestUrl(); |  | 
|  1245   LOG(LS_INFO) << "url: " << url; |  | 
|  1246   std::vector<std::string> parts; |  1193   std::vector<std::string> parts; | 
|  1247   rtc::split(url, '?', &parts); |  1194   rtc::split(url, '?', &parts); | 
|  1248   ASSERT_EQ(2U, parts.size()); |  1195   ASSERT_EQ(2U, parts.size()); | 
|  1249  |  1196  | 
|  1250   std::vector<std::string> args_parts; |  1197   std::vector<std::string> args_parts; | 
|  1251   rtc::split(parts[1], '&', &args_parts); |  1198   rtc::split(parts[1], '&', &args_parts); | 
|  1252  |  1199  | 
|  1253   std::map<std::string, std::string> args; |  1200   std::map<std::string, std::string> args; | 
|  1254   for (std::vector<std::string>::iterator it = args_parts.begin(); |  1201   for (std::vector<std::string>::iterator it = args_parts.begin(); | 
|  1255        it != args_parts.end(); ++it) { |  1202        it != args_parts.end(); ++it) { | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1301   AllocationSequenceForTest alloc_sequence( |  1248   AllocationSequenceForTest alloc_sequence( | 
|  1302       static_cast<cricket::BasicPortAllocatorSession*>(session_.get()), |  1249       static_cast<cricket::BasicPortAllocatorSession*>(session_.get()), | 
|  1303       &network1, &config, flag); |  1250       &network1, &config, flag); | 
|  1304   // This simply tests it will not crash if udp_socket_ in the |  1251   // This simply tests it will not crash if udp_socket_ in the | 
|  1305   // AllocationSequence is null, which is chosen in the constructor. |  1252   // AllocationSequence is null, which is chosen in the constructor. | 
|  1306   cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); |  1253   cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | 
|  1307   relay_server.ports.push_back( |  1254   relay_server.ports.push_back( | 
|  1308       cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false)); |  1255       cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false)); | 
|  1309   alloc_sequence.CreateTurnPort(relay_server); |  1256   alloc_sequence.CreateTurnPort(relay_server); | 
|  1310 } |  1257 } | 
| OLD | NEW |