| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |