Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: webrtc/p2p/base/port_unittest.cc

Issue 1821083002: Split ByteBuffer into writer/reader objects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/p2p/base/pseudotcp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webrtc/p2p/base/basicpacketsocketfactory.h" 11 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
12 #include "webrtc/p2p/base/relayport.h" 12 #include "webrtc/p2p/base/relayport.h"
13 #include "webrtc/p2p/base/stunport.h" 13 #include "webrtc/p2p/base/stunport.h"
14 #include "webrtc/p2p/base/tcpport.h" 14 #include "webrtc/p2p/base/tcpport.h"
15 #include "webrtc/p2p/base/testrelayserver.h" 15 #include "webrtc/p2p/base/testrelayserver.h"
16 #include "webrtc/p2p/base/teststunserver.h" 16 #include "webrtc/p2p/base/teststunserver.h"
17 #include "webrtc/p2p/base/testturnserver.h" 17 #include "webrtc/p2p/base/testturnserver.h"
18 #include "webrtc/p2p/base/transport.h" 18 #include "webrtc/p2p/base/transport.h"
19 #include "webrtc/p2p/base/turnport.h" 19 #include "webrtc/p2p/base/turnport.h"
20 #include "webrtc/base/arraysize.h" 20 #include "webrtc/base/arraysize.h"
21 #include "webrtc/base/buffer.h"
21 #include "webrtc/base/crc32.h" 22 #include "webrtc/base/crc32.h"
22 #include "webrtc/base/gunit.h" 23 #include "webrtc/base/gunit.h"
23 #include "webrtc/base/helpers.h" 24 #include "webrtc/base/helpers.h"
24 #include "webrtc/base/logging.h" 25 #include "webrtc/base/logging.h"
25 #include "webrtc/base/natserver.h" 26 #include "webrtc/base/natserver.h"
26 #include "webrtc/base/natsocketfactory.h" 27 #include "webrtc/base/natsocketfactory.h"
27 #include "webrtc/base/physicalsocketserver.h" 28 #include "webrtc/base/physicalsocketserver.h"
28 #include "webrtc/base/scoped_ptr.h" 29 #include "webrtc/base/scoped_ptr.h"
29 #include "webrtc/base/socketaddress.h" 30 #include "webrtc/base/socketaddress.h"
30 #include "webrtc/base/ssladapter.h" 31 #include "webrtc/base/ssladapter.h"
31 #include "webrtc/base/stringutils.h" 32 #include "webrtc/base/stringutils.h"
32 #include "webrtc/base/thread.h" 33 #include "webrtc/base/thread.h"
33 #include "webrtc/base/virtualsocketserver.h" 34 #include "webrtc/base/virtualsocketserver.h"
34 35
35 using rtc::AsyncPacketSocket; 36 using rtc::AsyncPacketSocket;
36 using rtc::ByteBuffer; 37 using rtc::Buffer;
38 using rtc::ByteBufferReader;
39 using rtc::ByteBufferWriter;
37 using rtc::NATType; 40 using rtc::NATType;
38 using rtc::NAT_OPEN_CONE; 41 using rtc::NAT_OPEN_CONE;
39 using rtc::NAT_ADDR_RESTRICTED; 42 using rtc::NAT_ADDR_RESTRICTED;
40 using rtc::NAT_PORT_RESTRICTED; 43 using rtc::NAT_PORT_RESTRICTED;
41 using rtc::NAT_SYMMETRIC; 44 using rtc::NAT_SYMMETRIC;
42 using rtc::PacketSocketFactory; 45 using rtc::PacketSocketFactory;
43 using rtc::scoped_ptr; 46 using rtc::scoped_ptr;
44 using rtc::Socket; 47 using rtc::Socket;
45 using rtc::SocketAddress; 48 using rtc::SocketAddress;
46 using namespace cricket; 49 using namespace cricket;
(...skipping 30 matching lines...) Expand all
77 assert(port->Candidates().size() >= 1); 80 assert(port->Candidates().size() >= 1);
78 return port->Candidates()[0]; 81 return port->Candidates()[0];
79 } 82 }
80 83
81 static SocketAddress GetAddress(Port* port) { 84 static SocketAddress GetAddress(Port* port) {
82 return GetCandidate(port).address(); 85 return GetCandidate(port).address();
83 } 86 }
84 87
85 static IceMessage* CopyStunMessage(const IceMessage* src) { 88 static IceMessage* CopyStunMessage(const IceMessage* src) {
86 IceMessage* dst = new IceMessage(); 89 IceMessage* dst = new IceMessage();
87 ByteBuffer buf; 90 ByteBufferWriter buf;
88 src->Write(&buf); 91 src->Write(&buf);
89 dst->Read(&buf); 92 ByteBufferReader read_buf(buf);
93 dst->Read(&read_buf);
90 return dst; 94 return dst;
91 } 95 }
92 96
93 static bool WriteStunMessage(const StunMessage* msg, ByteBuffer* buf) { 97 static bool WriteStunMessage(const StunMessage* msg, ByteBufferWriter* buf) {
94 buf->Resize(0); // clear out any existing buffer contents 98 buf->Resize(0); // clear out any existing buffer contents
95 return msg->Write(buf); 99 return msg->Write(buf);
96 } 100 }
97 101
98 // Stub port class for testing STUN generation and processing. 102 // Stub port class for testing STUN generation and processing.
99 class TestPort : public Port { 103 class TestPort : public Port {
100 public: 104 public:
101 TestPort(rtc::Thread* thread, 105 TestPort(rtc::Thread* thread,
102 const std::string& type, 106 const std::string& type,
103 rtc::PacketSocketFactory* factory, 107 rtc::PacketSocketFactory* factory,
(...skipping 12 matching lines...) Expand all
116 max_port, 120 max_port,
117 username_fragment, 121 username_fragment,
118 password) {} 122 password) {}
119 ~TestPort() {} 123 ~TestPort() {}
120 124
121 // Expose GetStunMessage so that we can test it. 125 // Expose GetStunMessage so that we can test it.
122 using cricket::Port::GetStunMessage; 126 using cricket::Port::GetStunMessage;
123 127
124 // The last StunMessage that was sent on this Port. 128 // The last StunMessage that was sent on this Port.
125 // TODO: Make these const; requires changes to SendXXXXResponse. 129 // TODO: Make these const; requires changes to SendXXXXResponse.
126 ByteBuffer* last_stun_buf() { return last_stun_buf_.get(); } 130 Buffer* last_stun_buf() { return last_stun_buf_.get(); }
127 IceMessage* last_stun_msg() { return last_stun_msg_.get(); } 131 IceMessage* last_stun_msg() { return last_stun_msg_.get(); }
128 int last_stun_error_code() { 132 int last_stun_error_code() {
129 int code = 0; 133 int code = 0;
130 if (last_stun_msg_) { 134 if (last_stun_msg_) {
131 const StunErrorCodeAttribute* error_attr = last_stun_msg_->GetErrorCode(); 135 const StunErrorCodeAttribute* error_attr = last_stun_msg_->GetErrorCode();
132 if (error_attr) { 136 if (error_attr) {
133 code = error_attr->code(); 137 code = error_attr->code();
134 } 138 }
135 } 139 }
136 return code; 140 return code;
(...skipping 30 matching lines...) Expand all
167 // Set use-candidate attribute flag as this will add USE-CANDIDATE attribute 171 // Set use-candidate attribute flag as this will add USE-CANDIDATE attribute
168 // in STUN binding requests. 172 // in STUN binding requests.
169 conn->set_use_candidate_attr(true); 173 conn->set_use_candidate_attr(true);
170 return conn; 174 return conn;
171 } 175 }
172 virtual int SendTo( 176 virtual int SendTo(
173 const void* data, size_t size, const rtc::SocketAddress& addr, 177 const void* data, size_t size, const rtc::SocketAddress& addr,
174 const rtc::PacketOptions& options, bool payload) { 178 const rtc::PacketOptions& options, bool payload) {
175 if (!payload) { 179 if (!payload) {
176 IceMessage* msg = new IceMessage; 180 IceMessage* msg = new IceMessage;
177 ByteBuffer* buf = new ByteBuffer(static_cast<const char*>(data), size); 181 Buffer* buf = new Buffer(static_cast<const char*>(data), size);
178 ByteBuffer::ReadPosition pos(buf->GetReadPosition()); 182 ByteBufferReader read_buf(*buf);
179 if (!msg->Read(buf)) { 183 if (!msg->Read(&read_buf)) {
180 delete msg; 184 delete msg;
181 delete buf; 185 delete buf;
182 return -1; 186 return -1;
183 } 187 }
184 buf->SetReadPosition(pos);
185 last_stun_buf_.reset(buf); 188 last_stun_buf_.reset(buf);
186 last_stun_msg_.reset(msg); 189 last_stun_msg_.reset(msg);
187 } 190 }
188 return static_cast<int>(size); 191 return static_cast<int>(size);
189 } 192 }
190 virtual int SetOption(rtc::Socket::Option opt, int value) { 193 virtual int SetOption(rtc::Socket::Option opt, int value) {
191 return 0; 194 return 0;
192 } 195 }
193 virtual int GetOption(rtc::Socket::Option opt, int* value) { 196 virtual int GetOption(rtc::Socket::Option opt, int* value) {
194 return -1; 197 return -1;
195 } 198 }
196 virtual int GetError() { 199 virtual int GetError() {
197 return 0; 200 return 0;
198 } 201 }
199 void Reset() { 202 void Reset() {
200 last_stun_buf_.reset(); 203 last_stun_buf_.reset();
201 last_stun_msg_.reset(); 204 last_stun_msg_.reset();
202 } 205 }
203 void set_type_preference(int type_preference) { 206 void set_type_preference(int type_preference) {
204 type_preference_ = type_preference; 207 type_preference_ = type_preference;
205 } 208 }
206 209
207 private: 210 private:
208 void OnSentPacket(rtc::AsyncPacketSocket* socket, 211 void OnSentPacket(rtc::AsyncPacketSocket* socket,
209 const rtc::SentPacket& sent_packet) { 212 const rtc::SentPacket& sent_packet) {
210 PortInterface::SignalSentPacket(sent_packet); 213 PortInterface::SignalSentPacket(sent_packet);
211 } 214 }
212 rtc::scoped_ptr<ByteBuffer> last_stun_buf_; 215 rtc::scoped_ptr<Buffer> last_stun_buf_;
213 rtc::scoped_ptr<IceMessage> last_stun_msg_; 216 rtc::scoped_ptr<IceMessage> last_stun_msg_;
214 int type_preference_ = 0; 217 int type_preference_ = 0;
215 }; 218 };
216 219
217 class TestChannel : public sigslot::has_slots<> { 220 class TestChannel : public sigslot::has_slots<> {
218 public: 221 public:
219 // Takes ownership of |p1| (but not |p2|). 222 // Takes ownership of |p1| (but not |p2|).
220 TestChannel(Port* p1) 223 TestChannel(Port* p1)
221 : ice_mode_(ICEMODE_FULL), 224 : ice_mode_(ICEMODE_FULL),
222 port_(p1), 225 port_(p1),
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 lport->SetIceTiebreaker(kTiebreaker1); 1324 lport->SetIceTiebreaker(kTiebreaker1);
1322 lport->PrepareAddress(); 1325 lport->PrepareAddress();
1323 ASSERT_FALSE(lport->Candidates().empty()); 1326 ASSERT_FALSE(lport->Candidates().empty());
1324 Connection* conn = lport->CreateConnection(lport->Candidates()[0], 1327 Connection* conn = lport->CreateConnection(lport->Candidates()[0],
1325 Port::ORIGIN_MESSAGE); 1328 Port::ORIGIN_MESSAGE);
1326 conn->Ping(0); 1329 conn->Ping(0);
1327 1330
1328 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); 1331 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
1329 IceMessage* msg = lport->last_stun_msg(); 1332 IceMessage* msg = lport->last_stun_msg();
1330 EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); 1333 EXPECT_EQ(STUN_BINDING_REQUEST, msg->type());
1331 conn->OnReadPacket(lport->last_stun_buf()->Data(), 1334 conn->OnReadPacket(lport->last_stun_buf()->data<char>(),
1332 lport->last_stun_buf()->Length(), 1335 lport->last_stun_buf()->size(),
1333 rtc::PacketTime()); 1336 rtc::PacketTime());
1334 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); 1337 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
1335 msg = lport->last_stun_msg(); 1338 msg = lport->last_stun_msg();
1336 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); 1339 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type());
1337 1340
1338 // If the tiebreaker value is different from port, we expect a error 1341 // If the tiebreaker value is different from port, we expect a error
1339 // response. 1342 // response.
1340 lport->Reset(); 1343 lport->Reset();
1341 lport->AddCandidateAddress(kLocalAddr2); 1344 lport->AddCandidateAddress(kLocalAddr2);
1342 // Creating a different connection as |conn| is receiving. 1345 // Creating a different connection as |conn| is receiving.
(...skipping 11 matching lines...) Expand all
1354 modified_req->AddAttribute(new StunByteStringAttribute( 1357 modified_req->AddAttribute(new StunByteStringAttribute(
1355 STUN_ATTR_USERNAME, username_attr->GetString())); 1358 STUN_ATTR_USERNAME, username_attr->GetString()));
1356 // To make sure we receive error response, adding tiebreaker less than 1359 // To make sure we receive error response, adding tiebreaker less than
1357 // what's present in request. 1360 // what's present in request.
1358 modified_req->AddAttribute(new StunUInt64Attribute( 1361 modified_req->AddAttribute(new StunUInt64Attribute(
1359 STUN_ATTR_ICE_CONTROLLING, kTiebreaker1 - 1)); 1362 STUN_ATTR_ICE_CONTROLLING, kTiebreaker1 - 1));
1360 modified_req->AddMessageIntegrity("lpass"); 1363 modified_req->AddMessageIntegrity("lpass");
1361 modified_req->AddFingerprint(); 1364 modified_req->AddFingerprint();
1362 1365
1363 lport->Reset(); 1366 lport->Reset();
1364 rtc::scoped_ptr<ByteBuffer> buf(new ByteBuffer()); 1367 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter());
1365 WriteStunMessage(modified_req.get(), buf.get()); 1368 WriteStunMessage(modified_req.get(), buf.get());
1366 conn1->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime()); 1369 conn1->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime());
1367 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); 1370 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
1368 msg = lport->last_stun_msg(); 1371 msg = lport->last_stun_msg();
1369 EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type()); 1372 EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type());
1370 } 1373 }
1371 1374
1372 // This test verifies role conflict signal is received when there is 1375 // This test verifies role conflict signal is received when there is
1373 // conflict in the role. In this case both ports are in controlling and 1376 // conflict in the role. In this case both ports are in controlling and
1374 // |rport| has higher tiebreaker value than |lport|. Since |lport| has lower 1377 // |rport| has higher tiebreaker value than |lport|. Since |lport| has lower
(...skipping 16 matching lines...) Expand all
1391 Connection* lconn = lport->CreateConnection(rport->Candidates()[0], 1394 Connection* lconn = lport->CreateConnection(rport->Candidates()[0],
1392 Port::ORIGIN_MESSAGE); 1395 Port::ORIGIN_MESSAGE);
1393 Connection* rconn = rport->CreateConnection(lport->Candidates()[0], 1396 Connection* rconn = rport->CreateConnection(lport->Candidates()[0],
1394 Port::ORIGIN_MESSAGE); 1397 Port::ORIGIN_MESSAGE);
1395 rconn->Ping(0); 1398 rconn->Ping(0);
1396 1399
1397 ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, 1000); 1400 ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, 1000);
1398 IceMessage* msg = rport->last_stun_msg(); 1401 IceMessage* msg = rport->last_stun_msg();
1399 EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); 1402 EXPECT_EQ(STUN_BINDING_REQUEST, msg->type());
1400 // Send rport binding request to lport. 1403 // Send rport binding request to lport.
1401 lconn->OnReadPacket(rport->last_stun_buf()->Data(), 1404 lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
1402 rport->last_stun_buf()->Length(), 1405 rport->last_stun_buf()->size(),
1403 rtc::PacketTime()); 1406 rtc::PacketTime());
1404 1407
1405 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); 1408 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
1406 EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); 1409 EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type());
1407 EXPECT_TRUE(role_conflict()); 1410 EXPECT_TRUE(role_conflict());
1408 } 1411 }
1409 1412
1410 TEST_F(PortTest, TestTcpNoDelay) { 1413 TEST_F(PortTest, TestTcpNoDelay) {
1411 TCPPort* port1 = CreateTcpPort(kLocalAddr1); 1414 TCPPort* port1 = CreateTcpPort(kLocalAddr1);
1412 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); 1415 port1->SetIceRole(cricket::ICEROLE_CONTROLLING);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 EXPECT_FALSE(msg->IsLegacy()); 1620 EXPECT_FALSE(msg->IsLegacy());
1618 const StunByteStringAttribute* username_attr = 1621 const StunByteStringAttribute* username_attr =
1619 msg->GetByteString(STUN_ATTR_USERNAME); 1622 msg->GetByteString(STUN_ATTR_USERNAME);
1620 ASSERT_TRUE(username_attr != NULL); 1623 ASSERT_TRUE(username_attr != NULL);
1621 const StunUInt32Attribute* priority_attr = msg->GetUInt32(STUN_ATTR_PRIORITY); 1624 const StunUInt32Attribute* priority_attr = msg->GetUInt32(STUN_ATTR_PRIORITY);
1622 ASSERT_TRUE(priority_attr != NULL); 1625 ASSERT_TRUE(priority_attr != NULL);
1623 EXPECT_EQ(kDefaultPrflxPriority, priority_attr->value()); 1626 EXPECT_EQ(kDefaultPrflxPriority, priority_attr->value());
1624 EXPECT_EQ("rfrag:lfrag", username_attr->GetString()); 1627 EXPECT_EQ("rfrag:lfrag", username_attr->GetString());
1625 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); 1628 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL);
1626 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( 1629 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity(
1627 lport->last_stun_buf()->Data(), lport->last_stun_buf()->Length(), 1630 lport->last_stun_buf()->data<char>(), lport->last_stun_buf()->size(),
1628 "rpass")); 1631 "rpass"));
1629 const StunUInt64Attribute* ice_controlling_attr = 1632 const StunUInt64Attribute* ice_controlling_attr =
1630 msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING); 1633 msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING);
1631 ASSERT_TRUE(ice_controlling_attr != NULL); 1634 ASSERT_TRUE(ice_controlling_attr != NULL);
1632 EXPECT_EQ(lport->IceTiebreaker(), ice_controlling_attr->value()); 1635 EXPECT_EQ(lport->IceTiebreaker(), ice_controlling_attr->value());
1633 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == NULL); 1636 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == NULL);
1634 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != NULL); 1637 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != NULL);
1635 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); 1638 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL);
1636 EXPECT_TRUE(StunMessage::ValidateFingerprint( 1639 EXPECT_TRUE(StunMessage::ValidateFingerprint(
1637 lport->last_stun_buf()->Data(), lport->last_stun_buf()->Length())); 1640 lport->last_stun_buf()->data<char>(), lport->last_stun_buf()->size()));
1638 1641
1639 // Request should not include ping count. 1642 // Request should not include ping count.
1640 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); 1643 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL);
1641 1644
1642 // Save a copy of the BINDING-REQUEST for use below. 1645 // Save a copy of the BINDING-REQUEST for use below.
1643 rtc::scoped_ptr<IceMessage> request(CopyStunMessage(msg)); 1646 rtc::scoped_ptr<IceMessage> request(CopyStunMessage(msg));
1644 1647
1645 // Respond with a BINDING-RESPONSE. 1648 // Respond with a BINDING-RESPONSE.
1646 rport->SendBindingResponse(request.get(), lport->Candidates()[0].address()); 1649 rport->SendBindingResponse(request.get(), lport->Candidates()[0].address());
1647 msg = rport->last_stun_msg(); 1650 msg = rport->last_stun_msg();
1648 ASSERT_TRUE(msg != NULL); 1651 ASSERT_TRUE(msg != NULL);
1649 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); 1652 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type());
1650 1653
1651 1654
1652 EXPECT_FALSE(msg->IsLegacy()); 1655 EXPECT_FALSE(msg->IsLegacy());
1653 const StunAddressAttribute* addr_attr = msg->GetAddress( 1656 const StunAddressAttribute* addr_attr = msg->GetAddress(
1654 STUN_ATTR_XOR_MAPPED_ADDRESS); 1657 STUN_ATTR_XOR_MAPPED_ADDRESS);
1655 ASSERT_TRUE(addr_attr != NULL); 1658 ASSERT_TRUE(addr_attr != NULL);
1656 EXPECT_EQ(lport->Candidates()[0].address(), addr_attr->GetAddress()); 1659 EXPECT_EQ(lport->Candidates()[0].address(), addr_attr->GetAddress());
1657 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); 1660 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL);
1658 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( 1661 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity(
1659 rport->last_stun_buf()->Data(), rport->last_stun_buf()->Length(), 1662 rport->last_stun_buf()->data<char>(), rport->last_stun_buf()->size(),
1660 "rpass")); 1663 "rpass"));
1661 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); 1664 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL);
1662 EXPECT_TRUE(StunMessage::ValidateFingerprint( 1665 EXPECT_TRUE(StunMessage::ValidateFingerprint(
1663 lport->last_stun_buf()->Data(), lport->last_stun_buf()->Length())); 1666 lport->last_stun_buf()->data<char>(), lport->last_stun_buf()->size()));
1664 // No USERNAME or PRIORITY in ICE responses. 1667 // No USERNAME or PRIORITY in ICE responses.
1665 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USERNAME) == NULL); 1668 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USERNAME) == NULL);
1666 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_PRIORITY) == NULL); 1669 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_PRIORITY) == NULL);
1667 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MAPPED_ADDRESS) == NULL); 1670 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MAPPED_ADDRESS) == NULL);
1668 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLING) == NULL); 1671 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLING) == NULL);
1669 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == NULL); 1672 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_ICE_CONTROLLED) == NULL);
1670 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); 1673 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL);
1671 1674
1672 // Response should not include ping count. 1675 // Response should not include ping count.
1673 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); 1676 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL);
1674 1677
1675 // Respond with a BINDING-ERROR-RESPONSE. This wouldn't happen in real life, 1678 // Respond with a BINDING-ERROR-RESPONSE. This wouldn't happen in real life,
1676 // but we can do it here. 1679 // but we can do it here.
1677 rport->SendBindingErrorResponse(request.get(), 1680 rport->SendBindingErrorResponse(request.get(),
1678 lport->Candidates()[0].address(), 1681 lport->Candidates()[0].address(),
1679 STUN_ERROR_SERVER_ERROR, 1682 STUN_ERROR_SERVER_ERROR,
1680 STUN_ERROR_REASON_SERVER_ERROR); 1683 STUN_ERROR_REASON_SERVER_ERROR);
1681 msg = rport->last_stun_msg(); 1684 msg = rport->last_stun_msg();
1682 ASSERT_TRUE(msg != NULL); 1685 ASSERT_TRUE(msg != NULL);
1683 EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type()); 1686 EXPECT_EQ(STUN_BINDING_ERROR_RESPONSE, msg->type());
1684 EXPECT_FALSE(msg->IsLegacy()); 1687 EXPECT_FALSE(msg->IsLegacy());
1685 const StunErrorCodeAttribute* error_attr = msg->GetErrorCode(); 1688 const StunErrorCodeAttribute* error_attr = msg->GetErrorCode();
1686 ASSERT_TRUE(error_attr != NULL); 1689 ASSERT_TRUE(error_attr != NULL);
1687 EXPECT_EQ(STUN_ERROR_SERVER_ERROR, error_attr->code()); 1690 EXPECT_EQ(STUN_ERROR_SERVER_ERROR, error_attr->code());
1688 EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR), error_attr->reason()); 1691 EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR), error_attr->reason());
1689 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); 1692 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL);
1690 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( 1693 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity(
1691 rport->last_stun_buf()->Data(), rport->last_stun_buf()->Length(), 1694 rport->last_stun_buf()->data<char>(), rport->last_stun_buf()->size(),
1692 "rpass")); 1695 "rpass"));
1693 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); 1696 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL);
1694 EXPECT_TRUE(StunMessage::ValidateFingerprint( 1697 EXPECT_TRUE(StunMessage::ValidateFingerprint(
1695 lport->last_stun_buf()->Data(), lport->last_stun_buf()->Length())); 1698 lport->last_stun_buf()->data<char>(), lport->last_stun_buf()->size()));
1696 // No USERNAME with ICE. 1699 // No USERNAME with ICE.
1697 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USERNAME) == NULL); 1700 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USERNAME) == NULL);
1698 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_PRIORITY) == NULL); 1701 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_PRIORITY) == NULL);
1699 1702
1700 // Testing STUN binding requests from rport --> lport, having ICE_CONTROLLED 1703 // Testing STUN binding requests from rport --> lport, having ICE_CONTROLLED
1701 // and (incremented) RETRANSMIT_COUNT attributes. 1704 // and (incremented) RETRANSMIT_COUNT attributes.
1702 rport->Reset(); 1705 rport->Reset();
1703 rport->set_send_retransmit_count_attribute(true); 1706 rport->set_send_retransmit_count_attribute(true);
1704 rconn->Ping(0); 1707 rconn->Ping(0);
1705 rconn->Ping(0); 1708 rconn->Ping(0);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 ASSERT_TRUE(use_candidate_attr != NULL); 1760 ASSERT_TRUE(use_candidate_attr != NULL);
1758 } 1761 }
1759 1762
1760 // Test handling STUN messages. 1763 // Test handling STUN messages.
1761 TEST_F(PortTest, TestHandleStunMessage) { 1764 TEST_F(PortTest, TestHandleStunMessage) {
1762 // Our port will act as the "remote" port. 1765 // Our port will act as the "remote" port.
1763 rtc::scoped_ptr<TestPort> port( 1766 rtc::scoped_ptr<TestPort> port(
1764 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); 1767 CreateTestPort(kLocalAddr2, "rfrag", "rpass"));
1765 1768
1766 rtc::scoped_ptr<IceMessage> in_msg, out_msg; 1769 rtc::scoped_ptr<IceMessage> in_msg, out_msg;
1767 rtc::scoped_ptr<ByteBuffer> buf(new ByteBuffer()); 1770 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter());
1768 rtc::SocketAddress addr(kLocalAddr1); 1771 rtc::SocketAddress addr(kLocalAddr1);
1769 std::string username; 1772 std::string username;
1770 1773
1771 // BINDING-REQUEST from local to remote with valid ICE username, 1774 // BINDING-REQUEST from local to remote with valid ICE username,
1772 // MESSAGE-INTEGRITY, and FINGERPRINT. 1775 // MESSAGE-INTEGRITY, and FINGERPRINT.
1773 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, 1776 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST,
1774 "rfrag:lfrag")); 1777 "rfrag:lfrag"));
1775 in_msg->AddMessageIntegrity("rpass"); 1778 in_msg->AddMessageIntegrity("rpass");
1776 in_msg->AddFingerprint(); 1779 in_msg->AddFingerprint();
1777 WriteStunMessage(in_msg.get(), buf.get()); 1780 WriteStunMessage(in_msg.get(), buf.get());
(...skipping 29 matching lines...) Expand all
1807 EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR), 1810 EXPECT_EQ(std::string(STUN_ERROR_REASON_SERVER_ERROR),
1808 out_msg->GetErrorCode()->reason()); 1811 out_msg->GetErrorCode()->reason());
1809 } 1812 }
1810 1813
1811 // Tests handling of ICE binding requests with missing or incorrect usernames. 1814 // Tests handling of ICE binding requests with missing or incorrect usernames.
1812 TEST_F(PortTest, TestHandleStunMessageBadUsername) { 1815 TEST_F(PortTest, TestHandleStunMessageBadUsername) {
1813 rtc::scoped_ptr<TestPort> port( 1816 rtc::scoped_ptr<TestPort> port(
1814 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); 1817 CreateTestPort(kLocalAddr2, "rfrag", "rpass"));
1815 1818
1816 rtc::scoped_ptr<IceMessage> in_msg, out_msg; 1819 rtc::scoped_ptr<IceMessage> in_msg, out_msg;
1817 rtc::scoped_ptr<ByteBuffer> buf(new ByteBuffer()); 1820 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter());
1818 rtc::SocketAddress addr(kLocalAddr1); 1821 rtc::SocketAddress addr(kLocalAddr1);
1819 std::string username; 1822 std::string username;
1820 1823
1821 // BINDING-REQUEST with no username. 1824 // BINDING-REQUEST with no username.
1822 in_msg.reset(CreateStunMessage(STUN_BINDING_REQUEST)); 1825 in_msg.reset(CreateStunMessage(STUN_BINDING_REQUEST));
1823 in_msg->AddMessageIntegrity("rpass"); 1826 in_msg->AddMessageIntegrity("rpass");
1824 in_msg->AddFingerprint(); 1827 in_msg->AddFingerprint();
1825 WriteStunMessage(in_msg.get(), buf.get()); 1828 WriteStunMessage(in_msg.get(), buf.get());
1826 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, 1829 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg,
1827 &username)); 1830 &username));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code()); 1879 EXPECT_EQ(STUN_ERROR_UNAUTHORIZED, port->last_stun_error_code());
1877 } 1880 }
1878 1881
1879 // Test handling STUN messages with missing or malformed M-I. 1882 // Test handling STUN messages with missing or malformed M-I.
1880 TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) { 1883 TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) {
1881 // Our port will act as the "remote" port. 1884 // Our port will act as the "remote" port.
1882 rtc::scoped_ptr<TestPort> port( 1885 rtc::scoped_ptr<TestPort> port(
1883 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); 1886 CreateTestPort(kLocalAddr2, "rfrag", "rpass"));
1884 1887
1885 rtc::scoped_ptr<IceMessage> in_msg, out_msg; 1888 rtc::scoped_ptr<IceMessage> in_msg, out_msg;
1886 rtc::scoped_ptr<ByteBuffer> buf(new ByteBuffer()); 1889 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter());
1887 rtc::SocketAddress addr(kLocalAddr1); 1890 rtc::SocketAddress addr(kLocalAddr1);
1888 std::string username; 1891 std::string username;
1889 1892
1890 // BINDING-REQUEST from local to remote with valid ICE username and 1893 // BINDING-REQUEST from local to remote with valid ICE username and
1891 // FINGERPRINT, but no MESSAGE-INTEGRITY. 1894 // FINGERPRINT, but no MESSAGE-INTEGRITY.
1892 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, 1895 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST,
1893 "rfrag:lfrag")); 1896 "rfrag:lfrag"));
1894 in_msg->AddFingerprint(); 1897 in_msg->AddFingerprint();
1895 WriteStunMessage(in_msg.get(), buf.get()); 1898 WriteStunMessage(in_msg.get(), buf.get());
1896 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, 1899 EXPECT_TRUE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg,
(...skipping 20 matching lines...) Expand all
1917 // Change this test to pass in data via Connection::OnReadPacket instead. 1920 // Change this test to pass in data via Connection::OnReadPacket instead.
1918 } 1921 }
1919 1922
1920 // Test handling STUN messages with missing or malformed FINGERPRINT. 1923 // Test handling STUN messages with missing or malformed FINGERPRINT.
1921 TEST_F(PortTest, TestHandleStunMessageBadFingerprint) { 1924 TEST_F(PortTest, TestHandleStunMessageBadFingerprint) {
1922 // Our port will act as the "remote" port. 1925 // Our port will act as the "remote" port.
1923 rtc::scoped_ptr<TestPort> port( 1926 rtc::scoped_ptr<TestPort> port(
1924 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); 1927 CreateTestPort(kLocalAddr2, "rfrag", "rpass"));
1925 1928
1926 rtc::scoped_ptr<IceMessage> in_msg, out_msg; 1929 rtc::scoped_ptr<IceMessage> in_msg, out_msg;
1927 rtc::scoped_ptr<ByteBuffer> buf(new ByteBuffer()); 1930 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter());
1928 rtc::SocketAddress addr(kLocalAddr1); 1931 rtc::SocketAddress addr(kLocalAddr1);
1929 std::string username; 1932 std::string username;
1930 1933
1931 // BINDING-REQUEST from local to remote with valid ICE username and 1934 // BINDING-REQUEST from local to remote with valid ICE username and
1932 // MESSAGE-INTEGRITY, but no FINGERPRINT; GetStunMessage should fail. 1935 // MESSAGE-INTEGRITY, but no FINGERPRINT; GetStunMessage should fail.
1933 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST, 1936 in_msg.reset(CreateStunMessageWithUsername(STUN_BINDING_REQUEST,
1934 "rfrag:lfrag")); 1937 "rfrag:lfrag"));
1935 in_msg->AddMessageIntegrity("rpass"); 1938 in_msg->AddMessageIntegrity("rpass");
1936 WriteStunMessage(in_msg.get(), buf.get()); 1939 WriteStunMessage(in_msg.get(), buf.get());
1937 EXPECT_FALSE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, 1940 EXPECT_FALSE(port->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 // Test handling of STUN binding indication messages . STUN binding 1989 // Test handling of STUN binding indication messages . STUN binding
1987 // indications are allowed only to the connection which is in read mode. 1990 // indications are allowed only to the connection which is in read mode.
1988 TEST_F(PortTest, TestHandleStunBindingIndication) { 1991 TEST_F(PortTest, TestHandleStunBindingIndication) {
1989 rtc::scoped_ptr<TestPort> lport( 1992 rtc::scoped_ptr<TestPort> lport(
1990 CreateTestPort(kLocalAddr2, "lfrag", "lpass")); 1993 CreateTestPort(kLocalAddr2, "lfrag", "lpass"));
1991 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); 1994 lport->SetIceRole(cricket::ICEROLE_CONTROLLING);
1992 lport->SetIceTiebreaker(kTiebreaker1); 1995 lport->SetIceTiebreaker(kTiebreaker1);
1993 1996
1994 // Verifying encoding and decoding STUN indication message. 1997 // Verifying encoding and decoding STUN indication message.
1995 rtc::scoped_ptr<IceMessage> in_msg, out_msg; 1998 rtc::scoped_ptr<IceMessage> in_msg, out_msg;
1996 rtc::scoped_ptr<ByteBuffer> buf(new ByteBuffer()); 1999 rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter());
1997 rtc::SocketAddress addr(kLocalAddr1); 2000 rtc::SocketAddress addr(kLocalAddr1);
1998 std::string username; 2001 std::string username;
1999 2002
2000 in_msg.reset(CreateStunMessage(STUN_BINDING_INDICATION)); 2003 in_msg.reset(CreateStunMessage(STUN_BINDING_INDICATION));
2001 in_msg->AddFingerprint(); 2004 in_msg->AddFingerprint();
2002 WriteStunMessage(in_msg.get(), buf.get()); 2005 WriteStunMessage(in_msg.get(), buf.get());
2003 EXPECT_TRUE(lport->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg, 2006 EXPECT_TRUE(lport->GetStunMessage(buf->Data(), buf->Length(), addr, &out_msg,
2004 &username)); 2007 &username));
2005 EXPECT_TRUE(out_msg.get() != NULL); 2008 EXPECT_TRUE(out_msg.get() != NULL);
2006 EXPECT_EQ(out_msg->type(), STUN_BINDING_INDICATION); 2009 EXPECT_EQ(out_msg->type(), STUN_BINDING_INDICATION);
(...skipping 14 matching lines...) Expand all
2021 Connection* lconn = lport->CreateConnection(rport->Candidates()[0], 2024 Connection* lconn = lport->CreateConnection(rport->Candidates()[0],
2022 Port::ORIGIN_MESSAGE); 2025 Port::ORIGIN_MESSAGE);
2023 Connection* rconn = rport->CreateConnection(lport->Candidates()[0], 2026 Connection* rconn = rport->CreateConnection(lport->Candidates()[0],
2024 Port::ORIGIN_MESSAGE); 2027 Port::ORIGIN_MESSAGE);
2025 rconn->Ping(0); 2028 rconn->Ping(0);
2026 2029
2027 ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, 1000); 2030 ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, 1000);
2028 IceMessage* msg = rport->last_stun_msg(); 2031 IceMessage* msg = rport->last_stun_msg();
2029 EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); 2032 EXPECT_EQ(STUN_BINDING_REQUEST, msg->type());
2030 // Send rport binding request to lport. 2033 // Send rport binding request to lport.
2031 lconn->OnReadPacket(rport->last_stun_buf()->Data(), 2034 lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
2032 rport->last_stun_buf()->Length(), 2035 rport->last_stun_buf()->size(),
2033 rtc::PacketTime()); 2036 rtc::PacketTime());
2034 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); 2037 ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
2035 EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); 2038 EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type());
2036 int64_t last_ping_received1 = lconn->last_ping_received(); 2039 int64_t last_ping_received1 = lconn->last_ping_received();
2037 2040
2038 // Adding a delay of 100ms. 2041 // Adding a delay of 100ms.
2039 rtc::Thread::Current()->ProcessMessages(100); 2042 rtc::Thread::Current()->ProcessMessages(100);
2040 // Pinging lconn using stun indication message. 2043 // Pinging lconn using stun indication message.
2041 lconn->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime()); 2044 lconn->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime());
2042 int64_t last_ping_received2 = lconn->last_ping_received(); 2045 int64_t last_ping_received2 = lconn->last_ping_received();
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 // NOTE: Ideally we should't create connection at this stage from lite 2411 // NOTE: Ideally we should't create connection at this stage from lite
2409 // port, as it should be done only after receiving ping with USE_CANDIDATE. 2412 // port, as it should be done only after receiving ping with USE_CANDIDATE.
2410 // But we need a connection to send a response message. 2413 // But we need a connection to send a response message.
2411 ice_lite_port->CreateConnection( 2414 ice_lite_port->CreateConnection(
2412 ice_full_port->Candidates()[0], cricket::Port::ORIGIN_MESSAGE); 2415 ice_full_port->Candidates()[0], cricket::Port::ORIGIN_MESSAGE);
2413 rtc::scoped_ptr<IceMessage> request(CopyStunMessage(msg)); 2416 rtc::scoped_ptr<IceMessage> request(CopyStunMessage(msg));
2414 ice_lite_port->SendBindingResponse( 2417 ice_lite_port->SendBindingResponse(
2415 request.get(), ice_full_port->Candidates()[0].address()); 2418 request.get(), ice_full_port->Candidates()[0].address());
2416 2419
2417 // Feeding the respone message from litemode to the full mode connection. 2420 // Feeding the respone message from litemode to the full mode connection.
2418 ch1.conn()->OnReadPacket(ice_lite_port->last_stun_buf()->Data(), 2421 ch1.conn()->OnReadPacket(ice_lite_port->last_stun_buf()->data<char>(),
2419 ice_lite_port->last_stun_buf()->Length(), 2422 ice_lite_port->last_stun_buf()->size(),
2420 rtc::PacketTime()); 2423 rtc::PacketTime());
2421 // Verifying full mode connection becomes writable from the response. 2424 // Verifying full mode connection becomes writable from the response.
2422 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(), 2425 EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(),
2423 kTimeout); 2426 kTimeout);
2424 EXPECT_TRUE_WAIT(ch1.nominated(), kTimeout); 2427 EXPECT_TRUE_WAIT(ch1.nominated(), kTimeout);
2425 2428
2426 // Clear existing stun messsages. Otherwise we will process old stun 2429 // Clear existing stun messsages. Otherwise we will process old stun
2427 // message right after we send ping. 2430 // message right after we send ping.
2428 ice_full_port->Reset(); 2431 ice_full_port->Reset();
2429 // Send ping. This must have USE_CANDIDATE_ATTR. 2432 // Send ping. This must have USE_CANDIDATE_ATTR.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 rtc::scoped_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); 2539 rtc::scoped_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1));
2537 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); 2540 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME));
2538 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME)); 2541 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME));
2539 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); 2542 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME));
2540 2543
2541 rtc::scoped_ptr<Port> turn_port( 2544 rtc::scoped_ptr<Port> turn_port(
2542 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); 2545 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP));
2543 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME)); 2546 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME));
2544 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME)); 2547 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME));
2545 } 2548 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/p2p/base/pseudotcp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698