blob: 4de2cadd2e5b6367297fcafc822f6d682b686a16 [file] [log] [blame]
[email protected]8b37a092012-10-18 21:53:491// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "net/quic/test_tools/quic_test_utils.h"
[email protected]9c0b1352012-11-04 00:03:276
[email protected]701bc892013-01-17 04:51:547#include "base/stl_util.h"
[email protected]b12764d2013-12-02 22:28:308#include "base/strings/string_number_conversions.h"
[email protected]8b37a092012-10-18 21:53:499#include "net/quic/crypto/crypto_framer.h"
[email protected]6f54ab32013-03-02 17:43:3510#include "net/quic/crypto/crypto_handshake.h"
[email protected]872edd9e2013-01-16 08:51:1511#include "net/quic/crypto/crypto_utils.h"
[email protected]5351cc4b2013-03-03 07:22:4112#include "net/quic/crypto/null_encrypter.h"
[email protected]4df69842013-02-27 06:32:1613#include "net/quic/crypto/quic_decrypter.h"
14#include "net/quic/crypto/quic_encrypter.h"
[email protected]a57e0272013-04-26 07:31:4715#include "net/quic/quic_framer.h"
[email protected]5351cc4b2013-03-03 07:22:4116#include "net/quic/quic_packet_creator.h"
[email protected]cbd731e2013-10-24 00:20:3917#include "net/quic/test_tools/quic_connection_peer.h"
[email protected]c244c5a12013-05-07 20:55:0418#include "net/spdy/spdy_frame_builder.h"
[email protected]8b37a092012-10-18 21:53:4919
[email protected]c244c5a12013-05-07 20:55:0420using base::StringPiece;
[email protected]8b37a092012-10-18 21:53:4921using std::max;
22using std::min;
23using std::string;
[email protected]cff7b7b2013-01-11 08:49:0724using testing::_;
[email protected]8b37a092012-10-18 21:53:4925
26namespace net {
27namespace test {
[email protected]965dbe62013-08-09 21:34:3128namespace {
29
30// No-op alarm implementation used by MockHelper.
31class TestAlarm : public QuicAlarm {
32 public:
33 explicit TestAlarm(QuicAlarm::Delegate* delegate)
34 : QuicAlarm(delegate) {
35 }
36
37 virtual void SetImpl() OVERRIDE {}
38 virtual void CancelImpl() OVERRIDE {}
39};
40
41} // namespace
[email protected]8b37a092012-10-18 21:53:4942
43MockFramerVisitor::MockFramerVisitor() {
44 // By default, we want to accept packets.
[email protected]14e8106c2013-03-14 16:25:3345 ON_CALL(*this, OnProtocolVersionMismatch(_))
46 .WillByDefault(testing::Return(false));
47
48 // By default, we want to accept packets.
[email protected]ec86d5462013-11-17 16:04:4949 ON_CALL(*this, OnUnauthenticatedHeader(_))
50 .WillByDefault(testing::Return(true));
51
[email protected]cff7b7b2013-01-11 08:49:0752 ON_CALL(*this, OnPacketHeader(_))
[email protected]8b37a092012-10-18 21:53:4953 .WillByDefault(testing::Return(true));
[email protected]a57e0272013-04-26 07:31:4754
55 ON_CALL(*this, OnStreamFrame(_))
56 .WillByDefault(testing::Return(true));
57
58 ON_CALL(*this, OnAckFrame(_))
59 .WillByDefault(testing::Return(true));
60
61 ON_CALL(*this, OnCongestionFeedbackFrame(_))
62 .WillByDefault(testing::Return(true));
63
64 ON_CALL(*this, OnRstStreamFrame(_))
65 .WillByDefault(testing::Return(true));
66
67 ON_CALL(*this, OnConnectionCloseFrame(_))
68 .WillByDefault(testing::Return(true));
69
70 ON_CALL(*this, OnGoAwayFrame(_))
71 .WillByDefault(testing::Return(true));
[email protected]8b37a092012-10-18 21:53:4972}
73
[email protected]044ac2b2012-11-13 21:41:0674MockFramerVisitor::~MockFramerVisitor() {
75}
[email protected]8b37a092012-10-18 21:53:4976
[email protected]48878092013-07-26 14:51:5677bool NoOpFramerVisitor::OnProtocolVersionMismatch(QuicVersion version) {
[email protected]14e8106c2013-03-14 16:25:3378 return false;
79}
80
[email protected]ec86d5462013-11-17 16:04:4981bool NoOpFramerVisitor::OnUnauthenticatedHeader(
82 const QuicPacketHeader& header) {
83 return true;
84}
85
[email protected]8b37a092012-10-18 21:53:4986bool NoOpFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) {
87 return true;
88}
89
[email protected]a57e0272013-04-26 07:31:4790bool NoOpFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) {
91 return true;
92}
93
94bool NoOpFramerVisitor::OnAckFrame(const QuicAckFrame& frame) {
95 return true;
96}
97
98bool NoOpFramerVisitor::OnCongestionFeedbackFrame(
99 const QuicCongestionFeedbackFrame& frame) {
100 return true;
101}
102
103bool NoOpFramerVisitor::OnRstStreamFrame(
104 const QuicRstStreamFrame& frame) {
105 return true;
106}
107
108bool NoOpFramerVisitor::OnConnectionCloseFrame(
109 const QuicConnectionCloseFrame& frame) {
110 return true;
111}
112
113bool NoOpFramerVisitor::OnGoAwayFrame(const QuicGoAwayFrame& frame) {
114 return true;
115}
116
[email protected]9db443912013-02-25 05:27:03117FramerVisitorCapturingFrames::FramerVisitorCapturingFrames() : frame_count_(0) {
[email protected]134e5c32012-12-12 19:20:36118}
119
[email protected]9db443912013-02-25 05:27:03120FramerVisitorCapturingFrames::~FramerVisitorCapturingFrames() {
[email protected]0ac0c5b2013-11-20 05:55:58121 Reset();
122}
123
124void FramerVisitorCapturingFrames::Reset() {
[email protected]583bcbcf2013-10-28 01:51:15125 STLDeleteElements(&stream_data_);
[email protected]0ac0c5b2013-11-20 05:55:58126 stream_frames_.clear();
127 frame_count_ = 0;
128 ack_.reset();
129 feedback_.reset();
130 rst_.reset();
131 close_.reset();
132 goaway_.reset();
133 version_negotiation_packet_.reset();
[email protected]26f3f8e2012-12-13 21:07:19134}
135
[email protected]9db443912013-02-25 05:27:03136bool FramerVisitorCapturingFrames::OnPacketHeader(
[email protected]4e6f0ed2012-11-02 22:15:38137 const QuicPacketHeader& header) {
138 header_ = header;
[email protected]9db443912013-02-25 05:27:03139 frame_count_ = 0;
[email protected]4e6f0ed2012-11-02 22:15:38140 return true;
141}
142
[email protected]a57e0272013-04-26 07:31:47143bool FramerVisitorCapturingFrames::OnStreamFrame(const QuicStreamFrame& frame) {
[email protected]583bcbcf2013-10-28 01:51:15144 // Make a copy of the frame and store a copy of underlying string, since
145 // frame.data may not exist outside this callback.
[email protected]5dafdb62013-11-14 01:24:26146 stream_data_.push_back(frame.GetDataAsString());
[email protected]583bcbcf2013-10-28 01:51:15147 QuicStreamFrame frame_copy = frame;
[email protected]5dafdb62013-11-14 01:24:26148 frame_copy.data.Clear();
149 frame_copy.data.Append(const_cast<char*>(stream_data_.back()->data()),
150 stream_data_.back()->size());
[email protected]583bcbcf2013-10-28 01:51:15151 stream_frames_.push_back(frame_copy);
[email protected]9db443912013-02-25 05:27:03152 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47153 return true;
[email protected]26f3f8e2012-12-13 21:07:19154}
155
[email protected]a57e0272013-04-26 07:31:47156bool FramerVisitorCapturingFrames::OnAckFrame(const QuicAckFrame& frame) {
[email protected]9db443912013-02-25 05:27:03157 ack_.reset(new QuicAckFrame(frame));
158 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47159 return true;
[email protected]9db443912013-02-25 05:27:03160}
161
[email protected]a57e0272013-04-26 07:31:47162bool FramerVisitorCapturingFrames::OnCongestionFeedbackFrame(
[email protected]26f3f8e2012-12-13 21:07:19163 const QuicCongestionFeedbackFrame& frame) {
164 feedback_.reset(new QuicCongestionFeedbackFrame(frame));
[email protected]9db443912013-02-25 05:27:03165 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47166 return true;
[email protected]9db443912013-02-25 05:27:03167}
168
[email protected]a57e0272013-04-26 07:31:47169bool FramerVisitorCapturingFrames::OnRstStreamFrame(
[email protected]9db443912013-02-25 05:27:03170 const QuicRstStreamFrame& frame) {
171 rst_.reset(new QuicRstStreamFrame(frame));
172 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47173 return true;
[email protected]9db443912013-02-25 05:27:03174}
175
[email protected]a57e0272013-04-26 07:31:47176bool FramerVisitorCapturingFrames::OnConnectionCloseFrame(
[email protected]9db443912013-02-25 05:27:03177 const QuicConnectionCloseFrame& frame) {
178 close_.reset(new QuicConnectionCloseFrame(frame));
179 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47180 return true;
[email protected]9db443912013-02-25 05:27:03181}
182
[email protected]a57e0272013-04-26 07:31:47183bool FramerVisitorCapturingFrames::OnGoAwayFrame(const QuicGoAwayFrame& frame) {
[email protected]9db443912013-02-25 05:27:03184 goaway_.reset(new QuicGoAwayFrame(frame));
185 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47186 return true;
[email protected]4e6f0ed2012-11-02 22:15:38187}
188
[email protected]14e8106c2013-03-14 16:25:33189void FramerVisitorCapturingFrames::OnVersionNegotiationPacket(
190 const QuicVersionNegotiationPacket& packet) {
191 version_negotiation_packet_.reset(new QuicVersionNegotiationPacket(packet));
192 frame_count_ = 0;
193}
194
[email protected]fee17f72013-02-03 07:47:41195FramerVisitorCapturingPublicReset::FramerVisitorCapturingPublicReset() {
196}
197
198FramerVisitorCapturingPublicReset::~FramerVisitorCapturingPublicReset() {
199}
200
201void FramerVisitorCapturingPublicReset::OnPublicResetPacket(
202 const QuicPublicResetPacket& public_reset) {
203 public_reset_packet_ = public_reset;
204}
205
[email protected]8d659e22013-01-19 04:26:10206MockConnectionVisitor::MockConnectionVisitor() {
207}
208
209MockConnectionVisitor::~MockConnectionVisitor() {
210}
211
[email protected]9c0b1352012-11-04 00:03:27212MockHelper::MockHelper() {
213}
214
215MockHelper::~MockHelper() {
216}
217
[email protected]97693d12012-11-16 16:05:00218const QuicClock* MockHelper::GetClock() const {
[email protected]9c0b1352012-11-04 00:03:27219 return &clock_;
220}
221
[email protected]9558c5d32012-12-22 00:08:14222QuicRandom* MockHelper::GetRandomGenerator() {
223 return &random_generator_;
224}
225
[email protected]965dbe62013-08-09 21:34:31226QuicAlarm* MockHelper::CreateAlarm(QuicAlarm::Delegate* delegate) {
227 return new TestAlarm(delegate);
228}
229
[email protected]fe053f92013-04-23 20:18:55230void MockHelper::AdvanceTime(QuicTime::Delta delta) {
231 clock_.AdvanceTime(delta);
232}
233
[email protected]14e8106c2013-03-14 16:25:33234MockConnection::MockConnection(QuicGuid guid,
235 IPEndPoint address,
236 bool is_server)
[email protected]2532de12013-05-09 12:29:33237 : QuicConnection(guid, address, new testing::NiceMock<MockHelper>(),
[email protected]cbd731e2013-10-24 00:20:39238 new testing::NiceMock<MockPacketWriter>(),
[email protected]b007e632013-10-28 08:39:25239 is_server, QuicSupportedVersions()),
[email protected]cbd731e2013-10-24 00:20:39240 has_mock_helper_(true),
[email protected]2cfc6bb82013-10-27 03:40:44241 writer_(QuicConnectionPeer::GetWriter(this)),
242 helper_(helper()) {
[email protected]044ac2b2012-11-13 21:41:06243}
244
[email protected]872edd9e2013-01-16 08:51:15245MockConnection::MockConnection(QuicGuid guid,
246 IPEndPoint address,
[email protected]14e8106c2013-03-14 16:25:33247 QuicConnectionHelperInterface* helper,
[email protected]cbd731e2013-10-24 00:20:39248 QuicPacketWriter* writer,
[email protected]14e8106c2013-03-14 16:25:33249 bool is_server)
[email protected]cbd731e2013-10-24 00:20:39250 : QuicConnection(guid, address, helper, writer, is_server,
[email protected]b007e632013-10-28 08:39:25251 QuicSupportedVersions()),
[email protected]fe053f92013-04-23 20:18:55252 has_mock_helper_(false) {
[email protected]872edd9e2013-01-16 08:51:15253}
254
[email protected]044ac2b2012-11-13 21:41:06255MockConnection::~MockConnection() {
256}
257
[email protected]fe053f92013-04-23 20:18:55258void MockConnection::AdvanceTime(QuicTime::Delta delta) {
259 CHECK(has_mock_helper_) << "Cannot advance time unless a MockClock is being"
260 " used";
261 static_cast<MockHelper*>(helper())->AdvanceTime(delta);
262}
263
[email protected]044ac2b2012-11-13 21:41:06264PacketSavingConnection::PacketSavingConnection(QuicGuid guid,
[email protected]14e8106c2013-03-14 16:25:33265 IPEndPoint address,
266 bool is_server)
267 : MockConnection(guid, address, is_server) {
[email protected]044ac2b2012-11-13 21:41:06268}
269
270PacketSavingConnection::~PacketSavingConnection() {
[email protected]701bc892013-01-17 04:51:54271 STLDeleteElements(&packets_);
[email protected]2532de12013-05-09 12:29:33272 STLDeleteElements(&encrypted_packets_);
[email protected]044ac2b2012-11-13 21:41:06273}
274
[email protected]fee17f72013-02-03 07:47:41275bool PacketSavingConnection::SendOrQueuePacket(
[email protected]8ba81212013-05-03 13:11:48276 EncryptionLevel level,
[email protected]ec86d5462013-11-17 16:04:49277 const SerializedPacket& packet,
278 TransmissionType transmission_type) {
279 packets_.push_back(packet.packet);
[email protected]2532de12013-05-09 12:29:33280 QuicEncryptedPacket* encrypted =
[email protected]ec86d5462013-11-17 16:04:49281 framer_.EncryptPacket(level, packet.sequence_number, *packet.packet);
[email protected]2532de12013-05-09 12:29:33282 encrypted_packets_.push_back(encrypted);
[email protected]044ac2b2012-11-13 21:41:06283 return true;
284}
285
286MockSession::MockSession(QuicConnection* connection, bool is_server)
[email protected]b064310782013-05-30 21:12:17287 : QuicSession(connection, DefaultQuicConfig(), is_server) {
[email protected]0ac0c5b2013-11-20 05:55:58288 ON_CALL(*this, WritevData(_, _, _, _, _, _))
[email protected]cff7b7b2013-01-11 08:49:07289 .WillByDefault(testing::Return(QuicConsumedData(0, false)));
[email protected]044ac2b2012-11-13 21:41:06290}
291
292MockSession::~MockSession() {
293}
294
[email protected]899951652013-05-16 12:52:39295TestSession::TestSession(QuicConnection* connection,
296 const QuicConfig& config,
297 bool is_server)
298 : QuicSession(connection, config, is_server),
[email protected]2532de12013-05-09 12:29:33299 crypto_stream_(NULL) {
300}
301
[email protected]b064310782013-05-30 21:12:17302TestSession::~TestSession() {}
[email protected]2532de12013-05-09 12:29:33303
304void TestSession::SetCryptoStream(QuicCryptoStream* stream) {
305 crypto_stream_ = stream;
306}
307
308QuicCryptoStream* TestSession::GetCryptoStream() {
309 return crypto_stream_;
310}
311
[email protected]cbd731e2013-10-24 00:20:39312MockPacketWriter::MockPacketWriter() {
313}
314
315MockPacketWriter::~MockPacketWriter() {
316}
317
[email protected]fee17f72013-02-03 07:47:41318MockSendAlgorithm::MockSendAlgorithm() {
[email protected]8d659e22013-01-19 04:26:10319}
320
[email protected]fee17f72013-02-03 07:47:41321MockSendAlgorithm::~MockSendAlgorithm() {
[email protected]8d659e22013-01-19 04:26:10322}
323
[email protected]97cf3022013-09-05 14:30:16324MockAckNotifierDelegate::MockAckNotifierDelegate() {
325}
326
327MockAckNotifierDelegate::~MockAckNotifierDelegate() {
328}
329
[email protected]8b37a092012-10-18 21:53:49330namespace {
331
332string HexDumpWithMarks(const char* data, int length,
333 const bool* marks, int mark_length) {
334 static const char kHexChars[] = "0123456789abcdef";
335 static const int kColumns = 4;
336
337 const int kSizeLimit = 1024;
338 if (length > kSizeLimit || mark_length > kSizeLimit) {
339 LOG(ERROR) << "Only dumping first " << kSizeLimit << " bytes.";
340 length = min(length, kSizeLimit);
341 mark_length = min(mark_length, kSizeLimit);
342 }
343
344 string hex;
345 for (const char* row = data; length > 0;
346 row += kColumns, length -= kColumns) {
347 for (const char *p = row; p < row + 4; ++p) {
348 if (p < row + length) {
349 const bool mark =
350 (marks && (p - data) < mark_length && marks[p - data]);
351 hex += mark ? '*' : ' ';
352 hex += kHexChars[(*p & 0xf0) >> 4];
353 hex += kHexChars[*p & 0x0f];
354 hex += mark ? '*' : ' ';
355 } else {
356 hex += " ";
357 }
358 }
359 hex = hex + " ";
360
361 for (const char *p = row; p < row + 4 && p < row + length; ++p)
362 hex += (*p >= 0x20 && *p <= 0x7f) ? (*p) : '.';
363
364 hex = hex + '\n';
365 }
366 return hex;
367}
368
369} // namespace
370
[email protected]b007e632013-10-28 08:39:25371QuicVersion QuicVersionMax() { return QuicSupportedVersions().front(); }
372
373QuicVersion QuicVersionMin() { return QuicSupportedVersions().back(); }
374
[email protected]8b37a092012-10-18 21:53:49375void CompareCharArraysWithHexError(
376 const string& description,
377 const char* actual,
378 const int actual_len,
379 const char* expected,
380 const int expected_len) {
[email protected]b007e632013-10-28 08:39:25381 EXPECT_EQ(actual_len, expected_len);
[email protected]8b37a092012-10-18 21:53:49382 const int min_len = min(actual_len, expected_len);
383 const int max_len = max(actual_len, expected_len);
[email protected]4356f0f2013-04-07 00:58:17384 scoped_ptr<bool[]> marks(new bool[max_len]);
[email protected]8b37a092012-10-18 21:53:49385 bool identical = (actual_len == expected_len);
386 for (int i = 0; i < min_len; ++i) {
387 if (actual[i] != expected[i]) {
388 marks[i] = true;
389 identical = false;
390 } else {
391 marks[i] = false;
392 }
393 }
394 for (int i = min_len; i < max_len; ++i) {
395 marks[i] = true;
396 }
397 if (identical) return;
398 ADD_FAILURE()
399 << "Description:\n"
400 << description
401 << "\n\nExpected:\n"
402 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len)
403 << "\nActual:\n"
404 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len);
405}
406
[email protected]b12764d2013-12-02 22:28:30407bool DecodeHexString(const base::StringPiece& hex, std::string* bytes) {
408 bytes->clear();
409 if (hex.empty())
410 return true;
411 std::vector<uint8> v;
412 if (!base::HexStringToBytes(hex.as_string(), &v))
413 return false;
414 if (!v.empty())
415 bytes->assign(reinterpret_cast<const char*>(&v[0]), v.size());
416 return true;
417}
418
[email protected]d3d15bf2013-01-30 02:51:54419static QuicPacket* ConstructPacketFromHandshakeMessage(
420 QuicGuid guid,
[email protected]14e8106c2013-03-14 16:25:33421 const CryptoHandshakeMessage& message,
422 bool should_include_version) {
[email protected]8b37a092012-10-18 21:53:49423 CryptoFramer crypto_framer;
[email protected]dc2cc742012-10-21 13:56:13424 scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message));
[email protected]b007e632013-10-28 08:39:25425 QuicFramer quic_framer(QuicSupportedVersions(), QuicTime::Zero(), false);
[email protected]8b37a092012-10-18 21:53:49426
427 QuicPacketHeader header;
[email protected]c995c572013-01-18 05:43:20428 header.public_header.guid = guid;
[email protected]9db443912013-02-25 05:27:03429 header.public_header.reset_flag = false;
[email protected]14e8106c2013-03-14 16:25:33430 header.public_header.version_flag = should_include_version;
[email protected]8b37a092012-10-18 21:53:49431 header.packet_sequence_number = 1;
[email protected]9db443912013-02-25 05:27:03432 header.entropy_flag = false;
433 header.entropy_hash = 0;
434 header.fec_flag = false;
[email protected]8b37a092012-10-18 21:53:49435 header.fec_group = 0;
436
[email protected]be24ab22012-10-22 03:01:52437 QuicStreamFrame stream_frame(kCryptoStreamId, false, 0,
[email protected]5dafdb62013-11-14 01:24:26438 MakeIOVector(data->AsStringPiece()));
[email protected]8b37a092012-10-18 21:53:49439
[email protected]be24ab22012-10-22 03:01:52440 QuicFrame frame(&stream_frame);
441 QuicFrames frames;
442 frames.push_back(frame);
[email protected]3e60db82013-08-05 19:43:06443 return quic_framer.BuildUnsizedDataPacket(header, frames).packet;
[email protected]8b37a092012-10-18 21:53:49444}
445
[email protected]2532de12013-05-09 12:29:33446QuicPacket* ConstructHandshakePacket(QuicGuid guid, QuicTag tag) {
[email protected]d3d15bf2013-01-30 02:51:54447 CryptoHandshakeMessage message;
[email protected]ccc66e8a2013-03-26 08:26:14448 message.set_tag(tag);
[email protected]14e8106c2013-03-14 16:25:33449 return ConstructPacketFromHandshakeMessage(guid, message, false);
[email protected]d3d15bf2013-01-30 02:51:54450}
451
[email protected]ea825e02013-08-21 18:12:45452size_t GetPacketLengthForOneStream(
453 QuicVersion version,
454 bool include_version,
455 QuicSequenceNumberLength sequence_number_length,
456 InFecGroup is_in_fec_group,
457 size_t* payload_length) {
[email protected]f62262b2013-07-05 20:57:30458 *payload_length = 1;
459 const size_t stream_length =
[email protected]5dafdb62013-11-14 01:24:26460 NullEncrypter().GetCiphertextSize(*payload_length) +
[email protected]b064310782013-05-30 21:12:17461 QuicPacketCreator::StreamFramePacketOverhead(
[email protected]3e60db82013-08-05 19:43:06462 version, PACKET_8BYTE_GUID, include_version,
[email protected]ea825e02013-08-21 18:12:45463 sequence_number_length, is_in_fec_group);
[email protected]5dafdb62013-11-14 01:24:26464 const size_t ack_length = NullEncrypter().GetCiphertextSize(
[email protected]8e01c062013-10-31 07:35:31465 QuicFramer::GetMinAckFrameSize(
466 version, sequence_number_length, PACKET_1BYTE_SEQUENCE_NUMBER)) +
[email protected]25c31dc2013-06-05 17:56:04467 GetPacketHeaderSize(PACKET_8BYTE_GUID, include_version,
[email protected]ea825e02013-08-21 18:12:45468 sequence_number_length, is_in_fec_group);
[email protected]f62262b2013-07-05 20:57:30469 if (stream_length < ack_length) {
470 *payload_length = 1 + ack_length - stream_length;
471 }
472
[email protected]5dafdb62013-11-14 01:24:26473 return NullEncrypter().GetCiphertextSize(*payload_length) +
[email protected]f62262b2013-07-05 20:57:30474 QuicPacketCreator::StreamFramePacketOverhead(
[email protected]3e60db82013-08-05 19:43:06475 version, PACKET_8BYTE_GUID, include_version,
[email protected]ea825e02013-08-21 18:12:45476 sequence_number_length, is_in_fec_group);
[email protected]5351cc4b2013-03-03 07:22:41477}
478
[email protected]ea2ab47b2013-08-13 00:44:11479// Size in bytes of the stream frame fields for an arbitrary StreamID and
480// offset and the last frame in a packet.
[email protected]3e60db82013-08-05 19:43:06481size_t GetMinStreamFrameSize(QuicVersion version) {
[email protected]ea2ab47b2013-08-13 00:44:11482 return kQuicFrameTypeSize + kQuicMaxStreamIdSize + kQuicMaxStreamOffsetSize;
[email protected]3e60db82013-08-05 19:43:06483}
484
[email protected]8e01c062013-10-31 07:35:31485TestEntropyCalculator::TestEntropyCalculator() { }
486
487TestEntropyCalculator::~TestEntropyCalculator() { }
488
[email protected]48878092013-07-26 14:51:56489QuicPacketEntropyHash TestEntropyCalculator::EntropyHash(
[email protected]9db443912013-02-25 05:27:03490 QuicPacketSequenceNumber sequence_number) const {
491 return 1u;
492}
493
[email protected]8e01c062013-10-31 07:35:31494MockEntropyCalculator::MockEntropyCalculator() { }
495
496MockEntropyCalculator::~MockEntropyCalculator() { }
497
[email protected]b064310782013-05-30 21:12:17498QuicConfig DefaultQuicConfig() {
499 QuicConfig config;
500 config.SetDefaults();
501 return config;
502}
503
[email protected]c244c5a12013-05-07 20:55:04504bool TestDecompressorVisitor::OnDecompressedData(StringPiece data) {
505 data.AppendToString(&data_);
506 return true;
507}
508
[email protected]899951652013-05-16 12:52:39509void TestDecompressorVisitor::OnDecompressionError() {
510 error_ = true;
511}
512
[email protected]8b37a092012-10-18 21:53:49513} // namespace test
[email protected]8b37a092012-10-18 21:53:49514} // namespace net