OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 13 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
12 #include "webrtc/p2p/base/relayport.h" | 14 #include "webrtc/p2p/base/relayport.h" |
13 #include "webrtc/p2p/base/stunport.h" | 15 #include "webrtc/p2p/base/stunport.h" |
14 #include "webrtc/p2p/base/tcpport.h" | 16 #include "webrtc/p2p/base/tcpport.h" |
15 #include "webrtc/p2p/base/testrelayserver.h" | 17 #include "webrtc/p2p/base/testrelayserver.h" |
16 #include "webrtc/p2p/base/teststunserver.h" | 18 #include "webrtc/p2p/base/teststunserver.h" |
17 #include "webrtc/p2p/base/testturnserver.h" | 19 #include "webrtc/p2p/base/testturnserver.h" |
18 #include "webrtc/p2p/base/transport.h" | 20 #include "webrtc/p2p/base/transport.h" |
19 #include "webrtc/p2p/base/turnport.h" | 21 #include "webrtc/p2p/base/turnport.h" |
20 #include "webrtc/base/arraysize.h" | 22 #include "webrtc/base/arraysize.h" |
21 #include "webrtc/base/buffer.h" | 23 #include "webrtc/base/buffer.h" |
22 #include "webrtc/base/crc32.h" | 24 #include "webrtc/base/crc32.h" |
23 #include "webrtc/base/gunit.h" | 25 #include "webrtc/base/gunit.h" |
24 #include "webrtc/base/helpers.h" | 26 #include "webrtc/base/helpers.h" |
25 #include "webrtc/base/logging.h" | 27 #include "webrtc/base/logging.h" |
26 #include "webrtc/base/natserver.h" | 28 #include "webrtc/base/natserver.h" |
27 #include "webrtc/base/natsocketfactory.h" | 29 #include "webrtc/base/natsocketfactory.h" |
28 #include "webrtc/base/physicalsocketserver.h" | 30 #include "webrtc/base/physicalsocketserver.h" |
29 #include "webrtc/base/scoped_ptr.h" | |
30 #include "webrtc/base/socketaddress.h" | 31 #include "webrtc/base/socketaddress.h" |
31 #include "webrtc/base/ssladapter.h" | 32 #include "webrtc/base/ssladapter.h" |
32 #include "webrtc/base/stringutils.h" | 33 #include "webrtc/base/stringutils.h" |
33 #include "webrtc/base/thread.h" | 34 #include "webrtc/base/thread.h" |
34 #include "webrtc/base/virtualsocketserver.h" | 35 #include "webrtc/base/virtualsocketserver.h" |
35 | 36 |
36 using rtc::AsyncPacketSocket; | 37 using rtc::AsyncPacketSocket; |
37 using rtc::Buffer; | 38 using rtc::Buffer; |
38 using rtc::ByteBufferReader; | 39 using rtc::ByteBufferReader; |
39 using rtc::ByteBufferWriter; | 40 using rtc::ByteBufferWriter; |
40 using rtc::NATType; | 41 using rtc::NATType; |
41 using rtc::NAT_OPEN_CONE; | 42 using rtc::NAT_OPEN_CONE; |
42 using rtc::NAT_ADDR_RESTRICTED; | 43 using rtc::NAT_ADDR_RESTRICTED; |
43 using rtc::NAT_PORT_RESTRICTED; | 44 using rtc::NAT_PORT_RESTRICTED; |
44 using rtc::NAT_SYMMETRIC; | 45 using rtc::NAT_SYMMETRIC; |
45 using rtc::PacketSocketFactory; | 46 using rtc::PacketSocketFactory; |
46 using rtc::scoped_ptr; | |
47 using rtc::Socket; | 47 using rtc::Socket; |
48 using rtc::SocketAddress; | 48 using rtc::SocketAddress; |
49 using namespace cricket; | 49 using namespace cricket; |
50 | 50 |
51 static const int kTimeout = 1000; | 51 static const int kTimeout = 1000; |
52 static const SocketAddress kLocalAddr1("192.168.1.2", 0); | 52 static const SocketAddress kLocalAddr1("192.168.1.2", 0); |
53 static const SocketAddress kLocalAddr2("192.168.1.3", 0); | 53 static const SocketAddress kLocalAddr2("192.168.1.3", 0); |
54 static const SocketAddress kNatAddr1("77.77.77.77", rtc::NAT_SERVER_UDP_PORT); | 54 static const SocketAddress kNatAddr1("77.77.77.77", rtc::NAT_SERVER_UDP_PORT); |
55 static const SocketAddress kNatAddr2("88.88.88.88", rtc::NAT_SERVER_UDP_PORT); | 55 static const SocketAddress kNatAddr2("88.88.88.88", rtc::NAT_SERVER_UDP_PORT); |
56 static const SocketAddress kStunAddr("99.99.99.1", STUN_SERVER_PORT); | 56 static const SocketAddress kStunAddr("99.99.99.1", STUN_SERVER_PORT); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 205 } |
206 void set_type_preference(int type_preference) { | 206 void set_type_preference(int type_preference) { |
207 type_preference_ = type_preference; | 207 type_preference_ = type_preference; |
208 } | 208 } |
209 | 209 |
210 private: | 210 private: |
211 void OnSentPacket(rtc::AsyncPacketSocket* socket, | 211 void OnSentPacket(rtc::AsyncPacketSocket* socket, |
212 const rtc::SentPacket& sent_packet) { | 212 const rtc::SentPacket& sent_packet) { |
213 PortInterface::SignalSentPacket(sent_packet); | 213 PortInterface::SignalSentPacket(sent_packet); |
214 } | 214 } |
215 rtc::scoped_ptr<Buffer> last_stun_buf_; | 215 std::unique_ptr<Buffer> last_stun_buf_; |
216 rtc::scoped_ptr<IceMessage> last_stun_msg_; | 216 std::unique_ptr<IceMessage> last_stun_msg_; |
217 int type_preference_ = 0; | 217 int type_preference_ = 0; |
218 }; | 218 }; |
219 | 219 |
220 class TestChannel : public sigslot::has_slots<> { | 220 class TestChannel : public sigslot::has_slots<> { |
221 public: | 221 public: |
222 // Takes ownership of |p1| (but not |p2|). | 222 // Takes ownership of |p1| (but not |p2|). |
223 TestChannel(Port* p1) | 223 TestChannel(Port* p1) |
224 : ice_mode_(ICEMODE_FULL), | 224 : ice_mode_(ICEMODE_FULL), |
225 port_(p1), | 225 port_(p1), |
226 complete_count_(0), | 226 complete_count_(0), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } | 337 } |
338 | 338 |
339 private: | 339 private: |
340 // ReadyToSend will only issue after a Connection recovers from EWOULDBLOCK. | 340 // ReadyToSend will only issue after a Connection recovers from EWOULDBLOCK. |
341 void OnConnectionReadyToSend(Connection* conn) { | 341 void OnConnectionReadyToSend(Connection* conn) { |
342 ASSERT_EQ(conn, conn_); | 342 ASSERT_EQ(conn, conn_); |
343 connection_ready_to_send_ = true; | 343 connection_ready_to_send_ = true; |
344 } | 344 } |
345 | 345 |
346 IceMode ice_mode_; | 346 IceMode ice_mode_; |
347 rtc::scoped_ptr<Port> port_; | 347 std::unique_ptr<Port> port_; |
348 | 348 |
349 int complete_count_; | 349 int complete_count_; |
350 Connection* conn_; | 350 Connection* conn_; |
351 SocketAddress remote_address_; | 351 SocketAddress remote_address_; |
352 rtc::scoped_ptr<StunMessage> remote_request_; | 352 std::unique_ptr<StunMessage> remote_request_; |
353 std::string remote_frag_; | 353 std::string remote_frag_; |
354 bool nominated_; | 354 bool nominated_; |
355 bool connection_ready_to_send_ = false; | 355 bool connection_ready_to_send_ = false; |
356 }; | 356 }; |
357 | 357 |
358 class PortTest : public testing::Test, public sigslot::has_slots<> { | 358 class PortTest : public testing::Test, public sigslot::has_slots<> { |
359 public: | 359 public: |
360 PortTest() | 360 PortTest() |
361 : main_(rtc::Thread::Current()), | 361 : main_(rtc::Thread::Current()), |
362 pss_(new rtc::PhysicalSocketServer), | 362 pss_(new rtc::PhysicalSocketServer), |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 | 757 |
758 rtc::BasicPacketSocketFactory* nat_socket_factory1() { | 758 rtc::BasicPacketSocketFactory* nat_socket_factory1() { |
759 return &nat_socket_factory1_; | 759 return &nat_socket_factory1_; |
760 } | 760 } |
761 | 761 |
762 protected: | 762 protected: |
763 rtc::VirtualSocketServer* vss() { return ss_.get(); } | 763 rtc::VirtualSocketServer* vss() { return ss_.get(); } |
764 | 764 |
765 private: | 765 private: |
766 rtc::Thread* main_; | 766 rtc::Thread* main_; |
767 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 767 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
768 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; | 768 std::unique_ptr<rtc::VirtualSocketServer> ss_; |
769 rtc::SocketServerScope ss_scope_; | 769 rtc::SocketServerScope ss_scope_; |
770 rtc::Network network_; | 770 rtc::Network network_; |
771 rtc::BasicPacketSocketFactory socket_factory_; | 771 rtc::BasicPacketSocketFactory socket_factory_; |
772 rtc::scoped_ptr<rtc::NATServer> nat_server1_; | 772 std::unique_ptr<rtc::NATServer> nat_server1_; |
773 rtc::scoped_ptr<rtc::NATServer> nat_server2_; | 773 std::unique_ptr<rtc::NATServer> nat_server2_; |
774 rtc::NATSocketFactory nat_factory1_; | 774 rtc::NATSocketFactory nat_factory1_; |
775 rtc::NATSocketFactory nat_factory2_; | 775 rtc::NATSocketFactory nat_factory2_; |
776 rtc::BasicPacketSocketFactory nat_socket_factory1_; | 776 rtc::BasicPacketSocketFactory nat_socket_factory1_; |
777 rtc::BasicPacketSocketFactory nat_socket_factory2_; | 777 rtc::BasicPacketSocketFactory nat_socket_factory2_; |
778 scoped_ptr<TestStunServer> stun_server_; | 778 std::unique_ptr<TestStunServer> stun_server_; |
779 TestTurnServer turn_server_; | 779 TestTurnServer turn_server_; |
780 TestRelayServer relay_server_; | 780 TestRelayServer relay_server_; |
781 std::string username_; | 781 std::string username_; |
782 std::string password_; | 782 std::string password_; |
783 bool role_conflict_; | 783 bool role_conflict_; |
784 bool destroyed_; | 784 bool destroyed_; |
785 }; | 785 }; |
786 | 786 |
787 void PortTest::TestConnectivity(const char* name1, Port* port1, | 787 void PortTest::TestConnectivity(const char* name1, Port* port1, |
788 const char* name2, Port* port2, | 788 const char* name2, Port* port2, |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1210 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1211 port1->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); | 1211 port1->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); |
1212 | 1212 |
1213 // Set up a channel and ensure the port will be deleted. | 1213 // Set up a channel and ensure the port will be deleted. |
1214 TestChannel ch1(port1); | 1214 TestChannel ch1(port1); |
1215 EXPECT_EQ(0, ch1.complete_count()); | 1215 EXPECT_EQ(0, ch1.complete_count()); |
1216 | 1216 |
1217 ch1.Start(); | 1217 ch1.Start(); |
1218 ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout); | 1218 ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout); |
1219 | 1219 |
1220 rtc::scoped_ptr<rtc::AsyncSocket> server( | 1220 std::unique_ptr<rtc::AsyncSocket> server( |
1221 vss()->CreateAsyncSocket(kLocalAddr2.family(), SOCK_STREAM)); | 1221 vss()->CreateAsyncSocket(kLocalAddr2.family(), SOCK_STREAM)); |
1222 // Bind but not listen. | 1222 // Bind but not listen. |
1223 EXPECT_EQ(0, server->Bind(kLocalAddr2)); | 1223 EXPECT_EQ(0, server->Bind(kLocalAddr2)); |
1224 | 1224 |
1225 Candidate c = GetCandidate(port1); | 1225 Candidate c = GetCandidate(port1); |
1226 c.set_address(server->GetLocalAddress()); | 1226 c.set_address(server->GetLocalAddress()); |
1227 | 1227 |
1228 ch1.CreateConnection(c); | 1228 ch1.CreateConnection(c); |
1229 EXPECT_TRUE(ch1.conn()); | 1229 EXPECT_TRUE(ch1.conn()); |
1230 EXPECT_TRUE_WAIT(!ch1.conn(), kTimeout); // for TCP connect | 1230 EXPECT_TRUE_WAIT(!ch1.conn(), kTimeout); // for TCP connect |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 port2->SetIceTiebreaker(kTiebreaker2); | 1315 port2->SetIceTiebreaker(kTiebreaker2); |
1316 // Same parameters as TestLocalToLocal above. | 1316 // Same parameters as TestLocalToLocal above. |
1317 TestConnectivity("udp", port1, "udp", port2, true, true, true, true); | 1317 TestConnectivity("udp", port1, "udp", port2, true, true, true, true); |
1318 } | 1318 } |
1319 | 1319 |
1320 // This test is trying to validate a successful and failure scenario in a | 1320 // This test is trying to validate a successful and failure scenario in a |
1321 // loopback test when protocol is RFC5245. For success IceTiebreaker, username | 1321 // loopback test when protocol is RFC5245. For success IceTiebreaker, username |
1322 // should remain equal to the request generated by the port and role of port | 1322 // should remain equal to the request generated by the port and role of port |
1323 // must be in controlling. | 1323 // must be in controlling. |
1324 TEST_F(PortTest, TestLoopbackCal) { | 1324 TEST_F(PortTest, TestLoopbackCal) { |
1325 rtc::scoped_ptr<TestPort> lport( | 1325 std::unique_ptr<TestPort> lport( |
1326 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); | 1326 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); |
1327 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1327 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1328 lport->SetIceTiebreaker(kTiebreaker1); | 1328 lport->SetIceTiebreaker(kTiebreaker1); |
1329 lport->PrepareAddress(); | 1329 lport->PrepareAddress(); |
1330 ASSERT_FALSE(lport->Candidates().empty()); | 1330 ASSERT_FALSE(lport->Candidates().empty()); |
1331 Connection* conn = lport->CreateConnection(lport->Candidates()[0], | 1331 Connection* conn = lport->CreateConnection(lport->Candidates()[0], |
1332 Port::ORIGIN_MESSAGE); | 1332 Port::ORIGIN_MESSAGE); |
1333 conn->Ping(0); | 1333 conn->Ping(0); |
1334 | 1334 |
1335 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); | 1335 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); |
(...skipping 11 matching lines...) Expand all Loading... |
1347 lport->Reset(); | 1347 lport->Reset(); |
1348 lport->AddCandidateAddress(kLocalAddr2); | 1348 lport->AddCandidateAddress(kLocalAddr2); |
1349 // Creating a different connection as |conn| is receiving. | 1349 // Creating a different connection as |conn| is receiving. |
1350 Connection* conn1 = lport->CreateConnection(lport->Candidates()[1], | 1350 Connection* conn1 = lport->CreateConnection(lport->Candidates()[1], |
1351 Port::ORIGIN_MESSAGE); | 1351 Port::ORIGIN_MESSAGE); |
1352 conn1->Ping(0); | 1352 conn1->Ping(0); |
1353 | 1353 |
1354 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); | 1354 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); |
1355 msg = lport->last_stun_msg(); | 1355 msg = lport->last_stun_msg(); |
1356 EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); | 1356 EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); |
1357 rtc::scoped_ptr<IceMessage> modified_req( | 1357 std::unique_ptr<IceMessage> modified_req( |
1358 CreateStunMessage(STUN_BINDING_REQUEST)); | 1358 CreateStunMessage(STUN_BINDING_REQUEST)); |
1359 const StunByteStringAttribute* username_attr = msg->GetByteString( | 1359 const StunByteStringAttribute* username_attr = msg->GetByteString( |
1360 STUN_ATTR_USERNAME); | 1360 STUN_ATTR_USERNAME); |
1361 modified_req->AddAttribute(new StunByteStringAttribute( | 1361 modified_req->AddAttribute(new StunByteStringAttribute( |
1362 STUN_ATTR_USERNAME, username_attr->GetString())); | 1362 STUN_ATTR_USERNAME, username_attr->GetString())); |
1363 // To make sure we receive error response, adding tiebreaker less than | 1363 // To make sure we receive error response, adding tiebreaker less than |
1364 // what's present in request. | 1364 // what's present in request. |
1365 modified_req->AddAttribute(new StunUInt64Attribute( | 1365 modified_req->AddAttribute(new StunUInt64Attribute( |
1366 STUN_ATTR_ICE_CONTROLLING, kTiebreaker1 - 1)); | 1366 STUN_ATTR_ICE_CONTROLLING, kTiebreaker1 - 1)); |
1367 modified_req->AddMessageIntegrity("lpass"); | 1367 modified_req->AddMessageIntegrity("lpass"); |
1368 modified_req->AddFingerprint(); | 1368 modified_req->AddFingerprint(); |
1369 | 1369 |
1370 lport->Reset(); | 1370 lport->Reset(); |
1371 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); | 1371 std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); |
1372 WriteStunMessage(modified_req.get(), buf.get()); | 1372 WriteStunMessage(modified_req.get(), buf.get()); |
1373 conn1->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime()); | 1373 conn1->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime()); |
1374 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); | 1374 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); |
1375 msg = lport->last_stun_msg(); | 1375 msg = lport->last_stun_msg(); |
1376 EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type()); | 1376 EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type()); |
1377 } | 1377 } |
1378 | 1378 |
1379 // This test verifies role conflict signal is received when there is | 1379 // This test verifies role conflict signal is received when there is |
1380 // conflict in the role. In this case both ports are in controlling and | 1380 // conflict in the role. In this case both ports are in controlling and |
1381 // |rport| has higher tiebreaker value than |lport|. Since |lport| has lower | 1381 // |rport| has higher tiebreaker value than |lport|. Since |lport| has lower |
1382 // value of tiebreaker, when it receives ping request from |rport| it will | 1382 // value of tiebreaker, when it receives ping request from |rport| it will |
1383 // send role conflict signal. | 1383 // send role conflict signal. |
1384 TEST_F(PortTest, TestIceRoleConflict) { | 1384 TEST_F(PortTest, TestIceRoleConflict) { |
1385 rtc::scoped_ptr<TestPort> lport( | 1385 std::unique_ptr<TestPort> lport( |
1386 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); | 1386 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); |
1387 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1387 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1388 lport->SetIceTiebreaker(kTiebreaker1); | 1388 lport->SetIceTiebreaker(kTiebreaker1); |
1389 rtc::scoped_ptr<TestPort> rport( | 1389 std::unique_ptr<TestPort> rport( |
1390 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | 1390 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
1391 rport->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1391 rport->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1392 rport->SetIceTiebreaker(kTiebreaker2); | 1392 rport->SetIceTiebreaker(kTiebreaker2); |
1393 | 1393 |
1394 lport->PrepareAddress(); | 1394 lport->PrepareAddress(); |
1395 rport->PrepareAddress(); | 1395 rport->PrepareAddress(); |
1396 ASSERT_FALSE(lport->Candidates().empty()); | 1396 ASSERT_FALSE(lport->Candidates().empty()); |
1397 ASSERT_FALSE(rport->Candidates().empty()); | 1397 ASSERT_FALSE(rport->Candidates().empty()); |
1398 Connection* lconn = lport->CreateConnection(rport->Candidates()[0], | 1398 Connection* lconn = lport->CreateConnection(rport->Candidates()[0], |
1399 Port::ORIGIN_MESSAGE); | 1399 Port::ORIGIN_MESSAGE); |
(...skipping 23 matching lines...) Expand all Loading... |
1423 ASSERT_EQ(0, success); // GetOption() should complete successfully w/ 0 | 1423 ASSERT_EQ(0, success); // GetOption() should complete successfully w/ 0 |
1424 ASSERT_EQ(1, option_value); | 1424 ASSERT_EQ(1, option_value); |
1425 delete port1; | 1425 delete port1; |
1426 } | 1426 } |
1427 | 1427 |
1428 TEST_F(PortTest, TestDelayedBindingUdp) { | 1428 TEST_F(PortTest, TestDelayedBindingUdp) { |
1429 FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket(); | 1429 FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket(); |
1430 FakePacketSocketFactory socket_factory; | 1430 FakePacketSocketFactory socket_factory; |
1431 | 1431 |
1432 socket_factory.set_next_udp_socket(socket); | 1432 socket_factory.set_next_udp_socket(socket); |
1433 scoped_ptr<UDPPort> port( | 1433 std::unique_ptr<UDPPort> port(CreateUdpPort(kLocalAddr1, &socket_factory)); |
1434 CreateUdpPort(kLocalAddr1, &socket_factory)); | |
1435 | 1434 |
1436 socket->set_state(AsyncPacketSocket::STATE_BINDING); | 1435 socket->set_state(AsyncPacketSocket::STATE_BINDING); |
1437 port->PrepareAddress(); | 1436 port->PrepareAddress(); |
1438 | 1437 |
1439 EXPECT_EQ(0U, port->Candidates().size()); | 1438 EXPECT_EQ(0U, port->Candidates().size()); |
1440 socket->SignalAddressReady(socket, kLocalAddr2); | 1439 socket->SignalAddressReady(socket, kLocalAddr2); |
1441 | 1440 |
1442 EXPECT_EQ(1U, port->Candidates().size()); | 1441 EXPECT_EQ(1U, port->Candidates().size()); |
1443 } | 1442 } |
1444 | 1443 |
1445 TEST_F(PortTest, TestDelayedBindingTcp) { | 1444 TEST_F(PortTest, TestDelayedBindingTcp) { |
1446 FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket(); | 1445 FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket(); |
1447 FakePacketSocketFactory socket_factory; | 1446 FakePacketSocketFactory socket_factory; |
1448 | 1447 |
1449 socket_factory.set_next_server_tcp_socket(socket); | 1448 socket_factory.set_next_server_tcp_socket(socket); |
1450 scoped_ptr<TCPPort> port( | 1449 std::unique_ptr<TCPPort> port(CreateTcpPort(kLocalAddr1, &socket_factory)); |
1451 CreateTcpPort(kLocalAddr1, &socket_factory)); | |
1452 | 1450 |
1453 socket->set_state(AsyncPacketSocket::STATE_BINDING); | 1451 socket->set_state(AsyncPacketSocket::STATE_BINDING); |
1454 port->PrepareAddress(); | 1452 port->PrepareAddress(); |
1455 | 1453 |
1456 EXPECT_EQ(0U, port->Candidates().size()); | 1454 EXPECT_EQ(0U, port->Candidates().size()); |
1457 socket->SignalAddressReady(socket, kLocalAddr2); | 1455 socket->SignalAddressReady(socket, kLocalAddr2); |
1458 | 1456 |
1459 EXPECT_EQ(1U, port->Candidates().size()); | 1457 EXPECT_EQ(1U, port->Candidates().size()); |
1460 } | 1458 } |
1461 | 1459 |
1462 void PortTest::TestCrossFamilyPorts(int type) { | 1460 void PortTest::TestCrossFamilyPorts(int type) { |
1463 FakePacketSocketFactory factory; | 1461 FakePacketSocketFactory factory; |
1464 scoped_ptr<Port> ports[4]; | 1462 std::unique_ptr<Port> ports[4]; |
1465 SocketAddress addresses[4] = {SocketAddress("192.168.1.3", 0), | 1463 SocketAddress addresses[4] = {SocketAddress("192.168.1.3", 0), |
1466 SocketAddress("192.168.1.4", 0), | 1464 SocketAddress("192.168.1.4", 0), |
1467 SocketAddress("2001:db8::1", 0), | 1465 SocketAddress("2001:db8::1", 0), |
1468 SocketAddress("2001:db8::2", 0)}; | 1466 SocketAddress("2001:db8::2", 0)}; |
1469 for (int i = 0; i < 4; i++) { | 1467 for (int i = 0; i < 4; i++) { |
1470 FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket(); | 1468 FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket(); |
1471 if (type == SOCK_DGRAM) { | 1469 if (type == SOCK_DGRAM) { |
1472 factory.set_next_udp_socket(socket); | 1470 factory.set_next_udp_socket(socket); |
1473 ports[i].reset(CreateUdpPort(addresses[i], &factory)); | 1471 ports[i].reset(CreateUdpPort(addresses[i], &factory)); |
1474 } else if (type == SOCK_STREAM) { | 1472 } else if (type == SOCK_STREAM) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 EXPECT_FALSE(NULL == c); | 1522 EXPECT_FALSE(NULL == c); |
1525 EXPECT_EQ(1U, p1->connections().size()); | 1523 EXPECT_EQ(1U, p1->connections().size()); |
1526 } else { | 1524 } else { |
1527 EXPECT_TRUE(NULL == c); | 1525 EXPECT_TRUE(NULL == c); |
1528 EXPECT_EQ(0U, p1->connections().size()); | 1526 EXPECT_EQ(0U, p1->connections().size()); |
1529 } | 1527 } |
1530 } | 1528 } |
1531 | 1529 |
1532 TEST_F(PortTest, TestUdpV6CrossTypePorts) { | 1530 TEST_F(PortTest, TestUdpV6CrossTypePorts) { |
1533 FakePacketSocketFactory factory; | 1531 FakePacketSocketFactory factory; |
1534 scoped_ptr<Port> ports[4]; | 1532 std::unique_ptr<Port> ports[4]; |
1535 SocketAddress addresses[4] = {SocketAddress("2001:db8::1", 0), | 1533 SocketAddress addresses[4] = {SocketAddress("2001:db8::1", 0), |
1536 SocketAddress("fe80::1", 0), | 1534 SocketAddress("fe80::1", 0), |
1537 SocketAddress("fe80::2", 0), | 1535 SocketAddress("fe80::2", 0), |
1538 SocketAddress("::1", 0)}; | 1536 SocketAddress("::1", 0)}; |
1539 for (int i = 0; i < 4; i++) { | 1537 for (int i = 0; i < 4; i++) { |
1540 FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket(); | 1538 FakeAsyncPacketSocket *socket = new FakeAsyncPacketSocket(); |
1541 factory.set_next_udp_socket(socket); | 1539 factory.set_next_udp_socket(socket); |
1542 ports[i].reset(CreateUdpPort(addresses[i], &factory)); | 1540 ports[i].reset(CreateUdpPort(addresses[i], &factory)); |
1543 socket->set_state(AsyncPacketSocket::STATE_BINDING); | 1541 socket->set_state(AsyncPacketSocket::STATE_BINDING); |
1544 socket->SignalAddressReady(socket, addresses[i]); | 1542 socket->SignalAddressReady(socket, addresses[i]); |
(...skipping 12 matching lines...) Expand all Loading... |
1557 | 1555 |
1558 ExpectPortsCanConnect(true, link_local1, link_local2); | 1556 ExpectPortsCanConnect(true, link_local1, link_local2); |
1559 ExpectPortsCanConnect(true, localhost, standard); | 1557 ExpectPortsCanConnect(true, localhost, standard); |
1560 ExpectPortsCanConnect(true, standard, localhost); | 1558 ExpectPortsCanConnect(true, standard, localhost); |
1561 } | 1559 } |
1562 | 1560 |
1563 // This test verifies DSCP value set through SetOption interface can be | 1561 // This test verifies DSCP value set through SetOption interface can be |
1564 // get through DefaultDscpValue. | 1562 // get through DefaultDscpValue. |
1565 TEST_F(PortTest, TestDefaultDscpValue) { | 1563 TEST_F(PortTest, TestDefaultDscpValue) { |
1566 int dscp; | 1564 int dscp; |
1567 rtc::scoped_ptr<UDPPort> udpport(CreateUdpPort(kLocalAddr1)); | 1565 std::unique_ptr<UDPPort> udpport(CreateUdpPort(kLocalAddr1)); |
1568 EXPECT_EQ(0, udpport->SetOption(rtc::Socket::OPT_DSCP, | 1566 EXPECT_EQ(0, udpport->SetOption(rtc::Socket::OPT_DSCP, |
1569 rtc::DSCP_CS6)); | 1567 rtc::DSCP_CS6)); |
1570 EXPECT_EQ(0, udpport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); | 1568 EXPECT_EQ(0, udpport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); |
1571 rtc::scoped_ptr<TCPPort> tcpport(CreateTcpPort(kLocalAddr1)); | 1569 std::unique_ptr<TCPPort> tcpport(CreateTcpPort(kLocalAddr1)); |
1572 EXPECT_EQ(0, tcpport->SetOption(rtc::Socket::OPT_DSCP, | 1570 EXPECT_EQ(0, tcpport->SetOption(rtc::Socket::OPT_DSCP, |
1573 rtc::DSCP_AF31)); | 1571 rtc::DSCP_AF31)); |
1574 EXPECT_EQ(0, tcpport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); | 1572 EXPECT_EQ(0, tcpport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); |
1575 EXPECT_EQ(rtc::DSCP_AF31, dscp); | 1573 EXPECT_EQ(rtc::DSCP_AF31, dscp); |
1576 rtc::scoped_ptr<StunPort> stunport( | 1574 std::unique_ptr<StunPort> stunport( |
1577 CreateStunPort(kLocalAddr1, nat_socket_factory1())); | 1575 CreateStunPort(kLocalAddr1, nat_socket_factory1())); |
1578 EXPECT_EQ(0, stunport->SetOption(rtc::Socket::OPT_DSCP, | 1576 EXPECT_EQ(0, stunport->SetOption(rtc::Socket::OPT_DSCP, |
1579 rtc::DSCP_AF41)); | 1577 rtc::DSCP_AF41)); |
1580 EXPECT_EQ(0, stunport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); | 1578 EXPECT_EQ(0, stunport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); |
1581 EXPECT_EQ(rtc::DSCP_AF41, dscp); | 1579 EXPECT_EQ(rtc::DSCP_AF41, dscp); |
1582 rtc::scoped_ptr<TurnPort> turnport1(CreateTurnPort( | 1580 std::unique_ptr<TurnPort> turnport1( |
1583 kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); | 1581 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); |
1584 // Socket is created in PrepareAddress. | 1582 // Socket is created in PrepareAddress. |
1585 turnport1->PrepareAddress(); | 1583 turnport1->PrepareAddress(); |
1586 EXPECT_EQ(0, turnport1->SetOption(rtc::Socket::OPT_DSCP, | 1584 EXPECT_EQ(0, turnport1->SetOption(rtc::Socket::OPT_DSCP, |
1587 rtc::DSCP_CS7)); | 1585 rtc::DSCP_CS7)); |
1588 EXPECT_EQ(0, turnport1->GetOption(rtc::Socket::OPT_DSCP, &dscp)); | 1586 EXPECT_EQ(0, turnport1->GetOption(rtc::Socket::OPT_DSCP, &dscp)); |
1589 EXPECT_EQ(rtc::DSCP_CS7, dscp); | 1587 EXPECT_EQ(rtc::DSCP_CS7, dscp); |
1590 // This will verify correct value returned without the socket. | 1588 // This will verify correct value returned without the socket. |
1591 rtc::scoped_ptr<TurnPort> turnport2(CreateTurnPort( | 1589 std::unique_ptr<TurnPort> turnport2( |
1592 kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); | 1590 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); |
1593 EXPECT_EQ(0, turnport2->SetOption(rtc::Socket::OPT_DSCP, | 1591 EXPECT_EQ(0, turnport2->SetOption(rtc::Socket::OPT_DSCP, |
1594 rtc::DSCP_CS6)); | 1592 rtc::DSCP_CS6)); |
1595 EXPECT_EQ(0, turnport2->GetOption(rtc::Socket::OPT_DSCP, &dscp)); | 1593 EXPECT_EQ(0, turnport2->GetOption(rtc::Socket::OPT_DSCP, &dscp)); |
1596 EXPECT_EQ(rtc::DSCP_CS6, dscp); | 1594 EXPECT_EQ(rtc::DSCP_CS6, dscp); |
1597 } | 1595 } |
1598 | 1596 |
1599 // Test sending STUN messages. | 1597 // Test sending STUN messages. |
1600 TEST_F(PortTest, TestSendStunMessage) { | 1598 TEST_F(PortTest, TestSendStunMessage) { |
1601 rtc::scoped_ptr<TestPort> lport( | 1599 std::unique_ptr<TestPort> lport( |
1602 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); | 1600 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); |
1603 rtc::scoped_ptr<TestPort> rport( | 1601 std::unique_ptr<TestPort> rport( |
1604 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | 1602 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
1605 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1603 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1606 lport->SetIceTiebreaker(kTiebreaker1); | 1604 lport->SetIceTiebreaker(kTiebreaker1); |
1607 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); | 1605 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); |
1608 rport->SetIceTiebreaker(kTiebreaker2); | 1606 rport->SetIceTiebreaker(kTiebreaker2); |
1609 | 1607 |
1610 // Send a fake ping from lport to rport. | 1608 // Send a fake ping from lport to rport. |
1611 lport->PrepareAddress(); | 1609 lport->PrepareAddress(); |
1612 rport->PrepareAddress(); | 1610 rport->PrepareAddress(); |
1613 ASSERT_FALSE(rport->Candidates().empty()); | 1611 ASSERT_FALSE(rport->Candidates().empty()); |
(...skipping 26 matching lines...) Expand all Loading... |
1640 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == NULL); | 1638 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == NULL); |
1641 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != NULL); | 1639 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != NULL); |
1642 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); | 1640 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); |
1643 EXPECT_TRUE(StunMessage::ValidateFingerprint( | 1641 EXPECT_TRUE(StunMessage::ValidateFingerprint( |
1644 lport->last_stun_buf()->data<char>(), lport->last_stun_buf()->size())); | 1642 lport->last_stun_buf()->data<char>(), lport->last_stun_buf()->size())); |
1645 | 1643 |
1646 // Request should not include ping count. | 1644 // Request should not include ping count. |
1647 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); | 1645 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); |
1648 | 1646 |
1649 // Save a copy of the BINDING-REQUEST for use below. | 1647 // Save a copy of the BINDING-REQUEST for use below. |
1650 rtc::scoped_ptr<IceMessage> request(CopyStunMessage(msg)); | 1648 std::unique_ptr<IceMessage> request(CopyStunMessage(msg)); |
1651 | 1649 |
1652 // Respond with a BINDING-RESPONSE. | 1650 // Respond with a BINDING-RESPONSE. |
1653 rport->SendBindingResponse(request.get(), lport->Candidates()[0].address()); | 1651 rport->SendBindingResponse(request.get(), lport->Candidates()[0].address()); |
1654 msg = rport->last_stun_msg(); | 1652 msg = rport->last_stun_msg(); |
1655 ASSERT_TRUE(msg != NULL); | 1653 ASSERT_TRUE(msg != NULL); |
1656 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); | 1654 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); |
1657 | 1655 |
1658 | 1656 |
1659 EXPECT_FALSE(msg->IsLegacy()); | 1657 EXPECT_FALSE(msg->IsLegacy()); |
1660 const StunAddressAttribute* addr_attr = msg->GetAddress( | 1658 const StunAddressAttribute* addr_attr = msg->GetAddress( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 lport->SendBindingResponse(request.get(), rport->Candidates()[0].address()); | 1729 lport->SendBindingResponse(request.get(), rport->Candidates()[0].address()); |
1732 msg = lport->last_stun_msg(); | 1730 msg = lport->last_stun_msg(); |
1733 | 1731 |
1734 // Response should include same ping count. | 1732 // Response should include same ping count. |
1735 retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); | 1733 retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); |
1736 ASSERT_TRUE(retransmit_attr != NULL); | 1734 ASSERT_TRUE(retransmit_attr != NULL); |
1737 EXPECT_EQ(2U, retransmit_attr->value()); | 1735 EXPECT_EQ(2U, retransmit_attr->value()); |
1738 } | 1736 } |
1739 | 1737 |
1740 TEST_F(PortTest, TestUseCandidateAttribute) { | 1738 TEST_F(PortTest, TestUseCandidateAttribute) { |
1741 rtc::scoped_ptr<TestPort> lport( | 1739 std::unique_ptr<TestPort> lport( |
1742 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); | 1740 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); |
1743 rtc::scoped_ptr<TestPort> rport( | 1741 std::unique_ptr<TestPort> rport( |
1744 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | 1742 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
1745 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1743 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1746 lport->SetIceTiebreaker(kTiebreaker1); | 1744 lport->SetIceTiebreaker(kTiebreaker1); |
1747 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); | 1745 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); |
1748 rport->SetIceTiebreaker(kTiebreaker2); | 1746 rport->SetIceTiebreaker(kTiebreaker2); |
1749 | 1747 |
1750 // Send a fake ping from lport to rport. | 1748 // Send a fake ping from lport to rport. |
1751 lport->PrepareAddress(); | 1749 lport->PrepareAddress(); |
1752 rport->PrepareAddress(); | 1750 rport->PrepareAddress(); |
1753 ASSERT_FALSE(rport->Candidates().empty()); | 1751 ASSERT_FALSE(rport->Candidates().empty()); |
1754 Connection* lconn = lport->CreateConnection( | 1752 Connection* lconn = lport->CreateConnection( |
1755 rport->Candidates()[0], Port::ORIGIN_MESSAGE); | 1753 rport->Candidates()[0], Port::ORIGIN_MESSAGE); |
1756 lconn->Ping(0); | 1754 lconn->Ping(0); |
1757 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); | 1755 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); |
1758 IceMessage* msg = lport->last_stun_msg(); | 1756 IceMessage* msg = lport->last_stun_msg(); |
1759 const StunUInt64Attribute* ice_controlling_attr = | 1757 const StunUInt64Attribute* ice_controlling_attr = |
1760 msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING); | 1758 msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING); |
1761 ASSERT_TRUE(ice_controlling_attr != NULL); | 1759 ASSERT_TRUE(ice_controlling_attr != NULL); |
1762 const StunByteStringAttribute* use_candidate_attr = msg->GetByteString( | 1760 const StunByteStringAttribute* use_candidate_attr = msg->GetByteString( |
1763 STUN_ATTR_USE_CANDIDATE); | 1761 STUN_ATTR_USE_CANDIDATE); |
1764 ASSERT_TRUE(use_candidate_attr != NULL); | 1762 ASSERT_TRUE(use_candidate_attr != NULL); |
1765 } | 1763 } |
1766 | 1764 |
1767 TEST_F(PortTest, TestNetworkInfoAttribute) { | 1765 TEST_F(PortTest, TestNetworkInfoAttribute) { |
1768 rtc::scoped_ptr<TestPort> lport( | 1766 std::unique_ptr<TestPort> lport( |
1769 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); | 1767 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); |
1770 // Set the network type for rport to be cellular so its cost will be 999. | 1768 // Set the network type for rport to be cellular so its cost will be 999. |
1771 SetNetworkType(rtc::ADAPTER_TYPE_CELLULAR); | 1769 SetNetworkType(rtc::ADAPTER_TYPE_CELLULAR); |
1772 rtc::scoped_ptr<TestPort> rport( | 1770 std::unique_ptr<TestPort> rport( |
1773 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | 1771 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
1774 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1772 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1775 lport->SetIceTiebreaker(kTiebreaker1); | 1773 lport->SetIceTiebreaker(kTiebreaker1); |
1776 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); | 1774 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); |
1777 rport->SetIceTiebreaker(kTiebreaker2); | 1775 rport->SetIceTiebreaker(kTiebreaker2); |
1778 | 1776 |
1779 uint16_t lnetwork_id = 9; | 1777 uint16_t lnetwork_id = 9; |
1780 lport->Network()->set_id(lnetwork_id); | 1778 lport->Network()->set_id(lnetwork_id); |
1781 // Send a fake ping from lport to rport. | 1779 // Send a fake ping from lport to rport. |
1782 lport->PrepareAddress(); | 1780 lport->PrepareAddress(); |
(...skipping 22 matching lines...) Expand all Loading... |
1805 network_info_attr = msg->GetUInt32(STUN_ATTR_NETWORK_INFO); | 1803 network_info_attr = msg->GetUInt32(STUN_ATTR_NETWORK_INFO); |
1806 ASSERT_TRUE(network_info_attr != NULL); | 1804 ASSERT_TRUE(network_info_attr != NULL); |
1807 network_info = network_info_attr->value(); | 1805 network_info = network_info_attr->value(); |
1808 EXPECT_EQ(rnetwork_id, network_info >> 16); | 1806 EXPECT_EQ(rnetwork_id, network_info >> 16); |
1809 EXPECT_EQ(cricket::kMaxNetworkCost, network_info & 0xFFFF); | 1807 EXPECT_EQ(cricket::kMaxNetworkCost, network_info & 0xFFFF); |
1810 } | 1808 } |
1811 | 1809 |
1812 // Test handling STUN messages. | 1810 // Test handling STUN messages. |
1813 TEST_F(PortTest, TestHandleStunMessage) { | 1811 TEST_F(PortTest, TestHandleStunMessage) { |
1814 // Our port will act as the "remote" port. | 1812 // Our port will act as the "remote" port. |
1815 rtc::scoped_ptr<TestPort> port( | 1813 std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
1816 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | |
1817 | 1814 |
1818 rtc::scoped_ptr<IceMessage> in_msg, out_msg; | 1815 std::unique_ptr<IceMessage> in_msg, out_msg; |
1819 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); | 1816 std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); |
1820 rtc::SocketAddress addr(kLocalAddr1); | 1817 rtc::SocketAddress addr(kLocalAddr1); |
1821 std::string username; | 1818 std::string username; |
1822 | 1819 |
1823 // BINDING-REQUEST from local to remote with valid ICE username, | 1820 // BINDING-REQUEST from local to remote with valid ICE username, |
1824 // MESSAGE-INTEGRITY, and FINGERPRINT. | 1821 // MESSAGE-INTEGRITY, and FINGERPRINT. |
1825 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, | 1822 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, |
1826 "rfrag:lfrag")); | 1823 "rfrag:lfrag")); |
1827 in_msg->AddMessageIntegrity("rpass"); | 1824 in_msg->AddMessageIntegrity("rpass"); |
1828 in_msg->AddFingerprint(); | 1825 in_msg->AddFingerprint(); |
1829 WriteStunMessage(in_msg.get(), buf.get()); | 1826 WriteStunMessage(in_msg.get(), buf.get()); |
(...skipping 25 matching lines...) Expand all Loading... |
1855 EXPECT_TRUE(out_msg.get() != NULL); | 1852 EXPECT_TRUE(out_msg.get() != NULL); |
1856 EXPECT_EQ("", username); | 1853 EXPECT_EQ("", username); |
1857 ASSERT_TRUE(out_msg->GetErrorCode() != NULL); | 1854 ASSERT_TRUE(out_msg->GetErrorCode() != NULL); |
1858 EXPECT_EQ(STUN_ERROR_SERVER_ERROR, out_msg->GetErrorCode()->code()); | 1855 EXPECT_EQ(STUN_ERROR_SERVER_ERROR, out_msg->GetErrorCode()->code()); |
1859 EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR), | 1856 EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR), |
1860 out_msg->GetErrorCode()->reason()); | 1857 out_msg->GetErrorCode()->reason()); |
1861 } | 1858 } |
1862 | 1859 |
1863 // Tests handling of ICE binding requests with missing or incorrect usernames. | 1860 // Tests handling of ICE binding requests with missing or incorrect usernames. |
1864 TEST_F(PortTest, TestHandleStunMessageBadUsername) { | 1861 TEST_F(PortTest, TestHandleStunMessageBadUsername) { |
1865 rtc::scoped_ptr<TestPort> port( | 1862 std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
1866 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | |
1867 | 1863 |
1868 rtc::scoped_ptr<IceMessage> in_msg, out_msg; | 1864 std::unique_ptr<IceMessage> in_msg, out_msg; |
1869 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); | 1865 std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); |
1870 rtc::SocketAddress addr(kLocalAddr1); | 1866 rtc::SocketAddress addr(kLocalAddr1); |
1871 std::string username; | 1867 std::string username; |
1872 | 1868 |
1873 // BINDING-REQUEST with no username. | 1869 // BINDING-REQUEST with no username. |
1874 in_msg.reset(CreateStunMessage(STUN_BINDING_REQUEST)); | 1870 in_msg.reset(CreateStunMessage(STUN_BINDING_REQUEST)); |
1875 in_msg->AddMessageIntegrity("rpass"); | 1871 in_msg->AddMessageIntegrity("rpass"); |
1876 in_msg->AddFingerprint(); | 1872 in_msg->AddFingerprint(); |
1877 WriteStunMessage(in_msg.get(), buf.get()); | 1873 WriteStunMessage(in_msg.get(), buf.get()); |
1878 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, | 1874 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, |
1879 &username)); | 1875 &username)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, | 1920 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, |
1925 &username)); | 1921 &username)); |
1926 EXPECT_TRUE(out_msg.get() == NULL); | 1922 EXPECT_TRUE(out_msg.get() == NULL); |
1927 EXPECT_EQ("", username); | 1923 EXPECT_EQ("", username); |
1928 EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); | 1924 EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); |
1929 } | 1925 } |
1930 | 1926 |
1931 // Test handling STUN messages with missing or malformed M-I. | 1927 // Test handling STUN messages with missing or malformed M-I. |
1932 TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) { | 1928 TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) { |
1933 // Our port will act as the "remote" port. | 1929 // Our port will act as the "remote" port. |
1934 rtc::scoped_ptr<TestPort> port( | 1930 std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
1935 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | |
1936 | 1931 |
1937 rtc::scoped_ptr<IceMessage> in_msg, out_msg; | 1932 std::unique_ptr<IceMessage> in_msg, out_msg; |
1938 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); | 1933 std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); |
1939 rtc::SocketAddress addr(kLocalAddr1); | 1934 rtc::SocketAddress addr(kLocalAddr1); |
1940 std::string username; | 1935 std::string username; |
1941 | 1936 |
1942 // BINDING-REQUEST from local to remote with valid ICE username and | 1937 // BINDING-REQUEST from local to remote with valid ICE username and |
1943 // FINGERPRINT, but no MESSAGE-INTEGRITY. | 1938 // FINGERPRINT, but no MESSAGE-INTEGRITY. |
1944 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, | 1939 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, |
1945 "rfrag:lfrag")); | 1940 "rfrag:lfrag")); |
1946 in_msg->AddFingerprint(); | 1941 in_msg->AddFingerprint(); |
1947 WriteStunMessage(in_msg.get(), buf.get()); | 1942 WriteStunMessage(in_msg.get(), buf.get()); |
1948 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, | 1943 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, |
(...skipping 16 matching lines...) Expand all Loading... |
1965 EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); | 1960 EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); |
1966 | 1961 |
1967 // TODO: BINDING-RESPONSES and BINDING-ERROR-RESPONSES are checked | 1962 // TODO: BINDING-RESPONSES and BINDING-ERROR-RESPONSES are checked |
1968 // by the Connection, not the Port, since they require the remote username. | 1963 // by the Connection, not the Port, since they require the remote username. |
1969 // Change this test to pass in data via Connection::OnReadPacket instead. | 1964 // Change this test to pass in data via Connection::OnReadPacket instead. |
1970 } | 1965 } |
1971 | 1966 |
1972 // Test handling STUN messages with missing or malformed FINGERPRINT. | 1967 // Test handling STUN messages with missing or malformed FINGERPRINT. |
1973 TEST_F(PortTest, TestHandleStunMessageBadFingerprint) { | 1968 TEST_F(PortTest, TestHandleStunMessageBadFingerprint) { |
1974 // Our port will act as the "remote" port. | 1969 // Our port will act as the "remote" port. |
1975 rtc::scoped_ptr<TestPort> port( | 1970 std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
1976 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | |
1977 | 1971 |
1978 rtc::scoped_ptr<IceMessage> in_msg, out_msg; | 1972 std::unique_ptr<IceMessage> in_msg, out_msg; |
1979 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); | 1973 std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); |
1980 rtc::SocketAddress addr(kLocalAddr1); | 1974 rtc::SocketAddress addr(kLocalAddr1); |
1981 std::string username; | 1975 std::string username; |
1982 | 1976 |
1983 // BINDING-REQUEST from local to remote with valid ICE username and | 1977 // BINDING-REQUEST from local to remote with valid ICE username and |
1984 // MESSAGE-INTEGRITY, but no FINGERPRINT; GetStunMessage should fail. | 1978 // MESSAGE-INTEGRITY, but no FINGERPRINT; GetStunMessage should fail. |
1985 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, | 1979 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, |
1986 "rfrag:lfrag")); | 1980 "rfrag:lfrag")); |
1987 in_msg->AddMessageIntegrity("rpass"); | 1981 in_msg->AddMessageIntegrity("rpass"); |
1988 WriteStunMessage(in_msg.get(), buf.get()); | 1982 WriteStunMessage(in_msg.get(), buf.get()); |
1989 EXPECT_FALSE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, | 1983 EXPECT_FALSE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 in_msg->SetTransactionID("TESTTESTBADD"); | 2025 in_msg->SetTransactionID("TESTTESTBADD"); |
2032 WriteStunMessage(in_msg.get(), buf.get()); | 2026 WriteStunMessage(in_msg.get(), buf.get()); |
2033 EXPECT_FALSE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, | 2027 EXPECT_FALSE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, |
2034 &username)); | 2028 &username)); |
2035 EXPECT_EQ(0, port->last_stun_error_code()); | 2029 EXPECT_EQ(0, port->last_stun_error_code()); |
2036 } | 2030 } |
2037 | 2031 |
2038 // Test handling of STUN binding indication messages . STUN binding | 2032 // Test handling of STUN binding indication messages . STUN binding |
2039 // indications are allowed only to the connection which is in read mode. | 2033 // indications are allowed only to the connection which is in read mode. |
2040 TEST_F(PortTest, TestHandleStunBindingIndication) { | 2034 TEST_F(PortTest, TestHandleStunBindingIndication) { |
2041 rtc::scoped_ptr<TestPort> lport( | 2035 std::unique_ptr<TestPort> lport( |
2042 CreateTestPort(kLocalAddr2, "lfrag", "lpass")); | 2036 CreateTestPort(kLocalAddr2, "lfrag", "lpass")); |
2043 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); | 2037 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); |
2044 lport->SetIceTiebreaker(kTiebreaker1); | 2038 lport->SetIceTiebreaker(kTiebreaker1); |
2045 | 2039 |
2046 // Verifying encoding and decoding STUN indication message. | 2040 // Verifying encoding and decoding STUN indication message. |
2047 rtc::scoped_ptr<IceMessage> in_msg, out_msg; | 2041 std::unique_ptr<IceMessage> in_msg, out_msg; |
2048 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); | 2042 std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); |
2049 rtc::SocketAddress addr(kLocalAddr1); | 2043 rtc::SocketAddress addr(kLocalAddr1); |
2050 std::string username; | 2044 std::string username; |
2051 | 2045 |
2052 in_msg.reset(CreateStunMessage(STUN_BINDING_INDICATION)); | 2046 in_msg.reset(CreateStunMessage(STUN_BINDING_INDICATION)); |
2053 in_msg->AddFingerprint(); | 2047 in_msg->AddFingerprint(); |
2054 WriteStunMessage(in_msg.get(), buf.get()); | 2048 WriteStunMessage(in_msg.get(), buf.get()); |
2055 EXPECT_TRUE(lport->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, | 2049 EXPECT_TRUE(lport->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, |
2056 &username)); | 2050 &username)); |
2057 EXPECT_TRUE(out_msg.get() != NULL); | 2051 EXPECT_TRUE(out_msg.get() != NULL); |
2058 EXPECT_EQ(out_msg->type(), STUN_BINDING_INDICATION); | 2052 EXPECT_EQ(out_msg->type(), STUN_BINDING_INDICATION); |
2059 EXPECT_EQ("", username); | 2053 EXPECT_EQ("", username); |
2060 | 2054 |
2061 // Verify connection can handle STUN indication and updates | 2055 // Verify connection can handle STUN indication and updates |
2062 // last_ping_received. | 2056 // last_ping_received. |
2063 rtc::scoped_ptr<TestPort> rport( | 2057 std::unique_ptr<TestPort> rport( |
2064 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | 2058 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
2065 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); | 2059 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); |
2066 rport->SetIceTiebreaker(kTiebreaker2); | 2060 rport->SetIceTiebreaker(kTiebreaker2); |
2067 | 2061 |
2068 lport->PrepareAddress(); | 2062 lport->PrepareAddress(); |
2069 rport->PrepareAddress(); | 2063 rport->PrepareAddress(); |
2070 ASSERT_FALSE(lport->Candidates().empty()); | 2064 ASSERT_FALSE(lport->Candidates().empty()); |
2071 ASSERT_FALSE(rport->Candidates().empty()); | 2065 ASSERT_FALSE(rport->Candidates().empty()); |
2072 | 2066 |
2073 Connection* lconn = lport->CreateConnection(rport->Candidates()[0], | 2067 Connection* lconn = lport->CreateConnection(rport->Candidates()[0], |
(...skipping 15 matching lines...) Expand all Loading... |
2089 | 2083 |
2090 // Adding a delay of 100ms. | 2084 // Adding a delay of 100ms. |
2091 rtc::Thread::Current()->ProcessMessages(100); | 2085 rtc::Thread::Current()->ProcessMessages(100); |
2092 // Pinging lconn using stun indication message. | 2086 // Pinging lconn using stun indication message. |
2093 lconn->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime()); | 2087 lconn->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime()); |
2094 int64_t last_ping_received2 = lconn->last_ping_received(); | 2088 int64_t last_ping_received2 = lconn->last_ping_received(); |
2095 EXPECT_GT(last_ping_received2, last_ping_received1); | 2089 EXPECT_GT(last_ping_received2, last_ping_received1); |
2096 } | 2090 } |
2097 | 2091 |
2098 TEST_F(PortTest, TestComputeCandidatePriority) { | 2092 TEST_F(PortTest, TestComputeCandidatePriority) { |
2099 rtc::scoped_ptr<TestPort> port( | 2093 std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr1, "name", "pass")); |
2100 CreateTestPort(kLocalAddr1, "name", "pass")); | |
2101 port->set_type_preference(90); | 2094 port->set_type_preference(90); |
2102 port->set_component(177); | 2095 port->set_component(177); |
2103 port->AddCandidateAddress(SocketAddress("192.168.1.4", 1234)); | 2096 port->AddCandidateAddress(SocketAddress("192.168.1.4", 1234)); |
2104 port->AddCandidateAddress(SocketAddress("2001:db8::1234", 1234)); | 2097 port->AddCandidateAddress(SocketAddress("2001:db8::1234", 1234)); |
2105 port->AddCandidateAddress(SocketAddress("fc12:3456::1234", 1234)); | 2098 port->AddCandidateAddress(SocketAddress("fc12:3456::1234", 1234)); |
2106 port->AddCandidateAddress(SocketAddress("::ffff:192.168.1.4", 1234)); | 2099 port->AddCandidateAddress(SocketAddress("::ffff:192.168.1.4", 1234)); |
2107 port->AddCandidateAddress(SocketAddress("::192.168.1.4", 1234)); | 2100 port->AddCandidateAddress(SocketAddress("::192.168.1.4", 1234)); |
2108 port->AddCandidateAddress(SocketAddress("2002::1234:5678", 1234)); | 2101 port->AddCandidateAddress(SocketAddress("2002::1234:5678", 1234)); |
2109 port->AddCandidateAddress(SocketAddress("2001::1234:5678", 1234)); | 2102 port->AddCandidateAddress(SocketAddress("2001::1234:5678", 1234)); |
2110 port->AddCandidateAddress(SocketAddress("fecf::1234:5678", 1234)); | 2103 port->AddCandidateAddress(SocketAddress("fecf::1234:5678", 1234)); |
(...skipping 16 matching lines...) Expand all Loading... |
2127 ASSERT_EQ(expected_priority_v4compat, port->Candidates()[4].priority()); | 2120 ASSERT_EQ(expected_priority_v4compat, port->Candidates()[4].priority()); |
2128 ASSERT_EQ(expected_priority_6to4, port->Candidates()[5].priority()); | 2121 ASSERT_EQ(expected_priority_6to4, port->Candidates()[5].priority()); |
2129 ASSERT_EQ(expected_priority_teredo, port->Candidates()[6].priority()); | 2122 ASSERT_EQ(expected_priority_teredo, port->Candidates()[6].priority()); |
2130 ASSERT_EQ(expected_priority_sitelocal, port->Candidates()[7].priority()); | 2123 ASSERT_EQ(expected_priority_sitelocal, port->Candidates()[7].priority()); |
2131 ASSERT_EQ(expected_priority_6bone, port->Candidates()[8].priority()); | 2124 ASSERT_EQ(expected_priority_6bone, port->Candidates()[8].priority()); |
2132 } | 2125 } |
2133 | 2126 |
2134 // In the case of shared socket, one port may be shared by local and stun. | 2127 // In the case of shared socket, one port may be shared by local and stun. |
2135 // Test that candidates with different types will have different foundation. | 2128 // Test that candidates with different types will have different foundation. |
2136 TEST_F(PortTest, TestFoundation) { | 2129 TEST_F(PortTest, TestFoundation) { |
2137 rtc::scoped_ptr<TestPort> testport( | 2130 std::unique_ptr<TestPort> testport( |
2138 CreateTestPort(kLocalAddr1, "name", "pass")); | 2131 CreateTestPort(kLocalAddr1, "name", "pass")); |
2139 testport->AddCandidateAddress(kLocalAddr1, kLocalAddr1, | 2132 testport->AddCandidateAddress(kLocalAddr1, kLocalAddr1, |
2140 LOCAL_PORT_TYPE, | 2133 LOCAL_PORT_TYPE, |
2141 cricket::ICE_TYPE_PREFERENCE_HOST, false); | 2134 cricket::ICE_TYPE_PREFERENCE_HOST, false); |
2142 testport->AddCandidateAddress(kLocalAddr2, kLocalAddr1, | 2135 testport->AddCandidateAddress(kLocalAddr2, kLocalAddr1, |
2143 STUN_PORT_TYPE, | 2136 STUN_PORT_TYPE, |
2144 cricket::ICE_TYPE_PREFERENCE_SRFLX, true); | 2137 cricket::ICE_TYPE_PREFERENCE_SRFLX, true); |
2145 EXPECT_NE(testport->Candidates()[0].foundation(), | 2138 EXPECT_NE(testport->Candidates()[0].foundation(), |
2146 testport->Candidates()[1].foundation()); | 2139 testport->Candidates()[1].foundation()); |
2147 } | 2140 } |
2148 | 2141 |
2149 // This test verifies the foundation of different types of ICE candidates. | 2142 // This test verifies the foundation of different types of ICE candidates. |
2150 TEST_F(PortTest, TestCandidateFoundation) { | 2143 TEST_F(PortTest, TestCandidateFoundation) { |
2151 rtc::scoped_ptr<rtc::NATServer> nat_server( | 2144 std::unique_ptr<rtc::NATServer> nat_server( |
2152 CreateNatServer(kNatAddr1, NAT_OPEN_CONE)); | 2145 CreateNatServer(kNatAddr1, NAT_OPEN_CONE)); |
2153 rtc::scoped_ptr<UDPPort> udpport1(CreateUdpPort(kLocalAddr1)); | 2146 std::unique_ptr<UDPPort> udpport1(CreateUdpPort(kLocalAddr1)); |
2154 udpport1->PrepareAddress(); | 2147 udpport1->PrepareAddress(); |
2155 rtc::scoped_ptr<UDPPort> udpport2(CreateUdpPort(kLocalAddr1)); | 2148 std::unique_ptr<UDPPort> udpport2(CreateUdpPort(kLocalAddr1)); |
2156 udpport2->PrepareAddress(); | 2149 udpport2->PrepareAddress(); |
2157 EXPECT_EQ(udpport1->Candidates()[0].foundation(), | 2150 EXPECT_EQ(udpport1->Candidates()[0].foundation(), |
2158 udpport2->Candidates()[0].foundation()); | 2151 udpport2->Candidates()[0].foundation()); |
2159 rtc::scoped_ptr<TCPPort> tcpport1(CreateTcpPort(kLocalAddr1)); | 2152 std::unique_ptr<TCPPort> tcpport1(CreateTcpPort(kLocalAddr1)); |
2160 tcpport1->PrepareAddress(); | 2153 tcpport1->PrepareAddress(); |
2161 rtc::scoped_ptr<TCPPort> tcpport2(CreateTcpPort(kLocalAddr1)); | 2154 std::unique_ptr<TCPPort> tcpport2(CreateTcpPort(kLocalAddr1)); |
2162 tcpport2->PrepareAddress(); | 2155 tcpport2->PrepareAddress(); |
2163 EXPECT_EQ(tcpport1->Candidates()[0].foundation(), | 2156 EXPECT_EQ(tcpport1->Candidates()[0].foundation(), |
2164 tcpport2->Candidates()[0].foundation()); | 2157 tcpport2->Candidates()[0].foundation()); |
2165 rtc::scoped_ptr<Port> stunport( | 2158 std::unique_ptr<Port> stunport( |
2166 CreateStunPort(kLocalAddr1, nat_socket_factory1())); | 2159 CreateStunPort(kLocalAddr1, nat_socket_factory1())); |
2167 stunport->PrepareAddress(); | 2160 stunport->PrepareAddress(); |
2168 ASSERT_EQ_WAIT(1U, stunport->Candidates().size(), kTimeout); | 2161 ASSERT_EQ_WAIT(1U, stunport->Candidates().size(), kTimeout); |
2169 EXPECT_NE(tcpport1->Candidates()[0].foundation(), | 2162 EXPECT_NE(tcpport1->Candidates()[0].foundation(), |
2170 stunport->Candidates()[0].foundation()); | 2163 stunport->Candidates()[0].foundation()); |
2171 EXPECT_NE(tcpport2->Candidates()[0].foundation(), | 2164 EXPECT_NE(tcpport2->Candidates()[0].foundation(), |
2172 stunport->Candidates()[0].foundation()); | 2165 stunport->Candidates()[0].foundation()); |
2173 EXPECT_NE(udpport1->Candidates()[0].foundation(), | 2166 EXPECT_NE(udpport1->Candidates()[0].foundation(), |
2174 stunport->Candidates()[0].foundation()); | 2167 stunport->Candidates()[0].foundation()); |
2175 EXPECT_NE(udpport2->Candidates()[0].foundation(), | 2168 EXPECT_NE(udpport2->Candidates()[0].foundation(), |
2176 stunport->Candidates()[0].foundation()); | 2169 stunport->Candidates()[0].foundation()); |
2177 // Verify GTURN candidate foundation. | 2170 // Verify GTURN candidate foundation. |
2178 rtc::scoped_ptr<RelayPort> relayport( | 2171 std::unique_ptr<RelayPort> relayport(CreateGturnPort(kLocalAddr1)); |
2179 CreateGturnPort(kLocalAddr1)); | |
2180 relayport->AddServerAddress( | 2172 relayport->AddServerAddress( |
2181 cricket::ProtocolAddress(kRelayUdpIntAddr, cricket::PROTO_UDP)); | 2173 cricket::ProtocolAddress(kRelayUdpIntAddr, cricket::PROTO_UDP)); |
2182 relayport->PrepareAddress(); | 2174 relayport->PrepareAddress(); |
2183 ASSERT_EQ_WAIT(1U, relayport->Candidates().size(), kTimeout); | 2175 ASSERT_EQ_WAIT(1U, relayport->Candidates().size(), kTimeout); |
2184 EXPECT_NE(udpport1->Candidates()[0].foundation(), | 2176 EXPECT_NE(udpport1->Candidates()[0].foundation(), |
2185 relayport->Candidates()[0].foundation()); | 2177 relayport->Candidates()[0].foundation()); |
2186 EXPECT_NE(udpport2->Candidates()[0].foundation(), | 2178 EXPECT_NE(udpport2->Candidates()[0].foundation(), |
2187 relayport->Candidates()[0].foundation()); | 2179 relayport->Candidates()[0].foundation()); |
2188 // Verifying TURN candidate foundation. | 2180 // Verifying TURN candidate foundation. |
2189 rtc::scoped_ptr<Port> turnport1(CreateTurnPort( | 2181 std::unique_ptr<Port> turnport1( |
2190 kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); | 2182 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); |
2191 turnport1->PrepareAddress(); | 2183 turnport1->PrepareAddress(); |
2192 ASSERT_EQ_WAIT(1U, turnport1->Candidates().size(), kTimeout); | 2184 ASSERT_EQ_WAIT(1U, turnport1->Candidates().size(), kTimeout); |
2193 EXPECT_NE(udpport1->Candidates()[0].foundation(), | 2185 EXPECT_NE(udpport1->Candidates()[0].foundation(), |
2194 turnport1->Candidates()[0].foundation()); | 2186 turnport1->Candidates()[0].foundation()); |
2195 EXPECT_NE(udpport2->Candidates()[0].foundation(), | 2187 EXPECT_NE(udpport2->Candidates()[0].foundation(), |
2196 turnport1->Candidates()[0].foundation()); | 2188 turnport1->Candidates()[0].foundation()); |
2197 EXPECT_NE(stunport->Candidates()[0].foundation(), | 2189 EXPECT_NE(stunport->Candidates()[0].foundation(), |
2198 turnport1->Candidates()[0].foundation()); | 2190 turnport1->Candidates()[0].foundation()); |
2199 rtc::scoped_ptr<Port> turnport2(CreateTurnPort( | 2191 std::unique_ptr<Port> turnport2( |
2200 kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); | 2192 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); |
2201 turnport2->PrepareAddress(); | 2193 turnport2->PrepareAddress(); |
2202 ASSERT_EQ_WAIT(1U, turnport2->Candidates().size(), kTimeout); | 2194 ASSERT_EQ_WAIT(1U, turnport2->Candidates().size(), kTimeout); |
2203 EXPECT_EQ(turnport1->Candidates()[0].foundation(), | 2195 EXPECT_EQ(turnport1->Candidates()[0].foundation(), |
2204 turnport2->Candidates()[0].foundation()); | 2196 turnport2->Candidates()[0].foundation()); |
2205 | 2197 |
2206 // Running a second turn server, to get different base IP address. | 2198 // Running a second turn server, to get different base IP address. |
2207 SocketAddress kTurnUdpIntAddr2("99.99.98.4", STUN_SERVER_PORT); | 2199 SocketAddress kTurnUdpIntAddr2("99.99.98.4", STUN_SERVER_PORT); |
2208 SocketAddress kTurnUdpExtAddr2("99.99.98.5", 0); | 2200 SocketAddress kTurnUdpExtAddr2("99.99.98.5", 0); |
2209 TestTurnServer turn_server2( | 2201 TestTurnServer turn_server2( |
2210 rtc::Thread::Current(), kTurnUdpIntAddr2, kTurnUdpExtAddr2); | 2202 rtc::Thread::Current(), kTurnUdpIntAddr2, kTurnUdpExtAddr2); |
2211 rtc::scoped_ptr<Port> turnport3(CreateTurnPort( | 2203 std::unique_ptr<Port> turnport3( |
2212 kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP, | 2204 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP, |
2213 kTurnUdpIntAddr2)); | 2205 kTurnUdpIntAddr2)); |
2214 turnport3->PrepareAddress(); | 2206 turnport3->PrepareAddress(); |
2215 ASSERT_EQ_WAIT(1U, turnport3->Candidates().size(), kTimeout); | 2207 ASSERT_EQ_WAIT(1U, turnport3->Candidates().size(), kTimeout); |
2216 EXPECT_NE(turnport3->Candidates()[0].foundation(), | 2208 EXPECT_NE(turnport3->Candidates()[0].foundation(), |
2217 turnport2->Candidates()[0].foundation()); | 2209 turnport2->Candidates()[0].foundation()); |
2218 | 2210 |
2219 // Start a TCP turn server, and check that two turn candidates have | 2211 // Start a TCP turn server, and check that two turn candidates have |
2220 // different foundations if their relay protocols are different. | 2212 // different foundations if their relay protocols are different. |
2221 TestTurnServer turn_server3(rtc::Thread::Current(), kTurnTcpIntAddr, | 2213 TestTurnServer turn_server3(rtc::Thread::Current(), kTurnTcpIntAddr, |
2222 kTurnUdpExtAddr, PROTO_TCP); | 2214 kTurnUdpExtAddr, PROTO_TCP); |
2223 rtc::scoped_ptr<Port> turnport4( | 2215 std::unique_ptr<Port> turnport4( |
2224 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_TCP, PROTO_UDP)); | 2216 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_TCP, PROTO_UDP)); |
2225 turnport4->PrepareAddress(); | 2217 turnport4->PrepareAddress(); |
2226 ASSERT_EQ_WAIT(1U, turnport4->Candidates().size(), kTimeout); | 2218 ASSERT_EQ_WAIT(1U, turnport4->Candidates().size(), kTimeout); |
2227 EXPECT_NE(turnport2->Candidates()[0].foundation(), | 2219 EXPECT_NE(turnport2->Candidates()[0].foundation(), |
2228 turnport4->Candidates()[0].foundation()); | 2220 turnport4->Candidates()[0].foundation()); |
2229 } | 2221 } |
2230 | 2222 |
2231 // This test verifies the related addresses of different types of | 2223 // This test verifies the related addresses of different types of |
2232 // ICE candiates. | 2224 // ICE candiates. |
2233 TEST_F(PortTest, TestCandidateRelatedAddress) { | 2225 TEST_F(PortTest, TestCandidateRelatedAddress) { |
2234 rtc::scoped_ptr<rtc::NATServer> nat_server( | 2226 std::unique_ptr<rtc::NATServer> nat_server( |
2235 CreateNatServer(kNatAddr1, NAT_OPEN_CONE)); | 2227 CreateNatServer(kNatAddr1, NAT_OPEN_CONE)); |
2236 rtc::scoped_ptr<UDPPort> udpport(CreateUdpPort(kLocalAddr1)); | 2228 std::unique_ptr<UDPPort> udpport(CreateUdpPort(kLocalAddr1)); |
2237 udpport->PrepareAddress(); | 2229 udpport->PrepareAddress(); |
2238 // For UDPPort, related address will be empty. | 2230 // For UDPPort, related address will be empty. |
2239 EXPECT_TRUE(udpport->Candidates()[0].related_address().IsNil()); | 2231 EXPECT_TRUE(udpport->Candidates()[0].related_address().IsNil()); |
2240 // Testing related address for stun candidates. | 2232 // Testing related address for stun candidates. |
2241 // For stun candidate related address must be equal to the base | 2233 // For stun candidate related address must be equal to the base |
2242 // socket address. | 2234 // socket address. |
2243 rtc::scoped_ptr<StunPort> stunport( | 2235 std::unique_ptr<StunPort> stunport( |
2244 CreateStunPort(kLocalAddr1, nat_socket_factory1())); | 2236 CreateStunPort(kLocalAddr1, nat_socket_factory1())); |
2245 stunport->PrepareAddress(); | 2237 stunport->PrepareAddress(); |
2246 ASSERT_EQ_WAIT(1U, stunport->Candidates().size(), kTimeout); | 2238 ASSERT_EQ_WAIT(1U, stunport->Candidates().size(), kTimeout); |
2247 // Check STUN candidate address. | 2239 // Check STUN candidate address. |
2248 EXPECT_EQ(stunport->Candidates()[0].address().ipaddr(), | 2240 EXPECT_EQ(stunport->Candidates()[0].address().ipaddr(), |
2249 kNatAddr1.ipaddr()); | 2241 kNatAddr1.ipaddr()); |
2250 // Check STUN candidate related address. | 2242 // Check STUN candidate related address. |
2251 EXPECT_EQ(stunport->Candidates()[0].related_address(), | 2243 EXPECT_EQ(stunport->Candidates()[0].related_address(), |
2252 stunport->GetLocalAddress()); | 2244 stunport->GetLocalAddress()); |
2253 // Verifying the related address for the GTURN candidates. | 2245 // Verifying the related address for the GTURN candidates. |
2254 // NOTE: In case of GTURN related address will be equal to the mapped | 2246 // NOTE: In case of GTURN related address will be equal to the mapped |
2255 // address, but address(mapped) will not be XOR. | 2247 // address, but address(mapped) will not be XOR. |
2256 rtc::scoped_ptr<RelayPort> relayport( | 2248 std::unique_ptr<RelayPort> relayport(CreateGturnPort(kLocalAddr1)); |
2257 CreateGturnPort(kLocalAddr1)); | |
2258 relayport->AddServerAddress( | 2249 relayport->AddServerAddress( |
2259 cricket::ProtocolAddress(kRelayUdpIntAddr, cricket::PROTO_UDP)); | 2250 cricket::ProtocolAddress(kRelayUdpIntAddr, cricket::PROTO_UDP)); |
2260 relayport->PrepareAddress(); | 2251 relayport->PrepareAddress(); |
2261 ASSERT_EQ_WAIT(1U, relayport->Candidates().size(), kTimeout); | 2252 ASSERT_EQ_WAIT(1U, relayport->Candidates().size(), kTimeout); |
2262 // For Gturn related address is set to "0.0.0.0:0" | 2253 // For Gturn related address is set to "0.0.0.0:0" |
2263 EXPECT_EQ(rtc::SocketAddress(), | 2254 EXPECT_EQ(rtc::SocketAddress(), |
2264 relayport->Candidates()[0].related_address()); | 2255 relayport->Candidates()[0].related_address()); |
2265 // Verifying the related address for TURN candidate. | 2256 // Verifying the related address for TURN candidate. |
2266 // For TURN related address must be equal to the mapped address. | 2257 // For TURN related address must be equal to the mapped address. |
2267 rtc::scoped_ptr<Port> turnport(CreateTurnPort( | 2258 std::unique_ptr<Port> turnport( |
2268 kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); | 2259 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); |
2269 turnport->PrepareAddress(); | 2260 turnport->PrepareAddress(); |
2270 ASSERT_EQ_WAIT(1U, turnport->Candidates().size(), kTimeout); | 2261 ASSERT_EQ_WAIT(1U, turnport->Candidates().size(), kTimeout); |
2271 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), | 2262 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), |
2272 turnport->Candidates()[0].address().ipaddr()); | 2263 turnport->Candidates()[0].address().ipaddr()); |
2273 EXPECT_EQ(kNatAddr1.ipaddr(), | 2264 EXPECT_EQ(kNatAddr1.ipaddr(), |
2274 turnport->Candidates()[0].related_address().ipaddr()); | 2265 turnport->Candidates()[0].related_address().ipaddr()); |
2275 } | 2266 } |
2276 | 2267 |
2277 // Test priority value overflow handling when preference is set to 3. | 2268 // Test priority value overflow handling when preference is set to 3. |
2278 TEST_F(PortTest, TestCandidatePriority) { | 2269 TEST_F(PortTest, TestCandidatePriority) { |
2279 cricket::Candidate cand1; | 2270 cricket::Candidate cand1; |
2280 cand1.set_priority(3); | 2271 cand1.set_priority(3); |
2281 cricket::Candidate cand2; | 2272 cricket::Candidate cand2; |
2282 cand2.set_priority(1); | 2273 cand2.set_priority(1); |
2283 EXPECT_TRUE(cand1.priority() > cand2.priority()); | 2274 EXPECT_TRUE(cand1.priority() > cand2.priority()); |
2284 } | 2275 } |
2285 | 2276 |
2286 // Test the Connection priority is calculated correctly. | 2277 // Test the Connection priority is calculated correctly. |
2287 TEST_F(PortTest, TestConnectionPriority) { | 2278 TEST_F(PortTest, TestConnectionPriority) { |
2288 rtc::scoped_ptr<TestPort> lport( | 2279 std::unique_ptr<TestPort> lport( |
2289 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); | 2280 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); |
2290 lport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_HOST); | 2281 lport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_HOST); |
2291 rtc::scoped_ptr<TestPort> rport( | 2282 std::unique_ptr<TestPort> rport( |
2292 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | 2283 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
2293 rport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_RELAY); | 2284 rport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_RELAY); |
2294 lport->set_component(123); | 2285 lport->set_component(123); |
2295 lport->AddCandidateAddress(SocketAddress("192.168.1.4", 1234)); | 2286 lport->AddCandidateAddress(SocketAddress("192.168.1.4", 1234)); |
2296 rport->set_component(23); | 2287 rport->set_component(23); |
2297 rport->AddCandidateAddress(SocketAddress("10.1.1.100", 1234)); | 2288 rport->AddCandidateAddress(SocketAddress("10.1.1.100", 1234)); |
2298 | 2289 |
2299 EXPECT_EQ(0x7E001E85U, lport->Candidates()[0].priority()); | 2290 EXPECT_EQ(0x7E001E85U, lport->Candidates()[0].priority()); |
2300 EXPECT_EQ(0x2001EE9U, rport->Candidates()[0].priority()); | 2291 EXPECT_EQ(0x2001EE9U, rport->Candidates()[0].priority()); |
2301 | 2292 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2421 | 2412 |
2422 // This test verifies the connection setup between ICEMODE_FULL | 2413 // This test verifies the connection setup between ICEMODE_FULL |
2423 // and ICEMODE_LITE. | 2414 // and ICEMODE_LITE. |
2424 // In this test |ch1| behaves like FULL mode client and we have created | 2415 // In this test |ch1| behaves like FULL mode client and we have created |
2425 // port which responds to the ping message just like LITE client. | 2416 // port which responds to the ping message just like LITE client. |
2426 TEST_F(PortTest, TestIceLiteConnectivity) { | 2417 TEST_F(PortTest, TestIceLiteConnectivity) { |
2427 TestPort* ice_full_port = CreateTestPort( | 2418 TestPort* ice_full_port = CreateTestPort( |
2428 kLocalAddr1, "lfrag", "lpass", | 2419 kLocalAddr1, "lfrag", "lpass", |
2429 cricket::ICEROLE_CONTROLLING, kTiebreaker1); | 2420 cricket::ICEROLE_CONTROLLING, kTiebreaker1); |
2430 | 2421 |
2431 rtc::scoped_ptr<TestPort> ice_lite_port(CreateTestPort( | 2422 std::unique_ptr<TestPort> ice_lite_port( |
2432 kLocalAddr2, "rfrag", "rpass", | 2423 CreateTestPort(kLocalAddr2, "rfrag", "rpass", cricket::ICEROLE_CONTROLLED, |
2433 cricket::ICEROLE_CONTROLLED, kTiebreaker2)); | 2424 kTiebreaker2)); |
2434 // Setup TestChannel. This behaves like FULL mode client. | 2425 // Setup TestChannel. This behaves like FULL mode client. |
2435 TestChannel ch1(ice_full_port); | 2426 TestChannel ch1(ice_full_port); |
2436 ch1.SetIceMode(ICEMODE_FULL); | 2427 ch1.SetIceMode(ICEMODE_FULL); |
2437 | 2428 |
2438 // Start gathering candidates. | 2429 // Start gathering candidates. |
2439 ch1.Start(); | 2430 ch1.Start(); |
2440 ice_lite_port->PrepareAddress(); | 2431 ice_lite_port->PrepareAddress(); |
2441 | 2432 |
2442 ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout); | 2433 ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout); |
2443 ASSERT_FALSE(ice_lite_port->Candidates().empty()); | 2434 ASSERT_FALSE(ice_lite_port->Candidates().empty()); |
(...skipping 11 matching lines...) Expand all Loading... |
2455 ASSERT_TRUE_WAIT(ice_full_port->last_stun_msg() != NULL, 1000); | 2446 ASSERT_TRUE_WAIT(ice_full_port->last_stun_msg() != NULL, 1000); |
2456 IceMessage* msg = ice_full_port->last_stun_msg(); | 2447 IceMessage* msg = ice_full_port->last_stun_msg(); |
2457 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); | 2448 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); |
2458 | 2449 |
2459 // Respond with a BINDING-RESPONSE from litemode client. | 2450 // Respond with a BINDING-RESPONSE from litemode client. |
2460 // NOTE: Ideally we should't create connection at this stage from lite | 2451 // NOTE: Ideally we should't create connection at this stage from lite |
2461 // port, as it should be done only after receiving ping with USE_CANDIDATE. | 2452 // port, as it should be done only after receiving ping with USE_CANDIDATE. |
2462 // But we need a connection to send a response message. | 2453 // But we need a connection to send a response message. |
2463 ice_lite_port->CreateConnection( | 2454 ice_lite_port->CreateConnection( |
2464 ice_full_port->Candidates()[0], cricket::Port::ORIGIN_MESSAGE); | 2455 ice_full_port->Candidates()[0], cricket::Port::ORIGIN_MESSAGE); |
2465 rtc::scoped_ptr<IceMessage> request(CopyStunMessage(msg)); | 2456 std::unique_ptr<IceMessage> request(CopyStunMessage(msg)); |
2466 ice_lite_port->SendBindingResponse( | 2457 ice_lite_port->SendBindingResponse( |
2467 request.get(), ice_full_port->Candidates()[0].address()); | 2458 request.get(), ice_full_port->Candidates()[0].address()); |
2468 | 2459 |
2469 // Feeding the respone message from litemode to the full mode connection. | 2460 // Feeding the respone message from litemode to the full mode connection. |
2470 ch1.conn()->OnReadPacket(ice_lite_port->last_stun_buf()->data<char>(), | 2461 ch1.conn()->OnReadPacket(ice_lite_port->last_stun_buf()->data<char>(), |
2471 ice_lite_port->last_stun_buf()->size(), | 2462 ice_lite_port->last_stun_buf()->size(), |
2472 rtc::PacketTime()); | 2463 rtc::PacketTime()); |
2473 // Verifying full mode connection becomes writable from the response. | 2464 // Verifying full mode connection becomes writable from the response. |
2474 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), | 2465 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), |
2475 kTimeout); | 2466 kTimeout); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2569 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); | 2560 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); |
2570 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); | 2561 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
2571 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); | 2562 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
2572 | 2563 |
2573 // After the connection is destroyed, the port should not be destroyed. | 2564 // After the connection is destroyed, the port should not be destroyed. |
2574 rtc::Thread::Current()->ProcessMessages(kTimeout); | 2565 rtc::Thread::Current()->ProcessMessages(kTimeout); |
2575 EXPECT_FALSE(destroyed()); | 2566 EXPECT_FALSE(destroyed()); |
2576 } | 2567 } |
2577 | 2568 |
2578 TEST_F(PortTest, TestSupportsProtocol) { | 2569 TEST_F(PortTest, TestSupportsProtocol) { |
2579 rtc::scoped_ptr<Port> udp_port(CreateUdpPort(kLocalAddr1)); | 2570 std::unique_ptr<Port> udp_port(CreateUdpPort(kLocalAddr1)); |
2580 EXPECT_TRUE(udp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); | 2571 EXPECT_TRUE(udp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); |
2581 EXPECT_FALSE(udp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); | 2572 EXPECT_FALSE(udp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); |
2582 | 2573 |
2583 rtc::scoped_ptr<Port> stun_port( | 2574 std::unique_ptr<Port> stun_port( |
2584 CreateStunPort(kLocalAddr1, nat_socket_factory1())); | 2575 CreateStunPort(kLocalAddr1, nat_socket_factory1())); |
2585 EXPECT_TRUE(stun_port->SupportsProtocol(UDP_PROTOCOL_NAME)); | 2576 EXPECT_TRUE(stun_port->SupportsProtocol(UDP_PROTOCOL_NAME)); |
2586 EXPECT_FALSE(stun_port->SupportsProtocol(TCP_PROTOCOL_NAME)); | 2577 EXPECT_FALSE(stun_port->SupportsProtocol(TCP_PROTOCOL_NAME)); |
2587 | 2578 |
2588 rtc::scoped_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); | 2579 std::unique_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); |
2589 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); | 2580 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); |
2590 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME)); | 2581 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME)); |
2591 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); | 2582 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); |
2592 | 2583 |
2593 rtc::scoped_ptr<Port> turn_port( | 2584 std::unique_ptr<Port> turn_port( |
2594 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); | 2585 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); |
2595 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME)); | 2586 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME)); |
2596 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME)); | 2587 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME)); |
2597 } | 2588 } |
OLD | NEW |