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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 GetEndpoint(ch)->saved_candidates_.push_back(new CandidateData(ch, c)); | 643 GetEndpoint(ch)->saved_candidates_.push_back(new CandidateData(ch, c)); |
644 } else { | 644 } else { |
645 main_->Post(this, MSG_CANDIDATE, new CandidateData(ch, c)); | 645 main_->Post(this, MSG_CANDIDATE, new CandidateData(ch, c)); |
646 } | 646 } |
647 } | 647 } |
648 | 648 |
649 void PauseCandidates(int endpoint) { | 649 void PauseCandidates(int endpoint) { |
650 GetEndpoint(endpoint)->save_candidates_ = true; | 650 GetEndpoint(endpoint)->save_candidates_ = true; |
651 } | 651 } |
652 | 652 |
| 653 // Tcp candidate verification has to be done when they are generated. |
| 654 void VerifySavedTcpCandidates(int endpoint, const std::string& tcptype) { |
| 655 for (auto& data : GetEndpoint(endpoint)->saved_candidates_) { |
| 656 EXPECT_EQ(data->candidate.protocol(), cricket::TCP_PROTOCOL_NAME); |
| 657 EXPECT_EQ(data->candidate.tcptype(), tcptype); |
| 658 if (data->candidate.tcptype() == cricket::TCPTYPE_ACTIVE_STR) { |
| 659 EXPECT_EQ(data->candidate.address().port(), cricket::DISCARD_PORT); |
| 660 } else if (data->candidate.tcptype() == cricket::TCPTYPE_PASSIVE_STR) { |
| 661 EXPECT_NE(data->candidate.address().port(), cricket::DISCARD_PORT); |
| 662 } else { |
| 663 FAIL() << "Unknown tcptype: " << data->candidate.tcptype(); |
| 664 } |
| 665 } |
| 666 } |
| 667 |
653 void ResumeCandidates(int endpoint) { | 668 void ResumeCandidates(int endpoint) { |
654 Endpoint* ed = GetEndpoint(endpoint); | 669 Endpoint* ed = GetEndpoint(endpoint); |
655 std::vector<CandidateData*>::iterator it = ed->saved_candidates_.begin(); | 670 std::vector<CandidateData*>::iterator it = ed->saved_candidates_.begin(); |
656 for (; it != ed->saved_candidates_.end(); ++it) { | 671 for (; it != ed->saved_candidates_.end(); ++it) { |
657 main_->Post(this, MSG_CANDIDATE, *it); | 672 main_->Post(this, MSG_CANDIDATE, *it); |
658 } | 673 } |
659 ed->saved_candidates_.clear(); | 674 ed->saved_candidates_.clear(); |
660 ed->save_candidates_ = false; | 675 ed->save_candidates_ = false; |
661 } | 676 } |
662 | 677 |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | | 1298 int kOnlyLocalTcpPorts = cricket::PORTALLOCATOR_DISABLE_UDP | |
1284 cricket::PORTALLOCATOR_DISABLE_STUN | | 1299 cricket::PORTALLOCATOR_DISABLE_STUN | |
1285 cricket::PORTALLOCATOR_DISABLE_RELAY; | 1300 cricket::PORTALLOCATOR_DISABLE_RELAY; |
1286 // Disable all protocols except TCP. | 1301 // Disable all protocols except TCP. |
1287 SetAllocatorFlags(0, kOnlyLocalTcpPorts); | 1302 SetAllocatorFlags(0, kOnlyLocalTcpPorts); |
1288 SetAllocatorFlags(1, kOnlyLocalTcpPorts); | 1303 SetAllocatorFlags(1, kOnlyLocalTcpPorts); |
1289 | 1304 |
1290 SetAllowTcpListen(0, true); // actpass. | 1305 SetAllowTcpListen(0, true); // actpass. |
1291 SetAllowTcpListen(1, false); // active. | 1306 SetAllowTcpListen(1, false); // active. |
1292 | 1307 |
| 1308 // Pause candidate so we could verify the candidate properties. |
| 1309 PauseCandidates(0); |
| 1310 PauseCandidates(1); |
1293 CreateChannels(1); | 1311 CreateChannels(1); |
1294 | 1312 |
| 1313 // Verify tcp candidates. |
| 1314 VerifySavedTcpCandidates(0, cricket::TCPTYPE_PASSIVE_STR); |
| 1315 VerifySavedTcpCandidates(1, cricket::TCPTYPE_ACTIVE_STR); |
| 1316 |
| 1317 // Resume candidates. |
| 1318 ResumeCandidates(0); |
| 1319 ResumeCandidates(1); |
| 1320 |
1295 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && | 1321 EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
1296 ep2_ch1()->receiving() && ep2_ch1()->writable(), | 1322 ep2_ch1()->receiving() && ep2_ch1()->writable(), |
1297 1000); | 1323 1000); |
1298 EXPECT_TRUE( | 1324 EXPECT_TRUE( |
1299 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && | 1325 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && |
1300 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && | 1326 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && |
1301 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); | 1327 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); |
1302 | 1328 |
1303 std::string kTcpProtocol = "tcp"; | |
1304 EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep1_ch1())->protocol()); | |
1305 EXPECT_EQ(kTcpProtocol, LocalCandidate(ep1_ch1())->protocol()); | |
1306 EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep2_ch1())->protocol()); | |
1307 EXPECT_EQ(kTcpProtocol, LocalCandidate(ep2_ch1())->protocol()); | |
1308 | |
1309 TestSendRecv(1); | 1329 TestSendRecv(1); |
1310 DestroyChannels(); | 1330 DestroyChannels(); |
1311 } | 1331 } |
1312 | 1332 |
1313 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { | 1333 TEST_F(P2PTransportChannelTest, TestIceRoleConflict) { |
1314 AddAddress(0, kPublicAddrs[0]); | 1334 AddAddress(0, kPublicAddrs[0]); |
1315 AddAddress(1, kPublicAddrs[1]); | 1335 AddAddress(1, kPublicAddrs[1]); |
1316 TestSignalRoleConflict(); | 1336 TestSignalRoleConflict(); |
1317 } | 1337 } |
1318 | 1338 |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2217 // It should stop getting ports after a new connection becomes strongly | 2237 // It should stop getting ports after a new connection becomes strongly |
2218 // connected. | 2238 // connected. |
2219 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); | 2239 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); |
2220 ch.MaybeStartGathering(); | 2240 ch.MaybeStartGathering(); |
2221 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100)); | 2241 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100)); |
2222 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); | 2242 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
2223 ASSERT_TRUE(conn2 != nullptr); | 2243 ASSERT_TRUE(conn2 != nullptr); |
2224 conn2->ReceivedPingResponse(); // Becomes writable and receiving | 2244 conn2->ReceivedPingResponse(); // Becomes writable and receiving |
2225 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); | 2245 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
2226 } | 2246 } |
OLD | NEW |