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

Side by Side Diff: net/quic/quic_framer_test.cc

Issue 1983183002: Landing Recent QUIC changes until 5/14/2016 02:25:25 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "first try to fix link error for win_clang build" Created 4 years, 7 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 | « net/quic/quic_framer.cc ('k') | net/quic/quic_headers_stream_test.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 6297 matching lines...) Expand 10 before | Expand all | Expand 10 after
6308 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 6308 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames));
6309 ASSERT_TRUE(data != nullptr); 6309 ASSERT_TRUE(data != nullptr);
6310 6310
6311 test::CompareCharArraysWithHexError( 6311 test::CompareCharArraysWithHexError(
6312 "constructed packet", data->data(), data->length(), 6312 "constructed packet", data->data(), data->length(),
6313 AsChars(framer_.version() <= QUIC_VERSION_33 ? packet : packet_34), 6313 AsChars(framer_.version() <= QUIC_VERSION_33 ? packet : packet_34),
6314 framer_.version() <= QUIC_VERSION_33 ? arraysize(packet) 6314 framer_.version() <= QUIC_VERSION_33 ? arraysize(packet)
6315 : arraysize(packet_34)); 6315 : arraysize(packet_34));
6316 } 6316 }
6317 6317
6318 TEST_P(QuicFramerTest, BuildPublicResetPacket) { 6318 TEST_P(QuicFramerTest, BuildPublicResetPacketOld) {
6319 FLAGS_quic_use_old_public_reset_packets = true;
6319 QuicPublicResetPacket reset_packet; 6320 QuicPublicResetPacket reset_packet;
6320 reset_packet.public_header.connection_id = kConnectionId; 6321 reset_packet.public_header.connection_id = kConnectionId;
6321 reset_packet.public_header.reset_flag = true; 6322 reset_packet.public_header.reset_flag = true;
6323 reset_packet.public_header.version_flag = false;
6324 reset_packet.rejected_packet_number = kPacketNumber;
6325 reset_packet.nonce_proof = kNonceProof;
6326
6327 // clang-format off
6328 unsigned char packet[] = {
6329 // public flags (public reset, 8 byte ConnectionId)
6330 0x0E,
6331 // connection_id
6332 0x10, 0x32, 0x54, 0x76,
6333 0x98, 0xBA, 0xDC, 0xFE,
6334 // message tag (kPRST)
6335 'P', 'R', 'S', 'T',
6336 // num_entries (2) + padding
6337 0x02, 0x00, 0x00, 0x00,
6338 // tag kRNON
6339 'R', 'N', 'O', 'N',
6340 // end offset 8
6341 0x08, 0x00, 0x00, 0x00,
6342 // tag kRSEQ
6343 'R', 'S', 'E', 'Q',
6344 // end offset 16
6345 0x10, 0x00, 0x00, 0x00,
6346 // nonce proof
6347 0x89, 0x67, 0x45, 0x23,
6348 0x01, 0xEF, 0xCD, 0xAB,
6349 // rejected packet number
6350 0xBC, 0x9A, 0x78, 0x56,
6351 0x34, 0x12, 0x00, 0x00,
6352 };
6353 // clang-format on
6354
6355 std::unique_ptr<QuicEncryptedPacket> data(
6356 framer_.BuildPublicResetPacket(reset_packet));
6357 ASSERT_TRUE(data != nullptr);
6358
6359 test::CompareCharArraysWithHexError("constructed packet", data->data(),
6360 data->length(), AsChars(packet),
6361 arraysize(packet));
6362 }
6363
6364 TEST_P(QuicFramerTest, BuildPublicResetPacket) {
6365 FLAGS_quic_use_old_public_reset_packets = false;
6366 QuicPublicResetPacket reset_packet;
6367 reset_packet.public_header.connection_id = kConnectionId;
6368 reset_packet.public_header.reset_flag = true;
6322 reset_packet.public_header.version_flag = false; 6369 reset_packet.public_header.version_flag = false;
6323 reset_packet.rejected_packet_number = kPacketNumber; 6370 reset_packet.rejected_packet_number = kPacketNumber;
6324 reset_packet.nonce_proof = kNonceProof; 6371 reset_packet.nonce_proof = kNonceProof;
6325 6372
6326 // clang-format off 6373 // clang-format off
6327 unsigned char packet[] = { 6374 unsigned char packet[] = {
6328 // public flags (public reset, 8 byte ConnectionId) 6375 // public flags (public reset, 8 byte ConnectionId)
6329 0x0A, 6376 0x0A,
6330 // connection_id 6377 // connection_id
6331 0x10, 0x32, 0x54, 0x76, 6378 0x10, 0x32, 0x54, 0x76,
(...skipping 22 matching lines...) Expand all
6354 std::unique_ptr<QuicEncryptedPacket> data( 6401 std::unique_ptr<QuicEncryptedPacket> data(
6355 framer_.BuildPublicResetPacket(reset_packet)); 6402 framer_.BuildPublicResetPacket(reset_packet));
6356 ASSERT_TRUE(data != nullptr); 6403 ASSERT_TRUE(data != nullptr);
6357 6404
6358 test::CompareCharArraysWithHexError("constructed packet", data->data(), 6405 test::CompareCharArraysWithHexError("constructed packet", data->data(),
6359 data->length(), AsChars(packet), 6406 data->length(), AsChars(packet),
6360 arraysize(packet)); 6407 arraysize(packet));
6361 } 6408 }
6362 6409
6363 TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { 6410 TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) {
6411 FLAGS_quic_use_old_public_reset_packets = false;
6364 QuicPublicResetPacket reset_packet; 6412 QuicPublicResetPacket reset_packet;
6365 reset_packet.public_header.connection_id = kConnectionId; 6413 reset_packet.public_header.connection_id = kConnectionId;
6366 reset_packet.public_header.reset_flag = true; 6414 reset_packet.public_header.reset_flag = true;
6367 reset_packet.public_header.version_flag = false; 6415 reset_packet.public_header.version_flag = false;
6368 reset_packet.rejected_packet_number = kPacketNumber; 6416 reset_packet.rejected_packet_number = kPacketNumber;
6369 reset_packet.nonce_proof = kNonceProof; 6417 reset_packet.nonce_proof = kNonceProof;
6370 reset_packet.client_address = IPEndPoint(Loopback4(), 0x1234); 6418 reset_packet.client_address = IPEndPoint(Loopback4(), 0x1234);
6371 6419
6372 // clang-format off 6420 // clang-format off
6373 unsigned char packet[] = { 6421 unsigned char packet[] = {
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
7096 'o', ' ', 'w', 'o', 7144 'o', ' ', 'w', 'o',
7097 'r', 'l', 'd', '!', 7145 'r', 'l', 'd', '!',
7098 }; 7146 };
7099 // clang-format on 7147 // clang-format on
7100 7148
7101 QuicFramerFuzzFunc(packet, arraysize(packet)); 7149 QuicFramerFuzzFunc(packet, arraysize(packet));
7102 } 7150 }
7103 7151
7104 } // namespace test 7152 } // namespace test
7105 } // namespace net 7153 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_headers_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698