| 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/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 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 // clang-format on | 1609 // clang-format on |
| 1610 | 1610 |
| 1611 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1611 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
| 1612 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1612 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
| 1613 | 1613 |
| 1614 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1614 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
| 1615 ASSERT_TRUE(visitor_.public_header_.get()); | 1615 ASSERT_TRUE(visitor_.public_header_.get()); |
| 1616 ASSERT_FALSE(visitor_.header_.get()); | 1616 ASSERT_FALSE(visitor_.header_.get()); |
| 1617 } | 1617 } |
| 1618 | 1618 |
| 1619 TEST_P(QuicFramerTest, NewAckFrameOneAckBlock) { | 1619 TEST_P(QuicFramerTest, AckFrameOneAckBlock) { |
| 1620 // clang-format off | 1620 // clang-format off |
| 1621 unsigned char packet[] = { | 1621 unsigned char packet[] = { |
| 1622 // public flags (8 byte connection_id) | 1622 // public flags (8 byte connection_id) |
| 1623 0x3C, | 1623 0x3C, |
| 1624 // connection_id | 1624 // connection_id |
| 1625 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, | 1625 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 1626 // packet number | 1626 // packet number |
| 1627 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 1627 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
| 1628 | 1628 |
| 1629 // frame type (ack frame) | 1629 // frame type (ack frame) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 CheckProcessingFails( | 1678 CheckProcessingFails( |
| 1679 packet, | 1679 packet, |
| 1680 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 1680 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
| 1681 !kIncludeVersion, !kIncludePathId, | 1681 !kIncludeVersion, !kIncludePathId, |
| 1682 !kIncludeDiversificationNonce, | 1682 !kIncludeDiversificationNonce, |
| 1683 PACKET_6BYTE_PACKET_NUMBER), | 1683 PACKET_6BYTE_PACKET_NUMBER), |
| 1684 expected_error, QUIC_INVALID_ACK_DATA); | 1684 expected_error, QUIC_INVALID_ACK_DATA); |
| 1685 } | 1685 } |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 TEST_P(QuicFramerTest, NewAckFrameTwoTimeStampsMultipleAckBlocks) { | 1688 TEST_P(QuicFramerTest, AckFrameTwoTimeStampsMultipleAckBlocks) { |
| 1689 // clang-format off | 1689 // clang-format off |
| 1690 unsigned char packet[] = { | 1690 unsigned char packet[] = { |
| 1691 // public flags (8 byte connection_id) | 1691 // public flags (8 byte connection_id) |
| 1692 0x3C, | 1692 0x3C, |
| 1693 // connection_id | 1693 // connection_id |
| 1694 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, | 1694 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 1695 // packet number | 1695 // packet number |
| 1696 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 1696 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
| 1697 | 1697 |
| 1698 // frame type (ack frame) | 1698 // frame type (ack frame) |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2904 | 2904 |
| 2905 QuicConnectionId connection_id = kConnectionId; | 2905 QuicConnectionId connection_id = kConnectionId; |
| 2906 std::unique_ptr<QuicEncryptedPacket> data( | 2906 std::unique_ptr<QuicEncryptedPacket> data( |
| 2907 framer_.BuildVersionNegotiationPacket(connection_id, | 2907 framer_.BuildVersionNegotiationPacket(connection_id, |
| 2908 SupportedVersions(GetParam()))); | 2908 SupportedVersions(GetParam()))); |
| 2909 test::CompareCharArraysWithHexError("constructed packet", data->data(), | 2909 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
| 2910 data->length(), AsChars(packet), | 2910 data->length(), AsChars(packet), |
| 2911 arraysize(packet)); | 2911 arraysize(packet)); |
| 2912 } | 2912 } |
| 2913 | 2913 |
| 2914 TEST_P(QuicFramerTest, BuildNewAckFramePacketOneAckBlock) { | 2914 TEST_P(QuicFramerTest, BuildAckFramePacketOneAckBlock) { |
| 2915 QuicPacketHeader header; | 2915 QuicPacketHeader header; |
| 2916 header.public_header.connection_id = kConnectionId; | 2916 header.public_header.connection_id = kConnectionId; |
| 2917 header.public_header.reset_flag = false; | 2917 header.public_header.reset_flag = false; |
| 2918 header.public_header.version_flag = false; | 2918 header.public_header.version_flag = false; |
| 2919 header.packet_number = kPacketNumber; | 2919 header.packet_number = kPacketNumber; |
| 2920 | 2920 |
| 2921 // Use kSmallLargestObserved to make this test finished in a short time. | 2921 // Use kSmallLargestObserved to make this test finished in a short time. |
| 2922 QuicAckFrame ack_frame; | 2922 QuicAckFrame ack_frame; |
| 2923 ack_frame.largest_observed = kSmallLargestObserved; | 2923 ack_frame.largest_observed = kSmallLargestObserved; |
| 2924 ack_frame.ack_delay_time = QuicTime::Delta::Zero(); | 2924 ack_frame.ack_delay_time = QuicTime::Delta::Zero(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2950 // clang-format on | 2950 // clang-format on |
| 2951 | 2951 |
| 2952 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 2952 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
| 2953 ASSERT_TRUE(data != nullptr); | 2953 ASSERT_TRUE(data != nullptr); |
| 2954 | 2954 |
| 2955 test::CompareCharArraysWithHexError("constructed packet", data->data(), | 2955 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
| 2956 data->length(), AsChars(packet), | 2956 data->length(), AsChars(packet), |
| 2957 arraysize(packet)); | 2957 arraysize(packet)); |
| 2958 } | 2958 } |
| 2959 | 2959 |
| 2960 TEST_P(QuicFramerTest, BuildNewAckFramePacketMultipleAckBlocks) { | 2960 TEST_P(QuicFramerTest, BuildAckFramePacketMultipleAckBlocks) { |
| 2961 QuicPacketHeader header; | 2961 QuicPacketHeader header; |
| 2962 header.public_header.connection_id = kConnectionId; | 2962 header.public_header.connection_id = kConnectionId; |
| 2963 header.public_header.reset_flag = false; | 2963 header.public_header.reset_flag = false; |
| 2964 header.public_header.version_flag = false; | 2964 header.public_header.version_flag = false; |
| 2965 header.packet_number = kPacketNumber; | 2965 header.packet_number = kPacketNumber; |
| 2966 | 2966 |
| 2967 // Use kSmallLargestObserved to make this test finished in a short time. | 2967 // Use kSmallLargestObserved to make this test finished in a short time. |
| 2968 QuicAckFrame ack_frame; | 2968 QuicAckFrame ack_frame; |
| 2969 ack_frame.largest_observed = kSmallLargestObserved; | 2969 ack_frame.largest_observed = kSmallLargestObserved; |
| 2970 ack_frame.ack_delay_time = QuicTime::Delta::Zero(); | 2970 ack_frame.ack_delay_time = QuicTime::Delta::Zero(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 // clang-format on | 3017 // clang-format on |
| 3018 | 3018 |
| 3019 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 3019 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
| 3020 ASSERT_TRUE(data != nullptr); | 3020 ASSERT_TRUE(data != nullptr); |
| 3021 | 3021 |
| 3022 test::CompareCharArraysWithHexError("constructed packet", data->data(), | 3022 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
| 3023 data->length(), AsChars(packet), | 3023 data->length(), AsChars(packet), |
| 3024 arraysize(packet)); | 3024 arraysize(packet)); |
| 3025 } | 3025 } |
| 3026 | 3026 |
| 3027 TEST_P(QuicFramerTest, BuildNewAckFramePacketMaxAckBlocks) { | 3027 TEST_P(QuicFramerTest, BuildAckFramePacketMaxAckBlocks) { |
| 3028 QuicPacketHeader header; | 3028 QuicPacketHeader header; |
| 3029 header.public_header.connection_id = kConnectionId; | 3029 header.public_header.connection_id = kConnectionId; |
| 3030 header.public_header.reset_flag = false; | 3030 header.public_header.reset_flag = false; |
| 3031 header.public_header.version_flag = false; | 3031 header.public_header.version_flag = false; |
| 3032 header.packet_number = kPacketNumber; | 3032 header.packet_number = kPacketNumber; |
| 3033 | 3033 |
| 3034 // Use kSmallLargestObservedto make this test finished in a short time. | 3034 // Use kSmallLargestObservedto make this test finished in a short time. |
| 3035 QuicAckFrame ack_frame; | 3035 QuicAckFrame ack_frame; |
| 3036 ack_frame.largest_observed = kSmallLargestObserved; | 3036 ack_frame.largest_observed = kSmallLargestObserved; |
| 3037 ack_frame.ack_delay_time = QuicTime::Delta::Zero(); | 3037 ack_frame.ack_delay_time = QuicTime::Delta::Zero(); |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4176 'o', ' ', 'w', 'o', | 4176 'o', ' ', 'w', 'o', |
| 4177 'r', 'l', 'd', '!', | 4177 'r', 'l', 'd', '!', |
| 4178 }; | 4178 }; |
| 4179 // clang-format on | 4179 // clang-format on |
| 4180 | 4180 |
| 4181 QuicFramerFuzzFunc(packet, arraysize(packet)); | 4181 QuicFramerFuzzFunc(packet, arraysize(packet)); |
| 4182 } | 4182 } |
| 4183 | 4183 |
| 4184 } // namespace test | 4184 } // namespace test |
| 4185 } // namespace net | 4185 } // namespace net |
| OLD | NEW |