Index: net/quic/quic_framer_test.cc |
diff --git a/net/quic/quic_framer_test.cc b/net/quic/quic_framer_test.cc |
index e44500886bb2829a4c8c0855cb0ef2f290652597..2b84a0ed0ad2d0e9a9e264102a4a689cc2fa79ae 100644 |
--- a/net/quic/quic_framer_test.cc |
+++ b/net/quic/quic_framer_test.cc |
@@ -54,7 +54,7 @@ size_t GetMinStreamFrameSize(QuicVersion version) { |
size_t GetSequenceNumberOffset(QuicConnectionIdLength connection_id_length, |
bool include_version) { |
return kConnectionIdOffset + connection_id_length + |
- (include_version ? kQuicVersionSize : 0); |
+ (include_version ? kQuicVersionSize : 0); |
} |
size_t GetSequenceNumberOffset(bool include_version) { |
@@ -65,7 +65,7 @@ size_t GetSequenceNumberOffset(bool include_version) { |
size_t GetPrivateFlagsOffset(QuicConnectionIdLength connection_id_length, |
bool include_version) { |
return GetSequenceNumberOffset(connection_id_length, include_version) + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
+ PACKET_6BYTE_SEQUENCE_NUMBER; |
} |
size_t GetPrivateFlagsOffset(bool include_version) { |
@@ -75,25 +75,25 @@ size_t GetPrivateFlagsOffset(bool include_version) { |
size_t GetPrivateFlagsOffset(bool include_version, |
QuicSequenceNumberLength sequence_number_length) { |
return GetSequenceNumberOffset(PACKET_8BYTE_CONNECTION_ID, include_version) + |
- sequence_number_length; |
+ sequence_number_length; |
} |
// Index into the fec group offset in the header. |
size_t GetFecGroupOffset(QuicConnectionIdLength connection_id_length, |
bool include_version) { |
return GetPrivateFlagsOffset(connection_id_length, include_version) + |
- kPrivateFlagsSize; |
+ kPrivateFlagsSize; |
} |
size_t GetFecGroupOffset(bool include_version) { |
return GetPrivateFlagsOffset(PACKET_8BYTE_CONNECTION_ID, include_version) + |
- kPrivateFlagsSize; |
+ kPrivateFlagsSize; |
} |
size_t GetFecGroupOffset(bool include_version, |
QuicSequenceNumberLength sequence_number_length) { |
return GetPrivateFlagsOffset(include_version, sequence_number_length) + |
- kPrivateFlagsSize; |
+ kPrivateFlagsSize; |
} |
// Index into the message tag of the public reset packet. |
@@ -104,9 +104,7 @@ const size_t kPublicResetPacketMessageTagOffset = |
class TestEncrypter : public QuicEncrypter { |
public: |
virtual ~TestEncrypter() {} |
- virtual bool SetKey(StringPiece key) OVERRIDE { |
- return true; |
- } |
+ virtual bool SetKey(StringPiece key) OVERRIDE { return true; } |
virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { |
return true; |
} |
@@ -125,24 +123,16 @@ class TestEncrypter : public QuicEncrypter { |
plaintext_ = plaintext.as_string(); |
return new QuicData(plaintext.data(), plaintext.length()); |
} |
- virtual size_t GetKeySize() const OVERRIDE { |
- return 0; |
- } |
- virtual size_t GetNoncePrefixSize() const OVERRIDE { |
- return 0; |
- } |
+ virtual size_t GetKeySize() const OVERRIDE { return 0; } |
+ virtual size_t GetNoncePrefixSize() const OVERRIDE { return 0; } |
virtual size_t GetMaxPlaintextSize(size_t ciphertext_size) const OVERRIDE { |
return ciphertext_size; |
} |
virtual size_t GetCiphertextSize(size_t plaintext_size) const OVERRIDE { |
return plaintext_size; |
} |
- virtual StringPiece GetKey() const OVERRIDE { |
- return StringPiece(); |
- } |
- virtual StringPiece GetNoncePrefix() const OVERRIDE { |
- return StringPiece(); |
- } |
+ virtual StringPiece GetKey() const OVERRIDE { return StringPiece(); } |
+ virtual StringPiece GetNoncePrefix() const OVERRIDE { return StringPiece(); } |
QuicPacketSequenceNumber sequence_number_; |
string associated_data_; |
string plaintext_; |
@@ -151,9 +141,7 @@ class TestEncrypter : public QuicEncrypter { |
class TestDecrypter : public QuicDecrypter { |
public: |
virtual ~TestDecrypter() {} |
- virtual bool SetKey(StringPiece key) OVERRIDE { |
- return true; |
- } |
+ virtual bool SetKey(StringPiece key) OVERRIDE { return true; } |
virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { |
return true; |
} |
@@ -173,12 +161,8 @@ class TestDecrypter : public QuicDecrypter { |
ciphertext_ = ciphertext.as_string(); |
return new QuicData(ciphertext.data(), ciphertext.length()); |
} |
- virtual StringPiece GetKey() const OVERRIDE { |
- return StringPiece(); |
- } |
- virtual StringPiece GetNoncePrefix() const OVERRIDE { |
- return StringPiece(); |
- } |
+ virtual StringPiece GetKey() const OVERRIDE { return StringPiece(); } |
+ virtual StringPiece GetNoncePrefix() const OVERRIDE { return StringPiece(); } |
QuicPacketSequenceNumber sequence_number_; |
string associated_data_; |
string ciphertext_; |
@@ -195,8 +179,7 @@ class TestQuicVisitor : public ::net::QuicFramerVisitorInterface { |
complete_packets_(0), |
revived_packets_(0), |
accept_packet_(true), |
- accept_public_header_(true) { |
- } |
+ accept_public_header_(true) {} |
virtual ~TestQuicVisitor() { |
STLDeleteElements(&stream_frames_); |
@@ -225,9 +208,7 @@ class TestQuicVisitor : public ::net::QuicFramerVisitorInterface { |
version_negotiation_packet_.reset(new QuicVersionNegotiationPacket(packet)); |
} |
- virtual void OnRevivedPacket() OVERRIDE { |
- ++revived_packets_; |
- } |
+ virtual void OnRevivedPacket() OVERRIDE { ++revived_packets_; } |
virtual bool OnProtocolVersionMismatch(QuicVersion version) OVERRIDE { |
DVLOG(1) << "QuicFramer Version Mismatch, version: " << version; |
@@ -295,9 +276,7 @@ class TestQuicVisitor : public ::net::QuicFramerVisitorInterface { |
fec_data_.push_back(new QuicFecData(fec)); |
} |
- virtual void OnPacketComplete() OVERRIDE { |
- ++complete_packets_; |
- } |
+ virtual void OnPacketComplete() OVERRIDE { ++complete_packets_; } |
virtual bool OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE { |
rst_stream_frame_ = frame; |
@@ -315,8 +294,8 @@ class TestQuicVisitor : public ::net::QuicFramerVisitorInterface { |
return true; |
} |
- virtual bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) |
- OVERRIDE { |
+ virtual bool OnWindowUpdateFrame( |
+ const QuicWindowUpdateFrame& frame) OVERRIDE { |
window_update_frame_ = frame; |
return true; |
} |
@@ -373,33 +352,33 @@ class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { |
// Helper function to get unsigned char representation of digit in the |
// units place of the current QUIC version number. |
unsigned char GetQuicVersionDigitOnes() { |
- return static_cast<unsigned char> ('0' + version_%10); |
+ return static_cast<unsigned char>('0' + version_ % 10); |
} |
// Helper function to get unsigned char representation of digit in the |
// tens place of the current QUIC version number. |
unsigned char GetQuicVersionDigitTens() { |
- return static_cast<unsigned char> ('0' + (version_/10)%10); |
+ return static_cast<unsigned char>('0' + (version_ / 10) % 10); |
} |
bool CheckEncryption(QuicPacketSequenceNumber sequence_number, |
QuicPacket* packet) { |
if (sequence_number != encrypter_->sequence_number_) { |
LOG(ERROR) << "Encrypted incorrect packet sequence number. expected " |
- << sequence_number << " actual: " |
- << encrypter_->sequence_number_; |
+ << sequence_number |
+ << " actual: " << encrypter_->sequence_number_; |
return false; |
} |
if (packet->AssociatedData() != encrypter_->associated_data_) { |
LOG(ERROR) << "Encrypted incorrect associated data. expected " |
- << packet->AssociatedData() << " actual: " |
- << encrypter_->associated_data_; |
+ << packet->AssociatedData() |
+ << " actual: " << encrypter_->associated_data_; |
return false; |
} |
if (packet->Plaintext() != encrypter_->plaintext_) { |
LOG(ERROR) << "Encrypted incorrect plaintext data. expected " |
- << packet->Plaintext() << " actual: " |
- << encrypter_->plaintext_; |
+ << packet->Plaintext() |
+ << " actual: " << encrypter_->plaintext_; |
return false; |
} |
return true; |
@@ -410,36 +389,37 @@ class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { |
if (visitor_.header_->packet_sequence_number != |
decrypter_->sequence_number_) { |
LOG(ERROR) << "Decrypted incorrect packet sequence number. expected " |
- << visitor_.header_->packet_sequence_number << " actual: " |
- << decrypter_->sequence_number_; |
+ << visitor_.header_->packet_sequence_number |
+ << " actual: " << decrypter_->sequence_number_; |
return false; |
} |
if (QuicFramer::GetAssociatedDataFromEncryptedPacket( |
- encrypted, PACKET_8BYTE_CONNECTION_ID, |
- includes_version, PACKET_6BYTE_SEQUENCE_NUMBER) != |
- decrypter_->associated_data_) { |
+ encrypted, |
+ PACKET_8BYTE_CONNECTION_ID, |
+ includes_version, |
+ PACKET_6BYTE_SEQUENCE_NUMBER) != decrypter_->associated_data_) { |
LOG(ERROR) << "Decrypted incorrect associated data. expected " |
<< QuicFramer::GetAssociatedDataFromEncryptedPacket( |
- encrypted, PACKET_8BYTE_CONNECTION_ID, |
- includes_version, PACKET_6BYTE_SEQUENCE_NUMBER) |
+ encrypted, |
+ PACKET_8BYTE_CONNECTION_ID, |
+ includes_version, |
+ PACKET_6BYTE_SEQUENCE_NUMBER) |
<< " actual: " << decrypter_->associated_data_; |
return false; |
} |
StringPiece ciphertext(encrypted.AsStringPiece().substr( |
- GetStartOfEncryptedData(PACKET_8BYTE_CONNECTION_ID, includes_version, |
+ GetStartOfEncryptedData(PACKET_8BYTE_CONNECTION_ID, |
+ includes_version, |
PACKET_6BYTE_SEQUENCE_NUMBER))); |
if (ciphertext != decrypter_->ciphertext_) { |
LOG(ERROR) << "Decrypted incorrect ciphertext data. expected " |
- << ciphertext << " actual: " |
- << decrypter_->ciphertext_; |
+ << ciphertext << " actual: " << decrypter_->ciphertext_; |
return false; |
} |
return true; |
} |
- char* AsChars(unsigned char* data) { |
- return reinterpret_cast<char*>(data); |
- } |
+ char* AsChars(unsigned char* data) { return reinterpret_cast<char*>(data); } |
void CheckProcessingFails(unsigned char* packet, |
size_t len, |
@@ -462,22 +442,24 @@ class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { |
bool include_version) { |
// Now test framing boundaries |
for (size_t i = kQuicFrameTypeSize; |
- i < GetMinStreamFrameSize(framer_.version()); ++i) { |
+ i < GetMinStreamFrameSize(framer_.version()); |
+ ++i) { |
string expected_error; |
if (i < kQuicFrameTypeSize + stream_id_size) { |
expected_error = "Unable to read stream_id."; |
} else if (i < kQuicFrameTypeSize + stream_id_size + |
- kQuicMaxStreamOffsetSize) { |
+ kQuicMaxStreamOffsetSize) { |
expected_error = "Unable to read offset."; |
} else { |
expected_error = "Unable to read frame data."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, include_version, |
- PACKET_6BYTE_SEQUENCE_NUMBER, |
- NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_STREAM_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ include_version, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_STREAM_DATA); |
} |
} |
@@ -610,7 +592,7 @@ TEST_P(QuicFramerTest, CalculatePacketSequenceNumberFromWireNearNextMax) { |
} |
TEST_P(QuicFramerTest, EmptyPacket) { |
- char packet[] = { 0x00 }; |
+ char packet[] = {0x00}; |
QuicEncryptedPacket encrypted(packet, 0, false); |
EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error()); |
@@ -618,24 +600,26 @@ TEST_P(QuicFramerTest, EmptyPacket) { |
TEST_P(QuicFramerTest, LargePacket) { |
unsigned char packet[kMaxPacketSize + 1] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
}; |
- memset(packet + GetPacketHeaderSize( |
- PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 0, |
- kMaxPacketSize - GetPacketHeaderSize( |
- PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + 1); |
+ memset(packet + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ 0, |
+ kMaxPacketSize - GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP) + |
+ 1); |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
@@ -649,17 +633,14 @@ TEST_P(QuicFramerTest, LargePacket) { |
} |
TEST_P(QuicFramerTest, PacketHeader) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -679,9 +660,10 @@ TEST_P(QuicFramerTest, PacketHeader) { |
EXPECT_EQ(0x00u, visitor_.header_->fec_group); |
// Now test framing boundaries |
- for (size_t i = 0; |
- i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ for (size_t i = 0; i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
++i) { |
string expected_error; |
if (i < kConnectionIdOffset) { |
@@ -703,16 +685,14 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteConnectionId) { |
QuicFramerPeer::SetLastSerializedConnectionId( |
&framer_, GG_UINT64_C(0xFEDCBA9876543210)); |
- unsigned char packet[] = { |
- // public flags (4 byte connection_id) |
- 0x38, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
+ unsigned char packet[] = {// public flags (4 byte connection_id) |
+ 0x38, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -732,9 +712,10 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteConnectionId) { |
EXPECT_EQ(0x00u, visitor_.header_->fec_group); |
// Now test framing boundaries |
- for (size_t i = 0; |
- i < GetPacketHeaderSize(PACKET_4BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ for (size_t i = 0; i < GetPacketHeaderSize(PACKET_4BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
++i) { |
string expected_error; |
if (i < kConnectionIdOffset) { |
@@ -759,16 +740,14 @@ TEST_P(QuicFramerTest, PacketHeader1ByteConnectionId) { |
QuicFramerPeer::SetLastSerializedConnectionId( |
&framer_, GG_UINT64_C(0xFEDCBA9876543210)); |
- unsigned char packet[] = { |
- // public flags (1 byte connection_id) |
- 0x34, |
- // connection_id |
- 0x10, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
+ unsigned char packet[] = {// public flags (1 byte connection_id) |
+ 0x34, |
+ // connection_id |
+ 0x10, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -788,9 +767,10 @@ TEST_P(QuicFramerTest, PacketHeader1ByteConnectionId) { |
EXPECT_EQ(0x00u, visitor_.header_->fec_group); |
// Now test framing boundaries |
- for (size_t i = 0; |
- i < GetPacketHeaderSize(PACKET_1BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ for (size_t i = 0; i < GetPacketHeaderSize(PACKET_1BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
++i) { |
string expected_error; |
if (i < kConnectionIdOffset) { |
@@ -815,15 +795,13 @@ TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) { |
QuicFramerPeer::SetLastSerializedConnectionId( |
&framer_, GG_UINT64_C(0xFEDCBA9876543210)); |
- unsigned char packet[] = { |
- // public flags (0 byte connection_id) |
- 0x30, |
- // connection_id |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
+ unsigned char packet[] = {// public flags (0 byte connection_id) |
+ 0x30, |
+ // connection_id |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -843,9 +821,10 @@ TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) { |
EXPECT_EQ(0x00u, visitor_.header_->fec_group); |
// Now test framing boundaries |
- for (size_t i = 0; |
- i < GetPacketHeaderSize(PACKET_0BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ for (size_t i = 0; i < GetPacketHeaderSize(PACKET_0BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
++i) { |
string expected_error; |
if (i < kConnectionIdOffset) { |
@@ -868,18 +847,18 @@ TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) { |
TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { |
unsigned char packet[] = { |
- // public flags (version) |
- 0x3D, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // version tag |
- 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
+ // public flags (version) |
+ 0x3D, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, |
+ 0x34, 0x12, |
+ // private flags |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -900,16 +879,17 @@ TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { |
EXPECT_EQ(0x00u, visitor_.header_->fec_group); |
// Now test framing boundaries |
- for (size_t i = 0; |
- i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ for (size_t i = 0; i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
++i) { |
string expected_error; |
if (i < kConnectionIdOffset) { |
expected_error = "Unable to read public flags."; |
} else if (i < kVersionOffset) { |
expected_error = "Unable to read ConnectionId."; |
- } else if (i < GetSequenceNumberOffset(kIncludeVersion)) { |
+ } else if (i < GetSequenceNumberOffset(kIncludeVersion)) { |
expected_error = "Unable to read protocol version."; |
} else if (i < GetPrivateFlagsOffset(kIncludeVersion)) { |
expected_error = "Unable to read sequence number."; |
@@ -923,19 +903,17 @@ TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { |
} |
TEST_P(QuicFramerTest, PacketHeaderWith4ByteSequenceNumber) { |
- QuicFramerPeer::SetLastSequenceNumber(&framer_, |
- GG_UINT64_C(0x123456789ABA)); |
+ QuicFramerPeer::SetLastSequenceNumber(&framer_, GG_UINT64_C(0x123456789ABA)); |
unsigned char packet[] = { |
- // public flags (8 byte connection_id and 4 byte sequence number) |
- 0x2C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- // private flags |
- 0x00, |
+ // public flags (8 byte connection_id and 4 byte sequence number) |
+ 0x2C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, |
+ // private flags |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -955,9 +933,10 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteSequenceNumber) { |
EXPECT_EQ(0x00u, visitor_.header_->fec_group); |
// Now test framing boundaries |
- for (size_t i = 0; |
- i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ for (size_t i = 0; i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_4BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
++i) { |
string expected_error; |
if (i < kConnectionIdOffset) { |
@@ -978,19 +957,17 @@ TEST_P(QuicFramerTest, PacketHeaderWith4ByteSequenceNumber) { |
} |
TEST_P(QuicFramerTest, PacketHeaderWith2ByteSequenceNumber) { |
- QuicFramerPeer::SetLastSequenceNumber(&framer_, |
- GG_UINT64_C(0x123456789ABA)); |
+ QuicFramerPeer::SetLastSequenceNumber(&framer_, GG_UINT64_C(0x123456789ABA)); |
unsigned char packet[] = { |
- // public flags (8 byte connection_id and 2 byte sequence number) |
- 0x1C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, |
- // private flags |
- 0x00, |
+ // public flags (8 byte connection_id and 2 byte sequence number) |
+ 0x1C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, |
+ // private flags |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1010,9 +987,10 @@ TEST_P(QuicFramerTest, PacketHeaderWith2ByteSequenceNumber) { |
EXPECT_EQ(0x00u, visitor_.header_->fec_group); |
// Now test framing boundaries |
- for (size_t i = 0; |
- i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ for (size_t i = 0; i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_2BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
++i) { |
string expected_error; |
if (i < kConnectionIdOffset) { |
@@ -1033,19 +1011,17 @@ TEST_P(QuicFramerTest, PacketHeaderWith2ByteSequenceNumber) { |
} |
TEST_P(QuicFramerTest, PacketHeaderWith1ByteSequenceNumber) { |
- QuicFramerPeer::SetLastSequenceNumber(&framer_, |
- GG_UINT64_C(0x123456789ABA)); |
+ QuicFramerPeer::SetLastSequenceNumber(&framer_, GG_UINT64_C(0x123456789ABA)); |
unsigned char packet[] = { |
- // public flags (8 byte connection_id and 1 byte sequence number) |
- 0x0C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, |
- // private flags |
- 0x00, |
+ // public flags (8 byte connection_id and 1 byte sequence number) |
+ 0x0C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, |
+ // private flags |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1065,9 +1041,10 @@ TEST_P(QuicFramerTest, PacketHeaderWith1ByteSequenceNumber) { |
EXPECT_EQ(0x00u, visitor_.header_->fec_group); |
// Now test framing boundaries |
- for (size_t i = 0; |
- i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ for (size_t i = 0; i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_1BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
++i) { |
string expected_error; |
if (i < kConnectionIdOffset) { |
@@ -1089,21 +1066,17 @@ TEST_P(QuicFramerTest, PacketHeaderWith1ByteSequenceNumber) { |
TEST_P(QuicFramerTest, InvalidPublicFlag) { |
unsigned char packet[] = { |
- // public flags: all flags set but the public reset flag and version flag. |
- 0xFC, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (padding) |
- 0x00, |
- 0x00, 0x00, 0x00, 0x00 |
- }; |
+ // public flags: all flags set but the public reset flag and version flag. |
+ 0xFC, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (padding) |
+ 0x00, 0x00, 0x00, 0x00, 0x00}; |
CheckProcessingFails(packet, |
arraysize(packet), |
"Illegal public flags value.", |
@@ -1117,23 +1090,21 @@ TEST_P(QuicFramerTest, InvalidPublicFlag) { |
TEST_P(QuicFramerTest, InvalidPublicFlagWithMatchingVersions) { |
unsigned char packet[] = { |
- // public flags (8 byte connection_id and version flag and an unknown flag) |
- 0x4D, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // version tag |
- 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (padding) |
- 0x00, |
- 0x00, 0x00, 0x00, 0x00 |
- }; |
+ // public flags (8 byte connection_id and version flag and an unknown |
+ // flag) |
+ 0x4D, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, |
+ 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (padding) |
+ 0x00, 0x00, 0x00, 0x00, 0x00}; |
CheckProcessingFails(packet, |
arraysize(packet), |
"Illegal public flags value.", |
@@ -1142,23 +1113,19 @@ TEST_P(QuicFramerTest, InvalidPublicFlagWithMatchingVersions) { |
TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) { |
unsigned char packet[] = { |
- // public flags (8 byte connection_id, version flag and an unknown flag) |
- 0x7D, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // version tag |
- 'Q', '0', '0', '0', |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (padding frame) |
- 0x00, |
- 0x00, 0x00, 0x00, 0x00 |
- }; |
+ // public flags (8 byte connection_id, version flag and an unknown flag) |
+ 0x7D, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', '0', '0', |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (padding frame) |
+ 0x00, 0x00, 0x00, 0x00, 0x00}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
@@ -1168,22 +1135,17 @@ TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) { |
}; |
TEST_P(QuicFramerTest, InvalidPrivateFlag) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x10, |
- |
- // frame type (padding) |
- 0x00, |
- 0x00, 0x00, 0x00, 0x00 |
- }; |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x10, |
+ |
+ // frame type (padding) |
+ 0x00, 0x00, 0x00, 0x00, 0x00}; |
CheckProcessingFails(packet, |
arraysize(packet), |
"Illegal private flags value.", |
@@ -1191,20 +1153,16 @@ TEST_P(QuicFramerTest, InvalidPrivateFlag) { |
}; |
TEST_P(QuicFramerTest, InvalidFECGroupOffset) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0x01, 0x00, 0x00, 0x00, |
- 0x00, 0x00, |
- // private flags (fec group) |
- 0x02, |
- // first fec protected packet offset |
- 0x10 |
- }; |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ // private flags (fec group) |
+ 0x02, |
+ // first fec protected packet offset |
+ 0x10}; |
CheckProcessingFails(packet, |
arraysize(packet), |
"First fec protected packet offset must be less " |
@@ -1214,33 +1172,28 @@ TEST_P(QuicFramerTest, InvalidFECGroupOffset) { |
TEST_P(QuicFramerTest, PaddingFrame) { |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (padding frame) |
- 0x00, |
- // Ignored data (which in this case is a stream frame) |
- // frame type (stream frame with fin) |
- 0xFF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (padding frame) |
+ 0x00, |
+ // Ignored data (which in this case is a stream frame) |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1252,39 +1205,36 @@ TEST_P(QuicFramerTest, PaddingFrame) { |
ASSERT_EQ(0u, visitor_.stream_frames_.size()); |
EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
// A packet with no frames is not acceptable. |
- CheckProcessingFails( |
- packet, |
- GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- "Packet has no frames.", QUIC_MISSING_PAYLOAD); |
+ CheckProcessingFails(packet, |
+ GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ "Packet has no frames.", |
+ QUIC_MISSING_PAYLOAD); |
} |
TEST_P(QuicFramerTest, StreamFrame) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (stream frame with fin) |
- 0xFF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1308,31 +1258,26 @@ TEST_P(QuicFramerTest, StreamFrame) { |
} |
TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (stream frame with fin) |
- 0xFE, |
- // stream id |
- 0x04, 0x03, 0x02, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFE, |
+ // stream id |
+ 0x04, 0x03, 0x02, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1344,8 +1289,7 @@ TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) { |
ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
- EXPECT_EQ(GG_UINT64_C(0x00020304), |
- visitor_.stream_frames_[0]->stream_id); |
+ EXPECT_EQ(GG_UINT64_C(0x00020304), visitor_.stream_frames_[0]->stream_id); |
EXPECT_TRUE(visitor_.stream_frames_[0]->fin); |
EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654), |
visitor_.stream_frames_[0]->offset); |
@@ -1357,31 +1301,26 @@ TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) { |
} |
TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (stream frame with fin) |
- 0xFD, |
- // stream id |
- 0x04, 0x03, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFD, |
+ // stream id |
+ 0x04, 0x03, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1406,31 +1345,26 @@ TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { |
} |
TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (stream frame with fin) |
- 0xFC, |
- // stream id |
- 0x04, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFC, |
+ // stream id |
+ 0x04, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1456,32 +1390,32 @@ TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) { |
TEST_P(QuicFramerTest, StreamFrameWithVersion) { |
unsigned char packet[] = { |
- // public flags (version, 8 byte connection_id) |
- 0x3D, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // version tag |
- 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (stream frame with fin) |
- 0xFF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ // public flags (version, 8 byte connection_id) |
+ 0x3D, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, |
+ 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, |
+ 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1509,31 +1443,26 @@ TEST_P(QuicFramerTest, StreamFrameWithVersion) { |
TEST_P(QuicFramerTest, RejectPacket) { |
visitor_.accept_packet_ = false; |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (stream frame with fin) |
- 0xFF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1550,12 +1479,10 @@ TEST_P(QuicFramerTest, RejectPacket) { |
TEST_P(QuicFramerTest, RejectPublicHeader) { |
visitor_.accept_public_header_ = false; |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1567,20 +1494,17 @@ TEST_P(QuicFramerTest, RejectPublicHeader) { |
} |
TEST_P(QuicFramerTest, RevivedStreamFrame) { |
- unsigned char payload[] = { |
- // frame type (stream frame with fin) |
- 0xFF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char payload[] = {// frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicPacketHeader header; |
@@ -1593,9 +1517,8 @@ TEST_P(QuicFramerTest, RevivedStreamFrame) { |
header.fec_group = 0; |
// Do not encrypt the payload because the revived payload is post-encryption. |
- EXPECT_TRUE(framer_.ProcessRevivedPacket(&header, |
- StringPiece(AsChars(payload), |
- arraysize(payload)))); |
+ EXPECT_TRUE(framer_.ProcessRevivedPacket( |
+ &header, StringPiece(AsChars(payload), arraysize(payload)))); |
EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
ASSERT_EQ(1, visitor_.revived_packets_); |
@@ -1623,33 +1546,28 @@ TEST_P(QuicFramerTest, RevivedStreamFrame) { |
} |
TEST_P(QuicFramerTest, StreamFrameInFecGroup) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x12, 0x34, |
- // private flags (fec group) |
- 0x02, |
- // first fec protected packet offset |
- 0x02, |
- |
- // frame type (stream frame with fin) |
- 0xFF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x12, 0x34, |
+ // private flags (fec group) |
+ 0x02, |
+ // first fec protected packet offset |
+ 0x02, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1659,8 +1577,7 @@ TEST_P(QuicFramerTest, StreamFrameInFecGroup) { |
ASSERT_TRUE(visitor_.header_.get()); |
EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
EXPECT_EQ(IN_FEC_GROUP, visitor_.header_->is_in_fec_group); |
- EXPECT_EQ(GG_UINT64_C(0x341256789ABA), |
- visitor_.header_->fec_group); |
+ EXPECT_EQ(GG_UINT64_C(0x341256789ABA), visitor_.header_->fec_group); |
const size_t fec_offset = |
GetStartOfFecProtectedData(PACKET_8BYTE_CONNECTION_ID, |
!kIncludeVersion, |
@@ -1684,40 +1601,37 @@ TEST_P(QuicFramerTest, AckFrame15) { |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x6C, |
- // entropy hash of sent packets till least awaiting - 1. |
- 0xAB, |
- // least packet sequence number awaiting an ack, delta from sequence number. |
- 0x08, 0x00, 0x00, 0x00, |
- 0x00, 0x00, |
- // entropy hash of all received packets. |
- 0xBA, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
- // num missing packets |
- 0x01, |
- // missing packet delta |
- 0x01, |
- // 0 more missing packets in range. |
- 0x00, |
- // Number of revived packets. |
- 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x6C, |
+ // entropy hash of sent packets till least awaiting - 1. |
+ 0xAB, |
+ // least packet sequence number awaiting an ack, delta from sequence |
+ // number. |
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ // entropy hash of all received packets. |
+ 0xBA, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
+ // num missing packets |
+ 0x01, |
+ // missing packet delta |
+ 0x01, |
+ // 0 more missing packets in range. |
+ 0x00, |
+ // Number of revived packets. |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1741,23 +1655,23 @@ TEST_P(QuicFramerTest, AckFrame15) { |
const size_t kSentEntropyOffset = kQuicFrameTypeSize; |
const size_t kLeastUnackedOffset = kSentEntropyOffset + kQuicEntropyHashSize; |
- const size_t kReceivedEntropyOffset = kLeastUnackedOffset + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
- const size_t kLargestObservedOffset = kReceivedEntropyOffset + |
- kQuicEntropyHashSize; |
- const size_t kMissingDeltaTimeOffset = kLargestObservedOffset + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
- const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset + |
- kQuicDeltaTimeLargestObservedSize; |
- const size_t kMissingPacketsOffset = kNumMissingPacketOffset + |
- kNumberOfMissingPacketsSize; |
- const size_t kMissingPacketsRange = kMissingPacketsOffset + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
- const size_t kRevivedPacketsLength = kMissingPacketsRange + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kReceivedEntropyOffset = |
+ kLeastUnackedOffset + PACKET_6BYTE_SEQUENCE_NUMBER; |
+ const size_t kLargestObservedOffset = |
+ kReceivedEntropyOffset + kQuicEntropyHashSize; |
+ const size_t kMissingDeltaTimeOffset = |
+ kLargestObservedOffset + PACKET_6BYTE_SEQUENCE_NUMBER; |
+ const size_t kNumMissingPacketOffset = |
+ kMissingDeltaTimeOffset + kQuicDeltaTimeLargestObservedSize; |
+ const size_t kMissingPacketsOffset = |
+ kNumMissingPacketOffset + kNumberOfMissingPacketsSize; |
+ const size_t kMissingPacketsRange = |
+ kMissingPacketsOffset + PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kRevivedPacketsLength = |
+ kMissingPacketsRange + PACKET_1BYTE_SEQUENCE_NUMBER; |
// Now test framing boundaries |
- const size_t ack_frame_size = kRevivedPacketsLength + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t ack_frame_size = |
+ kRevivedPacketsLength + PACKET_1BYTE_SEQUENCE_NUMBER; |
for (size_t i = kQuicFrameTypeSize; i < ack_frame_size; ++i) { |
string expected_error; |
if (i < kLeastUnackedOffset) { |
@@ -1779,11 +1693,13 @@ TEST_P(QuicFramerTest, AckFrame15) { |
} else { |
expected_error = "Unable to read num revived packets."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_ACK_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_ACK_DATA); |
} |
} |
@@ -1793,35 +1709,32 @@ TEST_P(QuicFramerTest, AckFrame) { |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x6C, |
- // entropy hash of all received packets. |
- 0xBA, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
- // num missing packets |
- 0x01, |
- // missing packet delta |
- 0x01, |
- // 0 more missing packets in range. |
- 0x00, |
- // Number of revived packets. |
- 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x6C, |
+ // entropy hash of all received packets. |
+ 0xBA, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
+ // num missing packets |
+ 0x01, |
+ // missing packet delta |
+ 0x01, |
+ // 0 more missing packets in range. |
+ 0x00, |
+ // Number of revived packets. |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1842,21 +1755,21 @@ TEST_P(QuicFramerTest, AckFrame) { |
EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *missing_iter); |
const size_t kReceivedEntropyOffset = kQuicFrameTypeSize; |
- const size_t kLargestObservedOffset = kReceivedEntropyOffset + |
- kQuicEntropyHashSize; |
- const size_t kMissingDeltaTimeOffset = kLargestObservedOffset + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
- const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset + |
- kQuicDeltaTimeLargestObservedSize; |
- const size_t kMissingPacketsOffset = kNumMissingPacketOffset + |
- kNumberOfMissingPacketsSize; |
- const size_t kMissingPacketsRange = kMissingPacketsOffset + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
- const size_t kRevivedPacketsLength = kMissingPacketsRange + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kLargestObservedOffset = |
+ kReceivedEntropyOffset + kQuicEntropyHashSize; |
+ const size_t kMissingDeltaTimeOffset = |
+ kLargestObservedOffset + PACKET_6BYTE_SEQUENCE_NUMBER; |
+ const size_t kNumMissingPacketOffset = |
+ kMissingDeltaTimeOffset + kQuicDeltaTimeLargestObservedSize; |
+ const size_t kMissingPacketsOffset = |
+ kNumMissingPacketOffset + kNumberOfMissingPacketsSize; |
+ const size_t kMissingPacketsRange = |
+ kMissingPacketsOffset + PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kRevivedPacketsLength = |
+ kMissingPacketsRange + PACKET_1BYTE_SEQUENCE_NUMBER; |
// Now test framing boundaries |
- const size_t ack_frame_size = kRevivedPacketsLength + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t ack_frame_size = |
+ kRevivedPacketsLength + PACKET_1BYTE_SEQUENCE_NUMBER; |
for (size_t i = kQuicFrameTypeSize; i < ack_frame_size; ++i) { |
string expected_error; |
if (i < kLargestObservedOffset) { |
@@ -1874,11 +1787,13 @@ TEST_P(QuicFramerTest, AckFrame) { |
} else { |
expected_error = "Unable to read num revived packets."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_ACK_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_ACK_DATA); |
} |
} |
@@ -1888,38 +1803,34 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets) { |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x6C, |
- // entropy hash of all received packets. |
- 0xBA, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
- // num missing packets |
- 0x01, |
- // missing packet delta |
- 0x01, |
- // 0 more missing packets in range. |
- 0x00, |
- // Number of revived packets. |
- 0x01, |
- // Revived packet sequence number. |
- 0xBE, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x6C, |
+ // entropy hash of all received packets. |
+ 0xBA, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
+ // num missing packets |
+ 0x01, |
+ // missing packet delta |
+ 0x01, |
+ // 0 more missing packets in range. |
+ 0x00, |
+ // Number of revived packets. |
+ 0x01, |
+ // Revived packet sequence number. |
+ 0xBE, 0x9A, 0x78, 0x56, 0x34, 0x12, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -1940,23 +1851,23 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets) { |
EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *missing_iter); |
const size_t kReceivedEntropyOffset = kQuicFrameTypeSize; |
- const size_t kLargestObservedOffset = kReceivedEntropyOffset + |
- kQuicEntropyHashSize; |
- const size_t kMissingDeltaTimeOffset = kLargestObservedOffset + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
- const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset + |
- kQuicDeltaTimeLargestObservedSize; |
- const size_t kMissingPacketsOffset = kNumMissingPacketOffset + |
- kNumberOfMissingPacketsSize; |
- const size_t kMissingPacketsRange = kMissingPacketsOffset + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
- const size_t kRevivedPacketsLength = kMissingPacketsRange + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
- const size_t kRevivedPacketSequenceNumberLength = kRevivedPacketsLength + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kLargestObservedOffset = |
+ kReceivedEntropyOffset + kQuicEntropyHashSize; |
+ const size_t kMissingDeltaTimeOffset = |
+ kLargestObservedOffset + PACKET_6BYTE_SEQUENCE_NUMBER; |
+ const size_t kNumMissingPacketOffset = |
+ kMissingDeltaTimeOffset + kQuicDeltaTimeLargestObservedSize; |
+ const size_t kMissingPacketsOffset = |
+ kNumMissingPacketOffset + kNumberOfMissingPacketsSize; |
+ const size_t kMissingPacketsRange = |
+ kMissingPacketsOffset + PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kRevivedPacketsLength = |
+ kMissingPacketsRange + PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kRevivedPacketSequenceNumberLength = |
+ kRevivedPacketsLength + PACKET_1BYTE_SEQUENCE_NUMBER; |
// Now test framing boundaries |
- const size_t ack_frame_size = kRevivedPacketSequenceNumberLength + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
+ const size_t ack_frame_size = |
+ kRevivedPacketSequenceNumberLength + PACKET_6BYTE_SEQUENCE_NUMBER; |
for (size_t i = kQuicFrameTypeSize; i < ack_frame_size; ++i) { |
string expected_error; |
if (i < kReceivedEntropyOffset) { |
@@ -1978,11 +1889,13 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets) { |
} else { |
expected_error = "Unable to read revived packet."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_ACK_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_ACK_DATA); |
} |
} |
@@ -1992,43 +1905,39 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets15) { |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x6C, |
- // entropy hash of sent packets till least awaiting - 1. |
- 0xAB, |
- // least packet sequence number awaiting an ack, delta from sequence number. |
- 0x08, 0x00, 0x00, 0x00, |
- 0x00, 0x00, |
- // entropy hash of all received packets. |
- 0xBA, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
- // num missing packets |
- 0x01, |
- // missing packet delta |
- 0x01, |
- // 0 more missing packets in range. |
- 0x00, |
- // Number of revived packets. |
- 0x01, |
- // Revived packet sequence number. |
- 0xBE, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x6C, |
+ // entropy hash of sent packets till least awaiting - 1. |
+ 0xAB, |
+ // least packet sequence number awaiting an ack, delta from sequence |
+ // number. |
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ // entropy hash of all received packets. |
+ 0xBA, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
+ // num missing packets |
+ 0x01, |
+ // missing packet delta |
+ 0x01, |
+ // 0 more missing packets in range. |
+ 0x00, |
+ // Number of revived packets. |
+ 0x01, |
+ // Revived packet sequence number. |
+ 0xBE, 0x9A, 0x78, 0x56, 0x34, 0x12, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2052,25 +1961,25 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets15) { |
const size_t kSentEntropyOffset = kQuicFrameTypeSize; |
const size_t kLeastUnackedOffset = kSentEntropyOffset + kQuicEntropyHashSize; |
- const size_t kReceivedEntropyOffset = kLeastUnackedOffset + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
- const size_t kLargestObservedOffset = kReceivedEntropyOffset + |
- kQuicEntropyHashSize; |
- const size_t kMissingDeltaTimeOffset = kLargestObservedOffset + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
- const size_t kNumMissingPacketOffset = kMissingDeltaTimeOffset + |
- kQuicDeltaTimeLargestObservedSize; |
- const size_t kMissingPacketsOffset = kNumMissingPacketOffset + |
- kNumberOfMissingPacketsSize; |
- const size_t kMissingPacketsRange = kMissingPacketsOffset + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
- const size_t kRevivedPacketsLength = kMissingPacketsRange + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
- const size_t kRevivedPacketSequenceNumberLength = kRevivedPacketsLength + |
- PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kReceivedEntropyOffset = |
+ kLeastUnackedOffset + PACKET_6BYTE_SEQUENCE_NUMBER; |
+ const size_t kLargestObservedOffset = |
+ kReceivedEntropyOffset + kQuicEntropyHashSize; |
+ const size_t kMissingDeltaTimeOffset = |
+ kLargestObservedOffset + PACKET_6BYTE_SEQUENCE_NUMBER; |
+ const size_t kNumMissingPacketOffset = |
+ kMissingDeltaTimeOffset + kQuicDeltaTimeLargestObservedSize; |
+ const size_t kMissingPacketsOffset = |
+ kNumMissingPacketOffset + kNumberOfMissingPacketsSize; |
+ const size_t kMissingPacketsRange = |
+ kMissingPacketsOffset + PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kRevivedPacketsLength = |
+ kMissingPacketsRange + PACKET_1BYTE_SEQUENCE_NUMBER; |
+ const size_t kRevivedPacketSequenceNumberLength = |
+ kRevivedPacketsLength + PACKET_1BYTE_SEQUENCE_NUMBER; |
// Now test framing boundaries |
- const size_t ack_frame_size = kRevivedPacketSequenceNumberLength + |
- PACKET_6BYTE_SEQUENCE_NUMBER; |
+ const size_t ack_frame_size = |
+ kRevivedPacketSequenceNumberLength + PACKET_6BYTE_SEQUENCE_NUMBER; |
for (size_t i = kQuicFrameTypeSize; i < ack_frame_size; ++i) { |
string expected_error; |
if (i < kLeastUnackedOffset) { |
@@ -2094,11 +2003,13 @@ TEST_P(QuicFramerTest, AckFrameRevivedPackets15) { |
} else { |
expected_error = "Unable to read revived packet."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_ACK_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_ACK_DATA); |
} |
} |
@@ -2107,27 +2018,24 @@ TEST_P(QuicFramerTest, AckFrameNoNacks) { |
return; |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (no nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x4C, |
- // entropy hash of all received packets. |
- 0xBA, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (no nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x4C, |
+ // entropy hash of all received packets. |
+ 0xBA, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2153,8 +2061,10 @@ TEST_P(QuicFramerTest, AckFrameNoNacks) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, AckFrameNoNacks15) { |
@@ -2162,32 +2072,29 @@ TEST_P(QuicFramerTest, AckFrameNoNacks15) { |
return; |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (no nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x4C, |
- // entropy hash of sent packets till least awaiting - 1. |
- 0xAB, |
- // least packet sequence number awaiting an ack, delta from sequence number. |
- 0x08, 0x00, 0x00, 0x00, |
- 0x00, 0x00, |
- // entropy hash of all received packets. |
- 0xBA, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (no nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x4C, |
+ // entropy hash of sent packets till least awaiting - 1. |
+ 0xAB, |
+ // least packet sequence number awaiting an ack, delta from sequence |
+ // number. |
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ // entropy hash of all received packets. |
+ 0xBA, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2215,8 +2122,10 @@ TEST_P(QuicFramerTest, AckFrameNoNacks15) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, AckFrame500Nacks) { |
@@ -2224,40 +2133,38 @@ TEST_P(QuicFramerTest, AckFrame500Nacks) { |
return; |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x6C, |
- // entropy hash of all received packets. |
- 0xBA, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
- // num missing packet ranges |
- 0x02, |
- // missing packet delta |
- 0x01, |
- // 243 more missing packets in range. |
- // The ranges are listed in this order so the re-constructed packet matches. |
- 0xF3, |
- // No gap between ranges |
- 0x00, |
- // 255 more missing packets in range. |
- 0xFF, |
- // No revived packets. |
- 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x6C, |
+ // entropy hash of all received packets. |
+ 0xBA, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
+ // num missing packet ranges |
+ 0x02, |
+ // missing packet delta |
+ 0x01, |
+ // 243 more missing packets in range. |
+ // The ranges are listed in this order so the re-constructed packet |
+ // matches. |
+ 0xF3, |
+ // No gap between ranges |
+ 0x00, |
+ // 255 more missing packets in range. |
+ 0xFF, |
+ // No revived packets. |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2290,8 +2197,10 @@ TEST_P(QuicFramerTest, AckFrame500Nacks) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, AckFrame500Nacks15) { |
@@ -2299,45 +2208,43 @@ TEST_P(QuicFramerTest, AckFrame500Nacks15) { |
return; |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x6C, |
- // entropy hash of sent packets till least awaiting - 1. |
- 0xAB, |
- // least packet sequence number awaiting an ack, delta from sequence number. |
- 0x08, 0x00, 0x00, 0x00, |
- 0x00, 0x00, |
- // entropy hash of all received packets. |
- 0xBA, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
- // num missing packet ranges |
- 0x02, |
- // missing packet delta |
- 0x01, |
- // 243 more missing packets in range. |
- // The ranges are listed in this order so the re-constructed packet matches. |
- 0xF3, |
- // No gap between ranges |
- 0x00, |
- // 255 more missing packets in range. |
- 0xFF, |
- // No revived packets. |
- 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x6C, |
+ // entropy hash of sent packets till least awaiting - 1. |
+ 0xAB, |
+ // least packet sequence number awaiting an ack, delta from sequence |
+ // number. |
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ // entropy hash of all received packets. |
+ 0xBA, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
+ // num missing packet ranges |
+ 0x02, |
+ // missing packet delta |
+ 0x01, |
+ // 243 more missing packets in range. |
+ // The ranges are listed in this order so the re-constructed packet |
+ // matches. |
+ 0xF3, |
+ // No gap between ranges |
+ 0x00, |
+ // 255 more missing packets in range. |
+ 0xFF, |
+ // No revived packets. |
+ 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2372,29 +2279,28 @@ TEST_P(QuicFramerTest, AckFrame500Nacks15) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (congestion feedback frame) |
- 0x20, |
- // congestion feedback type (tcp) |
- 0x00, |
- // ack_frame.feedback.tcp.receive_window |
- 0x03, 0x04, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (congestion feedback frame) |
+ 0x20, |
+ // congestion feedback type (tcp) |
+ 0x00, |
+ // ack_frame.feedback.tcp.receive_window |
+ 0x03, 0x04, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2419,47 +2325,44 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) { |
} else if (i < 4) { |
expected_error = "Unable to read receive window."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_CONGESTION_FEEDBACK_DATA); |
} |
} |
TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrival) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (congestion feedback frame) |
- 0x20, |
- // congestion feedback type (inter arrival) |
- 0x01, |
- // num received packets |
- 0x03, |
- // lowest sequence number |
- 0xBA, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // receive time |
- 0x87, 0x96, 0xA5, 0xB4, |
- 0xC3, 0xD2, 0xE1, 0x07, |
- // sequence delta |
- 0x01, 0x00, |
- // time delta |
- 0x01, 0x00, 0x00, 0x00, |
- // sequence delta (skip one packet) |
- 0x03, 0x00, |
- // time delta |
- 0x02, 0x00, 0x00, 0x00, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (congestion feedback frame) |
+ 0x20, |
+ // congestion feedback type (inter arrival) |
+ 0x01, |
+ // num received packets |
+ 0x03, |
+ // lowest sequence number |
+ 0xBA, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // receive time |
+ 0x87, 0x96, 0xA5, 0xB4, 0xC3, 0xD2, 0xE1, 0x07, |
+ // sequence delta |
+ 0x01, 0x00, |
+ // time delta |
+ 0x01, 0x00, 0x00, 0x00, |
+ // sequence delta (skip one packet) |
+ 0x03, 0x00, |
+ // time delta |
+ 0x02, 0x00, 0x00, 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2509,33 +2412,32 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrival) { |
} else if (i < 29) { |
expected_error = "Unable to read time delta in received packets."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_CONGESTION_FEEDBACK_DATA); |
} |
} |
TEST_P(QuicFramerTest, CongestionFeedbackFrameFixRate) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (congestion feedback frame) |
- 0x20, |
- // congestion feedback type (fix rate) |
- 0x02, |
- // bitrate_in_bytes_per_second; |
- 0x01, 0x02, 0x03, 0x04, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (congestion feedback frame) |
+ 0x20, |
+ // congestion feedback type (fix rate) |
+ 0x02, |
+ // bitrate_in_bytes_per_second; |
+ 0x01, 0x02, 0x03, 0x04, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2561,31 +2463,30 @@ TEST_P(QuicFramerTest, CongestionFeedbackFrameFixRate) { |
} else if (i < 6) { |
expected_error = "Unable to read bitrate."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_CONGESTION_FEEDBACK_DATA); |
} |
} |
TEST_P(QuicFramerTest, CongestionFeedbackFrameInvalidFeedback) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (congestion feedback frame) |
- 0x20, |
- // congestion feedback type (invalid) |
- 0x03, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (congestion feedback frame) |
+ 0x20, |
+ // congestion feedback type (invalid) |
+ 0x03, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2599,25 +2500,23 @@ TEST_P(QuicFramerTest, StopWaitingFrame) { |
return; |
} |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x06, |
- // entropy hash of sent packets till least awaiting - 1. |
- 0xAB, |
- // least packet sequence number awaiting an ack, delta from sequence number. |
- 0x08, 0x00, 0x00, 0x00, |
- 0x00, 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x06, |
+ // entropy hash of sent packets till least awaiting - 1. |
+ 0xAB, |
+ // least packet sequence number awaiting an ack, delta from sequence |
+ // number. |
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2643,46 +2542,42 @@ TEST_P(QuicFramerTest, StopWaitingFrame) { |
} else { |
expected_error = "Unable to read least unacked delta."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_STOP_WAITING_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_STOP_WAITING_DATA); |
} |
} |
TEST_P(QuicFramerTest, RstStreamFrameQuic) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (rst stream frame) |
- 0x01, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- |
- // sent byte offset |
- 0x01, 0x02, 0x03, 0x04, |
- 0x05, 0x06, 0x07, 0x08, |
- |
- // error code |
- 0x01, 0x00, 0x00, 0x00, |
- |
- // error details length |
- 0x0d, 0x00, |
- // error details |
- 'b', 'e', 'c', 'a', |
- 'u', 's', 'e', ' ', |
- 'I', ' ', 'c', 'a', |
- 'n', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (rst stream frame) |
+ 0x01, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ |
+ // sent byte offset |
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
+ |
+ // error code |
+ 0x01, 0x00, 0x00, 0x00, |
+ |
+ // error details length |
+ 0x0d, 0x00, |
+ // error details |
+ 'b', 'e', 'c', 'a', 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', 'n', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2700,52 +2595,50 @@ TEST_P(QuicFramerTest, RstStreamFrameQuic) { |
// Now test framing boundaries |
for (size_t i = kQuicFrameTypeSize; |
- i < QuicFramer::GetMinRstStreamFrameSize(version_); ++i) { |
+ i < QuicFramer::GetMinRstStreamFrameSize(version_); |
+ ++i) { |
string expected_error; |
if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { |
expected_error = "Unable to read stream_id."; |
} else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + |
- + kQuicMaxStreamOffsetSize) { |
+ +kQuicMaxStreamOffsetSize) { |
expected_error = "Unable to read rst stream sent byte offset."; |
} else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + |
- + kQuicMaxStreamOffsetSize + kQuicErrorCodeSize) { |
+ +kQuicMaxStreamOffsetSize + kQuicErrorCodeSize) { |
expected_error = "Unable to read rst stream error code."; |
} else { |
expected_error = "Unable to read rst stream error details."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_RST_STREAM_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_RST_STREAM_DATA); |
} |
} |
TEST_P(QuicFramerTest, ConnectionCloseFrame) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (connection close frame) |
- 0x02, |
- // error code |
- 0x11, 0x00, 0x00, 0x00, |
- |
- // error details length |
- 0x0d, 0x00, |
- // error details |
- 'b', 'e', 'c', 'a', |
- 'u', 's', 'e', ' ', |
- 'I', ' ', 'c', 'a', |
- 'n', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (connection close frame) |
+ 0x02, |
+ // error code |
+ 0x11, 0x00, 0x00, 0x00, |
+ |
+ // error details length |
+ 0x0d, 0x00, |
+ // error details |
+ 'b', 'e', 'c', 'a', 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', 'n', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2764,47 +2657,45 @@ TEST_P(QuicFramerTest, ConnectionCloseFrame) { |
// Now test framing boundaries |
for (size_t i = kQuicFrameTypeSize; |
- i < QuicFramer::GetMinConnectionCloseFrameSize(); ++i) { |
+ i < QuicFramer::GetMinConnectionCloseFrameSize(); |
+ ++i) { |
string expected_error; |
if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) { |
expected_error = "Unable to read connection close error code."; |
} else { |
expected_error = "Unable to read connection close error details."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_CONNECTION_CLOSE_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_CONNECTION_CLOSE_DATA); |
} |
} |
TEST_P(QuicFramerTest, GoAwayFrame) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (go away frame) |
- 0x03, |
- // error code |
- 0x09, 0x00, 0x00, 0x00, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // error details length |
- 0x0d, 0x00, |
- // error details |
- 'b', 'e', 'c', 'a', |
- 'u', 's', 'e', ' ', |
- 'I', ' ', 'c', 'a', |
- 'n', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (go away frame) |
+ 0x03, |
+ // error code |
+ 0x09, 0x00, 0x00, 0x00, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // error details length |
+ 0x0d, 0x00, |
+ // error details |
+ 'b', 'e', 'c', 'a', 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', 'n', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2822,44 +2713,43 @@ TEST_P(QuicFramerTest, GoAwayFrame) { |
const size_t reason_size = arraysize("because I can") - 1; |
// Now test framing boundaries |
for (size_t i = kQuicFrameTypeSize; |
- i < QuicFramer::GetMinGoAwayFrameSize() + reason_size; ++i) { |
+ i < QuicFramer::GetMinGoAwayFrameSize() + reason_size; |
+ ++i) { |
string expected_error; |
if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) { |
expected_error = "Unable to read go away error code."; |
- } else if (i < kQuicFrameTypeSize + kQuicErrorCodeSize + |
- kQuicMaxStreamIdSize) { |
+ } else if (i < |
+ kQuicFrameTypeSize + kQuicErrorCodeSize + kQuicMaxStreamIdSize) { |
expected_error = "Unable to read last good stream id."; |
} else { |
expected_error = "Unable to read goaway reason."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_GOAWAY_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_GOAWAY_DATA); |
} |
} |
TEST_P(QuicFramerTest, WindowUpdateFrame) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (window update frame) |
- 0x04, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // byte offset |
- 0x05, 0x06, 0x07, 0x08, |
- 0x09, 0x0a, 0x0b, 0x0c, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (window update frame) |
+ 0x04, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // byte offset |
+ 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2870,45 +2760,44 @@ TEST_P(QuicFramerTest, WindowUpdateFrame) { |
ASSERT_TRUE(visitor_.header_.get()); |
EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
- EXPECT_EQ(GG_UINT64_C(0x01020304), |
- visitor_.window_update_frame_.stream_id); |
+ EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.window_update_frame_.stream_id); |
EXPECT_EQ(GG_UINT64_C(0x0c0b0a0908070605), |
visitor_.window_update_frame_.byte_offset); |
// Now test framing boundaries |
for (size_t i = kQuicFrameTypeSize; |
- i < QuicFramer::GetWindowUpdateFrameSize(); ++i) { |
+ i < QuicFramer::GetWindowUpdateFrameSize(); |
+ ++i) { |
string expected_error; |
if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { |
expected_error = "Unable to read stream_id."; |
} else { |
expected_error = "Unable to read window byte_offset."; |
} |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_WINDOW_UPDATE_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_WINDOW_UPDATE_DATA); |
} |
} |
TEST_P(QuicFramerTest, BlockedFrame) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (blocked frame) |
- 0x05, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (blocked frame) |
+ 0x05, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2919,18 +2808,19 @@ TEST_P(QuicFramerTest, BlockedFrame) { |
ASSERT_TRUE(visitor_.header_.get()); |
EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
- EXPECT_EQ(GG_UINT64_C(0x01020304), |
- visitor_.blocked_frame_.stream_id); |
+ EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.blocked_frame_.stream_id); |
// Now test framing boundaries |
for (size_t i = kQuicFrameTypeSize; i < QuicFramer::GetBlockedFrameSize(); |
++i) { |
string expected_error = "Unable to read stream_id."; |
- CheckProcessingFails( |
- packet, |
- i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), |
- expected_error, QUIC_INVALID_BLOCKED_DATA); |
+ CheckProcessingFails(packet, |
+ i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP), |
+ expected_error, |
+ QUIC_INVALID_BLOCKED_DATA); |
} |
} |
@@ -2939,20 +2829,17 @@ TEST_P(QuicFramerTest, PingFrame) { |
return; |
} |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (ping frame) |
- 0x07, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (ping frame) |
+ 0x07, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -2968,30 +2855,26 @@ TEST_P(QuicFramerTest, PingFrame) { |
} |
TEST_P(QuicFramerTest, PublicResetPacket) { |
- unsigned char packet[] = { |
- // public flags (public reset, 8 byte connection_id) |
- 0x0E, |
- // 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 sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
+ unsigned char packet[] = {// public flags (public reset, 8 byte connection_id) |
+ 0x0E, |
+ // 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 sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -3006,8 +2889,7 @@ TEST_P(QuicFramerTest, PublicResetPacket) { |
visitor_.public_reset_packet_->nonce_proof); |
EXPECT_EQ(GG_UINT64_C(0x123456789ABC), |
visitor_.public_reset_packet_->rejected_sequence_number); |
- EXPECT_TRUE( |
- visitor_.public_reset_packet_->client_address.address().empty()); |
+ EXPECT_TRUE(visitor_.public_reset_packet_->client_address.address().empty()); |
// Now test framing boundaries |
for (size_t i = 0; i < arraysize(packet); ++i) { |
@@ -3015,87 +2897,79 @@ TEST_P(QuicFramerTest, PublicResetPacket) { |
DVLOG(1) << "iteration: " << i; |
if (i < kConnectionIdOffset) { |
expected_error = "Unable to read public flags."; |
- CheckProcessingFails(packet, i, expected_error, |
- QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails( |
+ packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); |
} else if (i < kPublicResetPacketMessageTagOffset) { |
expected_error = "Unable to read ConnectionId."; |
- CheckProcessingFails(packet, i, expected_error, |
- QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails( |
+ packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); |
} else { |
expected_error = "Unable to read reset message."; |
- CheckProcessingFails(packet, i, expected_error, |
- QUIC_INVALID_PUBLIC_RST_PACKET); |
+ CheckProcessingFails( |
+ packet, i, expected_error, QUIC_INVALID_PUBLIC_RST_PACKET); |
} |
} |
} |
TEST_P(QuicFramerTest, PublicResetPacketWithTrailingJunk) { |
- unsigned char packet[] = { |
- // public flags (public reset, 8 byte connection_id) |
- 0x0E, |
- // 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 sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- // trailing junk |
- 'j', 'u', 'n', 'k', |
+ unsigned char packet[] = {// public flags (public reset, 8 byte connection_id) |
+ 0x0E, |
+ // 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 sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, |
+ // trailing junk |
+ 'j', 'u', 'n', 'k', |
}; |
string expected_error = "Unable to read reset message."; |
- CheckProcessingFails(packet, arraysize(packet), expected_error, |
+ CheckProcessingFails(packet, |
+ arraysize(packet), |
+ expected_error, |
QUIC_INVALID_PUBLIC_RST_PACKET); |
} |
TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) { |
- unsigned char packet[] = { |
- // public flags (public reset, 8 byte connection_id) |
- 0x0E, |
- // 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 sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- // client address: 4.31.198.44:443 |
- 0x02, 0x00, |
- 0x04, 0x1F, 0xC6, 0x2C, |
- 0xBB, 0x01, |
+ unsigned char packet[] = {// public flags (public reset, 8 byte connection_id) |
+ 0x0E, |
+ // 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 sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, |
+ // client address: 4.31.198.44:443 |
+ 0x02, 0x00, 0x04, 0x1F, 0xC6, 0x2C, 0xBB, 0x01, |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -3111,8 +2985,8 @@ TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) { |
EXPECT_EQ(GG_UINT64_C(0x123456789ABC), |
visitor_.public_reset_packet_->rejected_sequence_number); |
EXPECT_EQ("4.31.198.44", |
- IPAddressToString(visitor_.public_reset_packet_-> |
- client_address.address())); |
+ IPAddressToString( |
+ visitor_.public_reset_packet_->client_address.address())); |
EXPECT_EQ(443, visitor_.public_reset_packet_->client_address.port()); |
// Now test framing boundaries |
@@ -3121,30 +2995,30 @@ TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) { |
DVLOG(1) << "iteration: " << i; |
if (i < kConnectionIdOffset) { |
expected_error = "Unable to read public flags."; |
- CheckProcessingFails(packet, i, expected_error, |
- QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails( |
+ packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); |
} else if (i < kPublicResetPacketMessageTagOffset) { |
expected_error = "Unable to read ConnectionId."; |
- CheckProcessingFails(packet, i, expected_error, |
- QUIC_INVALID_PACKET_HEADER); |
+ CheckProcessingFails( |
+ packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); |
} else { |
expected_error = "Unable to read reset message."; |
- CheckProcessingFails(packet, i, expected_error, |
- QUIC_INVALID_PUBLIC_RST_PACKET); |
+ CheckProcessingFails( |
+ packet, i, expected_error, QUIC_INVALID_PUBLIC_RST_PACKET); |
} |
} |
} |
TEST_P(QuicFramerTest, VersionNegotiationPacket) { |
unsigned char packet[] = { |
- // public flags (version, 8 byte connection_id) |
- 0x3D, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // version tag |
- 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
- 'Q', '2', '.', '0', |
+ // public flags (version, 8 byte connection_id) |
+ 0x3D, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ 'Q', '2', '.', '0', |
}; |
QuicFramerPeer::SetIsServer(&framer_, false); |
@@ -3172,25 +3046,20 @@ TEST_P(QuicFramerTest, VersionNegotiationPacket) { |
} |
TEST_P(QuicFramerTest, FecPacket) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (fec group & FEC) |
- 0x06, |
- // first fec protected packet offset |
- 0x01, |
- |
- // redundancy |
- 'a', 'b', 'c', 'd', |
- 'e', 'f', 'g', 'h', |
- 'i', 'j', 'k', 'l', |
- 'm', 'n', 'o', 'p', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (fec group & FEC) |
+ 0x06, |
+ // first fec protected packet offset |
+ 0x01, |
+ |
+ // redundancy |
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', |
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -3223,26 +3092,23 @@ TEST_P(QuicFramerTest, BuildPaddingFramePacket) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&padding_frame)); |
- unsigned char packet[kMaxPacketSize] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (padding frame) |
- 0x00, |
- 0x00, 0x00, 0x00, 0x00 |
- }; |
- |
- uint64 header_size = |
- GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ unsigned char packet[kMaxPacketSize] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, |
+ 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (padding frame) |
+ 0x00, 0x00, 0x00, 0x00, 0x00}; |
+ |
+ uint64 header_size = GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_6BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); |
scoped_ptr<QuicPacket> data( |
@@ -3250,7 +3116,8 @@ TEST_P(QuicFramerTest, BuildPaddingFramePacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
+ data->data(), |
+ data->length(), |
AsChars(packet), |
arraysize(packet)); |
} |
@@ -3272,24 +3139,22 @@ TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { |
frames.push_back(QuicFrame(&padding_frame)); |
unsigned char packet[kMaxPacketSize] = { |
- // public flags (8 byte connection_id and 4 byte sequence number) |
- 0x2C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- // private flags |
- 0x00, |
- |
- // frame type (padding frame) |
- 0x00, |
- 0x00, 0x00, 0x00, 0x00 |
- }; |
- |
- uint64 header_size = |
- GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ // public flags (8 byte connection_id and 4 byte sequence number) |
+ 0x2C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (padding frame) |
+ 0x00, 0x00, 0x00, 0x00, 0x00}; |
+ |
+ uint64 header_size = GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_4BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); |
scoped_ptr<QuicPacket> data( |
@@ -3297,7 +3162,8 @@ TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
+ data->data(), |
+ data->length(), |
AsChars(packet), |
arraysize(packet)); |
} |
@@ -3319,24 +3185,22 @@ TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { |
frames.push_back(QuicFrame(&padding_frame)); |
unsigned char packet[kMaxPacketSize] = { |
- // public flags (8 byte connection_id and 2 byte sequence number) |
- 0x1C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, |
- // private flags |
- 0x00, |
- |
- // frame type (padding frame) |
- 0x00, |
- 0x00, 0x00, 0x00, 0x00 |
- }; |
- |
- uint64 header_size = |
- GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ // public flags (8 byte connection_id and 2 byte sequence number) |
+ 0x1C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (padding frame) |
+ 0x00, 0x00, 0x00, 0x00, 0x00}; |
+ |
+ uint64 header_size = GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_2BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); |
scoped_ptr<QuicPacket> data( |
@@ -3344,7 +3208,8 @@ TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
+ data->data(), |
+ data->length(), |
AsChars(packet), |
arraysize(packet)); |
} |
@@ -3366,24 +3231,22 @@ TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) { |
frames.push_back(QuicFrame(&padding_frame)); |
unsigned char packet[kMaxPacketSize] = { |
- // public flags (8 byte connection_id and 1 byte sequence number) |
- 0x0C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, |
- // private flags |
- 0x00, |
- |
- // frame type (padding frame) |
- 0x00, |
- 0x00, 0x00, 0x00, 0x00 |
- }; |
- |
- uint64 header_size = |
- GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
- PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
+ // public flags (8 byte connection_id and 1 byte sequence number) |
+ 0x0C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (padding frame) |
+ 0x00, 0x00, 0x00, 0x00, 0x00}; |
+ |
+ uint64 header_size = GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
+ PACKET_1BYTE_SEQUENCE_NUMBER, |
+ NOT_IN_FEC_GROUP); |
memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); |
scoped_ptr<QuicPacket> data( |
@@ -3391,7 +3254,8 @@ TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
+ data->data(), |
+ data->length(), |
AsChars(packet), |
arraysize(packet)); |
} |
@@ -3415,29 +3279,24 @@ TEST_P(QuicFramerTest, BuildStreamFramePacket) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&stream_frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (stream frame with fin and no length) |
- 0xDF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (stream frame with fin and no length) |
+ 0xDF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
scoped_ptr<QuicPacket> data( |
@@ -3445,8 +3304,10 @@ TEST_P(QuicFramerTest, BuildStreamFramePacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildStreamFramePacketInFecGroup) { |
@@ -3469,31 +3330,26 @@ TEST_P(QuicFramerTest, BuildStreamFramePacketInFecGroup) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&stream_frame)); |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy, is_in_fec_group) |
- 0x03, |
- // FEC group |
- 0x00, |
- // frame type (stream frame with fin and data length field) |
- 0xFF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length (since packet is in an FEC group) |
- 0x0C, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy, is_in_fec_group) |
+ 0x03, |
+ // FEC group |
+ 0x00, |
+ // frame type (stream frame with fin and data length field) |
+ 0xFF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length (since packet is in an FEC group) |
+ 0x0C, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
}; |
scoped_ptr<QuicPacket> data( |
@@ -3501,8 +3357,10 @@ TEST_P(QuicFramerTest, BuildStreamFramePacketInFecGroup) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { |
@@ -3525,30 +3383,30 @@ TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { |
frames.push_back(QuicFrame(&stream_frame)); |
unsigned char packet[] = { |
- // public flags (version, 8 byte connection_id) |
- 0x3D, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // version tag |
- 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (stream frame with fin and no length) |
- 0xDF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ // public flags (version, 8 byte connection_id) |
+ 0x3D, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, |
+ 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (stream frame with fin and no length) |
+ 0xDF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, |
+ 0xDC, 0xFE, 0x98, 0xBA, |
+ // data |
+ 'h', 'e', 'l', 'l', |
+ 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicFramerPeer::SetIsServer(&framer_, false); |
@@ -3557,8 +3415,10 @@ TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { |
@@ -3568,13 +3428,13 @@ TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { |
header.version_flag = true; |
unsigned char packet[] = { |
- // public flags (version, 8 byte connection_id) |
- 0x0D, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // version tag |
- 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
+ // public flags (version, 8 byte connection_id) |
+ 0x0D, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, |
+ 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
}; |
QuicVersionVector versions; |
@@ -3583,8 +3443,10 @@ TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { |
framer_.BuildVersionNegotiationPacket(header, versions)); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildAckFramePacket) { |
@@ -3611,35 +3473,32 @@ TEST_P(QuicFramerTest, BuildAckFramePacket) { |
frames.push_back(QuicFrame(&ack_frame)); |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x6C, |
- // entropy hash of all received packets. |
- 0x43, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
- // num missing packet ranges |
- 0x01, |
- // missing packet delta |
- 0x01, |
- // 0 more missing packets in range. |
- 0x00, |
- // 0 revived packets. |
- 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x6C, |
+ // entropy hash of all received packets. |
+ 0x43, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
+ // num missing packet ranges |
+ 0x01, |
+ // missing packet delta |
+ 0x01, |
+ // 0 more missing packets in range. |
+ 0x00, |
+ // 0 revived packets. |
+ 0x00, |
}; |
scoped_ptr<QuicPacket> data( |
@@ -3647,8 +3506,10 @@ TEST_P(QuicFramerTest, BuildAckFramePacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildAckFramePacket15) { |
@@ -3677,40 +3538,37 @@ TEST_P(QuicFramerTest, BuildAckFramePacket15) { |
frames.push_back(QuicFrame(&ack_frame)); |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (ack frame) |
- // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
- 0x6C, |
- // entropy hash of sent packets till least awaiting - 1. |
- 0x14, |
- // least packet sequence number awaiting an ack, delta from sequence number. |
- 0x08, 0x00, 0x00, 0x00, |
- 0x00, 0x00, |
- // entropy hash of all received packets. |
- 0x43, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Zero delta time. |
- 0x0, 0x0, |
- // num missing packet ranges |
- 0x01, |
- // missing packet delta |
- 0x01, |
- // 0 more missing packets in range. |
- 0x00, |
- // 0 revived packets. |
- 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (ack frame) |
+ // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) |
+ 0x6C, |
+ // entropy hash of sent packets till least awaiting - 1. |
+ 0x14, |
+ // least packet sequence number awaiting an ack, delta from sequence |
+ // number. |
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ // entropy hash of all received packets. |
+ 0x43, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Zero delta time. |
+ 0x0, 0x0, |
+ // num missing packet ranges |
+ 0x01, |
+ // missing packet delta |
+ 0x01, |
+ // 0 more missing packets in range. |
+ 0x00, |
+ // 0 revived packets. |
+ 0x00, |
}; |
scoped_ptr<QuicPacket> data( |
@@ -3718,8 +3576,10 @@ TEST_P(QuicFramerTest, BuildAckFramePacket15) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) { |
@@ -3739,24 +3599,21 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&congestion_feedback_frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (congestion feedback frame) |
- 0x20, |
- // congestion feedback type (TCP) |
- 0x00, |
- // TCP receive window |
- 0x03, 0x04, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (congestion feedback frame) |
+ 0x20, |
+ // congestion feedback type (TCP) |
+ 0x00, |
+ // TCP receive window |
+ 0x03, 0x04, |
}; |
scoped_ptr<QuicPacket> data( |
@@ -3764,8 +3621,10 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) { |
@@ -3780,53 +3639,48 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) { |
QuicCongestionFeedbackFrame frame; |
frame.type = kInterArrival; |
- frame.inter_arrival.received_packet_times.insert( |
- make_pair(GG_UINT64_C(0x0123456789ABA), |
- start_.Add(QuicTime::Delta::FromMicroseconds( |
- GG_UINT64_C(0x07E1D2C3B4A59687))))); |
- frame.inter_arrival.received_packet_times.insert( |
- make_pair(GG_UINT64_C(0x0123456789ABB), |
- start_.Add(QuicTime::Delta::FromMicroseconds( |
- GG_UINT64_C(0x07E1D2C3B4A59688))))); |
- frame.inter_arrival.received_packet_times.insert( |
- make_pair(GG_UINT64_C(0x0123456789ABD), |
- start_.Add(QuicTime::Delta::FromMicroseconds( |
- GG_UINT64_C(0x07E1D2C3B4A59689))))); |
+ frame.inter_arrival.received_packet_times.insert(make_pair( |
+ GG_UINT64_C(0x0123456789ABA), |
+ start_.Add( |
+ QuicTime::Delta::FromMicroseconds(GG_UINT64_C(0x07E1D2C3B4A59687))))); |
+ frame.inter_arrival.received_packet_times.insert(make_pair( |
+ GG_UINT64_C(0x0123456789ABB), |
+ start_.Add( |
+ QuicTime::Delta::FromMicroseconds(GG_UINT64_C(0x07E1D2C3B4A59688))))); |
+ frame.inter_arrival.received_packet_times.insert(make_pair( |
+ GG_UINT64_C(0x0123456789ABD), |
+ start_.Add( |
+ QuicTime::Delta::FromMicroseconds(GG_UINT64_C(0x07E1D2C3B4A59689))))); |
QuicFrames frames; |
frames.push_back(QuicFrame(&frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (congestion feedback frame) |
- 0x20, |
- // congestion feedback type (inter arrival) |
- 0x01, |
- // num received packets |
- 0x03, |
- // lowest sequence number |
- 0xBA, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // receive time |
- 0x87, 0x96, 0xA5, 0xB4, |
- 0xC3, 0xD2, 0xE1, 0x07, |
- // sequence delta |
- 0x01, 0x00, |
- // time delta |
- 0x01, 0x00, 0x00, 0x00, |
- // sequence delta (skip one packet) |
- 0x03, 0x00, |
- // time delta |
- 0x02, 0x00, 0x00, 0x00, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (congestion feedback frame) |
+ 0x20, |
+ // congestion feedback type (inter arrival) |
+ 0x01, |
+ // num received packets |
+ 0x03, |
+ // lowest sequence number |
+ 0xBA, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // receive time |
+ 0x87, 0x96, 0xA5, 0xB4, 0xC3, 0xD2, 0xE1, 0x07, |
+ // sequence delta |
+ 0x01, 0x00, |
+ // time delta |
+ 0x01, 0x00, 0x00, 0x00, |
+ // sequence delta (skip one packet) |
+ 0x03, 0x00, |
+ // time delta |
+ 0x02, 0x00, 0x00, 0x00, |
}; |
scoped_ptr<QuicPacket> data( |
@@ -3834,8 +3688,10 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildStopWaitingPacket) { |
@@ -3859,24 +3715,22 @@ TEST_P(QuicFramerTest, BuildStopWaitingPacket) { |
frames.push_back(QuicFrame(&stop_waiting_frame)); |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xA8, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (stop waiting frame) |
- 0x06, |
- // entropy hash of sent packets till least awaiting - 1. |
- 0x14, |
- // least packet sequence number awaiting an ack, delta from sequence number. |
- 0x08, 0x00, 0x00, 0x00, |
- 0x00, 0x00, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xA8, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (stop waiting frame) |
+ 0x06, |
+ // entropy hash of sent packets till least awaiting - 1. |
+ 0x14, |
+ // least packet sequence number awaiting an ack, delta from sequence |
+ // number. |
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, |
}; |
scoped_ptr<QuicPacket> data( |
@@ -3884,8 +3738,10 @@ TEST_P(QuicFramerTest, BuildStopWaitingPacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) { |
@@ -3900,30 +3756,27 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) { |
QuicCongestionFeedbackFrame congestion_feedback_frame; |
congestion_feedback_frame.type = kFixRate; |
- congestion_feedback_frame.fix_rate.bitrate |
- = QuicBandwidth::FromBytesPerSecond(0x04030201); |
+ congestion_feedback_frame.fix_rate.bitrate = |
+ QuicBandwidth::FromBytesPerSecond(0x04030201); |
QuicFrames frames; |
frames.push_back(QuicFrame(&congestion_feedback_frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (congestion feedback frame) |
- 0x20, |
- // congestion feedback type (fix rate) |
- 0x02, |
- // bitrate_in_bytes_per_second; |
- 0x01, 0x02, 0x03, 0x04, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (congestion feedback frame) |
+ 0x20, |
+ // congestion feedback type (fix rate) |
+ 0x02, |
+ // bitrate_in_bytes_per_second; |
+ 0x01, 0x02, 0x03, 0x04, |
}; |
scoped_ptr<QuicPacket> data( |
@@ -3931,8 +3784,10 @@ TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInvalidFeedback) { |
@@ -3975,34 +3830,28 @@ TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { |
rst_frame.error_details = "because I can"; |
rst_frame.byte_offset = 0x0807060504030201; |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags |
- 0x00, |
- |
- // frame type (rst stream frame) |
- 0x01, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // sent byte offset |
- 0x01, 0x02, 0x03, 0x04, |
- 0x05, 0x06, 0x07, 0x08, |
- // error code |
- 0x08, 0x07, 0x06, 0x05, |
- // error details length |
- 0x0d, 0x00, |
- // error details |
- 'b', 'e', 'c', 'a', |
- 'u', 's', 'e', ' ', |
- 'I', ' ', 'c', 'a', |
- 'n', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags |
+ 0x00, |
+ |
+ // frame type (rst stream frame) |
+ 0x01, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // sent byte offset |
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
+ // error code |
+ 0x08, 0x07, 0x06, 0x05, |
+ // error details length |
+ 0x0d, 0x00, |
+ // error details |
+ 'b', 'e', 'c', 'a', 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', 'n', |
}; |
QuicFrames frames; |
@@ -4013,8 +3862,10 @@ TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildCloseFramePacket) { |
@@ -4034,29 +3885,24 @@ TEST_P(QuicFramerTest, BuildCloseFramePacket) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&close_frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy) |
- 0x01, |
- |
- // frame type (connection close frame) |
- 0x02, |
- // error code |
- 0x08, 0x07, 0x06, 0x05, |
- // error details length |
- 0x0d, 0x00, |
- // error details |
- 'b', 'e', 'c', 'a', |
- 'u', 's', 'e', ' ', |
- 'I', ' ', 'c', 'a', |
- 'n', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy) |
+ 0x01, |
+ |
+ // frame type (connection close frame) |
+ 0x02, |
+ // error code |
+ 0x08, 0x07, 0x06, 0x05, |
+ // error details length |
+ 0x0d, 0x00, |
+ // error details |
+ 'b', 'e', 'c', 'a', 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', 'n', |
}; |
scoped_ptr<QuicPacket> data( |
@@ -4064,8 +3910,10 @@ TEST_P(QuicFramerTest, BuildCloseFramePacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildGoAwayPacket) { |
@@ -4086,31 +3934,26 @@ TEST_P(QuicFramerTest, BuildGoAwayPacket) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&goaway_frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags(entropy) |
- 0x01, |
- |
- // frame type (go away frame) |
- 0x03, |
- // error code |
- 0x08, 0x07, 0x06, 0x05, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // error details length |
- 0x0d, 0x00, |
- // error details |
- 'b', 'e', 'c', 'a', |
- 'u', 's', 'e', ' ', |
- 'I', ' ', 'c', 'a', |
- 'n', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags(entropy) |
+ 0x01, |
+ |
+ // frame type (go away frame) |
+ 0x03, |
+ // error code |
+ 0x08, 0x07, 0x06, 0x05, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // error details length |
+ 0x0d, 0x00, |
+ // error details |
+ 'b', 'e', 'c', 'a', 'u', 's', 'e', ' ', |
+ 'I', ' ', 'c', 'a', 'n', |
}; |
scoped_ptr<QuicPacket> data( |
@@ -4118,8 +3961,10 @@ TEST_P(QuicFramerTest, BuildGoAwayPacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { |
@@ -4139,33 +3984,31 @@ TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&window_update_frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags(entropy) |
- 0x01, |
- |
- // frame type (window update frame) |
- 0x04, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // byte offset |
- 0x88, 0x77, 0x66, 0x55, |
- 0x44, 0x33, 0x22, 0x11, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags(entropy) |
+ 0x01, |
+ |
+ // frame type (window update frame) |
+ 0x04, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // byte offset |
+ 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, |
}; |
scoped_ptr<QuicPacket> data( |
framer_.BuildUnsizedDataPacket(header, frames).packet); |
ASSERT_TRUE(data != NULL); |
- test::CompareCharArraysWithHexError("constructed packet", data->data(), |
- data->length(), AsChars(packet), |
+ test::CompareCharArraysWithHexError("constructed packet", |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
arraysize(packet)); |
} |
@@ -4185,30 +4028,29 @@ TEST_P(QuicFramerTest, BuildBlockedPacket) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&blocked_frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags(entropy) |
- 0x01, |
- |
- // frame type (blocked frame) |
- 0x05, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags(entropy) |
+ 0x01, |
+ |
+ // frame type (blocked frame) |
+ 0x05, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
}; |
scoped_ptr<QuicPacket> data( |
framer_.BuildUnsizedDataPacket(header, frames).packet); |
ASSERT_TRUE(data != NULL); |
- test::CompareCharArraysWithHexError("constructed packet", data->data(), |
- data->length(), AsChars(packet), |
+ test::CompareCharArraysWithHexError("constructed packet", |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
arraysize(packet)); |
} |
@@ -4227,20 +4069,17 @@ TEST_P(QuicFramerTest, BuildPingPacket) { |
QuicFrames frames; |
frames.push_back(QuicFrame(&ping_frame)); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags(entropy) |
- 0x01, |
- |
- // frame type (ping frame) |
- 0x07, |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags(entropy) |
+ 0x01, |
+ |
+ // frame type (ping frame) |
+ 0x07, |
}; |
if (version_ > QUIC_VERSION_17) { |
@@ -4248,8 +4087,10 @@ TEST_P(QuicFramerTest, BuildPingPacket) { |
framer_.BuildUnsizedDataPacket(header, frames).packet); |
ASSERT_TRUE(data != NULL); |
- test::CompareCharArraysWithHexError("constructed packet", data->data(), |
- data->length(), AsChars(packet), |
+ test::CompareCharArraysWithHexError("constructed packet", |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
arraysize(packet)); |
} else { |
string expected_error = |
@@ -4268,30 +4109,26 @@ TEST_P(QuicFramerTest, BuildPublicResetPacket) { |
reset_packet.rejected_sequence_number = GG_UINT64_C(0x123456789ABC); |
reset_packet.nonce_proof = GG_UINT64_C(0xABCDEF0123456789); |
- unsigned char packet[] = { |
- // 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 (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 sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
+ unsigned char packet[] = {// 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 (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 sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, |
}; |
scoped_ptr<QuicEncryptedPacket> data( |
@@ -4299,8 +4136,10 @@ TEST_P(QuicFramerTest, BuildPublicResetPacket) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { |
@@ -4312,38 +4151,32 @@ TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { |
reset_packet.nonce_proof = GG_UINT64_C(0xABCDEF0123456789); |
reset_packet.client_address = IPEndPoint(Loopback4(), 0x1234); |
- unsigned char packet[] = { |
- // 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 (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 sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, 0x00, 0x00, |
- // client address |
- 0x02, 0x00, |
- 0x7F, 0x00, 0x00, 0x01, |
- 0x34, 0x12, |
+ unsigned char packet[] = {// 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 (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 sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, |
+ // client address |
+ 0x02, 0x00, 0x7F, 0x00, 0x00, 0x01, 0x34, 0x12, |
}; |
scoped_ptr<QuicEncryptedPacket> data( |
@@ -4351,8 +4184,10 @@ TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, BuildFecPacket) { |
@@ -4364,68 +4199,63 @@ TEST_P(QuicFramerTest, BuildFecPacket) { |
header.entropy_flag = true; |
header.packet_sequence_number = (GG_UINT64_C(0x123456789ABC)); |
header.is_in_fec_group = IN_FEC_GROUP; |
- header.fec_group = GG_UINT64_C(0x123456789ABB);; |
+ header.fec_group = GG_UINT64_C(0x123456789ABB); |
+ ; |
QuicFecData fec_data; |
fec_data.fec_group = 1; |
fec_data.redundancy = "abcdefghijklmnop"; |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (entropy & fec group & fec packet) |
- 0x07, |
- // first fec protected packet offset |
- 0x01, |
- |
- // redundancy |
- 'a', 'b', 'c', 'd', |
- 'e', 'f', 'g', 'h', |
- 'i', 'j', 'k', 'l', |
- 'm', 'n', 'o', 'p', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (entropy & fec group & fec packet) |
+ 0x07, |
+ // first fec protected packet offset |
+ 0x01, |
+ |
+ // redundancy |
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', |
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', |
}; |
- scoped_ptr<QuicPacket> data( |
- framer_.BuildFecPacket(header, fec_data).packet); |
+ scoped_ptr<QuicPacket> data(framer_.BuildFecPacket(header, fec_data).packet); |
ASSERT_TRUE(data != NULL); |
test::CompareCharArraysWithHexError("constructed packet", |
- data->data(), data->length(), |
- AsChars(packet), arraysize(packet)); |
+ data->data(), |
+ data->length(), |
+ AsChars(packet), |
+ arraysize(packet)); |
} |
TEST_P(QuicFramerTest, EncryptPacket) { |
QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC); |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (fec group & fec packet) |
- 0x06, |
- // first fec protected packet offset |
- 0x01, |
- |
- // redundancy |
- 'a', 'b', 'c', 'd', |
- 'e', 'f', 'g', 'h', |
- 'i', 'j', 'k', 'l', |
- 'm', 'n', 'o', 'p', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (fec group & fec packet) |
+ 0x06, |
+ // first fec protected packet offset |
+ 0x01, |
+ |
+ // redundancy |
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', |
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', |
}; |
scoped_ptr<QuicPacket> raw( |
- QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false, |
- PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
+ QuicPacket::NewDataPacket(AsChars(packet), |
+ arraysize(packet), |
+ false, |
+ PACKET_8BYTE_CONNECTION_ID, |
+ !kIncludeVersion, |
PACKET_6BYTE_SEQUENCE_NUMBER)); |
scoped_ptr<QuicEncryptedPacket> encrypted( |
framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw)); |
@@ -4436,32 +4266,30 @@ TEST_P(QuicFramerTest, EncryptPacket) { |
TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) { |
QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC); |
- unsigned char packet[] = { |
- // public flags (version, 8 byte connection_id) |
- 0x3D, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // version tag |
- 'Q', '.', '1', '0', |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (fec group & fec flags) |
- 0x06, |
- // first fec protected packet offset |
- 0x01, |
- |
- // redundancy |
- 'a', 'b', 'c', 'd', |
- 'e', 'f', 'g', 'h', |
- 'i', 'j', 'k', 'l', |
- 'm', 'n', 'o', 'p', |
+ unsigned char packet[] = {// public flags (version, 8 byte connection_id) |
+ 0x3D, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // version tag |
+ 'Q', '.', '1', '0', |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (fec group & fec flags) |
+ 0x06, |
+ // first fec protected packet offset |
+ 0x01, |
+ |
+ // redundancy |
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', |
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', |
}; |
scoped_ptr<QuicPacket> raw( |
- QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false, |
- PACKET_8BYTE_CONNECTION_ID, kIncludeVersion, |
+ QuicPacket::NewDataPacket(AsChars(packet), |
+ arraysize(packet), |
+ false, |
+ PACKET_8BYTE_CONNECTION_ID, |
+ kIncludeVersion, |
PACKET_6BYTE_SEQUENCE_NUMBER)); |
scoped_ptr<QuicEncryptedPacket> encrypted( |
framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw)); |
@@ -4500,9 +4328,8 @@ TEST_P(QuicFramerTest, Truncation) { |
framer_.BuildUnsizedDataPacket(header, frames).packet); |
ASSERT_TRUE(raw_ack_packet != NULL); |
- scoped_ptr<QuicEncryptedPacket> ack_packet( |
- framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, |
- *raw_ack_packet)); |
+ scoped_ptr<QuicEncryptedPacket> ack_packet(framer_.EncryptPacket( |
+ ENCRYPTION_NONE, header.packet_sequence_number, *raw_ack_packet)); |
// Now make sure we can turn our ack packet back into an ack frame |
ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); |
@@ -4550,9 +4377,8 @@ TEST_P(QuicFramerTest, Truncation15) { |
framer_.BuildUnsizedDataPacket(header, frames).packet); |
ASSERT_TRUE(raw_ack_packet != NULL); |
- scoped_ptr<QuicEncryptedPacket> ack_packet( |
- framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, |
- *raw_ack_packet)); |
+ scoped_ptr<QuicEncryptedPacket> ack_packet(framer_.EncryptPacket( |
+ ENCRYPTION_NONE, header.packet_sequence_number, *raw_ack_packet)); |
// Now make sure we can turn our ack packet back into an ack frame |
ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); |
@@ -4599,9 +4425,8 @@ TEST_P(QuicFramerTest, CleanTruncation) { |
framer_.BuildUnsizedDataPacket(header, frames).packet); |
ASSERT_TRUE(raw_ack_packet != NULL); |
- scoped_ptr<QuicEncryptedPacket> ack_packet( |
- framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, |
- *raw_ack_packet)); |
+ scoped_ptr<QuicEncryptedPacket> ack_packet(framer_.EncryptPacket( |
+ ENCRYPTION_NONE, header.packet_sequence_number, *raw_ack_packet)); |
// Now make sure we can turn our ack packet back into an ack frame |
ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); |
@@ -4614,37 +4439,31 @@ TEST_P(QuicFramerTest, CleanTruncation) { |
frames.push_back(frame); |
size_t original_raw_length = raw_ack_packet->length(); |
- raw_ack_packet.reset( |
- framer_.BuildUnsizedDataPacket(header, frames).packet); |
+ raw_ack_packet.reset(framer_.BuildUnsizedDataPacket(header, frames).packet); |
ASSERT_TRUE(raw_ack_packet != NULL); |
EXPECT_EQ(original_raw_length, raw_ack_packet->length()); |
ASSERT_TRUE(raw_ack_packet != NULL); |
} |
TEST_P(QuicFramerTest, EntropyFlagTest) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (Entropy) |
- 0x01, |
- |
- // frame type (stream frame with fin and no length) |
- 0xDF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (Entropy) |
+ 0x01, |
+ |
+ // frame type (stream frame with fin and no length) |
+ 0xDF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -4657,31 +4476,26 @@ TEST_P(QuicFramerTest, EntropyFlagTest) { |
}; |
TEST_P(QuicFramerTest, FecEntropyTest) { |
- unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // private flags (Entropy & fec group & FEC) |
- 0x07, |
- // first fec protected packet offset |
- 0xFF, |
- |
- // frame type (stream frame with fin and no length) |
- 0xDF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
+ unsigned char packet[] = {// public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // private flags (Entropy & fec group & FEC) |
+ 0x07, |
+ // first fec protected packet offset |
+ 0xFF, |
+ |
+ // frame type (stream frame with fin and no length) |
+ 0xDF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', |
+ 'r', 'l', 'd', '!', |
}; |
QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
@@ -4695,48 +4509,40 @@ TEST_P(QuicFramerTest, FecEntropyTest) { |
TEST_P(QuicFramerTest, StopPacketProcessing) { |
unsigned char packet[] = { |
- // public flags (8 byte connection_id) |
- 0x3C, |
- // connection_id |
- 0x10, 0x32, 0x54, 0x76, |
- 0x98, 0xBA, 0xDC, 0xFE, |
- // packet sequence number |
- 0xBC, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // Entropy |
- 0x01, |
- |
- // frame type (stream frame with fin) |
- 0xFF, |
- // stream id |
- 0x04, 0x03, 0x02, 0x01, |
- // offset |
- 0x54, 0x76, 0x10, 0x32, |
- 0xDC, 0xFE, 0x98, 0xBA, |
- // data length |
- 0x0c, 0x00, |
- // data |
- 'h', 'e', 'l', 'l', |
- 'o', ' ', 'w', 'o', |
- 'r', 'l', 'd', '!', |
- |
- // frame type (ack frame) |
- 0x40, |
- // entropy hash of sent packets till least awaiting - 1. |
- 0x14, |
- // least packet sequence number awaiting an ack |
- 0xA0, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // entropy hash of all received packets. |
- 0x43, |
- // largest observed packet sequence number |
- 0xBF, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
- // num missing packets |
- 0x01, |
- // missing packet |
- 0xBE, 0x9A, 0x78, 0x56, |
- 0x34, 0x12, |
+ // public flags (8 byte connection_id) |
+ 0x3C, |
+ // connection_id |
+ 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
+ // packet sequence number |
+ 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // Entropy |
+ 0x01, |
+ |
+ // frame type (stream frame with fin) |
+ 0xFF, |
+ // stream id |
+ 0x04, 0x03, 0x02, 0x01, |
+ // offset |
+ 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
+ // data length |
+ 0x0c, 0x00, |
+ // data |
+ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
+ |
+ // frame type (ack frame) |
+ 0x40, |
+ // entropy hash of sent packets till least awaiting - 1. |
+ 0x14, |
+ // least packet sequence number awaiting an ack |
+ 0xA0, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // entropy hash of all received packets. |
+ 0x43, |
+ // largest observed packet sequence number |
+ 0xBF, 0x9A, 0x78, 0x56, 0x34, 0x12, |
+ // num missing packets |
+ 0x01, |
+ // missing packet |
+ 0xBE, 0x9A, 0x78, 0x56, 0x34, 0x12, |
}; |
MockFramerVisitor visitor; |