| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 // Based on ICE_UFRAG_LENGTH | 87 // Based on ICE_UFRAG_LENGTH |
| 88 static const char* kIceUfrag[4] = {"TESTICEUFRAG0000", "TESTICEUFRAG0001", | 88 static const char* kIceUfrag[4] = {"TESTICEUFRAG0000", "TESTICEUFRAG0001", |
| 89 "TESTICEUFRAG0002", "TESTICEUFRAG0003"}; | 89 "TESTICEUFRAG0002", "TESTICEUFRAG0003"}; |
| 90 // Based on ICE_PWD_LENGTH | 90 // Based on ICE_PWD_LENGTH |
| 91 static const char* kIcePwd[4] = {"TESTICEPWD00000000000000", | 91 static const char* kIcePwd[4] = {"TESTICEPWD00000000000000", |
| 92 "TESTICEPWD00000000000001", | 92 "TESTICEPWD00000000000001", |
| 93 "TESTICEPWD00000000000002", | 93 "TESTICEPWD00000000000002", |
| 94 "TESTICEPWD00000000000003"}; | 94 "TESTICEPWD00000000000003"}; |
| 95 | 95 |
| 96 static const uint64 kTiebreaker1 = 11111; | 96 static const uint64_t kTiebreaker1 = 11111; |
| 97 static const uint64 kTiebreaker2 = 22222; | 97 static const uint64_t kTiebreaker2 = 22222; |
| 98 | 98 |
| 99 enum { | 99 enum { |
| 100 MSG_CANDIDATE | 100 MSG_CANDIDATE |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 // This test simulates 2 P2P endpoints that want to establish connectivity | 103 // This test simulates 2 P2P endpoints that want to establish connectivity |
| 104 // with each other over various network topologies and conditions, which can be | 104 // with each other over various network topologies and conditions, which can be |
| 105 // specified in each individial test. | 105 // specified in each individial test. |
| 106 // A virtual network (via VirtualSocketServer) along with virtual firewalls and | 106 // A virtual network (via VirtualSocketServer) along with virtual firewalls and |
| 107 // NATs (via Firewall/NATSocketServer) are used to simulate the various network | 107 // NATs (via Firewall/NATSocketServer) are used to simulate the various network |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 ChannelData* GetChannelData(cricket::TransportChannel* ch) { | 224 ChannelData* GetChannelData(cricket::TransportChannel* ch) { |
| 225 if (!HasChannel(ch)) return NULL; | 225 if (!HasChannel(ch)) return NULL; |
| 226 if (cd1_.ch_.get() == ch) | 226 if (cd1_.ch_.get() == ch) |
| 227 return &cd1_; | 227 return &cd1_; |
| 228 else | 228 else |
| 229 return &cd2_; | 229 return &cd2_; |
| 230 } | 230 } |
| 231 | 231 |
| 232 void SetIceRole(cricket::IceRole role) { role_ = role; } | 232 void SetIceRole(cricket::IceRole role) { role_ = role; } |
| 233 cricket::IceRole ice_role() { return role_; } | 233 cricket::IceRole ice_role() { return role_; } |
| 234 void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } | 234 void SetIceTiebreaker(uint64_t tiebreaker) { tiebreaker_ = tiebreaker; } |
| 235 uint64 GetIceTiebreaker() { return tiebreaker_; } | 235 uint64_t GetIceTiebreaker() { return tiebreaker_; } |
| 236 void OnRoleConflict(bool role_conflict) { role_conflict_ = role_conflict; } | 236 void OnRoleConflict(bool role_conflict) { role_conflict_ = role_conflict; } |
| 237 bool role_conflict() { return role_conflict_; } | 237 bool role_conflict() { return role_conflict_; } |
| 238 void SetAllocationStepDelay(uint32 delay) { | 238 void SetAllocationStepDelay(uint32_t delay) { |
| 239 allocator_->set_step_delay(delay); | 239 allocator_->set_step_delay(delay); |
| 240 } | 240 } |
| 241 void SetAllowTcpListen(bool allow_tcp_listen) { | 241 void SetAllowTcpListen(bool allow_tcp_listen) { |
| 242 allocator_->set_allow_tcp_listen(allow_tcp_listen); | 242 allocator_->set_allow_tcp_listen(allow_tcp_listen); |
| 243 } | 243 } |
| 244 | 244 |
| 245 rtc::FakeNetworkManager network_manager_; | 245 rtc::FakeNetworkManager network_manager_; |
| 246 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; | 246 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; |
| 247 ChannelData cd1_; | 247 ChannelData cd1_; |
| 248 ChannelData cd2_; | 248 ChannelData cd2_; |
| 249 cricket::IceRole role_; | 249 cricket::IceRole role_; |
| 250 uint64 tiebreaker_; | 250 uint64_t tiebreaker_; |
| 251 bool role_conflict_; | 251 bool role_conflict_; |
| 252 bool save_candidates_; | 252 bool save_candidates_; |
| 253 std::vector<CandidateData*> saved_candidates_; | 253 std::vector<CandidateData*> saved_candidates_; |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 ChannelData* GetChannelData(cricket::TransportChannel* channel) { | 256 ChannelData* GetChannelData(cricket::TransportChannel* channel) { |
| 257 if (ep1_.HasChannel(channel)) | 257 if (ep1_.HasChannel(channel)) |
| 258 return ep1_.GetChannelData(channel); | 258 return ep1_.GetChannelData(channel); |
| 259 else | 259 else |
| 260 return ep2_.GetChannelData(channel); | 260 return ep2_.GetChannelData(channel); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 info.address = (type == rtc::PROXY_HTTPS) ? | 368 info.address = (type == rtc::PROXY_HTTPS) ? |
| 369 kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; | 369 kHttpsProxyAddrs[endpoint] : kSocksProxyAddrs[endpoint]; |
| 370 GetAllocator(endpoint)->set_proxy("unittest/1.0", info); | 370 GetAllocator(endpoint)->set_proxy("unittest/1.0", info); |
| 371 } | 371 } |
| 372 void SetAllocatorFlags(int endpoint, int flags) { | 372 void SetAllocatorFlags(int endpoint, int flags) { |
| 373 GetAllocator(endpoint)->set_flags(flags); | 373 GetAllocator(endpoint)->set_flags(flags); |
| 374 } | 374 } |
| 375 void SetIceRole(int endpoint, cricket::IceRole role) { | 375 void SetIceRole(int endpoint, cricket::IceRole role) { |
| 376 GetEndpoint(endpoint)->SetIceRole(role); | 376 GetEndpoint(endpoint)->SetIceRole(role); |
| 377 } | 377 } |
| 378 void SetIceTiebreaker(int endpoint, uint64 tiebreaker) { | 378 void SetIceTiebreaker(int endpoint, uint64_t tiebreaker) { |
| 379 GetEndpoint(endpoint)->SetIceTiebreaker(tiebreaker); | 379 GetEndpoint(endpoint)->SetIceTiebreaker(tiebreaker); |
| 380 } | 380 } |
| 381 bool GetRoleConflict(int endpoint) { | 381 bool GetRoleConflict(int endpoint) { |
| 382 return GetEndpoint(endpoint)->role_conflict(); | 382 return GetEndpoint(endpoint)->role_conflict(); |
| 383 } | 383 } |
| 384 void SetAllocationStepDelay(int endpoint, uint32 delay) { | 384 void SetAllocationStepDelay(int endpoint, uint32_t delay) { |
| 385 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); | 385 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); |
| 386 } | 386 } |
| 387 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { | 387 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { |
| 388 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); | 388 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool IsLocalToPrflxOrTheReverse(const Result& expected) { | 391 bool IsLocalToPrflxOrTheReverse(const Result& expected) { |
| 392 return ((expected.local_type == "local" && | 392 return ((expected.local_type == "local" && |
| 393 expected.remote_type == "prflx") || | 393 expected.remote_type == "prflx") || |
| 394 (expected.local_type == "prflx" && | 394 (expected.local_type == "prflx" && |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (remote_type != expected.remote_type2) { | 479 if (remote_type != expected.remote_type2) { |
| 480 EXPECT_TRUE(expected.remote_type2 == cricket::LOCAL_PORT_TYPE || | 480 EXPECT_TRUE(expected.remote_type2 == cricket::LOCAL_PORT_TYPE || |
| 481 expected.remote_type2 == cricket::STUN_PORT_TYPE); | 481 expected.remote_type2 == cricket::STUN_PORT_TYPE); |
| 482 EXPECT_TRUE(remote_type == cricket::LOCAL_PORT_TYPE || | 482 EXPECT_TRUE(remote_type == cricket::LOCAL_PORT_TYPE || |
| 483 remote_type == cricket::STUN_PORT_TYPE || | 483 remote_type == cricket::STUN_PORT_TYPE || |
| 484 remote_type == cricket::PRFLX_PORT_TYPE); | 484 remote_type == cricket::PRFLX_PORT_TYPE); |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 | 487 |
| 488 void Test(const Result& expected) { | 488 void Test(const Result& expected) { |
| 489 int32 connect_start = rtc::Time(), connect_time; | 489 int32_t connect_start = rtc::Time(), connect_time; |
| 490 | 490 |
| 491 // Create the channels and wait for them to connect. | 491 // Create the channels and wait for them to connect. |
| 492 CreateChannels(1); | 492 CreateChannels(1); |
| 493 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && | 493 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && |
| 494 ep2_ch1() != NULL && | 494 ep2_ch1() != NULL && |
| 495 ep1_ch1()->receiving() && | 495 ep1_ch1()->receiving() && |
| 496 ep1_ch1()->writable() && | 496 ep1_ch1()->writable() && |
| 497 ep2_ch1()->receiving() && | 497 ep2_ch1()->receiving() && |
| 498 ep2_ch1()->writable(), | 498 ep2_ch1()->writable(), |
| 499 expected.connect_wait, | 499 expected.connect_wait, |
| 500 1000); | 500 1000); |
| 501 connect_time = rtc::TimeSince(connect_start); | 501 connect_time = rtc::TimeSince(connect_start); |
| 502 if (connect_time < expected.connect_wait) { | 502 if (connect_time < expected.connect_wait) { |
| 503 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; | 503 LOG(LS_INFO) << "Connect time: " << connect_time << " ms"; |
| 504 } else { | 504 } else { |
| 505 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" | 505 LOG(LS_INFO) << "Connect time: " << "TIMEOUT (" |
| 506 << expected.connect_wait << " ms)"; | 506 << expected.connect_wait << " ms)"; |
| 507 } | 507 } |
| 508 | 508 |
| 509 // Allow a few turns of the crank for the best connections to emerge. | 509 // Allow a few turns of the crank for the best connections to emerge. |
| 510 // This may take up to 2 seconds. | 510 // This may take up to 2 seconds. |
| 511 if (ep1_ch1()->best_connection() && | 511 if (ep1_ch1()->best_connection() && |
| 512 ep2_ch1()->best_connection()) { | 512 ep2_ch1()->best_connection()) { |
| 513 int32 converge_start = rtc::Time(), converge_time; | 513 int32_t converge_start = rtc::Time(), converge_time; |
| 514 int converge_wait = 2000; | 514 int converge_wait = 2000; |
| 515 EXPECT_TRUE_WAIT_MARGIN(CheckCandidate1(expected), | 515 EXPECT_TRUE_WAIT_MARGIN(CheckCandidate1(expected), |
| 516 converge_wait, converge_wait); | 516 converge_wait, converge_wait); |
| 517 // Also do EXPECT_EQ on each part so that failures are more verbose. | 517 // Also do EXPECT_EQ on each part so that failures are more verbose. |
| 518 ExpectCandidate1(expected); | 518 ExpectCandidate1(expected); |
| 519 | 519 |
| 520 // Verifying remote channel best connection information. This is done | 520 // Verifying remote channel best connection information. This is done |
| 521 // only for the RFC 5245 as controlled agent will use USE-CANDIDATE | 521 // only for the RFC 5245 as controlled agent will use USE-CANDIDATE |
| 522 // from controlling (ep1) agent. We can easily predict from EP1 result | 522 // from controlling (ep1) agent. We can easily predict from EP1 result |
| 523 // matrix. | 523 // matrix. |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) { | 1694 TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) { |
| 1695 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 1695 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 1696 cricket::P2PTransportChannel ch("connection resurrection", 1, nullptr, &pa); | 1696 cricket::P2PTransportChannel ch("connection resurrection", 1, nullptr, &pa); |
| 1697 PrepareChannel(&ch); | 1697 PrepareChannel(&ch); |
| 1698 ch.Connect(); | 1698 ch.Connect(); |
| 1699 | 1699 |
| 1700 // Create conn1 and keep track of original candidate priority. | 1700 // Create conn1 and keep track of original candidate priority. |
| 1701 ch.OnCandidate(CreateCandidate("1.1.1.1", 1, 1)); | 1701 ch.OnCandidate(CreateCandidate("1.1.1.1", 1, 1)); |
| 1702 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 1702 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
| 1703 ASSERT_TRUE(conn1 != nullptr); | 1703 ASSERT_TRUE(conn1 != nullptr); |
| 1704 uint32 remote_priority = conn1->remote_candidate().priority(); | 1704 uint32_t remote_priority = conn1->remote_candidate().priority(); |
| 1705 | 1705 |
| 1706 // Create a higher priority candidate and make the connection | 1706 // Create a higher priority candidate and make the connection |
| 1707 // receiving/writable. This will prune conn1. | 1707 // receiving/writable. This will prune conn1. |
| 1708 ch.OnCandidate(CreateCandidate("2.2.2.2", 2, 2)); | 1708 ch.OnCandidate(CreateCandidate("2.2.2.2", 2, 2)); |
| 1709 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 1709 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
| 1710 ASSERT_TRUE(conn2 != nullptr); | 1710 ASSERT_TRUE(conn2 != nullptr); |
| 1711 conn2->ReceivedPing(); | 1711 conn2->ReceivedPing(); |
| 1712 conn2->ReceivedPingResponse(); | 1712 conn2->ReceivedPingResponse(); |
| 1713 | 1713 |
| 1714 // Wait for conn1 to be destroyed. | 1714 // Wait for conn1 to be destroyed. |
| 1715 EXPECT_TRUE_WAIT(GetConnectionTo(&ch, "1.1.1.1", 1) == nullptr, 3000); | 1715 EXPECT_TRUE_WAIT(GetConnectionTo(&ch, "1.1.1.1", 1) == nullptr, 3000); |
| 1716 cricket::Port* port = GetPort(&ch); | 1716 cricket::Port* port = GetPort(&ch); |
| 1717 | 1717 |
| 1718 // Create a minimal STUN message with prflx priority. | 1718 // Create a minimal STUN message with prflx priority. |
| 1719 cricket::IceMessage request; | 1719 cricket::IceMessage request; |
| 1720 request.SetType(cricket::STUN_BINDING_REQUEST); | 1720 request.SetType(cricket::STUN_BINDING_REQUEST); |
| 1721 request.AddAttribute(new cricket::StunByteStringAttribute( | 1721 request.AddAttribute(new cricket::StunByteStringAttribute( |
| 1722 cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); | 1722 cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); |
| 1723 uint32 prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; | 1723 uint32_t prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; |
| 1724 request.AddAttribute(new cricket::StunUInt32Attribute( | 1724 request.AddAttribute(new cricket::StunUInt32Attribute( |
| 1725 cricket::STUN_ATTR_PRIORITY, prflx_priority)); | 1725 cricket::STUN_ATTR_PRIORITY, prflx_priority)); |
| 1726 EXPECT_NE(prflx_priority, remote_priority); | 1726 EXPECT_NE(prflx_priority, remote_priority); |
| 1727 | 1727 |
| 1728 // conn1 should be resurrected with original priority. | 1728 // conn1 should be resurrected with original priority. |
| 1729 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), | 1729 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), |
| 1730 cricket::PROTO_UDP, &request, kIceUfrag[1], false); | 1730 cricket::PROTO_UDP, &request, kIceUfrag[1], false); |
| 1731 conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 1731 conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
| 1732 ASSERT_TRUE(conn1 != nullptr); | 1732 ASSERT_TRUE(conn1 != nullptr); |
| 1733 EXPECT_EQ(conn1->remote_candidate().priority(), remote_priority); | 1733 EXPECT_EQ(conn1->remote_candidate().priority(), remote_priority); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); | 1826 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| 1827 cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa); | 1827 cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa); |
| 1828 PrepareChannel(&ch); | 1828 PrepareChannel(&ch); |
| 1829 ch.SetIceRole(cricket::ICEROLE_CONTROLLED); | 1829 ch.SetIceRole(cricket::ICEROLE_CONTROLLED); |
| 1830 ch.Connect(); | 1830 ch.Connect(); |
| 1831 // A minimal STUN message with prflx priority. | 1831 // A minimal STUN message with prflx priority. |
| 1832 cricket::IceMessage request; | 1832 cricket::IceMessage request; |
| 1833 request.SetType(cricket::STUN_BINDING_REQUEST); | 1833 request.SetType(cricket::STUN_BINDING_REQUEST); |
| 1834 request.AddAttribute(new cricket::StunByteStringAttribute( | 1834 request.AddAttribute(new cricket::StunByteStringAttribute( |
| 1835 cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); | 1835 cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); |
| 1836 uint32 prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; | 1836 uint32_t prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; |
| 1837 request.AddAttribute(new cricket::StunUInt32Attribute( | 1837 request.AddAttribute(new cricket::StunUInt32Attribute( |
| 1838 cricket::STUN_ATTR_PRIORITY, prflx_priority)); | 1838 cricket::STUN_ATTR_PRIORITY, prflx_priority)); |
| 1839 cricket::Port* port = GetPort(&ch); | 1839 cricket::Port* port = GetPort(&ch); |
| 1840 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), | 1840 port->SignalUnknownAddress(port, rtc::SocketAddress("1.1.1.1", 1), |
| 1841 cricket::PROTO_UDP, &request, kIceUfrag[1], false); | 1841 cricket::PROTO_UDP, &request, kIceUfrag[1], false); |
| 1842 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); | 1842 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
| 1843 ASSERT_TRUE(conn1 != nullptr); | 1843 ASSERT_TRUE(conn1 != nullptr); |
| 1844 EXPECT_EQ(conn1, ch.best_connection()); | 1844 EXPECT_EQ(conn1, ch.best_connection()); |
| 1845 conn1->ReceivedPingResponse(); | 1845 conn1->ReceivedPingResponse(); |
| 1846 EXPECT_EQ(conn1, ch.best_connection()); | 1846 EXPECT_EQ(conn1, ch.best_connection()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1912 // Switch because it is writable. | 1912 // Switch because it is writable. |
| 1913 conn2->OnReadPacket("DEF", 3, rtc::CreatePacketTime(0)); | 1913 conn2->OnReadPacket("DEF", 3, rtc::CreatePacketTime(0)); |
| 1914 EXPECT_EQ(conn2, ch.best_connection()); | 1914 EXPECT_EQ(conn2, ch.best_connection()); |
| 1915 | 1915 |
| 1916 // Now another STUN message with an unknown address and use_candidate will | 1916 // Now another STUN message with an unknown address and use_candidate will |
| 1917 // nominate the best connection. | 1917 // nominate the best connection. |
| 1918 cricket::IceMessage request; | 1918 cricket::IceMessage request; |
| 1919 request.SetType(cricket::STUN_BINDING_REQUEST); | 1919 request.SetType(cricket::STUN_BINDING_REQUEST); |
| 1920 request.AddAttribute(new cricket::StunByteStringAttribute( | 1920 request.AddAttribute(new cricket::StunByteStringAttribute( |
| 1921 cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); | 1921 cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); |
| 1922 uint32 prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; | 1922 uint32_t prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; |
| 1923 request.AddAttribute(new cricket::StunUInt32Attribute( | 1923 request.AddAttribute(new cricket::StunUInt32Attribute( |
| 1924 cricket::STUN_ATTR_PRIORITY, prflx_priority)); | 1924 cricket::STUN_ATTR_PRIORITY, prflx_priority)); |
| 1925 request.AddAttribute( | 1925 request.AddAttribute( |
| 1926 new cricket::StunByteStringAttribute(cricket::STUN_ATTR_USE_CANDIDATE)); | 1926 new cricket::StunByteStringAttribute(cricket::STUN_ATTR_USE_CANDIDATE)); |
| 1927 cricket::Port* port = GetPort(&ch); | 1927 cricket::Port* port = GetPort(&ch); |
| 1928 port->SignalUnknownAddress(port, rtc::SocketAddress("3.3.3.3", 3), | 1928 port->SignalUnknownAddress(port, rtc::SocketAddress("3.3.3.3", 3), |
| 1929 cricket::PROTO_UDP, &request, kIceUfrag[1], false); | 1929 cricket::PROTO_UDP, &request, kIceUfrag[1], false); |
| 1930 cricket::Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); | 1930 cricket::Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3); |
| 1931 ASSERT_TRUE(conn3 != nullptr); | 1931 ASSERT_TRUE(conn3 != nullptr); |
| 1932 EXPECT_EQ(conn2, ch.best_connection()); // Not writable yet. | 1932 EXPECT_EQ(conn2, ch.best_connection()); // Not writable yet. |
| 1933 conn3->ReceivedPingResponse(); // Become writable. | 1933 conn3->ReceivedPingResponse(); // Become writable. |
| 1934 EXPECT_EQ(conn3, ch.best_connection()); | 1934 EXPECT_EQ(conn3, ch.best_connection()); |
| 1935 | 1935 |
| 1936 // Now another data packet will not switch the best connection because the | 1936 // Now another data packet will not switch the best connection because the |
| 1937 // best connection was nominated by the controlling side. | 1937 // best connection was nominated by the controlling side. |
| 1938 conn2->ReceivedPing(); | 1938 conn2->ReceivedPing(); |
| 1939 conn2->ReceivedPingResponse(); | 1939 conn2->ReceivedPingResponse(); |
| 1940 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); | 1940 conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0)); |
| 1941 EXPECT_EQ(conn3, ch.best_connection()); | 1941 EXPECT_EQ(conn3, ch.best_connection()); |
| 1942 } | 1942 } |
| OLD | NEW |