Index: net/quic/core/quic_framer_test.cc |
diff --git a/net/quic/core/quic_framer_test.cc b/net/quic/core/quic_framer_test.cc |
index a39a272f423f99fda1bc4f5d52e54b6f1054903a..b6a6fe72c3b85497ff9fdd1024b9cdfa4323e897 100644 |
--- a/net/quic/core/quic_framer_test.cc |
+++ b/net/quic/core/quic_framer_test.cc |
@@ -31,6 +31,7 @@ using testing::_; |
namespace net { |
namespace test { |
+namespace { |
const QuicPacketNumber kEpoch = UINT64_C(1) << 48; |
const QuicPacketNumber kMask = kEpoch - 1; |
@@ -446,6 +447,26 @@ class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { |
test::TestQuicVisitor visitor_; |
}; |
+// Helper function to get index of packets in hex format. |
+// For each packet in hex format, integers and floating numbers are in big |
+// endian for v38 and up, and connection ID is in big endian according to |
+// perspective and flags. |
+// There are 4 combinations: |
+// 0 : little endian connection ID, little endian integers/floating numbers. |
+// 1 : big endian connection ID, little endian integers/floating numbers. |
+// 2 : little endian connection ID, big endian integers/floating numbers. |
+// 3 : big endian connection ID, big endian integers/floating numbers. |
+size_t GetPacketIndex(QuicVersion version, Perspective perspective) { |
+ size_t index = 0; |
+ if (QuicUtils::IsConnectionIdWireFormatBigEndian(perspective)) { |
+ index = 1; |
+ } |
+ if (version > QUIC_VERSION_38) { |
+ index += 2; |
+ } |
+ return index; |
+} |
+ |
// Run all framer tests with all supported versions of QUIC. |
INSTANTIATE_TEST_CASE_P(QuicFramerTests, |
QuicFramerTest, |
@@ -627,17 +648,31 @@ TEST_P(QuicFramerTest, PacketHeader) { |
// packet number |
0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
ASSERT_TRUE(visitor_.header_.get()); |
@@ -661,11 +696,8 @@ TEST_P(QuicFramerTest, PacketHeader) { |
} else { |
expected_error = "Unable to read packet number."; |
} |
- CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- i, expected_error, QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails(packets[index], i, expected_error, |
+ QUIC_INVALID_PACKET_HEADER); |
} |
} |
@@ -681,9 +713,20 @@ TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) { |
0xBC, 0x9A, 0x78, 0x56, |
0x34, 0x12, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (0 byte connection_id) |
+ 0x30, |
+ // connection_id |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
+ QuicEncryptedPacket encrypted( |
+ AsChars(framer_.version() > QUIC_VERSION_38 ? packet39 : packet), |
+ arraysize(packet), false); |
EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
ASSERT_TRUE(visitor_.header_.get()); |
@@ -708,7 +751,9 @@ TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) { |
} else { |
expected_error = "Unable to read packet number."; |
} |
- CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails( |
+ framer_.version() > QUIC_VERSION_38 ? packet39 : packet, i, |
+ expected_error, QUIC_INVALID_PACKET_HEADER); |
} |
} |
@@ -735,17 +780,35 @@ TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { |
// packet number |
0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (version) |
+ 0x39, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (version) |
+ 0x39, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
ASSERT_TRUE(visitor_.header_.get()); |
@@ -772,11 +835,8 @@ TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { |
} else { |
expected_error = "Unable to read packet number."; |
} |
- CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- i, expected_error, QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails(packets[index], i, expected_error, |
+ QUIC_INVALID_PACKET_HEADER); |
} |
} |
@@ -801,17 +861,31 @@ TEST_P(QuicFramerTest, PacketHeaderWith4BytePacketNumber) { |
// packet number |
0xBC, 0x9A, 0x78, 0x56, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id and 4 byte packet number) |
+ 0x28, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x56, 0x78, 0x9A, 0xBC, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id and 4 byte packet number) |
+ 0x28, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x56, 0x78, 0x9A, 0xBC, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
ASSERT_TRUE(visitor_.header_.get()); |
@@ -835,11 +909,8 @@ TEST_P(QuicFramerTest, PacketHeaderWith4BytePacketNumber) { |
} else { |
expected_error = "Unable to read packet number."; |
} |
- CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- i, expected_error, QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails(packets[index], i, expected_error, |
+ QUIC_INVALID_PACKET_HEADER); |
} |
} |
@@ -864,17 +935,31 @@ TEST_P(QuicFramerTest, PacketHeaderWith2BytePacketNumber) { |
// packet number |
0xBC, 0x9A, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id and 2 byte packet number) |
+ 0x18, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x9A, 0xBC, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id and 2 byte packet number) |
+ 0x18, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x9A, 0xBC, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
ASSERT_TRUE(visitor_.header_.get()); |
@@ -900,11 +985,8 @@ TEST_P(QuicFramerTest, PacketHeaderWith2BytePacketNumber) { |
} else { |
expected_error = "Unable to read packet number."; |
} |
- CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- i, expected_error, QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails(packets[index], i, expected_error, |
+ QUIC_INVALID_PACKET_HEADER); |
} |
} |
@@ -1070,17 +1152,50 @@ TEST_P(QuicFramerTest, PacketWithDiversificationNonce) { |
0x00, |
0x00, 0x00, 0x00, 0x00 |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags: includes nonce flag |
+ static_cast<unsigned char>( |
+ FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x3C : 0x7C), |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // nonce |
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (padding) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags: includes nonce flag |
+ static_cast<unsigned char>( |
+ FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x3C : 0x7C), |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // nonce |
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (padding) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
ASSERT_TRUE(visitor_.public_header_->nonce != nullptr); |
@@ -1127,16 +1242,47 @@ TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) { |
0x00, |
0x00, 0x00, 0x00, 0x00 |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id, version flag and an unknown flag) |
+ static_cast<unsigned char>( |
+ FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x39 : 0x79), |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', '0', '0', |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id, version flag and an unknown flag) |
+ static_cast<unsigned char>( |
+ FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x39 : 0x79), |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // version tag |
+ 'Q', '0', '0', '0', |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
ASSERT_TRUE(visitor_.header_.get()); |
@@ -1296,30 +1442,83 @@ TEST_P(QuicFramerTest, NewPaddingFrame) { |
// paddings |
0x00, 0x00, |
}; |
- // clang-format on |
- if (framer_.version() <= QUIC_VERSION_37) { |
- return; |
- } |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
- EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
- EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
- ASSERT_TRUE(visitor_.header_.get()); |
- EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
- !kIncludeDiversificationNonce)); |
+ // paddings |
+ 0x00, 0x00, |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ // paddings |
+ 0x00, 0x00, |
+ }; |
- ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
- EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
- EXPECT_EQ(2u, visitor_.padding_frames_.size()); |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // paddings |
+ 0x00, 0x00, |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ // paddings |
+ 0x00, 0x00, |
+ }; |
+ // clang-format on |
+ |
+ if (framer_.version() <= QUIC_VERSION_37) { |
+ return; |
+ } |
+ |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
+ EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
+ EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
+ ASSERT_TRUE(visitor_.header_.get()); |
+ EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
+ !kIncludeDiversificationNonce)); |
+ |
+ ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
+ EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
+ EXPECT_EQ(2u, visitor_.padding_frames_.size()); |
EXPECT_EQ(2, visitor_.padding_frames_[0]->num_padding_bytes); |
EXPECT_EQ(2, visitor_.padding_frames_[1]->num_padding_bytes); |
EXPECT_EQ(kStreamId, visitor_.stream_frames_[0]->stream_id); |
@@ -1378,17 +1577,61 @@ TEST_P(QuicFramerTest, StreamFrame) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -1404,11 +1647,8 @@ TEST_P(QuicFramerTest, StreamFrame) { |
CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); |
// Now test framing boundaries. |
- CheckStreamFrameBoundaries( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- kQuicMaxStreamIdSize, !kIncludeVersion); |
+ CheckStreamFrameBoundaries(packets[index], kQuicMaxStreamIdSize, |
+ !kIncludeVersion); |
} |
TEST_P(QuicFramerTest, MissingDiversificationNonce) { |
@@ -1467,17 +1707,62 @@ TEST_P(QuicFramerTest, MissingDiversificationNonce) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_DECRYPTION_FAILURE, framer_.error()); |
} |
@@ -1532,17 +1817,62 @@ TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFE, |
+ // stream id |
+ 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFE, |
+ // stream id |
+ 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -1560,11 +1890,7 @@ TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) { |
// Now test framing boundaries. |
const size_t stream_id_size = 3; |
- CheckStreamFrameBoundaries( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- stream_id_size, !kIncludeVersion); |
+ CheckStreamFrameBoundaries(packets[index], stream_id_size, !kIncludeVersion); |
} |
TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { |
@@ -1617,17 +1943,62 @@ TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFD, |
+ // stream id |
+ 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFD, |
+ // stream id |
+ 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -1645,11 +2016,7 @@ TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { |
// Now test framing boundaries. |
const size_t stream_id_size = 2; |
- CheckStreamFrameBoundaries( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- stream_id_size, !kIncludeVersion); |
+ CheckStreamFrameBoundaries(packets[index], stream_id_size, !kIncludeVersion); |
} |
TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) { |
@@ -1702,17 +2069,62 @@ TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFC, |
+ // stream id |
+ 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFC, |
+ // stream id |
+ 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -1730,11 +2142,7 @@ TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) { |
// Now test framing boundaries. |
const size_t stream_id_size = 1; |
- CheckStreamFrameBoundaries( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- stream_id_size, !kIncludeVersion); |
+ CheckStreamFrameBoundaries(packets[index], stream_id_size, !kIncludeVersion); |
} |
TEST_P(QuicFramerTest, StreamFrameWithVersion) { |
@@ -1791,23 +2199,72 @@ TEST_P(QuicFramerTest, StreamFrameWithVersion) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
- // clang-format on |
- |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
- EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
- EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
- ASSERT_TRUE(visitor_.header_.get()); |
- EXPECT_TRUE(visitor_.header_->public_header.version_flag); |
- EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]); |
+ unsigned char packet39[] = { |
+ // public flags (version, 8 byte connection_id) |
+ 0x39, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (version, 8 byte connection_id) |
+ 0x39, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ // clang-format on |
+ |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
+ EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
+ |
+ EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
+ ASSERT_TRUE(visitor_.header_.get()); |
+ EXPECT_TRUE(visitor_.header_->public_header.version_flag); |
+ EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]); |
EXPECT_TRUE(CheckDecryption(encrypted, kIncludeVersion, |
!kIncludeDiversificationNonce)); |
@@ -1819,11 +2276,8 @@ TEST_P(QuicFramerTest, StreamFrameWithVersion) { |
CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); |
// Now test framing boundaries. |
- CheckStreamFrameBoundaries( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- kQuicMaxStreamIdSize, kIncludeVersion); |
+ CheckStreamFrameBoundaries(packets[index], kQuicMaxStreamIdSize, |
+ kIncludeVersion); |
} |
TEST_P(QuicFramerTest, RejectPacket) { |
@@ -1878,17 +2332,62 @@ TEST_P(QuicFramerTest, RejectPacket) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -1978,17 +2477,55 @@ TEST_P(QuicFramerTest, AckFrameOneAckBlock) { |
// num timestamps. |
0x00, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (ack frame) |
+ // (one ack block, 2 byte largest observed, 2 byte block length) |
+ 0x45, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // first ack block length. |
+ 0x12, 0x34, |
+ // num timestamps. |
+ 0x00, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (ack frame) |
+ // (one ack block, 2 byte largest observed, 2 byte block length) |
+ 0x45, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // first ack block length. |
+ 0x12, 0x34, |
+ // num timestamps. |
+ 0x00, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -2024,9 +2561,7 @@ TEST_P(QuicFramerTest, AckFrameOneAckBlock) { |
expected_error = "Unable to read num received packets."; |
} |
CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
+ packets[index], |
i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, !kIncludeDiversificationNonce, |
PACKET_6BYTE_PACKET_NUMBER), |
@@ -2129,17 +2664,107 @@ TEST_P(QuicFramerTest, AckFrameTwoTimeStampsMultipleAckBlocks) { |
// Delta time. |
0x10, 0x32, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (ack frame) |
+ // (more than one ack block, 2 byte largest observed, 2 byte block length) |
+ 0x65, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // num ack blocks ranges. |
+ 0x04, |
+ // first ack block length. |
+ 0x00, 0x01, |
+ // gap to next block. |
+ 0x01, |
+ // ack block length. |
+ 0x0e, 0xaf, |
+ // gap to next block. |
+ 0xff, |
+ // ack block length. |
+ 0x00, 0x00, |
+ // gap to next block. |
+ 0x91, |
+ // ack block length. |
+ 0x01, 0xea, |
+ // gap to next block. |
+ 0x05, |
+ // ack block length. |
+ 0x00, 0x04, |
+ // Number of timestamps. |
+ 0x02, |
+ // Delta from largest observed. |
+ 0x01, |
+ // Delta time. |
+ 0x76, 0x54, 0x32, 0x10, |
+ // Delta from largest observed. |
+ 0x02, |
+ // Delta time. |
+ 0x32, 0x10, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (ack frame) |
+ // (more than one ack block, 2 byte largest observed, 2 byte block length) |
+ 0x65, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // num ack blocks ranges. |
+ 0x04, |
+ // first ack block length. |
+ 0x00, 0x01, |
+ // gap to next block. |
+ 0x01, |
+ // ack block length. |
+ 0x0e, 0xaf, |
+ // gap to next block. |
+ 0xff, |
+ // ack block length. |
+ 0x00, 0x00, |
+ // gap to next block. |
+ 0x91, |
+ // ack block length. |
+ 0x01, 0xea, |
+ // gap to next block. |
+ 0x05, |
+ // ack block length. |
+ 0x00, 0x04, |
+ // Number of timestamps. |
+ 0x02, |
+ // Delta from largest observed. |
+ 0x01, |
+ // Delta time. |
+ 0x76, 0x54, 0x32, 0x10, |
+ // Delta from largest observed. |
+ 0x02, |
+ // Delta time. |
+ 0x32, 0x10, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -2226,9 +2851,7 @@ TEST_P(QuicFramerTest, AckFrameTwoTimeStampsMultipleAckBlocks) { |
} |
CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
+ packets[index], |
i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, !kIncludeDiversificationNonce, |
PACKET_6BYTE_PACKET_NUMBER), |
@@ -2268,27 +2891,54 @@ TEST_P(QuicFramerTest, NewStopWaitingFrame) { |
0x08, 0x00, 0x00, 0x00, |
0x00, 0x00, |
}; |
- // clang-format on |
- |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
- EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
- EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
- ASSERT_TRUE(visitor_.header_.get()); |
- EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
- !kIncludeDiversificationNonce)); |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xA8, |
+ // frame type (stop waiting frame) |
+ 0x06, |
+ // least packet number awaiting an ack, delta from packet number. |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x08, |
+ }; |
- EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
- ASSERT_EQ(1u, visitor_.stop_waiting_frames_.size()); |
- const QuicStopWaitingFrame& frame = *visitor_.stop_waiting_frames_[0]; |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xA8, |
+ // frame type (stop waiting frame) |
+ 0x06, |
+ // least packet number awaiting an ack, delta from packet number. |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x08, |
+ }; |
+ // clang-format on |
+ |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
+ EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
+ |
+ EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
+ ASSERT_TRUE(visitor_.header_.get()); |
+ EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
+ !kIncludeDiversificationNonce)); |
+ |
+ EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
+ ASSERT_EQ(1u, visitor_.stop_waiting_frames_.size()); |
+ const QuicStopWaitingFrame& frame = *visitor_.stop_waiting_frames_[0]; |
EXPECT_EQ(kLeastUnacked, frame.least_unacked); |
const size_t frame_size = 7; |
@@ -2296,9 +2946,7 @@ TEST_P(QuicFramerTest, NewStopWaitingFrame) { |
string expected_error; |
expected_error = "Unable to read least unacked delta."; |
CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
+ packets[index], |
i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, !kIncludeDiversificationNonce, |
PACKET_6BYTE_PACKET_NUMBER), |
@@ -2352,17 +3000,58 @@ TEST_P(QuicFramerTest, RstStreamFrameQuic) { |
// error code |
0x01, 0x00, 0x00, 0x00, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (rst stream frame) |
+ 0x01, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ |
+ // sent byte offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ |
+ // error code |
+ 0x00, 0x00, 0x00, 0x01, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (rst stream frame) |
+ 0x01, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ |
+ // sent byte offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ |
+ // error code |
+ 0x00, 0x00, 0x00, 0x01, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -2388,9 +3077,7 @@ TEST_P(QuicFramerTest, RstStreamFrameQuic) { |
expected_error = "Unable to read rst stream error code."; |
} |
CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
+ packets[index], |
i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, !kIncludeDiversificationNonce, |
PACKET_6BYTE_PACKET_NUMBER), |
@@ -2446,17 +3133,60 @@ TEST_P(QuicFramerTest, ConnectionCloseFrame) { |
'I', ' ', 'c', 'a', |
'n', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (connection close frame) |
+ 0x02, |
+ // error code |
+ 0x00, 0x00, 0x00, 0x11, |
+ |
+ // error details length |
+ 0x00, 0x0d, |
+ // error details |
+ 'b', 'e', 'c', 'a', |
+ 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', |
+ 'n', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (connection close frame) |
+ 0x02, |
+ // error code |
+ 0x00, 0x00, 0x00, 0x11, |
+ |
+ // error details length |
+ 0x00, 0x0d, |
+ // error details |
+ 'b', 'e', 'c', 'a', |
+ 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', |
+ 'n', |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -2481,9 +3211,7 @@ TEST_P(QuicFramerTest, ConnectionCloseFrame) { |
expected_error = "Unable to read connection close error details."; |
} |
CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
+ packets[index], |
i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, !kIncludeDiversificationNonce, |
PACKET_6BYTE_PACKET_NUMBER), |
@@ -2541,17 +3269,62 @@ TEST_P(QuicFramerTest, GoAwayFrame) { |
'I', ' ', 'c', 'a', |
'n', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (go away frame) |
+ 0x03, |
+ // error code |
+ 0x00, 0x00, 0x00, 0x09, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // error details length |
+ 0x00, 0x0d, |
+ // error details |
+ 'b', 'e', 'c', 'a', |
+ 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', |
+ 'n', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (go away frame) |
+ 0x03, |
+ // error code |
+ 0x00, 0x00, 0x00, 0x09, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // error details length |
+ 0x00, 0x0d, |
+ // error details |
+ 'b', 'e', 'c', 'a', |
+ 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', |
+ 'n', |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -2577,9 +3350,7 @@ TEST_P(QuicFramerTest, GoAwayFrame) { |
expected_error = "Unable to read goaway reason."; |
} |
CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
+ packets[index], |
i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, !kIncludeDiversificationNonce, |
PACKET_6BYTE_PACKET_NUMBER), |
@@ -2625,17 +3396,50 @@ TEST_P(QuicFramerTest, WindowUpdateFrame) { |
0x54, 0x76, 0x10, 0x32, |
0xDC, 0xFE, 0x98, 0xBA, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (window update frame) |
+ 0x04, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // byte offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (window update frame) |
+ 0x04, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // byte offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -2656,9 +3460,7 @@ TEST_P(QuicFramerTest, WindowUpdateFrame) { |
expected_error = "Unable to read window byte_offset."; |
} |
CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
+ packets[index], |
i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, !kIncludeDiversificationNonce, |
PACKET_6BYTE_PACKET_NUMBER), |
@@ -2698,17 +3500,44 @@ TEST_P(QuicFramerTest, BlockedFrame) { |
// stream id |
0x04, 0x03, 0x02, 0x01, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (blocked frame) |
+ 0x05, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (blocked frame) |
+ 0x05, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ }; |
// clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -2723,9 +3552,7 @@ TEST_P(QuicFramerTest, BlockedFrame) { |
++i) { |
string expected_error = "Unable to read stream_id."; |
CheckProcessingFails( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
+ packets[index], |
i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, !kIncludeDiversificationNonce, |
PACKET_6BYTE_PACKET_NUMBER), |
@@ -2761,17 +3588,40 @@ TEST_P(QuicFramerTest, PingFrame) { |
// frame type (ping frame) |
0x07, |
}; |
- // clang-format on |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (ping frame) |
+ 0x07, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (ping frame) |
+ 0x07, |
+ }; |
+ // clang-format on |
+ |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -2855,7 +3705,6 @@ TEST_P(QuicFramerTest, PublicResetPacketV33) { |
EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag); |
EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag); |
EXPECT_EQ(kNonceProof, visitor_.public_reset_packet_->nonce_proof); |
- EXPECT_EQ(0u, visitor_.public_reset_packet_->rejected_packet_number); |
EXPECT_EQ( |
IpAddressFamily::IP_UNSPEC, |
visitor_.public_reset_packet_->client_address.host().address_family()); |
@@ -2974,7 +3823,6 @@ TEST_P(QuicFramerTest, PublicResetPacket) { |
EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag); |
EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag); |
EXPECT_EQ(kNonceProof, visitor_.public_reset_packet_->nonce_proof); |
- EXPECT_EQ(0u, visitor_.public_reset_packet_->rejected_packet_number); |
EXPECT_EQ( |
IpAddressFamily::IP_UNSPEC, |
visitor_.public_reset_packet_->client_address.host().address_family()); |
@@ -3176,7 +4024,6 @@ TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) { |
EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag); |
EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag); |
EXPECT_EQ(kNonceProof, visitor_.public_reset_packet_->nonce_proof); |
- EXPECT_EQ(0u, visitor_.public_reset_packet_->rejected_packet_number); |
EXPECT_EQ("4.31.198.44", |
visitor_.public_reset_packet_->client_address.host().ToString()); |
EXPECT_EQ(443, visitor_.public_reset_packet_->client_address.port()); |
@@ -3380,29 +4227,52 @@ TEST_P(QuicFramerTest, BuildPaddingFramePacket) { |
0x00, |
0x00, 0x00, 0x00, 0x00 |
}; |
+ |
+ unsigned char packet39[kMaxPacketSize] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
+ |
+ unsigned char packet_cid_be39[kMaxPacketSize] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
uint64_t header_size = GetPacketHeaderSize( |
framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
!kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER); |
- memset((QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet) + |
- header_size + 1, |
- 0x00, kMaxPacketSize - header_size - 1); |
+ memset((packets[index]) + header_size + 1, 0x00, |
+ kMaxPacketSize - header_size - 1); |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildStreamFramePacketWithNewPaddingFrame) { |
@@ -3478,20 +4348,74 @@ TEST_P(QuicFramerTest, BuildStreamFramePacketWithNewPaddingFrame) { |
// paddings |
0x00, 0x00, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // paddings |
+ 0x00, 0x00, |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ // paddings |
+ 0x00, 0x00, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // paddings |
+ 0x00, 0x00, |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ // paddings |
+ 0x00, 0x00, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { |
@@ -3531,29 +4455,50 @@ TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { |
0x00, |
0x00, 0x00, 0x00, 0x00 |
}; |
+ |
+ unsigned char packet39[kMaxPacketSize] = { |
+ // public flags (8 byte connection_id and 4 byte packet number) |
+ 0x28, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
+ |
+ unsigned char packet_cid_be39[kMaxPacketSize] = { |
+ // public flags (8 byte connection_id and 4 byte packet number) |
+ 0x28, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
uint64_t header_size = GetPacketHeaderSize( |
framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
!kIncludeDiversificationNonce, PACKET_4BYTE_PACKET_NUMBER); |
- memset((QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet) + |
- header_size + 1, |
- 0x00, kMaxPacketSize - header_size - 1); |
+ memset((packets[index]) + header_size + 1, 0x00, |
+ kMaxPacketSize - header_size - 1); |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { |
@@ -3593,29 +4538,50 @@ TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { |
0x00, |
0x00, 0x00, 0x00, 0x00 |
}; |
+ |
+ unsigned char packet39[kMaxPacketSize] = { |
+ // public flags (8 byte connection_id and 2 byte packet number) |
+ 0x18, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x9A, 0xBC, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
+ |
+ unsigned char packet_cid_be39[kMaxPacketSize] = { |
+ // public flags (8 byte connection_id and 2 byte packet number) |
+ 0x18, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x9A, 0xBC, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ 0x00, 0x00, 0x00, 0x00 |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
uint64_t header_size = GetPacketHeaderSize( |
framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
!kIncludeDiversificationNonce, PACKET_2BYTE_PACKET_NUMBER); |
- memset((QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet) + |
- header_size + 1, |
- 0x00, kMaxPacketSize - header_size - 1); |
+ memset((packets[index]) + header_size + 1, 0x00, |
+ kMaxPacketSize - header_size - 1); |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) { |
@@ -3737,20 +4703,62 @@ TEST_P(QuicFramerTest, BuildStreamFramePacket) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin and no length) |
+ 0xDF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin and no length) |
+ 0xDF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { |
@@ -3806,21 +4814,60 @@ TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { |
// data |
'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
}; |
- // clang-format on |
- QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); |
- std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
- ASSERT_TRUE(data != nullptr); |
+ unsigned char packet39[] = { |
+ // public flags (version, 8 byte connection_id) |
+ static_cast<unsigned char>( |
+ FLAGS_quic_reloadable_flag_quic_remove_v33_hacks2 ? 0x39 : 0x3D), |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ // frame type (stream frame with fin and no length) |
+ 0xDF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, 0x32, 0x10, 0x76, 0x54, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (version, 8 byte connection_id) |
+ static_cast<unsigned char>( |
+ FLAGS_quic_reloadable_flag_quic_remove_v33_hacks2 ? 0x39 : 0x3D), |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin and no length) |
+ 0xDF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, 0x32, 0x10, 0x76, 0x54, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
+ }; |
+ // clang-format on |
+ |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); |
+ std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
+ ASSERT_TRUE(data != nullptr); |
+ |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { |
@@ -3916,20 +4963,59 @@ TEST_P(QuicFramerTest, BuildAckFramePacketOneAckBlock) { |
// num timestamps. |
0x00, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (ack frame) |
+ // (no ack blocks, 2 byte largest observed, 2 byte block length) |
+ 0x45, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // first ack block length. |
+ 0x12, 0x34, |
+ // num timestamps. |
+ 0x00, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (ack frame) |
+ // (no ack blocks, 2 byte largest observed, 2 byte block length) |
+ 0x45, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // first ack block length. |
+ 0x12, 0x34, |
+ // num timestamps. |
+ 0x00, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildAckFramePacketMultipleAckBlocks) { |
@@ -4028,20 +5114,95 @@ TEST_P(QuicFramerTest, BuildAckFramePacketMultipleAckBlocks) { |
// num timestamps. |
0x00, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (ack frame) |
+ // (has ack blocks, 2 byte largest observed, 2 byte block length) |
+ 0x65, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // num ack blocks ranges. |
+ 0x04, |
+ // first ack block length. |
+ 0x00, 0x01, |
+ // gap to next block. |
+ 0x01, |
+ // ack block length. |
+ 0x0e, 0xaf, |
+ // gap to next block. |
+ 0xff, |
+ // ack block length. |
+ 0x00, 0x00, |
+ // gap to next block. |
+ 0x91, |
+ // ack block length. |
+ 0x01, 0xea, |
+ // gap to next block. |
+ 0x05, |
+ // ack block length. |
+ 0x00, 0x04, |
+ // num timestamps. |
+ 0x00, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (ack frame) |
+ // (has ack blocks, 2 byte largest observed, 2 byte block length) |
+ 0x65, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // num ack blocks ranges. |
+ 0x04, |
+ // first ack block length. |
+ 0x00, 0x01, |
+ // gap to next block. |
+ 0x01, |
+ // ack block length. |
+ 0x0e, 0xaf, |
+ // gap to next block. |
+ 0xff, |
+ // ack block length. |
+ 0x00, 0x00, |
+ // gap to next block. |
+ 0x91, |
+ // ack block length. |
+ 0x01, 0xea, |
+ // gap to next block. |
+ 0x05, |
+ // ack block length. |
+ 0x00, 0x04, |
+ // num timestamps. |
+ 0x00, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildAckFramePacketMaxAckBlocks) { |
@@ -4249,20 +5410,203 @@ TEST_P(QuicFramerTest, BuildAckFramePacketMaxAckBlocks) { |
// num timestamps. |
0x00, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ // frame type (ack frame) |
+ // (has ack blocks, 2 byte largest observed, 2 byte block length) |
+ 0x65, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // num ack blocks ranges. |
+ 0xff, |
+ // first ack block length. |
+ 0x0f, 0xdd, |
+ // 255 = 4 * 63 + 3 |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ // num timestamps. |
+ 0x00, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ // frame type (ack frame) |
+ // (has ack blocks, 2 byte largest observed, 2 byte block length) |
+ 0x65, |
+ // largest acked |
+ 0x12, 0x34, |
+ // Zero delta time. |
+ 0x00, 0x00, |
+ // num ack blocks ranges. |
+ 0xff, |
+ // first ack block length. |
+ 0x0f, 0xdd, |
+ // 255 = 4 * 63 + 3 |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
+ // num timestamps. |
+ 0x00, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildNewStopWaitingPacket) { |
@@ -4308,20 +5652,48 @@ TEST_P(QuicFramerTest, BuildNewStopWaitingPacket) { |
0x1C, 0x00, 0x00, 0x00, |
0x00, 0x00, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (stop waiting frame) |
+ 0x06, |
+ // least packet number awaiting an ack, delta from packet number. |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x1C, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
+ |
+ // frame type (stop waiting frame) |
+ 0x06, |
+ // least packet number awaiting an ack, delta from packet number. |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x1C, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { |
@@ -4377,22 +5749,60 @@ TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { |
// error code |
0x08, 0x07, 0x06, 0x05, |
}; |
- // clang-format on |
- QuicFrames frames = {QuicFrame(&rst_frame)}; |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
- std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
- ASSERT_TRUE(data != nullptr); |
+ // frame type (rst stream frame) |
+ 0x01, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // sent byte offset |
+ 0x08, 0x07, 0x06, 0x05, |
+ 0x04, 0x03, 0x02, 0x01, |
+ // error code |
+ 0x05, 0x06, 0x07, 0x08, |
+ }; |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (rst stream frame) |
+ 0x01, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // sent byte offset |
+ 0x08, 0x07, 0x06, 0x05, |
+ 0x04, 0x03, 0x02, 0x01, |
+ // error code |
+ 0x05, 0x06, 0x07, 0x08, |
+ }; |
+ // clang-format on |
+ |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicFrames frames = {QuicFrame(&rst_frame)}; |
+ |
+ std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
+ ASSERT_TRUE(data != nullptr); |
+ |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildCloseFramePacket) { |
@@ -4453,20 +5863,62 @@ TEST_P(QuicFramerTest, BuildCloseFramePacket) { |
'I', ' ', 'c', 'a', |
'n', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (connection close frame) |
+ 0x02, |
+ // error code |
+ 0x05, 0x06, 0x07, 0x08, |
+ // error details length |
+ 0x00, 0x0d, |
+ // error details |
+ 'b', 'e', 'c', 'a', |
+ 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', |
+ 'n', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (connection close frame) |
+ 0x02, |
+ // error code |
+ 0x05, 0x06, 0x07, 0x08, |
+ // error details length |
+ 0x00, 0x0d, |
+ // error details |
+ 'b', 'e', 'c', 'a', |
+ 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', |
+ 'n', |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildGoAwayPacket) { |
@@ -4532,20 +5984,66 @@ TEST_P(QuicFramerTest, BuildGoAwayPacket) { |
'I', ' ', 'c', 'a', |
'n', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (go away frame) |
+ 0x03, |
+ // error code |
+ 0x05, 0x06, 0x07, 0x08, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // error details length |
+ 0x00, 0x0d, |
+ // error details |
+ 'b', 'e', 'c', 'a', |
+ 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', |
+ 'n', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (go away frame) |
+ 0x03, |
+ // error code |
+ 0x05, 0x06, 0x07, 0x08, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // error details length |
+ 0x00, 0x0d, |
+ // error details |
+ 'b', 'e', 'c', 'a', |
+ 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', |
+ 'n', |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { |
@@ -4598,20 +6096,54 @@ TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { |
0x88, 0x77, 0x66, 0x55, |
0x44, 0x33, 0x22, 0x11, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (window update frame) |
+ 0x04, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // byte offset |
+ 0x11, 0x22, 0x33, 0x44, |
+ 0x55, 0x66, 0x77, 0x88, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (window update frame) |
+ 0x04, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // byte offset |
+ 0x11, 0x22, 0x33, 0x44, |
+ 0x55, 0x66, 0x77, 0x88, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildBlockedPacket) { |
@@ -4657,20 +6189,48 @@ TEST_P(QuicFramerTest, BuildBlockedPacket) { |
// stream id |
0x04, 0x03, 0x02, 0x01, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (blocked frame) |
+ 0x05, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (blocked frame) |
+ 0x05, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildPingPacket) { |
@@ -4709,20 +6269,44 @@ TEST_P(QuicFramerTest, BuildPingPacket) { |
// frame type (ping frame) |
0x07, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (ping frame) |
+ 0x07, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (ping frame) |
+ 0x07, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
// Test that the MTU discovery packet is serialized correctly as a PING packet. |
@@ -4762,211 +6346,58 @@ TEST_P(QuicFramerTest, BuildMtuDiscoveryPacket) { |
// frame type (ping frame) |
0x07, |
}; |
- // clang-format on |
- |
- std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
- ASSERT_TRUE(data != nullptr); |
- |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
-} |
- |
-TEST_P(QuicFramerTest, BuildPublicResetPacketOld) { |
- FLAGS_quic_reloadable_flag_quic_use_old_public_reset_packets = true; |
- QuicPublicResetPacket reset_packet; |
- reset_packet.public_header.connection_id = kConnectionId; |
- reset_packet.public_header.reset_flag = true; |
- reset_packet.public_header.version_flag = false; |
- reset_packet.rejected_packet_number = kPacketNumber; |
- reset_packet.nonce_proof = kNonceProof; |
- // clang-format off |
- unsigned char packet[] = { |
- // public flags (public reset, 8 byte ConnectionId) |
- 0x0E, |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
// connection_id |
0x10, 0x32, 0x54, 0x76, |
0x98, 0xBA, 0xDC, 0xFE, |
- // message tag (kPRST) |
- 'P', 'R', 'S', 'T', |
- // num_entries (2) + padding |
- 0x02, 0x00, 0x00, 0x00, |
- // tag kRNON |
- 'R', 'N', 'O', 'N', |
- // end offset 8 |
- 0x08, 0x00, 0x00, 0x00, |
- // tag kRSEQ |
- 'R', 'S', 'E', 'Q', |
- // end offset 16 |
- 0x10, 0x00, 0x00, 0x00, |
- // nonce proof |
- 0x89, 0x67, 0x45, 0x23, |
- 0x01, 0xEF, 0xCD, 0xAB, |
- // rejected packet number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- }; |
- |
- unsigned char packet_cid_be[] = { |
- // public flags (public reset, 8 byte ConnectionId) |
- 0x0E, |
- // connection_id |
- 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
- // message tag (kPRST) |
- 'P', 'R', 'S', 'T', |
- // num_entries (2) + padding |
- 0x02, 0x00, 0x00, 0x00, |
- // tag kRNON |
- 'R', 'N', 'O', 'N', |
- // end offset 8 |
- 0x08, 0x00, 0x00, 0x00, |
- // tag kRSEQ |
- 'R', 'S', 'E', 'Q', |
- // end offset 16 |
- 0x10, 0x00, 0x00, 0x00, |
- // nonce proof |
- 0x89, 0x67, 0x45, 0x23, |
- 0x01, 0xEF, 0xCD, 0xAB, |
- // rejected packet number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- }; |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
- unsigned char packet_no_rejected_packet_number[] = { |
- // public flags (public reset, 8 byte ConnectionId) |
- 0x0E, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // message tag (kPRST) |
- 'P', 'R', 'S', 'T', |
- // num_entries (1) + padding |
- 0x01, 0x00, 0x00, 0x00, |
- // tag kRNON |
- 'R', 'N', 'O', 'N', |
- // end offset 8 |
- 0x08, 0x00, 0x00, 0x00, |
- // nonce proof |
- 0x89, 0x67, 0x45, 0x23, |
- 0x01, 0xEF, 0xCD, 0xAB, |
+ // frame type (ping frame) |
+ 0x07, |
}; |
- unsigned char packet_no_rejected_packet_number_cid_be[] = { |
- // public flags (public reset, 8 byte ConnectionId) |
- 0x0E, |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
// connection_id |
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
- // message tag (kPRST) |
- 'P', 'R', 'S', 'T', |
- // num_entries (1) + padding |
- 0x01, 0x00, 0x00, 0x00, |
- // tag kRNON |
- 'R', 'N', 'O', 'N', |
- // end offset 8 |
- 0x08, 0x00, 0x00, 0x00, |
- // nonce proof |
- 0x89, 0x67, 0x45, 0x23, |
- 0x01, 0xEF, 0xCD, 0xAB, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (ping frame) |
+ 0x07, |
}; |
// clang-format on |
- std::unique_ptr<QuicEncryptedPacket> data( |
- framer_.BuildPublicResetPacket(reset_packet)); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
ASSERT_TRUE(data != nullptr); |
- if (FLAGS_quic_reloadable_flag_quic_remove_packet_number_from_public_reset) { |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_no_rejected_packet_number_cid_be |
- : packet_no_rejected_packet_number), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_no_rejected_packet_number_cid_be) |
- : arraysize(packet_no_rejected_packet_number)); |
- } else { |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
- } |
+ |
+ test::CompareCharArraysWithHexError("constructed packet", data->data(), |
+ data->length(), AsChars(packets[index]), |
+ arraysize(packet)); |
} |
-TEST_P(QuicFramerTest, BuildPublicResetPacket) { |
- FLAGS_quic_reloadable_flag_quic_use_old_public_reset_packets = false; |
+TEST_P(QuicFramerTest, BuildPublicResetPacketOld) { |
+ FLAGS_quic_reloadable_flag_quic_use_old_public_reset_packets = true; |
QuicPublicResetPacket reset_packet; |
reset_packet.public_header.connection_id = kConnectionId; |
reset_packet.public_header.reset_flag = true; |
reset_packet.public_header.version_flag = false; |
- reset_packet.rejected_packet_number = kPacketNumber; |
reset_packet.nonce_proof = kNonceProof; |
// clang-format off |
unsigned char packet[] = { |
// public flags (public reset, 8 byte ConnectionId) |
- 0x0A, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // message tag (kPRST) |
- 'P', 'R', 'S', 'T', |
- // num_entries (2) + padding |
- 0x02, 0x00, 0x00, 0x00, |
- // tag kRNON |
- 'R', 'N', 'O', 'N', |
- // end offset 8 |
- 0x08, 0x00, 0x00, 0x00, |
- // tag kRSEQ |
- 'R', 'S', 'E', 'Q', |
- // end offset 16 |
- 0x10, 0x00, 0x00, 0x00, |
- // nonce proof |
- 0x89, 0x67, 0x45, 0x23, |
- 0x01, 0xEF, 0xCD, 0xAB, |
- // rejected packet number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- }; |
- |
- unsigned char packet_cid_be[] = { |
- // public flags (public reset, 8 byte ConnectionId) |
- 0x0A, |
- // connection_id |
- 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
- // message tag (kPRST) |
- 'P', 'R', 'S', 'T', |
- // num_entries (2) + padding |
- 0x02, 0x00, 0x00, 0x00, |
- // tag kRNON |
- 'R', 'N', 'O', 'N', |
- // end offset 8 |
- 0x08, 0x00, 0x00, 0x00, |
- // tag kRSEQ |
- 'R', 'S', 'E', 'Q', |
- // end offset 16 |
- 0x10, 0x00, 0x00, 0x00, |
- // nonce proof |
- 0x89, 0x67, 0x45, 0x23, |
- 0x01, 0xEF, 0xCD, 0xAB, |
- // rejected packet number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- }; |
- |
- unsigned char packet_no_rejected_packet_number[] = { |
- // public flags (public reset, 8 byte ConnectionId) |
- 0x0A, |
+ 0x0E, |
// connection_id |
0x10, 0x32, 0x54, 0x76, |
0x98, 0xBA, 0xDC, 0xFE, |
@@ -4983,9 +6414,9 @@ TEST_P(QuicFramerTest, BuildPublicResetPacket) { |
0x01, 0xEF, 0xCD, 0xAB, |
}; |
- unsigned char packet_no_rejected_packet_number_cid_be[] = { |
+ unsigned char packet_cid_be[] = { |
// public flags (public reset, 8 byte ConnectionId) |
- 0x0A, |
+ 0x0E, |
// connection_id |
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
// message tag (kPRST) |
@@ -5005,110 +6436,92 @@ TEST_P(QuicFramerTest, BuildPublicResetPacket) { |
std::unique_ptr<QuicEncryptedPacket> data( |
framer_.BuildPublicResetPacket(reset_packet)); |
ASSERT_TRUE(data != nullptr); |
- |
- if (FLAGS_quic_reloadable_flag_quic_remove_packet_number_from_public_reset) { |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_no_rejected_packet_number_cid_be |
- : packet_no_rejected_packet_number), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_no_rejected_packet_number_cid_be) |
- : arraysize(packet_no_rejected_packet_number)); |
- } else { |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
- } |
+ test::CompareCharArraysWithHexError( |
+ "constructed packet", data->data(), data->length(), |
+ AsChars( |
+ QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
+ ? packet_cid_be |
+ : packet), |
+ QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
+ ? arraysize(packet_cid_be) |
+ : arraysize(packet)); |
} |
-TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { |
+TEST_P(QuicFramerTest, BuildPublicResetPacket) { |
FLAGS_quic_reloadable_flag_quic_use_old_public_reset_packets = false; |
QuicPublicResetPacket reset_packet; |
reset_packet.public_header.connection_id = kConnectionId; |
reset_packet.public_header.reset_flag = true; |
reset_packet.public_header.version_flag = false; |
- reset_packet.rejected_packet_number = kPacketNumber; |
reset_packet.nonce_proof = kNonceProof; |
- reset_packet.client_address = |
- QuicSocketAddress(QuicIpAddress::Loopback4(), 0x1234); |
// clang-format off |
unsigned char packet[] = { |
- // public flags (public reset, 8 byte ConnectionId) |
- 0x0A, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // message tag (kPRST) |
- 'P', 'R', 'S', 'T', |
- // num_entries (3) + padding |
- 0x03, 0x00, 0x00, 0x00, |
- // tag kRNON |
- 'R', 'N', 'O', 'N', |
- // end offset 8 |
- 0x08, 0x00, 0x00, 0x00, |
- // tag kRSEQ |
- 'R', 'S', 'E', 'Q', |
- // end offset 16 |
- 0x10, 0x00, 0x00, 0x00, |
- // tag kCADR |
- 'C', 'A', 'D', 'R', |
- // end offset 24 |
- 0x18, 0x00, 0x00, 0x00, |
- // nonce proof |
- 0x89, 0x67, 0x45, 0x23, |
- 0x01, 0xEF, 0xCD, 0xAB, |
- // rejected packet number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- // client address |
- 0x02, 0x00, |
- 0x7F, 0x00, 0x00, 0x01, |
- 0x34, 0x12, |
+ // public flags (public reset, 8 byte ConnectionId) |
+ 0x0A, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // message tag (kPRST) |
+ 'P', 'R', 'S', 'T', |
+ // num_entries (1) + padding |
+ 0x01, 0x00, 0x00, 0x00, |
+ // tag kRNON |
+ 'R', 'N', 'O', 'N', |
+ // end offset 8 |
+ 0x08, 0x00, 0x00, 0x00, |
+ // nonce proof |
+ 0x89, 0x67, 0x45, 0x23, |
+ 0x01, 0xEF, 0xCD, 0xAB, |
+ }; |
+ |
+ unsigned char packet_cid_be[] = { |
+ // public flags (public reset, 8 byte ConnectionId) |
+ 0x0A, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, |
+ 0x76, 0x54, 0x32, 0x10, |
+ // message tag (kPRST) |
+ 'P', 'R', 'S', 'T', |
+ // num_entries (1) + padding |
+ 0x01, 0x00, 0x00, 0x00, |
+ // tag kRNON |
+ 'R', 'N', 'O', 'N', |
+ // end offset 8 |
+ 0x08, 0x00, 0x00, 0x00, |
+ // nonce proof |
+ 0x89, 0x67, 0x45, 0x23, |
+ 0x01, 0xEF, 0xCD, 0xAB, |
}; |
+ // clang-format on |
- unsigned char packet_cid_be[] = { |
- // public flags (public reset, 8 byte ConnectionId) |
- 0x0A, |
- // connection_id |
- 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
- // message tag (kPRST) |
- 'P', 'R', 'S', 'T', |
- // num_entries (3) + padding |
- 0x03, 0x00, 0x00, 0x00, |
- // tag kRNON |
- 'R', 'N', 'O', 'N', |
- // end offset 8 |
- 0x08, 0x00, 0x00, 0x00, |
- // tag kRSEQ |
- 'R', 'S', 'E', 'Q', |
- // end offset 16 |
- 0x10, 0x00, 0x00, 0x00, |
- // tag kCADR |
- 'C', 'A', 'D', 'R', |
- // end offset 24 |
- 0x18, 0x00, 0x00, 0x00, |
- // nonce proof |
- 0x89, 0x67, 0x45, 0x23, |
- 0x01, 0xEF, 0xCD, 0xAB, |
- // rejected packet number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- // client address |
- 0x02, 0x00, |
- 0x7F, 0x00, 0x00, 0x01, |
- 0x34, 0x12, |
- }; |
+ std::unique_ptr<QuicEncryptedPacket> data( |
+ framer_.BuildPublicResetPacket(reset_packet)); |
+ ASSERT_TRUE(data != nullptr); |
+ |
+ test::CompareCharArraysWithHexError( |
+ "constructed packet", data->data(), data->length(), |
+ AsChars( |
+ QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
+ ? packet_cid_be |
+ : packet), |
+ QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
+ ? arraysize(packet_cid_be) |
+ : arraysize(packet)); |
+} |
+ |
+TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { |
+ FLAGS_quic_reloadable_flag_quic_use_old_public_reset_packets = false; |
+ QuicPublicResetPacket reset_packet; |
+ reset_packet.public_header.connection_id = kConnectionId; |
+ reset_packet.public_header.reset_flag = true; |
+ reset_packet.public_header.version_flag = false; |
+ reset_packet.nonce_proof = kNonceProof; |
+ reset_packet.client_address = |
+ QuicSocketAddress(QuicIpAddress::Loopback4(), 0x1234); |
- unsigned char packet_no_rejected_packet_number[] = { |
+ // clang-format off |
+ unsigned char packet[] = { |
// public flags (public reset, 8 byte ConnectionId) |
0x0A, |
// connection_id |
@@ -5135,11 +6548,12 @@ TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { |
0x34, 0x12, |
}; |
- unsigned char packet_no_rejected_packet_number_cid_be[] = { |
+ unsigned char packet_cid_be[] = { |
// public flags (public reset, 8 byte ConnectionId) |
0x0A, |
// connection_id |
- 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ 0xFE, 0xDC, 0xBA, 0x98, |
+ 0x76, 0x54, 0x32, 0x10, |
// message tag (kPRST) |
'P', 'R', 'S', 'T', |
// num_entries (2) + padding |
@@ -5166,29 +6580,16 @@ TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { |
framer_.BuildPublicResetPacket(reset_packet)); |
ASSERT_TRUE(data != nullptr); |
- if (FLAGS_quic_reloadable_flag_quic_remove_packet_number_from_public_reset) { |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_no_rejected_packet_number_cid_be |
- : packet_no_rejected_packet_number), |
- |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_no_rejected_packet_number_cid_be) |
- : arraysize(packet_no_rejected_packet_number)); |
- } else { |
- test::CompareCharArraysWithHexError( |
- "constructed packet", data->data(), data->length(), |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
+ test::CompareCharArraysWithHexError( |
+ "constructed packet", data->data(), data->length(), |
+ AsChars( |
+ QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
+ ? packet_cid_be |
+ : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
- } |
+ QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
+ ? arraysize(packet_cid_be) |
+ : arraysize(packet)); |
} |
TEST_P(QuicFramerTest, EncryptPacket) { |
@@ -5226,17 +6627,46 @@ TEST_P(QuicFramerTest, EncryptPacket) { |
'i', 'j', 'k', 'l', |
'm', 'n', 'o', 'p', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // redundancy |
+ 'a', 'b', 'c', 'd', |
+ 'e', 'f', 'g', 'h', |
+ 'i', 'j', 'k', 'l', |
+ 'm', 'n', 'o', 'p', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // redundancy |
+ 'a', 'b', 'c', 'd', |
+ 'e', 'f', 'g', 'h', |
+ 'i', 'j', 'k', 'l', |
+ 'm', 'n', 'o', 'p', |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
std::unique_ptr<QuicPacket> raw(new QuicPacket( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false, PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
+ AsChars(packets[index]), arraysize(packet), false, |
+ PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
!kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER)); |
char buffer[kMaxPacketSize]; |
size_t encrypted_length = framer_.EncryptPayload( |
@@ -5285,17 +6715,51 @@ TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) { |
'i', 'j', 'k', 'l', |
'm', 'n', 'o', 'p', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (version, 8 byte connection_id) |
+ 0x39, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '.', '1', '0', |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // redundancy |
+ 'a', 'b', 'c', 'd', |
+ 'e', 'f', 'g', 'h', |
+ 'i', 'j', 'k', 'l', |
+ 'm', 'n', 'o', 'p', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (version, 8 byte connection_id) |
+ 0x39, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // version tag |
+ 'Q', '.', '1', '0', |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // redundancy |
+ 'a', 'b', 'c', 'd', |
+ 'e', 'f', 'g', 'h', |
+ 'i', 'j', 'k', 'l', |
+ 'm', 'n', 'o', 'p', |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
std::unique_ptr<QuicPacket> raw(new QuicPacket( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false, PACKET_8BYTE_CONNECTION_ID, kIncludeVersion, |
+ AsChars(packets[index]), arraysize(packet), false, |
+ PACKET_8BYTE_CONNECTION_ID, kIncludeVersion, |
!kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER)); |
char buffer[kMaxPacketSize]; |
size_t encrypted_length = framer_.EncryptPayload( |
@@ -5485,8 +6949,88 @@ TEST_P(QuicFramerTest, StopPacketProcessing) { |
0xBE, 0x9A, 0x78, 0x56, |
0x34, 0x12, |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ |
+ // frame type (ack frame) |
+ 0x40, |
+ // least packet number awaiting an ack |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xA0, |
+ // largest observed packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBF, |
+ // num missing packets |
+ 0x01, |
+ // missing packet |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBE, |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ |
+ // frame type (ack frame) |
+ 0x40, |
+ // least packet number awaiting an ack |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xA0, |
+ // largest observed packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBF, |
+ // num missing packets |
+ 0x01, |
+ // missing packet |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBE, |
+ }; |
// clang-format on |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
MockFramerVisitor visitor; |
framer_.set_visitor(&visitor); |
EXPECT_CALL(visitor, OnPacket()); |
@@ -5498,15 +7042,8 @@ TEST_P(QuicFramerTest, StopPacketProcessing) { |
EXPECT_CALL(visitor, OnUnauthenticatedHeader(_)).WillOnce(Return(true)); |
EXPECT_CALL(visitor, OnDecryptedPacket(_)); |
- QuicEncryptedPacket encrypted( |
- AsChars( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet), |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet), |
- false); |
+ QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
+ false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
} |
@@ -5675,16 +7212,67 @@ TEST_P(QuicFramerTest, FramerFuzzTest) { |
'o', ' ', 'w', 'o', |
'r', 'l', 'd', '!', |
}; |
+ |
+ unsigned char packet39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
+ |
+ unsigned char packet_cid_be39[] = { |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
+ // packet number |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x9A, 0xBC, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x01, 0x02, 0x03, 0x04, |
+ // offset |
+ 0xBA, 0x98, 0xFE, 0xDC, |
+ 0x32, 0x10, 0x76, 0x54, |
+ // data length |
+ 0x00, 0x0c, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
+ }; |
// clang-format on |
- QuicFramerFuzzFunc( |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? packet_cid_be |
- : packet, |
- QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) |
- ? arraysize(packet_cid_be) |
- : arraysize(packet)); |
+ unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
+ size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
+ |
+ QuicFramerFuzzFunc(packets[index], arraysize(packet)); |
} |
+} // namespace |
} // namespace test |
} // namespace net |