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

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

Issue 2409013002: relnote: Remove rejected packet number from public reset packet. (Closed)
Patch Set: flip the flag default to false Created 4 years, 2 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/core/quic_framer.cc ('k') | net/quic/core/quic_protocol.h » ('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/core/quic_framer.h" 5 #include "net/quic/core/quic_framer.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 5601 matching lines...) Expand 10 before | Expand all | Expand 10 after
5612 'R', 'S', 'E', 'Q', 5612 'R', 'S', 'E', 'Q',
5613 // end offset 16 5613 // end offset 16
5614 0x10, 0x00, 0x00, 0x00, 5614 0x10, 0x00, 0x00, 0x00,
5615 // nonce proof 5615 // nonce proof
5616 0x89, 0x67, 0x45, 0x23, 5616 0x89, 0x67, 0x45, 0x23,
5617 0x01, 0xEF, 0xCD, 0xAB, 5617 0x01, 0xEF, 0xCD, 0xAB,
5618 // rejected packet number 5618 // rejected packet number
5619 0xBC, 0x9A, 0x78, 0x56, 5619 0xBC, 0x9A, 0x78, 0x56,
5620 0x34, 0x12, 0x00, 0x00, 5620 0x34, 0x12, 0x00, 0x00,
5621 }; 5621 };
5622 unsigned char packet_no_rejected_packet_number[] = {
5623 // public flags (public reset, 8 byte ConnectionId)
5624 0x0E,
5625 // connection_id
5626 0x10, 0x32, 0x54, 0x76,
5627 0x98, 0xBA, 0xDC, 0xFE,
5628 // message tag (kPRST)
5629 'P', 'R', 'S', 'T',
5630 // num_entries (1) + padding
5631 0x01, 0x00, 0x00, 0x00,
5632 // tag kRNON
5633 'R', 'N', 'O', 'N',
5634 // end offset 8
5635 0x08, 0x00, 0x00, 0x00,
5636 // nonce proof
5637 0x89, 0x67, 0x45, 0x23,
5638 0x01, 0xEF, 0xCD, 0xAB,
5639 };
5622 // clang-format on 5640 // clang-format on
5623 5641
5624 std::unique_ptr<QuicEncryptedPacket> data( 5642 std::unique_ptr<QuicEncryptedPacket> data(
5625 framer_.BuildPublicResetPacket(reset_packet)); 5643 framer_.BuildPublicResetPacket(reset_packet));
5626 ASSERT_TRUE(data != nullptr); 5644 ASSERT_TRUE(data != nullptr);
5627 5645 if (FLAGS_quic_remove_packet_number_from_public_reset) {
5628 test::CompareCharArraysWithHexError("constructed packet", data->data(), 5646 test::CompareCharArraysWithHexError(
5629 data->length(), AsChars(packet), 5647 "constructed packet", data->data(), data->length(),
5630 arraysize(packet)); 5648 AsChars(packet_no_rejected_packet_number),
5649 arraysize(packet_no_rejected_packet_number));
5650 } else {
5651 test::CompareCharArraysWithHexError("constructed packet", data->data(),
5652 data->length(), AsChars(packet),
5653 arraysize(packet));
5654 }
5631 } 5655 }
5632 5656
5633 TEST_P(QuicFramerTest, BuildPublicResetPacket) { 5657 TEST_P(QuicFramerTest, BuildPublicResetPacket) {
5634 FLAGS_quic_use_old_public_reset_packets = false; 5658 FLAGS_quic_use_old_public_reset_packets = false;
5635 QuicPublicResetPacket reset_packet; 5659 QuicPublicResetPacket reset_packet;
5636 reset_packet.public_header.connection_id = kConnectionId; 5660 reset_packet.public_header.connection_id = kConnectionId;
5637 reset_packet.public_header.reset_flag = true; 5661 reset_packet.public_header.reset_flag = true;
5638 reset_packet.public_header.version_flag = false; 5662 reset_packet.public_header.version_flag = false;
5639 reset_packet.rejected_packet_number = kPacketNumber; 5663 reset_packet.rejected_packet_number = kPacketNumber;
5640 reset_packet.nonce_proof = kNonceProof; 5664 reset_packet.nonce_proof = kNonceProof;
(...skipping 17 matching lines...) Expand all
5658 'R', 'S', 'E', 'Q', 5682 'R', 'S', 'E', 'Q',
5659 // end offset 16 5683 // end offset 16
5660 0x10, 0x00, 0x00, 0x00, 5684 0x10, 0x00, 0x00, 0x00,
5661 // nonce proof 5685 // nonce proof
5662 0x89, 0x67, 0x45, 0x23, 5686 0x89, 0x67, 0x45, 0x23,
5663 0x01, 0xEF, 0xCD, 0xAB, 5687 0x01, 0xEF, 0xCD, 0xAB,
5664 // rejected packet number 5688 // rejected packet number
5665 0xBC, 0x9A, 0x78, 0x56, 5689 0xBC, 0x9A, 0x78, 0x56,
5666 0x34, 0x12, 0x00, 0x00, 5690 0x34, 0x12, 0x00, 0x00,
5667 }; 5691 };
5692 unsigned char packet_no_rejected_packet_number[] = {
5693 // public flags (public reset, 8 byte ConnectionId)
5694 0x0A,
5695 // connection_id
5696 0x10, 0x32, 0x54, 0x76,
5697 0x98, 0xBA, 0xDC, 0xFE,
5698 // message tag (kPRST)
5699 'P', 'R', 'S', 'T',
5700 // num_entries (1) + padding
5701 0x01, 0x00, 0x00, 0x00,
5702 // tag kRNON
5703 'R', 'N', 'O', 'N',
5704 // end offset 8
5705 0x08, 0x00, 0x00, 0x00,
5706 // nonce proof
5707 0x89, 0x67, 0x45, 0x23,
5708 0x01, 0xEF, 0xCD, 0xAB,
5709 };
5668 // clang-format on 5710 // clang-format on
5669 5711
5670 std::unique_ptr<QuicEncryptedPacket> data( 5712 std::unique_ptr<QuicEncryptedPacket> data(
5671 framer_.BuildPublicResetPacket(reset_packet)); 5713 framer_.BuildPublicResetPacket(reset_packet));
5672 ASSERT_TRUE(data != nullptr); 5714 ASSERT_TRUE(data != nullptr);
5673 5715
5674 test::CompareCharArraysWithHexError("constructed packet", data->data(), 5716 if (FLAGS_quic_remove_packet_number_from_public_reset) {
5675 data->length(), AsChars(packet), 5717 test::CompareCharArraysWithHexError(
5676 arraysize(packet)); 5718 "constructed packet", data->data(), data->length(),
5719 AsChars(packet_no_rejected_packet_number),
5720 arraysize(packet_no_rejected_packet_number));
5721 } else {
5722 test::CompareCharArraysWithHexError("constructed packet", data->data(),
5723 data->length(), AsChars(packet),
5724 arraysize(packet));
5725 }
5677 } 5726 }
5678 5727
5679 TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { 5728 TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) {
5680 FLAGS_quic_use_old_public_reset_packets = false; 5729 FLAGS_quic_use_old_public_reset_packets = false;
5681 QuicPublicResetPacket reset_packet; 5730 QuicPublicResetPacket reset_packet;
5682 reset_packet.public_header.connection_id = kConnectionId; 5731 reset_packet.public_header.connection_id = kConnectionId;
5683 reset_packet.public_header.reset_flag = true; 5732 reset_packet.public_header.reset_flag = true;
5684 reset_packet.public_header.version_flag = false; 5733 reset_packet.public_header.version_flag = false;
5685 reset_packet.rejected_packet_number = kPacketNumber; 5734 reset_packet.rejected_packet_number = kPacketNumber;
5686 reset_packet.nonce_proof = kNonceProof; 5735 reset_packet.nonce_proof = kNonceProof;
(...skipping 26 matching lines...) Expand all
5713 0x89, 0x67, 0x45, 0x23, 5762 0x89, 0x67, 0x45, 0x23,
5714 0x01, 0xEF, 0xCD, 0xAB, 5763 0x01, 0xEF, 0xCD, 0xAB,
5715 // rejected packet number 5764 // rejected packet number
5716 0xBC, 0x9A, 0x78, 0x56, 5765 0xBC, 0x9A, 0x78, 0x56,
5717 0x34, 0x12, 0x00, 0x00, 5766 0x34, 0x12, 0x00, 0x00,
5718 // client address 5767 // client address
5719 0x02, 0x00, 5768 0x02, 0x00,
5720 0x7F, 0x00, 0x00, 0x01, 5769 0x7F, 0x00, 0x00, 0x01,
5721 0x34, 0x12, 5770 0x34, 0x12,
5722 }; 5771 };
5772 unsigned char packet_no_rejected_packet_number[] = {
5773 // public flags (public reset, 8 byte ConnectionId)
5774 0x0A,
5775 // connection_id
5776 0x10, 0x32, 0x54, 0x76,
5777 0x98, 0xBA, 0xDC, 0xFE,
5778 // message tag (kPRST)
5779 'P', 'R', 'S', 'T',
5780 // num_entries (2) + padding
5781 0x02, 0x00, 0x00, 0x00,
5782 // tag kRNON
5783 'R', 'N', 'O', 'N',
5784 // end offset 8
5785 0x08, 0x00, 0x00, 0x00,
5786 // tag kCADR
5787 'C', 'A', 'D', 'R',
5788 // end offset 16
5789 0x10, 0x00, 0x00, 0x00,
5790 // nonce proof
5791 0x89, 0x67, 0x45, 0x23,
5792 0x01, 0xEF, 0xCD, 0xAB,
5793 // client address
5794 0x02, 0x00,
5795 0x7F, 0x00, 0x00, 0x01,
5796 0x34, 0x12,
5797 };
5723 // clang-format on 5798 // clang-format on
5724 5799
5725 std::unique_ptr<QuicEncryptedPacket> data( 5800 std::unique_ptr<QuicEncryptedPacket> data(
5726 framer_.BuildPublicResetPacket(reset_packet)); 5801 framer_.BuildPublicResetPacket(reset_packet));
5727 ASSERT_TRUE(data != nullptr); 5802 ASSERT_TRUE(data != nullptr);
5728 5803
5729 test::CompareCharArraysWithHexError("constructed packet", data->data(), 5804 if (FLAGS_quic_remove_packet_number_from_public_reset) {
5730 data->length(), AsChars(packet), 5805 test::CompareCharArraysWithHexError(
5731 arraysize(packet)); 5806 "constructed packet", data->data(), data->length(),
5807 AsChars(packet_no_rejected_packet_number),
5808 arraysize(packet_no_rejected_packet_number));
5809 } else {
5810 test::CompareCharArraysWithHexError("constructed packet", data->data(),
5811 data->length(), AsChars(packet),
5812 arraysize(packet));
5813 }
5732 } 5814 }
5733 5815
5734 TEST_P(QuicFramerTest, EncryptPacket) { 5816 TEST_P(QuicFramerTest, EncryptPacket) {
5735 QuicPacketNumber packet_number = kPacketNumber; 5817 QuicPacketNumber packet_number = kPacketNumber;
5736 // clang-format off 5818 // clang-format off
5737 unsigned char packet[] = { 5819 unsigned char packet[] = {
5738 // public flags (8 byte connection_id) 5820 // public flags (8 byte connection_id)
5739 static_cast<unsigned char>( 5821 static_cast<unsigned char>(
5740 framer_.version() > QUIC_VERSION_32 ? 0x38 : 0x3C), 5822 framer_.version() > QUIC_VERSION_32 ? 0x38 : 0x3C),
5741 // connection_id 5823 // connection_id
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
6406 'o', ' ', 'w', 'o', 6488 'o', ' ', 'w', 'o',
6407 'r', 'l', 'd', '!', 6489 'r', 'l', 'd', '!',
6408 }; 6490 };
6409 // clang-format on 6491 // clang-format on
6410 6492
6411 QuicFramerFuzzFunc(packet, arraysize(packet)); 6493 QuicFramerFuzzFunc(packet, arraysize(packet));
6412 } 6494 }
6413 6495
6414 } // namespace test 6496 } // namespace test
6415 } // namespace net 6497 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_framer.cc ('k') | net/quic/core/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698