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

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

Issue 182523002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed rch's comments in Patch set 1 of CL 181463007 Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 21 matching lines...) Expand all
32 using std::vector; 32 using std::vector;
33 using testing::Return; 33 using testing::Return;
34 using testing::_; 34 using testing::_;
35 35
36 namespace net { 36 namespace net {
37 namespace test { 37 namespace test {
38 38
39 const QuicPacketSequenceNumber kEpoch = GG_UINT64_C(1) << 48; 39 const QuicPacketSequenceNumber kEpoch = GG_UINT64_C(1) << 48;
40 const QuicPacketSequenceNumber kMask = kEpoch - 1; 40 const QuicPacketSequenceNumber kMask = kEpoch - 1;
41 41
42 // Index into the guid offset in the header. 42 // Index into the connection_id offset in the header.
43 const size_t kGuidOffset = kPublicFlagsSize; 43 const size_t kConnectionIdOffset = kPublicFlagsSize;
44 // Index into the version string in the header. (if present). 44 // Index into the version string in the header. (if present).
45 const size_t kVersionOffset = kGuidOffset + PACKET_8BYTE_GUID; 45 const size_t kVersionOffset = kConnectionIdOffset + PACKET_8BYTE_CONNECTION_ID;
46 46
47 // Size in bytes of the stream frame fields for an arbitrary StreamID and 47 // Size in bytes of the stream frame fields for an arbitrary StreamID and
48 // offset and the last frame in a packet. 48 // offset and the last frame in a packet.
49 size_t GetMinStreamFrameSize(QuicVersion version) { 49 size_t GetMinStreamFrameSize(QuicVersion version) {
50 return kQuicFrameTypeSize + kQuicMaxStreamIdSize + kQuicMaxStreamOffsetSize; 50 return kQuicFrameTypeSize + kQuicMaxStreamIdSize + kQuicMaxStreamOffsetSize;
51 } 51 }
52 52
53 // Index into the sequence number offset in the header. 53 // Index into the sequence number offset in the header.
54 size_t GetSequenceNumberOffset(QuicGuidLength guid_length, 54 size_t GetSequenceNumberOffset(QuicConnectionIdLength connection_id_length,
55 bool include_version) { 55 bool include_version) {
56 return kGuidOffset + guid_length + 56 return kConnectionIdOffset + connection_id_length +
57 (include_version ? kQuicVersionSize : 0); 57 (include_version ? kQuicVersionSize : 0);
58 } 58 }
59 59
60 size_t GetSequenceNumberOffset(bool include_version) { 60 size_t GetSequenceNumberOffset(bool include_version) {
61 return GetSequenceNumberOffset(PACKET_8BYTE_GUID, include_version); 61 return GetSequenceNumberOffset(PACKET_8BYTE_CONNECTION_ID, include_version);
62 } 62 }
63 63
64 // Index into the private flags offset in the data packet header. 64 // Index into the private flags offset in the data packet header.
65 size_t GetPrivateFlagsOffset(QuicGuidLength guid_length, bool include_version) { 65 size_t GetPrivateFlagsOffset(QuicConnectionIdLength connection_id_length,
66 return GetSequenceNumberOffset(guid_length, include_version) + 66 bool include_version) {
67 return GetSequenceNumberOffset(connection_id_length, include_version) +
67 PACKET_6BYTE_SEQUENCE_NUMBER; 68 PACKET_6BYTE_SEQUENCE_NUMBER;
68 } 69 }
69 70
70 size_t GetPrivateFlagsOffset(bool include_version) { 71 size_t GetPrivateFlagsOffset(bool include_version) {
71 return GetPrivateFlagsOffset(PACKET_8BYTE_GUID, include_version); 72 return GetPrivateFlagsOffset(PACKET_8BYTE_CONNECTION_ID, include_version);
72 } 73 }
73 74
74 size_t GetPrivateFlagsOffset(bool include_version, 75 size_t GetPrivateFlagsOffset(bool include_version,
75 QuicSequenceNumberLength sequence_number_length) { 76 QuicSequenceNumberLength sequence_number_length) {
76 return GetSequenceNumberOffset(PACKET_8BYTE_GUID, include_version) + 77 return GetSequenceNumberOffset(PACKET_8BYTE_CONNECTION_ID, include_version) +
77 sequence_number_length; 78 sequence_number_length;
78 } 79 }
79 80
80 // Index into the fec group offset in the header. 81 // Index into the fec group offset in the header.
81 size_t GetFecGroupOffset(QuicGuidLength guid_length, bool include_version) { 82 size_t GetFecGroupOffset(QuicConnectionIdLength connection_id_length,
82 return GetPrivateFlagsOffset(guid_length, include_version) + 83 bool include_version) {
84 return GetPrivateFlagsOffset(connection_id_length, include_version) +
83 kPrivateFlagsSize; 85 kPrivateFlagsSize;
84 } 86 }
85 87
86 size_t GetFecGroupOffset(bool include_version) { 88 size_t GetFecGroupOffset(bool include_version) {
87 return GetPrivateFlagsOffset(PACKET_8BYTE_GUID, include_version) + 89 return GetPrivateFlagsOffset(PACKET_8BYTE_CONNECTION_ID, include_version) +
88 kPrivateFlagsSize; 90 kPrivateFlagsSize;
89 } 91 }
90 92
91 size_t GetFecGroupOffset(bool include_version, 93 size_t GetFecGroupOffset(bool include_version,
92 QuicSequenceNumberLength sequence_number_length) { 94 QuicSequenceNumberLength sequence_number_length) {
93 return GetPrivateFlagsOffset(include_version, sequence_number_length) + 95 return GetPrivateFlagsOffset(include_version, sequence_number_length) +
94 kPrivateFlagsSize; 96 kPrivateFlagsSize;
95 } 97 }
96 98
97 // Index into the message tag of the public reset packet. 99 // Index into the message tag of the public reset packet.
98 // Public resets always have full guids. 100 // Public resets always have full connection_ids.
99 const size_t kPublicResetPacketMessageTagOffset = 101 const size_t kPublicResetPacketMessageTagOffset =
100 kGuidOffset + PACKET_8BYTE_GUID; 102 kConnectionIdOffset + PACKET_8BYTE_CONNECTION_ID;
101 103
102 // TODO(wtc): remove this when we drop support for QUIC_VERSION_13. 104 // TODO(wtc): remove this when we drop support for QUIC_VERSION_13.
103 // Index into the nonce proof of the public reset packet. 105 // Index into the nonce proof of the public reset packet.
104 // Public resets always have full guids. 106 // Public resets always have full connection_ids.
105 const size_t kPublicResetPacketNonceProofOffset = 107 const size_t kPublicResetPacketNonceProofOffset =
106 kGuidOffset + PACKET_8BYTE_GUID; 108 kConnectionIdOffset + PACKET_8BYTE_CONNECTION_ID;
107 109
108 // TODO(wtc): remove this when we drop support for QUIC_VERSION_13. 110 // TODO(wtc): remove this when we drop support for QUIC_VERSION_13.
109 // Index into the rejected sequence number of the public reset packet. 111 // Index into the rejected sequence number of the public reset packet.
110 const size_t kPublicResetPacketRejectedSequenceNumberOffset = 112 const size_t kPublicResetPacketRejectedSequenceNumberOffset =
111 kPublicResetPacketNonceProofOffset + kPublicResetNonceSize; 113 kPublicResetPacketNonceProofOffset + kPublicResetNonceSize;
112 114
113 class TestEncrypter : public QuicEncrypter { 115 class TestEncrypter : public QuicEncrypter {
114 public: 116 public:
115 virtual ~TestEncrypter() {} 117 virtual ~TestEncrypter() {}
116 virtual bool SetKey(StringPiece key) OVERRIDE { 118 virtual bool SetKey(StringPiece key) OVERRIDE {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 bool CheckDecryption(const QuicEncryptedPacket& encrypted, 409 bool CheckDecryption(const QuicEncryptedPacket& encrypted,
408 bool includes_version) { 410 bool includes_version) {
409 if (visitor_.header_->packet_sequence_number != 411 if (visitor_.header_->packet_sequence_number !=
410 decrypter_->sequence_number_) { 412 decrypter_->sequence_number_) {
411 LOG(ERROR) << "Decrypted incorrect packet sequence number. expected " 413 LOG(ERROR) << "Decrypted incorrect packet sequence number. expected "
412 << visitor_.header_->packet_sequence_number << " actual: " 414 << visitor_.header_->packet_sequence_number << " actual: "
413 << decrypter_->sequence_number_; 415 << decrypter_->sequence_number_;
414 return false; 416 return false;
415 } 417 }
416 if (QuicFramer::GetAssociatedDataFromEncryptedPacket( 418 if (QuicFramer::GetAssociatedDataFromEncryptedPacket(
417 encrypted, PACKET_8BYTE_GUID, 419 encrypted, PACKET_8BYTE_CONNECTION_ID,
418 includes_version, PACKET_6BYTE_SEQUENCE_NUMBER) != 420 includes_version, PACKET_6BYTE_SEQUENCE_NUMBER) !=
419 decrypter_->associated_data_) { 421 decrypter_->associated_data_) {
420 LOG(ERROR) << "Decrypted incorrect associated data. expected " 422 LOG(ERROR) << "Decrypted incorrect associated data. expected "
421 << QuicFramer::GetAssociatedDataFromEncryptedPacket( 423 << QuicFramer::GetAssociatedDataFromEncryptedPacket(
422 encrypted, PACKET_8BYTE_GUID, 424 encrypted, PACKET_8BYTE_CONNECTION_ID,
423 includes_version, PACKET_6BYTE_SEQUENCE_NUMBER) 425 includes_version, PACKET_6BYTE_SEQUENCE_NUMBER)
424 << " actual: " << decrypter_->associated_data_; 426 << " actual: " << decrypter_->associated_data_;
425 return false; 427 return false;
426 } 428 }
427 StringPiece ciphertext(encrypted.AsStringPiece().substr( 429 StringPiece ciphertext(encrypted.AsStringPiece().substr(
428 GetStartOfEncryptedData(PACKET_8BYTE_GUID, includes_version, 430 GetStartOfEncryptedData(PACKET_8BYTE_CONNECTION_ID, includes_version,
429 PACKET_6BYTE_SEQUENCE_NUMBER))); 431 PACKET_6BYTE_SEQUENCE_NUMBER)));
430 if (ciphertext != decrypter_->ciphertext_) { 432 if (ciphertext != decrypter_->ciphertext_) {
431 LOG(ERROR) << "Decrypted incorrect ciphertext data. expected " 433 LOG(ERROR) << "Decrypted incorrect ciphertext data. expected "
432 << ciphertext << " actual: " 434 << ciphertext << " actual: "
433 << decrypter_->ciphertext_; 435 << decrypter_->ciphertext_;
434 return false; 436 return false;
435 } 437 }
436 return true; 438 return true;
437 } 439 }
438 440
(...skipping 27 matching lines...) Expand all
466 if (i < kQuicFrameTypeSize + stream_id_size) { 468 if (i < kQuicFrameTypeSize + stream_id_size) {
467 expected_error = "Unable to read stream_id."; 469 expected_error = "Unable to read stream_id.";
468 } else if (i < kQuicFrameTypeSize + stream_id_size + 470 } else if (i < kQuicFrameTypeSize + stream_id_size +
469 kQuicMaxStreamOffsetSize) { 471 kQuicMaxStreamOffsetSize) {
470 expected_error = "Unable to read offset."; 472 expected_error = "Unable to read offset.";
471 } else { 473 } else {
472 expected_error = "Unable to read frame data."; 474 expected_error = "Unable to read frame data.";
473 } 475 }
474 CheckProcessingFails( 476 CheckProcessingFails(
475 packet, 477 packet,
476 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, include_version, 478 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, include_version,
477 PACKET_6BYTE_SEQUENCE_NUMBER, 479 PACKET_6BYTE_SEQUENCE_NUMBER,
478 NOT_IN_FEC_GROUP), 480 NOT_IN_FEC_GROUP),
479 expected_error, QUIC_INVALID_STREAM_DATA); 481 expected_error, QUIC_INVALID_STREAM_DATA);
480 } 482 }
481 } 483 }
482 484
483 void CheckCalculatePacketSequenceNumber( 485 void CheckCalculatePacketSequenceNumber(
484 QuicPacketSequenceNumber expected_sequence_number, 486 QuicPacketSequenceNumber expected_sequence_number,
485 QuicPacketSequenceNumber last_sequence_number) { 487 QuicPacketSequenceNumber last_sequence_number) {
486 QuicPacketSequenceNumber wire_sequence_number = 488 QuicPacketSequenceNumber wire_sequence_number =
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 612
611 TEST_P(QuicFramerTest, EmptyPacket) { 613 TEST_P(QuicFramerTest, EmptyPacket) {
612 char packet[] = { 0x00 }; 614 char packet[] = { 0x00 };
613 QuicEncryptedPacket encrypted(packet, 0, false); 615 QuicEncryptedPacket encrypted(packet, 0, false);
614 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 616 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
615 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error()); 617 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error());
616 } 618 }
617 619
618 TEST_P(QuicFramerTest, LargePacket) { 620 TEST_P(QuicFramerTest, LargePacket) {
619 unsigned char packet[kMaxPacketSize + 1] = { 621 unsigned char packet[kMaxPacketSize + 1] = {
620 // public flags (8 byte guid) 622 // public flags (8 byte connection_id)
621 0x3C, 623 0x3C,
622 // guid 624 // connection_id
623 0x10, 0x32, 0x54, 0x76, 625 0x10, 0x32, 0x54, 0x76,
624 0x98, 0xBA, 0xDC, 0xFE, 626 0x98, 0xBA, 0xDC, 0xFE,
625 // packet sequence number 627 // packet sequence number
626 0xBC, 0x9A, 0x78, 0x56, 628 0xBC, 0x9A, 0x78, 0x56,
627 0x34, 0x12, 629 0x34, 0x12,
628 // private flags 630 // private flags
629 0x00, 631 0x00,
630 }; 632 };
631 633
632 memset(packet + GetPacketHeaderSize( 634 memset(packet + GetPacketHeaderSize(
633 PACKET_8BYTE_GUID, !kIncludeVersion, 635 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
634 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 0, 636 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 0,
635 kMaxPacketSize - GetPacketHeaderSize( 637 kMaxPacketSize - GetPacketHeaderSize(
636 PACKET_8BYTE_GUID, !kIncludeVersion, 638 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
637 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + 1); 639 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + 1);
638 640
639 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 641 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
640 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 642 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
641 643
642 ASSERT_TRUE(visitor_.header_.get()); 644 ASSERT_TRUE(visitor_.header_.get());
643 // Make sure we've parsed the packet header, so we can send an error. 645 // Make sure we've parsed the packet header, so we can send an error.
644 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 646 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
645 visitor_.header_->public_header.guid); 647 visitor_.header_->public_header.connection_id);
646 // Make sure the correct error is propagated. 648 // Make sure the correct error is propagated.
647 EXPECT_EQ(QUIC_PACKET_TOO_LARGE, framer_.error()); 649 EXPECT_EQ(QUIC_PACKET_TOO_LARGE, framer_.error());
648 } 650 }
649 651
650 TEST_P(QuicFramerTest, PacketHeader) { 652 TEST_P(QuicFramerTest, PacketHeader) {
651 unsigned char packet[] = { 653 unsigned char packet[] = {
652 // public flags (8 byte guid) 654 // public flags (8 byte connection_id)
653 0x3C, 655 0x3C,
654 // guid 656 // connection_id
655 0x10, 0x32, 0x54, 0x76, 657 0x10, 0x32, 0x54, 0x76,
656 0x98, 0xBA, 0xDC, 0xFE, 658 0x98, 0xBA, 0xDC, 0xFE,
657 // packet sequence number 659 // packet sequence number
658 0xBC, 0x9A, 0x78, 0x56, 660 0xBC, 0x9A, 0x78, 0x56,
659 0x34, 0x12, 661 0x34, 0x12,
660 // private flags 662 // private flags
661 0x00, 663 0x00,
662 }; 664 };
663 665
664 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 666 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
665 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 667 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
666 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); 668 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
667 ASSERT_TRUE(visitor_.header_.get()); 669 ASSERT_TRUE(visitor_.header_.get());
668 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 670 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
669 visitor_.header_->public_header.guid); 671 visitor_.header_->public_header.connection_id);
670 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 672 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
671 EXPECT_FALSE(visitor_.header_->public_header.version_flag); 673 EXPECT_FALSE(visitor_.header_->public_header.version_flag);
672 EXPECT_FALSE(visitor_.header_->fec_flag); 674 EXPECT_FALSE(visitor_.header_->fec_flag);
673 EXPECT_FALSE(visitor_.header_->entropy_flag); 675 EXPECT_FALSE(visitor_.header_->entropy_flag);
674 EXPECT_EQ(0, visitor_.header_->entropy_hash); 676 EXPECT_EQ(0, visitor_.header_->entropy_hash);
675 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 677 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
676 visitor_.header_->packet_sequence_number); 678 visitor_.header_->packet_sequence_number);
677 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 679 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
678 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 680 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
679 681
680 // Now test framing boundaries 682 // Now test framing boundaries
681 for (size_t i = 0; 683 for (size_t i = 0;
682 i < GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 684 i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
683 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 685 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
684 ++i) { 686 ++i) {
685 string expected_error; 687 string expected_error;
686 if (i < kGuidOffset) { 688 if (i < kConnectionIdOffset) {
687 expected_error = "Unable to read public flags."; 689 expected_error = "Unable to read public flags.";
688 } else if (i < GetSequenceNumberOffset(!kIncludeVersion)) { 690 } else if (i < GetSequenceNumberOffset(!kIncludeVersion)) {
689 expected_error = "Unable to read GUID."; 691 expected_error = "Unable to read ConnectionId.";
690 } else if (i < GetPrivateFlagsOffset(!kIncludeVersion)) { 692 } else if (i < GetPrivateFlagsOffset(!kIncludeVersion)) {
691 expected_error = "Unable to read sequence number."; 693 expected_error = "Unable to read sequence number.";
692 } else if (i < GetFecGroupOffset(!kIncludeVersion)) { 694 } else if (i < GetFecGroupOffset(!kIncludeVersion)) {
693 expected_error = "Unable to read private flags."; 695 expected_error = "Unable to read private flags.";
694 } else { 696 } else {
695 expected_error = "Unable to read first fec protected packet offset."; 697 expected_error = "Unable to read first fec protected packet offset.";
696 } 698 }
697 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); 699 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER);
698 } 700 }
699 } 701 }
700 702
701 TEST_P(QuicFramerTest, PacketHeaderWith4ByteGuid) { 703 TEST_P(QuicFramerTest, PacketHeaderWith4ByteConnectionId) {
702 QuicFramerPeer::SetLastSerializedGuid(&framer_, 704 QuicFramerPeer::SetLastSerializedConnectionId(
703 GG_UINT64_C(0xFEDCBA9876543210)); 705 &framer_, GG_UINT64_C(0xFEDCBA9876543210));
704 706
705 unsigned char packet[] = { 707 unsigned char packet[] = {
706 // public flags (4 byte guid) 708 // public flags (4 byte connection_id)
707 0x38, 709 0x38,
708 // guid 710 // connection_id
709 0x10, 0x32, 0x54, 0x76, 711 0x10, 0x32, 0x54, 0x76,
710 // packet sequence number 712 // packet sequence number
711 0xBC, 0x9A, 0x78, 0x56, 713 0xBC, 0x9A, 0x78, 0x56,
712 0x34, 0x12, 714 0x34, 0x12,
713 // private flags 715 // private flags
714 0x00, 716 0x00,
715 }; 717 };
716 718
717 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 719 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
718 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 720 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
719 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); 721 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
720 ASSERT_TRUE(visitor_.header_.get()); 722 ASSERT_TRUE(visitor_.header_.get());
721 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 723 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
722 visitor_.header_->public_header.guid); 724 visitor_.header_->public_header.connection_id);
723 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 725 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
724 EXPECT_FALSE(visitor_.header_->public_header.version_flag); 726 EXPECT_FALSE(visitor_.header_->public_header.version_flag);
725 EXPECT_FALSE(visitor_.header_->fec_flag); 727 EXPECT_FALSE(visitor_.header_->fec_flag);
726 EXPECT_FALSE(visitor_.header_->entropy_flag); 728 EXPECT_FALSE(visitor_.header_->entropy_flag);
727 EXPECT_EQ(0, visitor_.header_->entropy_hash); 729 EXPECT_EQ(0, visitor_.header_->entropy_hash);
728 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 730 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
729 visitor_.header_->packet_sequence_number); 731 visitor_.header_->packet_sequence_number);
730 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 732 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
731 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 733 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
732 734
733 // Now test framing boundaries 735 // Now test framing boundaries
734 for (size_t i = 0; 736 for (size_t i = 0;
735 i < GetPacketHeaderSize(PACKET_4BYTE_GUID, !kIncludeVersion, 737 i < GetPacketHeaderSize(PACKET_4BYTE_CONNECTION_ID, !kIncludeVersion,
736 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 738 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
737 ++i) { 739 ++i) {
738 string expected_error; 740 string expected_error;
739 if (i < kGuidOffset) { 741 if (i < kConnectionIdOffset) {
740 expected_error = "Unable to read public flags."; 742 expected_error = "Unable to read public flags.";
741 } else if (i < GetSequenceNumberOffset(PACKET_4BYTE_GUID, 743 } else if (i < GetSequenceNumberOffset(PACKET_4BYTE_CONNECTION_ID,
742 !kIncludeVersion)) { 744 !kIncludeVersion)) {
743 expected_error = "Unable to read GUID."; 745 expected_error = "Unable to read ConnectionId.";
744 } else if (i < GetPrivateFlagsOffset(PACKET_4BYTE_GUID, 746 } else if (i < GetPrivateFlagsOffset(PACKET_4BYTE_CONNECTION_ID,
745 !kIncludeVersion)) { 747 !kIncludeVersion)) {
746 expected_error = "Unable to read sequence number."; 748 expected_error = "Unable to read sequence number.";
747 } else if (i < GetFecGroupOffset(PACKET_4BYTE_GUID, !kIncludeVersion)) { 749 } else if (i < GetFecGroupOffset(PACKET_4BYTE_CONNECTION_ID,
750 !kIncludeVersion)) {
748 expected_error = "Unable to read private flags."; 751 expected_error = "Unable to read private flags.";
749 } else { 752 } else {
750 expected_error = "Unable to read first fec protected packet offset."; 753 expected_error = "Unable to read first fec protected packet offset.";
751 } 754 }
752 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); 755 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER);
753 } 756 }
754 } 757 }
755 758
756 TEST_P(QuicFramerTest, PacketHeader1ByteGuid) { 759 TEST_P(QuicFramerTest, PacketHeader1ByteConnectionId) {
757 QuicFramerPeer::SetLastSerializedGuid(&framer_, 760 QuicFramerPeer::SetLastSerializedConnectionId(
758 GG_UINT64_C(0xFEDCBA9876543210)); 761 &framer_, GG_UINT64_C(0xFEDCBA9876543210));
759 762
760 unsigned char packet[] = { 763 unsigned char packet[] = {
761 // public flags (1 byte guid) 764 // public flags (1 byte connection_id)
762 0x34, 765 0x34,
763 // guid 766 // connection_id
764 0x10, 767 0x10,
765 // packet sequence number 768 // packet sequence number
766 0xBC, 0x9A, 0x78, 0x56, 769 0xBC, 0x9A, 0x78, 0x56,
767 0x34, 0x12, 770 0x34, 0x12,
768 // private flags 771 // private flags
769 0x00, 772 0x00,
770 }; 773 };
771 774
772 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 775 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
773 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 776 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
774 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); 777 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
775 ASSERT_TRUE(visitor_.header_.get()); 778 ASSERT_TRUE(visitor_.header_.get());
776 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 779 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
777 visitor_.header_->public_header.guid); 780 visitor_.header_->public_header.connection_id);
778 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 781 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
779 EXPECT_FALSE(visitor_.header_->public_header.version_flag); 782 EXPECT_FALSE(visitor_.header_->public_header.version_flag);
780 EXPECT_FALSE(visitor_.header_->fec_flag); 783 EXPECT_FALSE(visitor_.header_->fec_flag);
781 EXPECT_FALSE(visitor_.header_->entropy_flag); 784 EXPECT_FALSE(visitor_.header_->entropy_flag);
782 EXPECT_EQ(0, visitor_.header_->entropy_hash); 785 EXPECT_EQ(0, visitor_.header_->entropy_hash);
783 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 786 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
784 visitor_.header_->packet_sequence_number); 787 visitor_.header_->packet_sequence_number);
785 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 788 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
786 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 789 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
787 790
788 // Now test framing boundaries 791 // Now test framing boundaries
789 for (size_t i = 0; 792 for (size_t i = 0;
790 i < GetPacketHeaderSize(PACKET_1BYTE_GUID, !kIncludeVersion, 793 i < GetPacketHeaderSize(PACKET_1BYTE_CONNECTION_ID, !kIncludeVersion,
791 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 794 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
792 ++i) { 795 ++i) {
793 string expected_error; 796 string expected_error;
794 if (i < kGuidOffset) { 797 if (i < kConnectionIdOffset) {
795 expected_error = "Unable to read public flags."; 798 expected_error = "Unable to read public flags.";
796 } else if (i < GetSequenceNumberOffset(PACKET_1BYTE_GUID, 799 } else if (i < GetSequenceNumberOffset(PACKET_1BYTE_CONNECTION_ID,
797 !kIncludeVersion)) { 800 !kIncludeVersion)) {
798 expected_error = "Unable to read GUID."; 801 expected_error = "Unable to read ConnectionId.";
799 } else if (i < GetPrivateFlagsOffset(PACKET_1BYTE_GUID, !kIncludeVersion)) { 802 } else if (i < GetPrivateFlagsOffset(PACKET_1BYTE_CONNECTION_ID,
803 !kIncludeVersion)) {
800 expected_error = "Unable to read sequence number."; 804 expected_error = "Unable to read sequence number.";
801 } else if (i < GetFecGroupOffset(PACKET_1BYTE_GUID, !kIncludeVersion)) { 805 } else if (i < GetFecGroupOffset(PACKET_1BYTE_CONNECTION_ID,
806 !kIncludeVersion)) {
802 expected_error = "Unable to read private flags."; 807 expected_error = "Unable to read private flags.";
803 } else { 808 } else {
804 expected_error = "Unable to read first fec protected packet offset."; 809 expected_error = "Unable to read first fec protected packet offset.";
805 } 810 }
806 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); 811 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER);
807 } 812 }
808 } 813 }
809 814
810 TEST_P(QuicFramerTest, PacketHeaderWith0ByteGuid) { 815 TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) {
811 QuicFramerPeer::SetLastSerializedGuid(&framer_, 816 QuicFramerPeer::SetLastSerializedConnectionId(
812 GG_UINT64_C(0xFEDCBA9876543210)); 817 &framer_, GG_UINT64_C(0xFEDCBA9876543210));
813 818
814 unsigned char packet[] = { 819 unsigned char packet[] = {
815 // public flags (0 byte guid) 820 // public flags (0 byte connection_id)
816 0x30, 821 0x30,
817 // guid 822 // connection_id
818 // packet sequence number 823 // packet sequence number
819 0xBC, 0x9A, 0x78, 0x56, 824 0xBC, 0x9A, 0x78, 0x56,
820 0x34, 0x12, 825 0x34, 0x12,
821 // private flags 826 // private flags
822 0x00, 827 0x00,
823 }; 828 };
824 829
825 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 830 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
826 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 831 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
827 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); 832 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
828 ASSERT_TRUE(visitor_.header_.get()); 833 ASSERT_TRUE(visitor_.header_.get());
829 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 834 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
830 visitor_.header_->public_header.guid); 835 visitor_.header_->public_header.connection_id);
831 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 836 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
832 EXPECT_FALSE(visitor_.header_->public_header.version_flag); 837 EXPECT_FALSE(visitor_.header_->public_header.version_flag);
833 EXPECT_FALSE(visitor_.header_->fec_flag); 838 EXPECT_FALSE(visitor_.header_->fec_flag);
834 EXPECT_FALSE(visitor_.header_->entropy_flag); 839 EXPECT_FALSE(visitor_.header_->entropy_flag);
835 EXPECT_EQ(0, visitor_.header_->entropy_hash); 840 EXPECT_EQ(0, visitor_.header_->entropy_hash);
836 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 841 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
837 visitor_.header_->packet_sequence_number); 842 visitor_.header_->packet_sequence_number);
838 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 843 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
839 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 844 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
840 845
841 // Now test framing boundaries 846 // Now test framing boundaries
842 for (size_t i = 0; 847 for (size_t i = 0;
843 i < GetPacketHeaderSize(PACKET_0BYTE_GUID, !kIncludeVersion, 848 i < GetPacketHeaderSize(PACKET_0BYTE_CONNECTION_ID, !kIncludeVersion,
844 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 849 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
845 ++i) { 850 ++i) {
846 string expected_error; 851 string expected_error;
847 if (i < kGuidOffset) { 852 if (i < kConnectionIdOffset) {
848 expected_error = "Unable to read public flags."; 853 expected_error = "Unable to read public flags.";
849 } else if (i < GetSequenceNumberOffset(PACKET_0BYTE_GUID, 854 } else if (i < GetSequenceNumberOffset(PACKET_0BYTE_CONNECTION_ID,
850 !kIncludeVersion)) { 855 !kIncludeVersion)) {
851 expected_error = "Unable to read GUID."; 856 expected_error = "Unable to read ConnectionId.";
852 } else if (i < GetPrivateFlagsOffset(PACKET_0BYTE_GUID, !kIncludeVersion)) { 857 } else if (i < GetPrivateFlagsOffset(PACKET_0BYTE_CONNECTION_ID,
858 !kIncludeVersion)) {
853 expected_error = "Unable to read sequence number."; 859 expected_error = "Unable to read sequence number.";
854 } else if (i < GetFecGroupOffset(PACKET_0BYTE_GUID, !kIncludeVersion)) { 860 } else if (i < GetFecGroupOffset(PACKET_0BYTE_CONNECTION_ID,
861 !kIncludeVersion)) {
855 expected_error = "Unable to read private flags."; 862 expected_error = "Unable to read private flags.";
856 } else { 863 } else {
857 expected_error = "Unable to read first fec protected packet offset."; 864 expected_error = "Unable to read first fec protected packet offset.";
858 } 865 }
859 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); 866 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER);
860 } 867 }
861 } 868 }
862 869
863 TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { 870 TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) {
864 unsigned char packet[] = { 871 unsigned char packet[] = {
865 // public flags (version) 872 // public flags (version)
866 0x3D, 873 0x3D,
867 // guid 874 // connection_id
868 0x10, 0x32, 0x54, 0x76, 875 0x10, 0x32, 0x54, 0x76,
869 0x98, 0xBA, 0xDC, 0xFE, 876 0x98, 0xBA, 0xDC, 0xFE,
870 // version tag 877 // version tag
871 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 878 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
872 // packet sequence number 879 // packet sequence number
873 0xBC, 0x9A, 0x78, 0x56, 880 0xBC, 0x9A, 0x78, 0x56,
874 0x34, 0x12, 881 0x34, 0x12,
875 // private flags 882 // private flags
876 0x00, 883 0x00,
877 }; 884 };
878 885
879 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 886 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
880 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 887 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
881 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); 888 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
882 ASSERT_TRUE(visitor_.header_.get()); 889 ASSERT_TRUE(visitor_.header_.get());
883 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 890 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
884 visitor_.header_->public_header.guid); 891 visitor_.header_->public_header.connection_id);
885 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 892 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
886 EXPECT_TRUE(visitor_.header_->public_header.version_flag); 893 EXPECT_TRUE(visitor_.header_->public_header.version_flag);
887 EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]); 894 EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]);
888 EXPECT_FALSE(visitor_.header_->fec_flag); 895 EXPECT_FALSE(visitor_.header_->fec_flag);
889 EXPECT_FALSE(visitor_.header_->entropy_flag); 896 EXPECT_FALSE(visitor_.header_->entropy_flag);
890 EXPECT_EQ(0, visitor_.header_->entropy_hash); 897 EXPECT_EQ(0, visitor_.header_->entropy_hash);
891 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 898 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
892 visitor_.header_->packet_sequence_number); 899 visitor_.header_->packet_sequence_number);
893 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 900 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
894 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 901 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
895 902
896 // Now test framing boundaries 903 // Now test framing boundaries
897 for (size_t i = 0; 904 for (size_t i = 0;
898 i < GetPacketHeaderSize(PACKET_8BYTE_GUID, kIncludeVersion, 905 i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, kIncludeVersion,
899 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 906 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
900 ++i) { 907 ++i) {
901 string expected_error; 908 string expected_error;
902 if (i < kGuidOffset) { 909 if (i < kConnectionIdOffset) {
903 expected_error = "Unable to read public flags."; 910 expected_error = "Unable to read public flags.";
904 } else if (i < kVersionOffset) { 911 } else if (i < kVersionOffset) {
905 expected_error = "Unable to read GUID."; 912 expected_error = "Unable to read ConnectionId.";
906 } else if (i < GetSequenceNumberOffset(kIncludeVersion)) { 913 } else if (i < GetSequenceNumberOffset(kIncludeVersion)) {
907 expected_error = "Unable to read protocol version."; 914 expected_error = "Unable to read protocol version.";
908 } else if (i < GetPrivateFlagsOffset(kIncludeVersion)) { 915 } else if (i < GetPrivateFlagsOffset(kIncludeVersion)) {
909 expected_error = "Unable to read sequence number."; 916 expected_error = "Unable to read sequence number.";
910 } else if (i < GetFecGroupOffset(kIncludeVersion)) { 917 } else if (i < GetFecGroupOffset(kIncludeVersion)) {
911 expected_error = "Unable to read private flags."; 918 expected_error = "Unable to read private flags.";
912 } else { 919 } else {
913 expected_error = "Unable to read first fec protected packet offset."; 920 expected_error = "Unable to read first fec protected packet offset.";
914 } 921 }
915 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); 922 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER);
916 } 923 }
917 } 924 }
918 925
919 TEST_P(QuicFramerTest, PacketHeaderWith4ByteSequenceNumber) { 926 TEST_P(QuicFramerTest, PacketHeaderWith4ByteSequenceNumber) {
920 QuicFramerPeer::SetLastSequenceNumber(&framer_, 927 QuicFramerPeer::SetLastSequenceNumber(&framer_,
921 GG_UINT64_C(0x123456789ABA)); 928 GG_UINT64_C(0x123456789ABA));
922 929
923 unsigned char packet[] = { 930 unsigned char packet[] = {
924 // public flags (8 byte guid and 4 byte sequence number) 931 // public flags (8 byte connection_id and 4 byte sequence number)
925 0x2C, 932 0x2C,
926 // guid 933 // connection_id
927 0x10, 0x32, 0x54, 0x76, 934 0x10, 0x32, 0x54, 0x76,
928 0x98, 0xBA, 0xDC, 0xFE, 935 0x98, 0xBA, 0xDC, 0xFE,
929 // packet sequence number 936 // packet sequence number
930 0xBC, 0x9A, 0x78, 0x56, 937 0xBC, 0x9A, 0x78, 0x56,
931 // private flags 938 // private flags
932 0x00, 939 0x00,
933 }; 940 };
934 941
935 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 942 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
936 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 943 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
937 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); 944 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
938 ASSERT_TRUE(visitor_.header_.get()); 945 ASSERT_TRUE(visitor_.header_.get());
939 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 946 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
940 visitor_.header_->public_header.guid); 947 visitor_.header_->public_header.connection_id);
941 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 948 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
942 EXPECT_FALSE(visitor_.header_->public_header.version_flag); 949 EXPECT_FALSE(visitor_.header_->public_header.version_flag);
943 EXPECT_FALSE(visitor_.header_->fec_flag); 950 EXPECT_FALSE(visitor_.header_->fec_flag);
944 EXPECT_FALSE(visitor_.header_->entropy_flag); 951 EXPECT_FALSE(visitor_.header_->entropy_flag);
945 EXPECT_EQ(0, visitor_.header_->entropy_hash); 952 EXPECT_EQ(0, visitor_.header_->entropy_hash);
946 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 953 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
947 visitor_.header_->packet_sequence_number); 954 visitor_.header_->packet_sequence_number);
948 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 955 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
949 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 956 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
950 957
951 // Now test framing boundaries 958 // Now test framing boundaries
952 for (size_t i = 0; 959 for (size_t i = 0;
953 i < GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 960 i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
954 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 961 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
955 ++i) { 962 ++i) {
956 string expected_error; 963 string expected_error;
957 if (i < kGuidOffset) { 964 if (i < kConnectionIdOffset) {
958 expected_error = "Unable to read public flags."; 965 expected_error = "Unable to read public flags.";
959 } else if (i < GetSequenceNumberOffset(!kIncludeVersion)) { 966 } else if (i < GetSequenceNumberOffset(!kIncludeVersion)) {
960 expected_error = "Unable to read GUID."; 967 expected_error = "Unable to read ConnectionId.";
961 } else if (i < GetPrivateFlagsOffset(!kIncludeVersion, 968 } else if (i < GetPrivateFlagsOffset(!kIncludeVersion,
962 PACKET_4BYTE_SEQUENCE_NUMBER)) { 969 PACKET_4BYTE_SEQUENCE_NUMBER)) {
963 expected_error = "Unable to read sequence number."; 970 expected_error = "Unable to read sequence number.";
964 } else if (i < GetFecGroupOffset(!kIncludeVersion, 971 } else if (i < GetFecGroupOffset(!kIncludeVersion,
965 PACKET_4BYTE_SEQUENCE_NUMBER)) { 972 PACKET_4BYTE_SEQUENCE_NUMBER)) {
966 expected_error = "Unable to read private flags."; 973 expected_error = "Unable to read private flags.";
967 } else { 974 } else {
968 expected_error = "Unable to read first fec protected packet offset."; 975 expected_error = "Unable to read first fec protected packet offset.";
969 } 976 }
970 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); 977 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER);
971 } 978 }
972 } 979 }
973 980
974 TEST_P(QuicFramerTest, PacketHeaderWith2ByteSequenceNumber) { 981 TEST_P(QuicFramerTest, PacketHeaderWith2ByteSequenceNumber) {
975 QuicFramerPeer::SetLastSequenceNumber(&framer_, 982 QuicFramerPeer::SetLastSequenceNumber(&framer_,
976 GG_UINT64_C(0x123456789ABA)); 983 GG_UINT64_C(0x123456789ABA));
977 984
978 unsigned char packet[] = { 985 unsigned char packet[] = {
979 // public flags (8 byte guid and 2 byte sequence number) 986 // public flags (8 byte connection_id and 2 byte sequence number)
980 0x1C, 987 0x1C,
981 // guid 988 // connection_id
982 0x10, 0x32, 0x54, 0x76, 989 0x10, 0x32, 0x54, 0x76,
983 0x98, 0xBA, 0xDC, 0xFE, 990 0x98, 0xBA, 0xDC, 0xFE,
984 // packet sequence number 991 // packet sequence number
985 0xBC, 0x9A, 992 0xBC, 0x9A,
986 // private flags 993 // private flags
987 0x00, 994 0x00,
988 }; 995 };
989 996
990 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 997 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
991 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 998 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
992 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); 999 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
993 ASSERT_TRUE(visitor_.header_.get()); 1000 ASSERT_TRUE(visitor_.header_.get());
994 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 1001 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
995 visitor_.header_->public_header.guid); 1002 visitor_.header_->public_header.connection_id);
996 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 1003 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
997 EXPECT_FALSE(visitor_.header_->public_header.version_flag); 1004 EXPECT_FALSE(visitor_.header_->public_header.version_flag);
998 EXPECT_FALSE(visitor_.header_->fec_flag); 1005 EXPECT_FALSE(visitor_.header_->fec_flag);
999 EXPECT_FALSE(visitor_.header_->entropy_flag); 1006 EXPECT_FALSE(visitor_.header_->entropy_flag);
1000 EXPECT_EQ(0, visitor_.header_->entropy_hash); 1007 EXPECT_EQ(0, visitor_.header_->entropy_hash);
1001 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 1008 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
1002 visitor_.header_->packet_sequence_number); 1009 visitor_.header_->packet_sequence_number);
1003 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 1010 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
1004 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 1011 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
1005 1012
1006 // Now test framing boundaries 1013 // Now test framing boundaries
1007 for (size_t i = 0; 1014 for (size_t i = 0;
1008 i < GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 1015 i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
1009 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 1016 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
1010 ++i) { 1017 ++i) {
1011 string expected_error; 1018 string expected_error;
1012 if (i < kGuidOffset) { 1019 if (i < kConnectionIdOffset) {
1013 expected_error = "Unable to read public flags."; 1020 expected_error = "Unable to read public flags.";
1014 } else if (i < GetSequenceNumberOffset(!kIncludeVersion)) { 1021 } else if (i < GetSequenceNumberOffset(!kIncludeVersion)) {
1015 expected_error = "Unable to read GUID."; 1022 expected_error = "Unable to read ConnectionId.";
1016 } else if (i < GetPrivateFlagsOffset(!kIncludeVersion, 1023 } else if (i < GetPrivateFlagsOffset(!kIncludeVersion,
1017 PACKET_2BYTE_SEQUENCE_NUMBER)) { 1024 PACKET_2BYTE_SEQUENCE_NUMBER)) {
1018 expected_error = "Unable to read sequence number."; 1025 expected_error = "Unable to read sequence number.";
1019 } else if (i < GetFecGroupOffset(!kIncludeVersion, 1026 } else if (i < GetFecGroupOffset(!kIncludeVersion,
1020 PACKET_2BYTE_SEQUENCE_NUMBER)) { 1027 PACKET_2BYTE_SEQUENCE_NUMBER)) {
1021 expected_error = "Unable to read private flags."; 1028 expected_error = "Unable to read private flags.";
1022 } else { 1029 } else {
1023 expected_error = "Unable to read first fec protected packet offset."; 1030 expected_error = "Unable to read first fec protected packet offset.";
1024 } 1031 }
1025 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); 1032 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER);
1026 } 1033 }
1027 } 1034 }
1028 1035
1029 TEST_P(QuicFramerTest, PacketHeaderWith1ByteSequenceNumber) { 1036 TEST_P(QuicFramerTest, PacketHeaderWith1ByteSequenceNumber) {
1030 QuicFramerPeer::SetLastSequenceNumber(&framer_, 1037 QuicFramerPeer::SetLastSequenceNumber(&framer_,
1031 GG_UINT64_C(0x123456789ABA)); 1038 GG_UINT64_C(0x123456789ABA));
1032 1039
1033 unsigned char packet[] = { 1040 unsigned char packet[] = {
1034 // public flags (8 byte guid and 1 byte sequence number) 1041 // public flags (8 byte connection_id and 1 byte sequence number)
1035 0x0C, 1042 0x0C,
1036 // guid 1043 // connection_id
1037 0x10, 0x32, 0x54, 0x76, 1044 0x10, 0x32, 0x54, 0x76,
1038 0x98, 0xBA, 0xDC, 0xFE, 1045 0x98, 0xBA, 0xDC, 0xFE,
1039 // packet sequence number 1046 // packet sequence number
1040 0xBC, 1047 0xBC,
1041 // private flags 1048 // private flags
1042 0x00, 1049 0x00,
1043 }; 1050 };
1044 1051
1045 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 1052 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
1046 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 1053 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
1047 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); 1054 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error());
1048 ASSERT_TRUE(visitor_.header_.get()); 1055 ASSERT_TRUE(visitor_.header_.get());
1049 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 1056 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
1050 visitor_.header_->public_header.guid); 1057 visitor_.header_->public_header.connection_id);
1051 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 1058 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
1052 EXPECT_FALSE(visitor_.header_->public_header.version_flag); 1059 EXPECT_FALSE(visitor_.header_->public_header.version_flag);
1053 EXPECT_FALSE(visitor_.header_->fec_flag); 1060 EXPECT_FALSE(visitor_.header_->fec_flag);
1054 EXPECT_FALSE(visitor_.header_->entropy_flag); 1061 EXPECT_FALSE(visitor_.header_->entropy_flag);
1055 EXPECT_EQ(0, visitor_.header_->entropy_hash); 1062 EXPECT_EQ(0, visitor_.header_->entropy_hash);
1056 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 1063 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
1057 visitor_.header_->packet_sequence_number); 1064 visitor_.header_->packet_sequence_number);
1058 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 1065 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
1059 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 1066 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
1060 1067
1061 // Now test framing boundaries 1068 // Now test framing boundaries
1062 for (size_t i = 0; 1069 for (size_t i = 0;
1063 i < GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 1070 i < GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
1064 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 1071 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
1065 ++i) { 1072 ++i) {
1066 string expected_error; 1073 string expected_error;
1067 if (i < kGuidOffset) { 1074 if (i < kConnectionIdOffset) {
1068 expected_error = "Unable to read public flags."; 1075 expected_error = "Unable to read public flags.";
1069 } else if (i < GetSequenceNumberOffset(!kIncludeVersion)) { 1076 } else if (i < GetSequenceNumberOffset(!kIncludeVersion)) {
1070 expected_error = "Unable to read GUID."; 1077 expected_error = "Unable to read ConnectionId.";
1071 } else if (i < GetPrivateFlagsOffset(!kIncludeVersion, 1078 } else if (i < GetPrivateFlagsOffset(!kIncludeVersion,
1072 PACKET_1BYTE_SEQUENCE_NUMBER)) { 1079 PACKET_1BYTE_SEQUENCE_NUMBER)) {
1073 expected_error = "Unable to read sequence number."; 1080 expected_error = "Unable to read sequence number.";
1074 } else if (i < GetFecGroupOffset(!kIncludeVersion, 1081 } else if (i < GetFecGroupOffset(!kIncludeVersion,
1075 PACKET_1BYTE_SEQUENCE_NUMBER)) { 1082 PACKET_1BYTE_SEQUENCE_NUMBER)) {
1076 expected_error = "Unable to read private flags."; 1083 expected_error = "Unable to read private flags.";
1077 } else { 1084 } else {
1078 expected_error = "Unable to read first fec protected packet offset."; 1085 expected_error = "Unable to read first fec protected packet offset.";
1079 } 1086 }
1080 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); 1087 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER);
1081 } 1088 }
1082 } 1089 }
1083 1090
1084 TEST_P(QuicFramerTest, InvalidPublicFlag) { 1091 TEST_P(QuicFramerTest, InvalidPublicFlag) {
1085 unsigned char packet[] = { 1092 unsigned char packet[] = {
1086 // public flags, unknown flag at bit 6 1093 // public flags, unknown flag at bit 6
1087 0x40, 1094 0x40,
1088 // guid 1095 // connection_id
1089 0x10, 0x32, 0x54, 0x76, 1096 0x10, 0x32, 0x54, 0x76,
1090 0x98, 0xBA, 0xDC, 0xFE, 1097 0x98, 0xBA, 0xDC, 0xFE,
1091 // packet sequence number 1098 // packet sequence number
1092 0xBC, 0x9A, 0x78, 0x56, 1099 0xBC, 0x9A, 0x78, 0x56,
1093 0x34, 0x12, 1100 0x34, 0x12,
1094 // private flags 1101 // private flags
1095 0x00, 1102 0x00,
1096 1103
1097 // frame type (padding) 1104 // frame type (padding)
1098 0x00, 1105 0x00,
1099 0x00, 0x00, 0x00, 0x00 1106 0x00, 0x00, 0x00, 0x00
1100 }; 1107 };
1101 CheckProcessingFails(packet, 1108 CheckProcessingFails(packet,
1102 arraysize(packet), 1109 arraysize(packet),
1103 "Illegal public flags value.", 1110 "Illegal public flags value.",
1104 QUIC_INVALID_PACKET_HEADER); 1111 QUIC_INVALID_PACKET_HEADER);
1105 }; 1112 };
1106 1113
1107 TEST_P(QuicFramerTest, InvalidPublicFlagWithMatchingVersions) { 1114 TEST_P(QuicFramerTest, InvalidPublicFlagWithMatchingVersions) {
1108 unsigned char packet[] = { 1115 unsigned char packet[] = {
1109 // public flags (8 byte guid and version flag and an unknown flag) 1116 // public flags (8 byte connection_id and version flag and an unknown flag)
1110 0x4D, 1117 0x4D,
1111 // guid 1118 // connection_id
1112 0x10, 0x32, 0x54, 0x76, 1119 0x10, 0x32, 0x54, 0x76,
1113 0x98, 0xBA, 0xDC, 0xFE, 1120 0x98, 0xBA, 0xDC, 0xFE,
1114 // version tag 1121 // version tag
1115 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 1122 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
1116 // packet sequence number 1123 // packet sequence number
1117 0xBC, 0x9A, 0x78, 0x56, 1124 0xBC, 0x9A, 0x78, 0x56,
1118 0x34, 0x12, 1125 0x34, 0x12,
1119 // private flags 1126 // private flags
1120 0x00, 1127 0x00,
1121 1128
1122 // frame type (padding) 1129 // frame type (padding)
1123 0x00, 1130 0x00,
1124 0x00, 0x00, 0x00, 0x00 1131 0x00, 0x00, 0x00, 0x00
1125 }; 1132 };
1126 CheckProcessingFails(packet, 1133 CheckProcessingFails(packet,
1127 arraysize(packet), 1134 arraysize(packet),
1128 "Illegal public flags value.", 1135 "Illegal public flags value.",
1129 QUIC_INVALID_PACKET_HEADER); 1136 QUIC_INVALID_PACKET_HEADER);
1130 }; 1137 };
1131 1138
1132 TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) { 1139 TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) {
1133 unsigned char packet[] = { 1140 unsigned char packet[] = {
1134 // public flags (8 byte guid, version flag and an unknown flag) 1141 // public flags (8 byte connection_id, version flag and an unknown flag)
1135 0x7D, 1142 0x7D,
1136 // guid 1143 // connection_id
1137 0x10, 0x32, 0x54, 0x76, 1144 0x10, 0x32, 0x54, 0x76,
1138 0x98, 0xBA, 0xDC, 0xFE, 1145 0x98, 0xBA, 0xDC, 0xFE,
1139 // version tag 1146 // version tag
1140 'Q', '0', '0', '0', 1147 'Q', '0', '0', '0',
1141 // packet sequence number 1148 // packet sequence number
1142 0xBC, 0x9A, 0x78, 0x56, 1149 0xBC, 0x9A, 0x78, 0x56,
1143 0x34, 0x12, 1150 0x34, 0x12,
1144 // private flags 1151 // private flags
1145 0x00, 1152 0x00,
1146 1153
1147 // frame type (padding frame) 1154 // frame type (padding frame)
1148 0x00, 1155 0x00,
1149 0x00, 0x00, 0x00, 0x00 1156 0x00, 0x00, 0x00, 0x00
1150 }; 1157 };
1151 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 1158 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
1152 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 1159 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
1153 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 1160 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
1154 ASSERT_TRUE(visitor_.header_.get()); 1161 ASSERT_TRUE(visitor_.header_.get());
1155 EXPECT_EQ(0, visitor_.frame_count_); 1162 EXPECT_EQ(0, visitor_.frame_count_);
1156 EXPECT_EQ(1, visitor_.version_mismatch_); 1163 EXPECT_EQ(1, visitor_.version_mismatch_);
1157 }; 1164 };
1158 1165
1159 TEST_P(QuicFramerTest, InvalidPrivateFlag) { 1166 TEST_P(QuicFramerTest, InvalidPrivateFlag) {
1160 unsigned char packet[] = { 1167 unsigned char packet[] = {
1161 // public flags (8 byte guid) 1168 // public flags (8 byte connection_id)
1162 0x3C, 1169 0x3C,
1163 // guid 1170 // connection_id
1164 0x10, 0x32, 0x54, 0x76, 1171 0x10, 0x32, 0x54, 0x76,
1165 0x98, 0xBA, 0xDC, 0xFE, 1172 0x98, 0xBA, 0xDC, 0xFE,
1166 // packet sequence number 1173 // packet sequence number
1167 0xBC, 0x9A, 0x78, 0x56, 1174 0xBC, 0x9A, 0x78, 0x56,
1168 0x34, 0x12, 1175 0x34, 0x12,
1169 // private flags 1176 // private flags
1170 0x10, 1177 0x10,
1171 1178
1172 // frame type (padding) 1179 // frame type (padding)
1173 0x00, 1180 0x00,
1174 0x00, 0x00, 0x00, 0x00 1181 0x00, 0x00, 0x00, 0x00
1175 }; 1182 };
1176 CheckProcessingFails(packet, 1183 CheckProcessingFails(packet,
1177 arraysize(packet), 1184 arraysize(packet),
1178 "Illegal private flags value.", 1185 "Illegal private flags value.",
1179 QUIC_INVALID_PACKET_HEADER); 1186 QUIC_INVALID_PACKET_HEADER);
1180 }; 1187 };
1181 1188
1182 TEST_P(QuicFramerTest, InvalidFECGroupOffset) { 1189 TEST_P(QuicFramerTest, InvalidFECGroupOffset) {
1183 unsigned char packet[] = { 1190 unsigned char packet[] = {
1184 // public flags (8 byte guid) 1191 // public flags (8 byte connection_id)
1185 0x3C, 1192 0x3C,
1186 // guid 1193 // connection_id
1187 0x10, 0x32, 0x54, 0x76, 1194 0x10, 0x32, 0x54, 0x76,
1188 0x98, 0xBA, 0xDC, 0xFE, 1195 0x98, 0xBA, 0xDC, 0xFE,
1189 // packet sequence number 1196 // packet sequence number
1190 0x01, 0x00, 0x00, 0x00, 1197 0x01, 0x00, 0x00, 0x00,
1191 0x00, 0x00, 1198 0x00, 0x00,
1192 // private flags (fec group) 1199 // private flags (fec group)
1193 0x02, 1200 0x02,
1194 // first fec protected packet offset 1201 // first fec protected packet offset
1195 0x10 1202 0x10
1196 }; 1203 };
1197 CheckProcessingFails(packet, 1204 CheckProcessingFails(packet,
1198 arraysize(packet), 1205 arraysize(packet),
1199 "First fec protected packet offset must be less " 1206 "First fec protected packet offset must be less "
1200 "than the sequence number.", 1207 "than the sequence number.",
1201 QUIC_INVALID_PACKET_HEADER); 1208 QUIC_INVALID_PACKET_HEADER);
1202 }; 1209 };
1203 1210
1204 TEST_P(QuicFramerTest, PaddingFrame) { 1211 TEST_P(QuicFramerTest, PaddingFrame) {
1205 unsigned char packet[] = { 1212 unsigned char packet[] = {
1206 // public flags (8 byte guid) 1213 // public flags (8 byte connection_id)
1207 0x3C, 1214 0x3C,
1208 // guid 1215 // connection_id
1209 0x10, 0x32, 0x54, 0x76, 1216 0x10, 0x32, 0x54, 0x76,
1210 0x98, 0xBA, 0xDC, 0xFE, 1217 0x98, 0xBA, 0xDC, 0xFE,
1211 // packet sequence number 1218 // packet sequence number
1212 0xBC, 0x9A, 0x78, 0x56, 1219 0xBC, 0x9A, 0x78, 0x56,
1213 0x34, 0x12, 1220 0x34, 0x12,
1214 // private flags 1221 // private flags
1215 0x00, 1222 0x00,
1216 1223
1217 // frame type (padding frame) 1224 // frame type (padding frame)
1218 0x00, 1225 0x00,
(...skipping 17 matching lines...) Expand all
1236 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 1243 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
1237 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 1244 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
1238 ASSERT_TRUE(visitor_.header_.get()); 1245 ASSERT_TRUE(visitor_.header_.get());
1239 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); 1246 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion));
1240 1247
1241 ASSERT_EQ(0u, visitor_.stream_frames_.size()); 1248 ASSERT_EQ(0u, visitor_.stream_frames_.size());
1242 EXPECT_EQ(0u, visitor_.ack_frames_.size()); 1249 EXPECT_EQ(0u, visitor_.ack_frames_.size());
1243 // A packet with no frames is not acceptable. 1250 // A packet with no frames is not acceptable.
1244 CheckProcessingFails( 1251 CheckProcessingFails(
1245 packet, 1252 packet,
1246 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 1253 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
1247 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 1254 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
1248 "Packet has no frames.", QUIC_MISSING_PAYLOAD); 1255 "Packet has no frames.", QUIC_MISSING_PAYLOAD);
1249 } 1256 }
1250 1257
1251 TEST_P(QuicFramerTest, StreamFrame) { 1258 TEST_P(QuicFramerTest, StreamFrame) {
1252 unsigned char packet[] = { 1259 unsigned char packet[] = {
1253 // public flags (8 byte guid) 1260 // public flags (8 byte connection_id)
1254 0x3C, 1261 0x3C,
1255 // guid 1262 // connection_id
1256 0x10, 0x32, 0x54, 0x76, 1263 0x10, 0x32, 0x54, 0x76,
1257 0x98, 0xBA, 0xDC, 0xFE, 1264 0x98, 0xBA, 0xDC, 0xFE,
1258 // packet sequence number 1265 // packet sequence number
1259 0xBC, 0x9A, 0x78, 0x56, 1266 0xBC, 0x9A, 0x78, 0x56,
1260 0x34, 0x12, 1267 0x34, 0x12,
1261 // private flags 1268 // private flags
1262 0x00, 1269 0x00,
1263 1270
1264 // frame type (stream frame with fin) 1271 // frame type (stream frame with fin)
1265 0xFF, 1272 0xFF,
(...skipping 25 matching lines...) Expand all
1291 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654), 1298 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654),
1292 visitor_.stream_frames_[0]->offset); 1299 visitor_.stream_frames_[0]->offset);
1293 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]); 1300 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]);
1294 1301
1295 // Now test framing boundaries 1302 // Now test framing boundaries
1296 CheckStreamFrameBoundaries(packet, kQuicMaxStreamIdSize, !kIncludeVersion); 1303 CheckStreamFrameBoundaries(packet, kQuicMaxStreamIdSize, !kIncludeVersion);
1297 } 1304 }
1298 1305
1299 TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) { 1306 TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) {
1300 unsigned char packet[] = { 1307 unsigned char packet[] = {
1301 // public flags (8 byte guid) 1308 // public flags (8 byte connection_id)
1302 0x3C, 1309 0x3C,
1303 // guid 1310 // connection_id
1304 0x10, 0x32, 0x54, 0x76, 1311 0x10, 0x32, 0x54, 0x76,
1305 0x98, 0xBA, 0xDC, 0xFE, 1312 0x98, 0xBA, 0xDC, 0xFE,
1306 // packet sequence number 1313 // packet sequence number
1307 0xBC, 0x9A, 0x78, 0x56, 1314 0xBC, 0x9A, 0x78, 0x56,
1308 0x34, 0x12, 1315 0x34, 0x12,
1309 // private flags 1316 // private flags
1310 0x00, 1317 0x00,
1311 1318
1312 // frame type (stream frame with fin) 1319 // frame type (stream frame with fin)
1313 0xFE, 1320 0xFE,
(...skipping 26 matching lines...) Expand all
1340 visitor_.stream_frames_[0]->offset); 1347 visitor_.stream_frames_[0]->offset);
1341 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]); 1348 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]);
1342 1349
1343 // Now test framing boundaries 1350 // Now test framing boundaries
1344 const size_t stream_id_size = 3; 1351 const size_t stream_id_size = 3;
1345 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion); 1352 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion);
1346 } 1353 }
1347 1354
1348 TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { 1355 TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) {
1349 unsigned char packet[] = { 1356 unsigned char packet[] = {
1350 // public flags (8 byte guid) 1357 // public flags (8 byte connection_id)
1351 0x3C, 1358 0x3C,
1352 // guid 1359 // connection_id
1353 0x10, 0x32, 0x54, 0x76, 1360 0x10, 0x32, 0x54, 0x76,
1354 0x98, 0xBA, 0xDC, 0xFE, 1361 0x98, 0xBA, 0xDC, 0xFE,
1355 // packet sequence number 1362 // packet sequence number
1356 0xBC, 0x9A, 0x78, 0x56, 1363 0xBC, 0x9A, 0x78, 0x56,
1357 0x34, 0x12, 1364 0x34, 0x12,
1358 // private flags 1365 // private flags
1359 0x00, 1366 0x00,
1360 1367
1361 // frame type (stream frame with fin) 1368 // frame type (stream frame with fin)
1362 0xFD, 1369 0xFD,
(...skipping 26 matching lines...) Expand all
1389 visitor_.stream_frames_[0]->offset); 1396 visitor_.stream_frames_[0]->offset);
1390 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]); 1397 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]);
1391 1398
1392 // Now test framing boundaries 1399 // Now test framing boundaries
1393 const size_t stream_id_size = 2; 1400 const size_t stream_id_size = 2;
1394 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion); 1401 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion);
1395 } 1402 }
1396 1403
1397 TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) { 1404 TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) {
1398 unsigned char packet[] = { 1405 unsigned char packet[] = {
1399 // public flags (8 byte guid) 1406 // public flags (8 byte connection_id)
1400 0x3C, 1407 0x3C,
1401 // guid 1408 // connection_id
1402 0x10, 0x32, 0x54, 0x76, 1409 0x10, 0x32, 0x54, 0x76,
1403 0x98, 0xBA, 0xDC, 0xFE, 1410 0x98, 0xBA, 0xDC, 0xFE,
1404 // packet sequence number 1411 // packet sequence number
1405 0xBC, 0x9A, 0x78, 0x56, 1412 0xBC, 0x9A, 0x78, 0x56,
1406 0x34, 0x12, 1413 0x34, 0x12,
1407 // private flags 1414 // private flags
1408 0x00, 1415 0x00,
1409 1416
1410 // frame type (stream frame with fin) 1417 // frame type (stream frame with fin)
1411 0xFC, 1418 0xFC,
(...skipping 26 matching lines...) Expand all
1438 visitor_.stream_frames_[0]->offset); 1445 visitor_.stream_frames_[0]->offset);
1439 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]); 1446 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]);
1440 1447
1441 // Now test framing boundaries 1448 // Now test framing boundaries
1442 const size_t stream_id_size = 1; 1449 const size_t stream_id_size = 1;
1443 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion); 1450 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion);
1444 } 1451 }
1445 1452
1446 TEST_P(QuicFramerTest, StreamFrameWithVersion) { 1453 TEST_P(QuicFramerTest, StreamFrameWithVersion) {
1447 unsigned char packet[] = { 1454 unsigned char packet[] = {
1448 // public flags (version, 8 byte guid) 1455 // public flags (version, 8 byte connection_id)
1449 0x3D, 1456 0x3D,
1450 // guid 1457 // connection_id
1451 0x10, 0x32, 0x54, 0x76, 1458 0x10, 0x32, 0x54, 0x76,
1452 0x98, 0xBA, 0xDC, 0xFE, 1459 0x98, 0xBA, 0xDC, 0xFE,
1453 // version tag 1460 // version tag
1454 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 1461 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
1455 // packet sequence number 1462 // packet sequence number
1456 0xBC, 0x9A, 0x78, 0x56, 1463 0xBC, 0x9A, 0x78, 0x56,
1457 0x34, 0x12, 1464 0x34, 0x12,
1458 // private flags 1465 // private flags
1459 0x00, 1466 0x00,
1460 1467
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]); 1499 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]);
1493 1500
1494 // Now test framing boundaries 1501 // Now test framing boundaries
1495 CheckStreamFrameBoundaries(packet, kQuicMaxStreamIdSize, kIncludeVersion); 1502 CheckStreamFrameBoundaries(packet, kQuicMaxStreamIdSize, kIncludeVersion);
1496 } 1503 }
1497 1504
1498 TEST_P(QuicFramerTest, RejectPacket) { 1505 TEST_P(QuicFramerTest, RejectPacket) {
1499 visitor_.accept_packet_ = false; 1506 visitor_.accept_packet_ = false;
1500 1507
1501 unsigned char packet[] = { 1508 unsigned char packet[] = {
1502 // public flags (8 byte guid) 1509 // public flags (8 byte connection_id)
1503 0x3C, 1510 0x3C,
1504 // guid 1511 // connection_id
1505 0x10, 0x32, 0x54, 0x76, 1512 0x10, 0x32, 0x54, 0x76,
1506 0x98, 0xBA, 0xDC, 0xFE, 1513 0x98, 0xBA, 0xDC, 0xFE,
1507 // packet sequence number 1514 // packet sequence number
1508 0xBC, 0x9A, 0x78, 0x56, 1515 0xBC, 0x9A, 0x78, 0x56,
1509 0x34, 0x12, 1516 0x34, 0x12,
1510 // private flags 1517 // private flags
1511 0x00, 1518 0x00,
1512 1519
1513 // frame type (stream frame with fin) 1520 // frame type (stream frame with fin)
1514 0xFF, 1521 0xFF,
(...skipping 18 matching lines...) Expand all
1533 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); 1540 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion));
1534 1541
1535 ASSERT_EQ(0u, visitor_.stream_frames_.size()); 1542 ASSERT_EQ(0u, visitor_.stream_frames_.size());
1536 EXPECT_EQ(0u, visitor_.ack_frames_.size()); 1543 EXPECT_EQ(0u, visitor_.ack_frames_.size());
1537 } 1544 }
1538 1545
1539 TEST_P(QuicFramerTest, RejectPublicHeader) { 1546 TEST_P(QuicFramerTest, RejectPublicHeader) {
1540 visitor_.accept_public_header_ = false; 1547 visitor_.accept_public_header_ = false;
1541 1548
1542 unsigned char packet[] = { 1549 unsigned char packet[] = {
1543 // public flags (8 byte guid) 1550 // public flags (8 byte connection_id)
1544 0x3C, 1551 0x3C,
1545 // guid 1552 // connection_id
1546 0x10, 0x32, 0x54, 0x76, 1553 0x10, 0x32, 0x54, 0x76,
1547 0x98, 0xBA, 0xDC, 0xFE, 1554 0x98, 0xBA, 0xDC, 0xFE,
1548 }; 1555 };
1549 1556
1550 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 1557 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
1551 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 1558 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
1552 1559
1553 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 1560 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
1554 ASSERT_TRUE(visitor_.public_header_.get()); 1561 ASSERT_TRUE(visitor_.public_header_.get());
1555 ASSERT_FALSE(visitor_.header_.get()); 1562 ASSERT_FALSE(visitor_.header_.get());
(...skipping 10 matching lines...) Expand all
1566 0xDC, 0xFE, 0x98, 0xBA, 1573 0xDC, 0xFE, 0x98, 0xBA,
1567 // data length 1574 // data length
1568 0x0c, 0x00, 1575 0x0c, 0x00,
1569 // data 1576 // data
1570 'h', 'e', 'l', 'l', 1577 'h', 'e', 'l', 'l',
1571 'o', ' ', 'w', 'o', 1578 'o', ' ', 'w', 'o',
1572 'r', 'l', 'd', '!', 1579 'r', 'l', 'd', '!',
1573 }; 1580 };
1574 1581
1575 QuicPacketHeader header; 1582 QuicPacketHeader header;
1576 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 1583 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
1577 header.public_header.reset_flag = false; 1584 header.public_header.reset_flag = false;
1578 header.public_header.version_flag = false; 1585 header.public_header.version_flag = false;
1579 header.fec_flag = true; 1586 header.fec_flag = true;
1580 header.entropy_flag = true; 1587 header.entropy_flag = true;
1581 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 1588 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
1582 header.fec_group = 0; 1589 header.fec_group = 0;
1583 1590
1584 // Do not encrypt the payload because the revived payload is post-encryption. 1591 // Do not encrypt the payload because the revived payload is post-encryption.
1585 EXPECT_TRUE(framer_.ProcessRevivedPacket(&header, 1592 EXPECT_TRUE(framer_.ProcessRevivedPacket(&header,
1586 StringPiece(AsChars(payload), 1593 StringPiece(AsChars(payload),
1587 arraysize(payload)))); 1594 arraysize(payload))));
1588 1595
1589 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 1596 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
1590 ASSERT_EQ(1, visitor_.revived_packets_); 1597 ASSERT_EQ(1, visitor_.revived_packets_);
1591 ASSERT_TRUE(visitor_.header_.get()); 1598 ASSERT_TRUE(visitor_.header_.get());
1592 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 1599 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
1593 visitor_.header_->public_header.guid); 1600 visitor_.header_->public_header.connection_id);
1594 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); 1601 EXPECT_FALSE(visitor_.header_->public_header.reset_flag);
1595 EXPECT_FALSE(visitor_.header_->public_header.version_flag); 1602 EXPECT_FALSE(visitor_.header_->public_header.version_flag);
1596 EXPECT_TRUE(visitor_.header_->fec_flag); 1603 EXPECT_TRUE(visitor_.header_->fec_flag);
1597 EXPECT_TRUE(visitor_.header_->entropy_flag); 1604 EXPECT_TRUE(visitor_.header_->entropy_flag);
1598 EXPECT_EQ(1 << (header.packet_sequence_number % 8), 1605 EXPECT_EQ(1 << (header.packet_sequence_number % 8),
1599 visitor_.header_->entropy_hash); 1606 visitor_.header_->entropy_hash);
1600 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 1607 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
1601 visitor_.header_->packet_sequence_number); 1608 visitor_.header_->packet_sequence_number);
1602 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 1609 EXPECT_EQ(NOT_IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
1603 EXPECT_EQ(0x00u, visitor_.header_->fec_group); 1610 EXPECT_EQ(0x00u, visitor_.header_->fec_group);
1604 1611
1605 ASSERT_EQ(1u, visitor_.stream_frames_.size()); 1612 ASSERT_EQ(1u, visitor_.stream_frames_.size());
1606 EXPECT_EQ(0u, visitor_.ack_frames_.size()); 1613 EXPECT_EQ(0u, visitor_.ack_frames_.size());
1607 EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.stream_frames_[0]->stream_id); 1614 EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.stream_frames_[0]->stream_id);
1608 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); 1615 EXPECT_TRUE(visitor_.stream_frames_[0]->fin);
1609 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654), 1616 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654),
1610 visitor_.stream_frames_[0]->offset); 1617 visitor_.stream_frames_[0]->offset);
1611 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]); 1618 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]);
1612 } 1619 }
1613 1620
1614 TEST_P(QuicFramerTest, StreamFrameInFecGroup) { 1621 TEST_P(QuicFramerTest, StreamFrameInFecGroup) {
1615 unsigned char packet[] = { 1622 unsigned char packet[] = {
1616 // public flags (8 byte guid) 1623 // public flags (8 byte connection_id)
1617 0x3C, 1624 0x3C,
1618 // guid 1625 // connection_id
1619 0x10, 0x32, 0x54, 0x76, 1626 0x10, 0x32, 0x54, 0x76,
1620 0x98, 0xBA, 0xDC, 0xFE, 1627 0x98, 0xBA, 0xDC, 0xFE,
1621 // packet sequence number 1628 // packet sequence number
1622 0xBC, 0x9A, 0x78, 0x56, 1629 0xBC, 0x9A, 0x78, 0x56,
1623 0x12, 0x34, 1630 0x12, 0x34,
1624 // private flags (fec group) 1631 // private flags (fec group)
1625 0x02, 1632 0x02,
1626 // first fec protected packet offset 1633 // first fec protected packet offset
1627 0x02, 1634 0x02,
1628 1635
(...skipping 14 matching lines...) Expand all
1643 1650
1644 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 1651 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
1645 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 1652 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
1646 1653
1647 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 1654 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
1648 ASSERT_TRUE(visitor_.header_.get()); 1655 ASSERT_TRUE(visitor_.header_.get());
1649 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); 1656 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion));
1650 EXPECT_EQ(IN_FEC_GROUP, visitor_.header_->is_in_fec_group); 1657 EXPECT_EQ(IN_FEC_GROUP, visitor_.header_->is_in_fec_group);
1651 EXPECT_EQ(GG_UINT64_C(0x341256789ABA), 1658 EXPECT_EQ(GG_UINT64_C(0x341256789ABA),
1652 visitor_.header_->fec_group); 1659 visitor_.header_->fec_group);
1653 const size_t fec_offset = GetStartOfFecProtectedData( 1660 const size_t fec_offset =
1654 PACKET_8BYTE_GUID, !kIncludeVersion, PACKET_6BYTE_SEQUENCE_NUMBER); 1661 GetStartOfFecProtectedData(PACKET_8BYTE_CONNECTION_ID,
1662 !kIncludeVersion,
1663 PACKET_6BYTE_SEQUENCE_NUMBER);
1655 EXPECT_EQ( 1664 EXPECT_EQ(
1656 string(AsChars(packet) + fec_offset, arraysize(packet) - fec_offset), 1665 string(AsChars(packet) + fec_offset, arraysize(packet) - fec_offset),
1657 visitor_.fec_protected_payload_); 1666 visitor_.fec_protected_payload_);
1658 1667
1659 ASSERT_EQ(1u, visitor_.stream_frames_.size()); 1668 ASSERT_EQ(1u, visitor_.stream_frames_.size());
1660 EXPECT_EQ(0u, visitor_.ack_frames_.size()); 1669 EXPECT_EQ(0u, visitor_.ack_frames_.size());
1661 EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.stream_frames_[0]->stream_id); 1670 EXPECT_EQ(GG_UINT64_C(0x01020304), visitor_.stream_frames_[0]->stream_id);
1662 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); 1671 EXPECT_TRUE(visitor_.stream_frames_[0]->fin);
1663 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654), 1672 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654),
1664 visitor_.stream_frames_[0]->offset); 1673 visitor_.stream_frames_[0]->offset);
1665 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]); 1674 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0]);
1666 } 1675 }
1667 1676
1668 TEST_P(QuicFramerTest, AckFrameV14) { 1677 TEST_P(QuicFramerTest, AckFrameV14) {
1669 if (framer_.version() > QUIC_VERSION_14) { 1678 if (framer_.version() > QUIC_VERSION_14) {
1670 return; 1679 return;
1671 } 1680 }
1672 1681
1673 unsigned char packet[] = { 1682 unsigned char packet[] = {
1674 // public flags (8 byte guid) 1683 // public flags (8 byte connection_id)
1675 0x3C, 1684 0x3C,
1676 // guid 1685 // connection_id
1677 0x10, 0x32, 0x54, 0x76, 1686 0x10, 0x32, 0x54, 0x76,
1678 0x98, 0xBA, 0xDC, 0xFE, 1687 0x98, 0xBA, 0xDC, 0xFE,
1679 // packet sequence number 1688 // packet sequence number
1680 0xA8, 0x9A, 0x78, 0x56, 1689 0xA8, 0x9A, 0x78, 0x56,
1681 0x34, 0x12, 1690 0x34, 0x12,
1682 // private flags (entropy) 1691 // private flags (entropy)
1683 0x01, 1692 0x01,
1684 1693
1685 // frame type (ack frame) 1694 // frame type (ack frame)
1686 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 1695 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 expected_error = "Unable to read delta time largest observed."; 1764 expected_error = "Unable to read delta time largest observed.";
1756 } else if (i < kMissingPacketsOffset) { 1765 } else if (i < kMissingPacketsOffset) {
1757 expected_error = "Unable to read num missing packet ranges."; 1766 expected_error = "Unable to read num missing packet ranges.";
1758 } else if (i < kMissingPacketsRange) { 1767 } else if (i < kMissingPacketsRange) {
1759 expected_error = "Unable to read missing sequence number delta."; 1768 expected_error = "Unable to read missing sequence number delta.";
1760 } else { 1769 } else {
1761 expected_error = "Unable to read missing sequence number range."; 1770 expected_error = "Unable to read missing sequence number range.";
1762 } 1771 }
1763 CheckProcessingFails( 1772 CheckProcessingFails(
1764 packet, 1773 packet,
1765 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 1774 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
1766 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 1775 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
1767 expected_error, QUIC_INVALID_ACK_DATA); 1776 expected_error, QUIC_INVALID_ACK_DATA);
1768 } 1777 }
1769 } 1778 }
1770 1779
1771 TEST_P(QuicFramerTest, AckFrame15) { 1780 TEST_P(QuicFramerTest, AckFrame15) {
1772 if (framer_.version() != QUIC_VERSION_15) { 1781 if (framer_.version() != QUIC_VERSION_15) {
1773 return; 1782 return;
1774 } 1783 }
1775 1784
1776 unsigned char packet[] = { 1785 unsigned char packet[] = {
1777 // public flags (8 byte guid) 1786 // public flags (8 byte connection_id)
1778 0x3C, 1787 0x3C,
1779 // guid 1788 // connection_id
1780 0x10, 0x32, 0x54, 0x76, 1789 0x10, 0x32, 0x54, 0x76,
1781 0x98, 0xBA, 0xDC, 0xFE, 1790 0x98, 0xBA, 0xDC, 0xFE,
1782 // packet sequence number 1791 // packet sequence number
1783 0xA8, 0x9A, 0x78, 0x56, 1792 0xA8, 0x9A, 0x78, 0x56,
1784 0x34, 0x12, 1793 0x34, 0x12,
1785 // private flags (entropy) 1794 // private flags (entropy)
1786 0x01, 1795 0x01,
1787 1796
1788 // frame type (ack frame) 1797 // frame type (ack frame)
1789 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 1798 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 expected_error = "Unable to read num missing packet ranges."; 1873 expected_error = "Unable to read num missing packet ranges.";
1865 } else if (i < kMissingPacketsRange) { 1874 } else if (i < kMissingPacketsRange) {
1866 expected_error = "Unable to read missing sequence number delta."; 1875 expected_error = "Unable to read missing sequence number delta.";
1867 } else if (i < kRevivedPacketsLength) { 1876 } else if (i < kRevivedPacketsLength) {
1868 expected_error = "Unable to read missing sequence number range."; 1877 expected_error = "Unable to read missing sequence number range.";
1869 } else { 1878 } else {
1870 expected_error = "Unable to read num revived packets."; 1879 expected_error = "Unable to read num revived packets.";
1871 } 1880 }
1872 CheckProcessingFails( 1881 CheckProcessingFails(
1873 packet, 1882 packet,
1874 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 1883 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
1875 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 1884 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
1876 expected_error, QUIC_INVALID_ACK_DATA); 1885 expected_error, QUIC_INVALID_ACK_DATA);
1877 } 1886 }
1878 } 1887 }
1879 1888
1880 TEST_P(QuicFramerTest, AckFrame) { 1889 TEST_P(QuicFramerTest, AckFrame) {
1881 if (framer_.version() <= QUIC_VERSION_15) { 1890 if (framer_.version() <= QUIC_VERSION_15) {
1882 return; 1891 return;
1883 } 1892 }
1884 1893
1885 unsigned char packet[] = { 1894 unsigned char packet[] = {
1886 // public flags (8 byte guid) 1895 // public flags (8 byte connection_id)
1887 0x3C, 1896 0x3C,
1888 // guid 1897 // connection_id
1889 0x10, 0x32, 0x54, 0x76, 1898 0x10, 0x32, 0x54, 0x76,
1890 0x98, 0xBA, 0xDC, 0xFE, 1899 0x98, 0xBA, 0xDC, 0xFE,
1891 // packet sequence number 1900 // packet sequence number
1892 0xA8, 0x9A, 0x78, 0x56, 1901 0xA8, 0x9A, 0x78, 0x56,
1893 0x34, 0x12, 1902 0x34, 0x12,
1894 // private flags (entropy) 1903 // private flags (entropy)
1895 0x01, 1904 0x01,
1896 1905
1897 // frame type (ack frame) 1906 // frame type (ack frame)
1898 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 1907 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 expected_error = "Unable to read num missing packet ranges."; 1968 expected_error = "Unable to read num missing packet ranges.";
1960 } else if (i < kMissingPacketsRange) { 1969 } else if (i < kMissingPacketsRange) {
1961 expected_error = "Unable to read missing sequence number delta."; 1970 expected_error = "Unable to read missing sequence number delta.";
1962 } else if (i < kRevivedPacketsLength) { 1971 } else if (i < kRevivedPacketsLength) {
1963 expected_error = "Unable to read missing sequence number range."; 1972 expected_error = "Unable to read missing sequence number range.";
1964 } else { 1973 } else {
1965 expected_error = "Unable to read num revived packets."; 1974 expected_error = "Unable to read num revived packets.";
1966 } 1975 }
1967 CheckProcessingFails( 1976 CheckProcessingFails(
1968 packet, 1977 packet,
1969 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 1978 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
1970 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 1979 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
1971 expected_error, QUIC_INVALID_ACK_DATA); 1980 expected_error, QUIC_INVALID_ACK_DATA);
1972 } 1981 }
1973 } 1982 }
1974 1983
1975 TEST_P(QuicFramerTest, AckFrameRevivedPackets) { 1984 TEST_P(QuicFramerTest, AckFrameRevivedPackets) {
1976 if (framer_.version() <= QUIC_VERSION_15) { 1985 if (framer_.version() <= QUIC_VERSION_15) {
1977 return; 1986 return;
1978 } 1987 }
1979 1988
1980 unsigned char packet[] = { 1989 unsigned char packet[] = {
1981 // public flags (8 byte guid) 1990 // public flags (8 byte connection_id)
1982 0x3C, 1991 0x3C,
1983 // guid 1992 // connection_id
1984 0x10, 0x32, 0x54, 0x76, 1993 0x10, 0x32, 0x54, 0x76,
1985 0x98, 0xBA, 0xDC, 0xFE, 1994 0x98, 0xBA, 0xDC, 0xFE,
1986 // packet sequence number 1995 // packet sequence number
1987 0xA8, 0x9A, 0x78, 0x56, 1996 0xA8, 0x9A, 0x78, 0x56,
1988 0x34, 0x12, 1997 0x34, 0x12,
1989 // private flags (entropy) 1998 // private flags (entropy)
1990 0x01, 1999 0x01,
1991 2000
1992 // frame type (ack frame) 2001 // frame type (ack frame)
1993 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 2002 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 expected_error = "Unable to read missing sequence number delta."; 2072 expected_error = "Unable to read missing sequence number delta.";
2064 } else if (i < kRevivedPacketsLength) { 2073 } else if (i < kRevivedPacketsLength) {
2065 expected_error = "Unable to read missing sequence number range."; 2074 expected_error = "Unable to read missing sequence number range.";
2066 } else if (i < kRevivedPacketSequenceNumberLength) { 2075 } else if (i < kRevivedPacketSequenceNumberLength) {
2067 expected_error = "Unable to read num revived packets."; 2076 expected_error = "Unable to read num revived packets.";
2068 } else { 2077 } else {
2069 expected_error = "Unable to read revived packet."; 2078 expected_error = "Unable to read revived packet.";
2070 } 2079 }
2071 CheckProcessingFails( 2080 CheckProcessingFails(
2072 packet, 2081 packet,
2073 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 2082 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
2074 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 2083 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
2075 expected_error, QUIC_INVALID_ACK_DATA); 2084 expected_error, QUIC_INVALID_ACK_DATA);
2076 } 2085 }
2077 } 2086 }
2078 2087
2079 TEST_P(QuicFramerTest, AckFrameRevivedPackets15) { 2088 TEST_P(QuicFramerTest, AckFrameRevivedPackets15) {
2080 if (framer_.version() != QUIC_VERSION_15) { 2089 if (framer_.version() != QUIC_VERSION_15) {
2081 return; 2090 return;
2082 } 2091 }
2083 2092
2084 unsigned char packet[] = { 2093 unsigned char packet[] = {
2085 // public flags (8 byte guid) 2094 // public flags (8 byte connection_id)
2086 0x3C, 2095 0x3C,
2087 // guid 2096 // connection_id
2088 0x10, 0x32, 0x54, 0x76, 2097 0x10, 0x32, 0x54, 0x76,
2089 0x98, 0xBA, 0xDC, 0xFE, 2098 0x98, 0xBA, 0xDC, 0xFE,
2090 // packet sequence number 2099 // packet sequence number
2091 0xA8, 0x9A, 0x78, 0x56, 2100 0xA8, 0x9A, 0x78, 0x56,
2092 0x34, 0x12, 2101 0x34, 0x12,
2093 // private flags (entropy) 2102 // private flags (entropy)
2094 0x01, 2103 0x01,
2095 2104
2096 // frame type (ack frame) 2105 // frame type (ack frame)
2097 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 2106 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 expected_error = "Unable to read missing sequence number delta."; 2188 expected_error = "Unable to read missing sequence number delta.";
2180 } else if (i < kRevivedPacketsLength) { 2189 } else if (i < kRevivedPacketsLength) {
2181 expected_error = "Unable to read missing sequence number range."; 2190 expected_error = "Unable to read missing sequence number range.";
2182 } else if (i < kRevivedPacketSequenceNumberLength) { 2191 } else if (i < kRevivedPacketSequenceNumberLength) {
2183 expected_error = "Unable to read num revived packets."; 2192 expected_error = "Unable to read num revived packets.";
2184 } else { 2193 } else {
2185 expected_error = "Unable to read revived packet."; 2194 expected_error = "Unable to read revived packet.";
2186 } 2195 }
2187 CheckProcessingFails( 2196 CheckProcessingFails(
2188 packet, 2197 packet,
2189 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 2198 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
2190 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 2199 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
2191 expected_error, QUIC_INVALID_ACK_DATA); 2200 expected_error, QUIC_INVALID_ACK_DATA);
2192 } 2201 }
2193 } 2202 }
2194 2203
2195 TEST_P(QuicFramerTest, AckFrameNoNacks) { 2204 TEST_P(QuicFramerTest, AckFrameNoNacks) {
2196 if (framer_.version() <= QUIC_VERSION_15) { 2205 if (framer_.version() <= QUIC_VERSION_15) {
2197 return; 2206 return;
2198 } 2207 }
2199 unsigned char packet[] = { 2208 unsigned char packet[] = {
2200 // public flags (8 byte guid) 2209 // public flags (8 byte connection_id)
2201 0x3C, 2210 0x3C,
2202 // guid 2211 // connection_id
2203 0x10, 0x32, 0x54, 0x76, 2212 0x10, 0x32, 0x54, 0x76,
2204 0x98, 0xBA, 0xDC, 0xFE, 2213 0x98, 0xBA, 0xDC, 0xFE,
2205 // packet sequence number 2214 // packet sequence number
2206 0xA8, 0x9A, 0x78, 0x56, 2215 0xA8, 0x9A, 0x78, 0x56,
2207 0x34, 0x12, 2216 0x34, 0x12,
2208 // private flags (entropy) 2217 // private flags (entropy)
2209 0x01, 2218 0x01,
2210 2219
2211 // frame type (ack frame) 2220 // frame type (ack frame)
2212 // (no nacks, not truncated, 6 byte largest observed, 1 byte delta) 2221 // (no nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 test::CompareCharArraysWithHexError("constructed packet", 2254 test::CompareCharArraysWithHexError("constructed packet",
2246 data->data(), data->length(), 2255 data->data(), data->length(),
2247 AsChars(packet), arraysize(packet)); 2256 AsChars(packet), arraysize(packet));
2248 } 2257 }
2249 2258
2250 TEST_P(QuicFramerTest, AckFrameNoNacks15) { 2259 TEST_P(QuicFramerTest, AckFrameNoNacks15) {
2251 if (framer_.version() > QUIC_VERSION_15) { 2260 if (framer_.version() > QUIC_VERSION_15) {
2252 return; 2261 return;
2253 } 2262 }
2254 unsigned char packet[] = { 2263 unsigned char packet[] = {
2255 // public flags (8 byte guid) 2264 // public flags (8 byte connection_id)
2256 0x3C, 2265 0x3C,
2257 // guid 2266 // connection_id
2258 0x10, 0x32, 0x54, 0x76, 2267 0x10, 0x32, 0x54, 0x76,
2259 0x98, 0xBA, 0xDC, 0xFE, 2268 0x98, 0xBA, 0xDC, 0xFE,
2260 // packet sequence number 2269 // packet sequence number
2261 0xA8, 0x9A, 0x78, 0x56, 2270 0xA8, 0x9A, 0x78, 0x56,
2262 0x34, 0x12, 2271 0x34, 0x12,
2263 // private flags (entropy) 2272 // private flags (entropy)
2264 0x01, 2273 0x01,
2265 2274
2266 // frame type (ack frame) 2275 // frame type (ack frame)
2267 // (no nacks, not truncated, 6 byte largest observed, 1 byte delta) 2276 // (no nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 test::CompareCharArraysWithHexError("constructed packet", 2316 test::CompareCharArraysWithHexError("constructed packet",
2308 data->data(), data->length(), 2317 data->data(), data->length(),
2309 AsChars(packet), arraysize(packet)); 2318 AsChars(packet), arraysize(packet));
2310 } 2319 }
2311 2320
2312 TEST_P(QuicFramerTest, AckFrame500Nacks) { 2321 TEST_P(QuicFramerTest, AckFrame500Nacks) {
2313 if (framer_.version() <= QUIC_VERSION_15) { 2322 if (framer_.version() <= QUIC_VERSION_15) {
2314 return; 2323 return;
2315 } 2324 }
2316 unsigned char packet[] = { 2325 unsigned char packet[] = {
2317 // public flags (8 byte guid) 2326 // public flags (8 byte connection_id)
2318 0x3C, 2327 0x3C,
2319 // guid 2328 // connection_id
2320 0x10, 0x32, 0x54, 0x76, 2329 0x10, 0x32, 0x54, 0x76,
2321 0x98, 0xBA, 0xDC, 0xFE, 2330 0x98, 0xBA, 0xDC, 0xFE,
2322 // packet sequence number 2331 // packet sequence number
2323 0xA8, 0x9A, 0x78, 0x56, 2332 0xA8, 0x9A, 0x78, 0x56,
2324 0x34, 0x12, 2333 0x34, 0x12,
2325 // private flags (entropy) 2334 // private flags (entropy)
2326 0x01, 2335 0x01,
2327 2336
2328 // frame type (ack frame) 2337 // frame type (ack frame)
2329 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 2338 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 test::CompareCharArraysWithHexError("constructed packet", 2391 test::CompareCharArraysWithHexError("constructed packet",
2383 data->data(), data->length(), 2392 data->data(), data->length(),
2384 AsChars(packet), arraysize(packet)); 2393 AsChars(packet), arraysize(packet));
2385 } 2394 }
2386 2395
2387 TEST_P(QuicFramerTest, AckFrame500Nacks15) { 2396 TEST_P(QuicFramerTest, AckFrame500Nacks15) {
2388 if (framer_.version() != QUIC_VERSION_15) { 2397 if (framer_.version() != QUIC_VERSION_15) {
2389 return; 2398 return;
2390 } 2399 }
2391 unsigned char packet[] = { 2400 unsigned char packet[] = {
2392 // public flags (8 byte guid) 2401 // public flags (8 byte connection_id)
2393 0x3C, 2402 0x3C,
2394 // guid 2403 // connection_id
2395 0x10, 0x32, 0x54, 0x76, 2404 0x10, 0x32, 0x54, 0x76,
2396 0x98, 0xBA, 0xDC, 0xFE, 2405 0x98, 0xBA, 0xDC, 0xFE,
2397 // packet sequence number 2406 // packet sequence number
2398 0xA8, 0x9A, 0x78, 0x56, 2407 0xA8, 0x9A, 0x78, 0x56,
2399 0x34, 0x12, 2408 0x34, 0x12,
2400 // private flags (entropy) 2409 // private flags (entropy)
2401 0x01, 2410 0x01,
2402 2411
2403 // frame type (ack frame) 2412 // frame type (ack frame)
2404 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 2413 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2464 test::CompareCharArraysWithHexError("constructed packet", 2473 test::CompareCharArraysWithHexError("constructed packet",
2465 data->data(), data->length(), 2474 data->data(), data->length(),
2466 AsChars(packet), arraysize(packet)); 2475 AsChars(packet), arraysize(packet));
2467 } 2476 }
2468 2477
2469 TEST_P(QuicFramerTest, AckFrame500NacksV14) { 2478 TEST_P(QuicFramerTest, AckFrame500NacksV14) {
2470 if (framer_.version() > QUIC_VERSION_14) { 2479 if (framer_.version() > QUIC_VERSION_14) {
2471 return; 2480 return;
2472 } 2481 }
2473 unsigned char packet[] = { 2482 unsigned char packet[] = {
2474 // public flags (8 byte guid) 2483 // public flags (8 byte connection_id)
2475 0x3C, 2484 0x3C,
2476 // guid 2485 // connection_id
2477 0x10, 0x32, 0x54, 0x76, 2486 0x10, 0x32, 0x54, 0x76,
2478 0x98, 0xBA, 0xDC, 0xFE, 2487 0x98, 0xBA, 0xDC, 0xFE,
2479 // packet sequence number 2488 // packet sequence number
2480 0xA8, 0x9A, 0x78, 0x56, 2489 0xA8, 0x9A, 0x78, 0x56,
2481 0x34, 0x12, 2490 0x34, 0x12,
2482 // private flags (entropy) 2491 // private flags (entropy)
2483 0x01, 2492 0x01,
2484 2493
2485 // frame type (ack frame) 2494 // frame type (ack frame)
2486 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 2495 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 test::CompareCharArraysWithHexError("constructed packet", 2552 test::CompareCharArraysWithHexError("constructed packet",
2544 data->data(), data->length(), 2553 data->data(), data->length(),
2545 AsChars(packet), arraysize(packet)); 2554 AsChars(packet), arraysize(packet));
2546 } 2555 }
2547 2556
2548 TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) { 2557 TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) {
2549 if (framer_.version() <= QUIC_VERSION_14) { 2558 if (framer_.version() <= QUIC_VERSION_14) {
2550 return; 2559 return;
2551 } 2560 }
2552 unsigned char packet[] = { 2561 unsigned char packet[] = {
2553 // public flags (8 byte guid) 2562 // public flags (8 byte connection_id)
2554 0x3C, 2563 0x3C,
2555 // guid 2564 // connection_id
2556 0x10, 0x32, 0x54, 0x76, 2565 0x10, 0x32, 0x54, 0x76,
2557 0x98, 0xBA, 0xDC, 0xFE, 2566 0x98, 0xBA, 0xDC, 0xFE,
2558 // packet sequence number 2567 // packet sequence number
2559 0xBC, 0x9A, 0x78, 0x56, 2568 0xBC, 0x9A, 0x78, 0x56,
2560 0x34, 0x12, 2569 0x34, 0x12,
2561 // private flags 2570 // private flags
2562 0x00, 2571 0x00,
2563 2572
2564 // frame type (congestion feedback frame) 2573 // frame type (congestion feedback frame)
2565 0x20, 2574 0x20,
(...skipping 20 matching lines...) Expand all
2586 // Now test framing boundaries 2595 // Now test framing boundaries
2587 for (size_t i = kQuicFrameTypeSize; i < 4; ++i) { 2596 for (size_t i = kQuicFrameTypeSize; i < 4; ++i) {
2588 string expected_error; 2597 string expected_error;
2589 if (i < 2) { 2598 if (i < 2) {
2590 expected_error = "Unable to read congestion feedback type."; 2599 expected_error = "Unable to read congestion feedback type.";
2591 } else if (i < 4) { 2600 } else if (i < 4) {
2592 expected_error = "Unable to read receive window."; 2601 expected_error = "Unable to read receive window.";
2593 } 2602 }
2594 CheckProcessingFails( 2603 CheckProcessingFails(
2595 packet, 2604 packet,
2596 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 2605 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
2597 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 2606 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
2598 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA); 2607 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
2599 } 2608 }
2600 } 2609 }
2601 2610
2602 TEST_P(QuicFramerTest, CongestionFeedbackFrameTCPV14) { 2611 TEST_P(QuicFramerTest, CongestionFeedbackFrameTCPV14) {
2603 if (framer_.version() > QUIC_VERSION_14) { 2612 if (framer_.version() > QUIC_VERSION_14) {
2604 return; 2613 return;
2605 } 2614 }
2606 unsigned char packet[] = { 2615 unsigned char packet[] = {
2607 // public flags (8 byte guid) 2616 // public flags (8 byte connection_id)
2608 0x3C, 2617 0x3C,
2609 // guid 2618 // connection_id
2610 0x10, 0x32, 0x54, 0x76, 2619 0x10, 0x32, 0x54, 0x76,
2611 0x98, 0xBA, 0xDC, 0xFE, 2620 0x98, 0xBA, 0xDC, 0xFE,
2612 // packet sequence number 2621 // packet sequence number
2613 0xBC, 0x9A, 0x78, 0x56, 2622 0xBC, 0x9A, 0x78, 0x56,
2614 0x34, 0x12, 2623 0x34, 0x12,
2615 // private flags 2624 // private flags
2616 0x00, 2625 0x00,
2617 2626
2618 // frame type (congestion feedback frame) 2627 // frame type (congestion feedback frame)
2619 0x20, 2628 0x20,
(...skipping 24 matching lines...) Expand all
2644 string expected_error; 2653 string expected_error;
2645 if (i < 2) { 2654 if (i < 2) {
2646 expected_error = "Unable to read congestion feedback type."; 2655 expected_error = "Unable to read congestion feedback type.";
2647 } else if (i < 4) { 2656 } else if (i < 4) {
2648 expected_error = "Unable to read accumulated number of lost packets."; 2657 expected_error = "Unable to read accumulated number of lost packets.";
2649 } else if (i < 6) { 2658 } else if (i < 6) {
2650 expected_error = "Unable to read receive window."; 2659 expected_error = "Unable to read receive window.";
2651 } 2660 }
2652 CheckProcessingFails( 2661 CheckProcessingFails(
2653 packet, 2662 packet,
2654 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 2663 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
2655 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 2664 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
2656 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA); 2665 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
2657 } 2666 }
2658 } 2667 }
2659 2668
2660 TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrival) { 2669 TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrival) {
2661 if (framer_.version() <= QUIC_VERSION_14) { 2670 if (framer_.version() <= QUIC_VERSION_14) {
2662 return; 2671 return;
2663 } 2672 }
2664 unsigned char packet[] = { 2673 unsigned char packet[] = {
2665 // public flags (8 byte guid) 2674 // public flags (8 byte connection_id)
2666 0x3C, 2675 0x3C,
2667 // guid 2676 // connection_id
2668 0x10, 0x32, 0x54, 0x76, 2677 0x10, 0x32, 0x54, 0x76,
2669 0x98, 0xBA, 0xDC, 0xFE, 2678 0x98, 0xBA, 0xDC, 0xFE,
2670 // packet sequence number 2679 // packet sequence number
2671 0xBC, 0x9A, 0x78, 0x56, 2680 0xBC, 0x9A, 0x78, 0x56,
2672 0x34, 0x12, 2681 0x34, 0x12,
2673 // private flags 2682 // private flags
2674 0x00, 2683 0x00,
2675 2684
2676 // frame type (congestion feedback frame) 2685 // frame type (congestion feedback frame)
2677 0x20, 2686 0x20,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 expected_error = "Unable to read sequence delta in received packets."; 2746 expected_error = "Unable to read sequence delta in received packets.";
2738 } else if (i < 23) { 2747 } else if (i < 23) {
2739 expected_error = "Unable to read time delta in received packets."; 2748 expected_error = "Unable to read time delta in received packets.";
2740 } else if (i < 25) { 2749 } else if (i < 25) {
2741 expected_error = "Unable to read sequence delta in received packets."; 2750 expected_error = "Unable to read sequence delta in received packets.";
2742 } else if (i < 29) { 2751 } else if (i < 29) {
2743 expected_error = "Unable to read time delta in received packets."; 2752 expected_error = "Unable to read time delta in received packets.";
2744 } 2753 }
2745 CheckProcessingFails( 2754 CheckProcessingFails(
2746 packet, 2755 packet,
2747 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 2756 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
2748 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 2757 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
2749 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA); 2758 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
2750 } 2759 }
2751 } 2760 }
2752 2761
2753 TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrivalV14) { 2762 TEST_P(QuicFramerTest, CongestionFeedbackFrameInterArrivalV14) {
2754 if (framer_.version() > QUIC_VERSION_14) { 2763 if (framer_.version() > QUIC_VERSION_14) {
2755 return; 2764 return;
2756 } 2765 }
2757 unsigned char packet[] = { 2766 unsigned char packet[] = {
2758 // public flags (8 byte guid) 2767 // public flags (8 byte connection_id)
2759 0x3C, 2768 0x3C,
2760 // guid 2769 // connection_id
2761 0x10, 0x32, 0x54, 0x76, 2770 0x10, 0x32, 0x54, 0x76,
2762 0x98, 0xBA, 0xDC, 0xFE, 2771 0x98, 0xBA, 0xDC, 0xFE,
2763 // packet sequence number 2772 // packet sequence number
2764 0xBC, 0x9A, 0x78, 0x56, 2773 0xBC, 0x9A, 0x78, 0x56,
2765 0x34, 0x12, 2774 0x34, 0x12,
2766 // private flags 2775 // private flags
2767 0x00, 2776 0x00,
2768 2777
2769 // frame type (congestion feedback frame) 2778 // frame type (congestion feedback frame)
2770 0x20, 2779 0x20,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 expected_error = "Unable to read sequence delta in received packets."; 2843 expected_error = "Unable to read sequence delta in received packets.";
2835 } else if (i < 25) { 2844 } else if (i < 25) {
2836 expected_error = "Unable to read time delta in received packets."; 2845 expected_error = "Unable to read time delta in received packets.";
2837 } else if (i < 27) { 2846 } else if (i < 27) {
2838 expected_error = "Unable to read sequence delta in received packets."; 2847 expected_error = "Unable to read sequence delta in received packets.";
2839 } else if (i < 31) { 2848 } else if (i < 31) {
2840 expected_error = "Unable to read time delta in received packets."; 2849 expected_error = "Unable to read time delta in received packets.";
2841 } 2850 }
2842 CheckProcessingFails( 2851 CheckProcessingFails(
2843 packet, 2852 packet,
2844 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 2853 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
2845 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 2854 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
2846 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA); 2855 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
2847 } 2856 }
2848 } 2857 }
2849 2858
2850 TEST_P(QuicFramerTest, CongestionFeedbackFrameFixRate) { 2859 TEST_P(QuicFramerTest, CongestionFeedbackFrameFixRate) {
2851 unsigned char packet[] = { 2860 unsigned char packet[] = {
2852 // public flags (8 byte guid) 2861 // public flags (8 byte connection_id)
2853 0x3C, 2862 0x3C,
2854 // guid 2863 // connection_id
2855 0x10, 0x32, 0x54, 0x76, 2864 0x10, 0x32, 0x54, 0x76,
2856 0x98, 0xBA, 0xDC, 0xFE, 2865 0x98, 0xBA, 0xDC, 0xFE,
2857 // packet sequence number 2866 // packet sequence number
2858 0xBC, 0x9A, 0x78, 0x56, 2867 0xBC, 0x9A, 0x78, 0x56,
2859 0x34, 0x12, 2868 0x34, 0x12,
2860 // private flags 2869 // private flags
2861 0x00, 2870 0x00,
2862 2871
2863 // frame type (congestion feedback frame) 2872 // frame type (congestion feedback frame)
2864 0x20, 2873 0x20,
(...skipping 21 matching lines...) Expand all
2886 // Now test framing boundaries 2895 // Now test framing boundaries
2887 for (size_t i = kQuicFrameTypeSize; i < 6; ++i) { 2896 for (size_t i = kQuicFrameTypeSize; i < 6; ++i) {
2888 string expected_error; 2897 string expected_error;
2889 if (i < 2) { 2898 if (i < 2) {
2890 expected_error = "Unable to read congestion feedback type."; 2899 expected_error = "Unable to read congestion feedback type.";
2891 } else if (i < 6) { 2900 } else if (i < 6) {
2892 expected_error = "Unable to read bitrate."; 2901 expected_error = "Unable to read bitrate.";
2893 } 2902 }
2894 CheckProcessingFails( 2903 CheckProcessingFails(
2895 packet, 2904 packet,
2896 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 2905 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
2897 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 2906 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
2898 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA); 2907 expected_error, QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
2899 } 2908 }
2900 } 2909 }
2901 2910
2902 TEST_P(QuicFramerTest, CongestionFeedbackFrameInvalidFeedback) { 2911 TEST_P(QuicFramerTest, CongestionFeedbackFrameInvalidFeedback) {
2903 unsigned char packet[] = { 2912 unsigned char packet[] = {
2904 // public flags (8 byte guid) 2913 // public flags (8 byte connection_id)
2905 0x3C, 2914 0x3C,
2906 // guid 2915 // connection_id
2907 0x10, 0x32, 0x54, 0x76, 2916 0x10, 0x32, 0x54, 0x76,
2908 0x98, 0xBA, 0xDC, 0xFE, 2917 0x98, 0xBA, 0xDC, 0xFE,
2909 // packet sequence number 2918 // packet sequence number
2910 0xBC, 0x9A, 0x78, 0x56, 2919 0xBC, 0x9A, 0x78, 0x56,
2911 0x34, 0x12, 2920 0x34, 0x12,
2912 // private flags 2921 // private flags
2913 0x00, 2922 0x00,
2914 2923
2915 // frame type (congestion feedback frame) 2924 // frame type (congestion feedback frame)
2916 0x20, 2925 0x20,
2917 // congestion feedback type (invalid) 2926 // congestion feedback type (invalid)
2918 0x03, 2927 0x03,
2919 }; 2928 };
2920 2929
2921 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 2930 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
2922 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); 2931 EXPECT_FALSE(framer_.ProcessPacket(encrypted));
2923 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); 2932 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion));
2924 EXPECT_EQ(QUIC_INVALID_CONGESTION_FEEDBACK_DATA, framer_.error()); 2933 EXPECT_EQ(QUIC_INVALID_CONGESTION_FEEDBACK_DATA, framer_.error());
2925 } 2934 }
2926 2935
2927 TEST_P(QuicFramerTest, StopWaitingFrame) { 2936 TEST_P(QuicFramerTest, StopWaitingFrame) {
2928 if (framer_.version() <= QUIC_VERSION_15) { 2937 if (framer_.version() <= QUIC_VERSION_15) {
2929 return; 2938 return;
2930 } 2939 }
2931 unsigned char packet[] = { 2940 unsigned char packet[] = {
2932 // public flags (8 byte guid) 2941 // public flags (8 byte connection_id)
2933 0x3C, 2942 0x3C,
2934 // guid 2943 // connection_id
2935 0x10, 0x32, 0x54, 0x76, 2944 0x10, 0x32, 0x54, 0x76,
2936 0x98, 0xBA, 0xDC, 0xFE, 2945 0x98, 0xBA, 0xDC, 0xFE,
2937 // packet sequence number 2946 // packet sequence number
2938 0xA8, 0x9A, 0x78, 0x56, 2947 0xA8, 0x9A, 0x78, 0x56,
2939 0x34, 0x12, 2948 0x34, 0x12,
2940 // private flags (entropy) 2949 // private flags (entropy)
2941 0x01, 2950 0x01,
2942 2951
2943 // frame type (ack frame) 2952 // frame type (ack frame)
2944 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 2953 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 23 matching lines...) Expand all
2968 const size_t frame_size = 7; 2977 const size_t frame_size = 7;
2969 for (size_t i = kQuicFrameTypeSize; i < frame_size; ++i) { 2978 for (size_t i = kQuicFrameTypeSize; i < frame_size; ++i) {
2970 string expected_error; 2979 string expected_error;
2971 if (i < kLeastUnackedOffset) { 2980 if (i < kLeastUnackedOffset) {
2972 expected_error = "Unable to read entropy hash for sent packets."; 2981 expected_error = "Unable to read entropy hash for sent packets.";
2973 } else { 2982 } else {
2974 expected_error = "Unable to read least unacked delta."; 2983 expected_error = "Unable to read least unacked delta.";
2975 } 2984 }
2976 CheckProcessingFails( 2985 CheckProcessingFails(
2977 packet, 2986 packet,
2978 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 2987 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
2979 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 2988 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
2980 expected_error, QUIC_INVALID_STOP_WAITING_DATA); 2989 expected_error, QUIC_INVALID_STOP_WAITING_DATA);
2981 } 2990 }
2982 } 2991 }
2983 2992
2984 TEST_P(QuicFramerTest, RstStreamFrameVersion13) { 2993 TEST_P(QuicFramerTest, RstStreamFrameVersion13) {
2985 if (version_ > QUIC_VERSION_13) { 2994 if (version_ > QUIC_VERSION_13) {
2986 return; 2995 return;
2987 } 2996 }
2988 2997
2989 unsigned char packet[] = { 2998 unsigned char packet[] = {
2990 // public flags (8 byte guid) 2999 // public flags (8 byte connection_id)
2991 0x3C, 3000 0x3C,
2992 // guid 3001 // connection_id
2993 0x10, 0x32, 0x54, 0x76, 3002 0x10, 0x32, 0x54, 0x76,
2994 0x98, 0xBA, 0xDC, 0xFE, 3003 0x98, 0xBA, 0xDC, 0xFE,
2995 // packet sequence number 3004 // packet sequence number
2996 0xBC, 0x9A, 0x78, 0x56, 3005 0xBC, 0x9A, 0x78, 0x56,
2997 0x34, 0x12, 3006 0x34, 0x12,
2998 // private flags 3007 // private flags
2999 0x00, 3008 0x00,
3000 3009
3001 // frame type (rst stream frame) 3010 // frame type (rst stream frame)
3002 0x01, 3011 0x01,
(...skipping 29 matching lines...) Expand all
3032 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { 3041 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) {
3033 expected_error = "Unable to read stream_id."; 3042 expected_error = "Unable to read stream_id.";
3034 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + 3043 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize +
3035 kQuicErrorCodeSize) { 3044 kQuicErrorCodeSize) {
3036 expected_error = "Unable to read rst stream error code."; 3045 expected_error = "Unable to read rst stream error code.";
3037 } else { 3046 } else {
3038 expected_error = "Unable to read rst stream error details."; 3047 expected_error = "Unable to read rst stream error details.";
3039 } 3048 }
3040 CheckProcessingFails( 3049 CheckProcessingFails(
3041 packet, 3050 packet,
3042 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3051 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3043 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 3052 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
3044 expected_error, QUIC_INVALID_RST_STREAM_DATA); 3053 expected_error, QUIC_INVALID_RST_STREAM_DATA);
3045 } 3054 }
3046 } 3055 }
3047 3056
3048 TEST_P(QuicFramerTest, RstStreamFrameQuic) { 3057 TEST_P(QuicFramerTest, RstStreamFrameQuic) {
3049 if (version_ <= QUIC_VERSION_13) { 3058 if (version_ <= QUIC_VERSION_13) {
3050 return; 3059 return;
3051 } 3060 }
3052 3061
3053 unsigned char packet[] = { 3062 unsigned char packet[] = {
3054 // public flags (8 byte guid) 3063 // public flags (8 byte connection_id)
3055 0x3C, 3064 0x3C,
3056 // guid 3065 // connection_id
3057 0x10, 0x32, 0x54, 0x76, 3066 0x10, 0x32, 0x54, 0x76,
3058 0x98, 0xBA, 0xDC, 0xFE, 3067 0x98, 0xBA, 0xDC, 0xFE,
3059 // packet sequence number 3068 // packet sequence number
3060 0xBC, 0x9A, 0x78, 0x56, 3069 0xBC, 0x9A, 0x78, 0x56,
3061 0x34, 0x12, 3070 0x34, 0x12,
3062 // private flags 3071 // private flags
3063 0x00, 3072 0x00,
3064 3073
3065 // frame type (rst stream frame) 3074 // frame type (rst stream frame)
3066 0x01, 3075 0x01,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 + kQuicMaxStreamOffsetSize) { 3115 + kQuicMaxStreamOffsetSize) {
3107 expected_error = "Unable to read rst stream sent byte offset."; 3116 expected_error = "Unable to read rst stream sent byte offset.";
3108 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + 3117 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize +
3109 + kQuicMaxStreamOffsetSize + kQuicErrorCodeSize) { 3118 + kQuicMaxStreamOffsetSize + kQuicErrorCodeSize) {
3110 expected_error = "Unable to read rst stream error code."; 3119 expected_error = "Unable to read rst stream error code.";
3111 } else { 3120 } else {
3112 expected_error = "Unable to read rst stream error details."; 3121 expected_error = "Unable to read rst stream error details.";
3113 } 3122 }
3114 CheckProcessingFails( 3123 CheckProcessingFails(
3115 packet, 3124 packet,
3116 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3125 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3117 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 3126 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
3118 expected_error, QUIC_INVALID_RST_STREAM_DATA); 3127 expected_error, QUIC_INVALID_RST_STREAM_DATA);
3119 } 3128 }
3120 } 3129 }
3121 3130
3122 TEST_P(QuicFramerTest, ConnectionCloseFrame) { 3131 TEST_P(QuicFramerTest, ConnectionCloseFrame) {
3123 unsigned char packet[] = { 3132 unsigned char packet[] = {
3124 // public flags (8 byte guid) 3133 // public flags (8 byte connection_id)
3125 0x3C, 3134 0x3C,
3126 // guid 3135 // connection_id
3127 0x10, 0x32, 0x54, 0x76, 3136 0x10, 0x32, 0x54, 0x76,
3128 0x98, 0xBA, 0xDC, 0xFE, 3137 0x98, 0xBA, 0xDC, 0xFE,
3129 // packet sequence number 3138 // packet sequence number
3130 0xBC, 0x9A, 0x78, 0x56, 3139 0xBC, 0x9A, 0x78, 0x56,
3131 0x34, 0x12, 3140 0x34, 0x12,
3132 // private flags 3141 // private flags
3133 0x00, 3142 0x00,
3134 3143
3135 // frame type (connection close frame) 3144 // frame type (connection close frame)
3136 0x02, 3145 0x02,
(...skipping 27 matching lines...) Expand all
3164 for (size_t i = kQuicFrameTypeSize; 3173 for (size_t i = kQuicFrameTypeSize;
3165 i < QuicFramer::GetMinConnectionCloseFrameSize(); ++i) { 3174 i < QuicFramer::GetMinConnectionCloseFrameSize(); ++i) {
3166 string expected_error; 3175 string expected_error;
3167 if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) { 3176 if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) {
3168 expected_error = "Unable to read connection close error code."; 3177 expected_error = "Unable to read connection close error code.";
3169 } else { 3178 } else {
3170 expected_error = "Unable to read connection close error details."; 3179 expected_error = "Unable to read connection close error details.";
3171 } 3180 }
3172 CheckProcessingFails( 3181 CheckProcessingFails(
3173 packet, 3182 packet,
3174 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3183 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3175 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 3184 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
3176 expected_error, QUIC_INVALID_CONNECTION_CLOSE_DATA); 3185 expected_error, QUIC_INVALID_CONNECTION_CLOSE_DATA);
3177 } 3186 }
3178 } 3187 }
3179 3188
3180 TEST_P(QuicFramerTest, GoAwayFrame) { 3189 TEST_P(QuicFramerTest, GoAwayFrame) {
3181 unsigned char packet[] = { 3190 unsigned char packet[] = {
3182 // public flags (8 byte guid) 3191 // public flags (8 byte connection_id)
3183 0x3C, 3192 0x3C,
3184 // guid 3193 // connection_id
3185 0x10, 0x32, 0x54, 0x76, 3194 0x10, 0x32, 0x54, 0x76,
3186 0x98, 0xBA, 0xDC, 0xFE, 3195 0x98, 0xBA, 0xDC, 0xFE,
3187 // packet sequence number 3196 // packet sequence number
3188 0xBC, 0x9A, 0x78, 0x56, 3197 0xBC, 0x9A, 0x78, 0x56,
3189 0x34, 0x12, 3198 0x34, 0x12,
3190 // private flags 3199 // private flags
3191 0x00, 3200 0x00,
3192 3201
3193 // frame type (go away frame) 3202 // frame type (go away frame)
3194 0x03, 3203 0x03,
(...skipping 30 matching lines...) Expand all
3225 if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) { 3234 if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) {
3226 expected_error = "Unable to read go away error code."; 3235 expected_error = "Unable to read go away error code.";
3227 } else if (i < kQuicFrameTypeSize + kQuicErrorCodeSize + 3236 } else if (i < kQuicFrameTypeSize + kQuicErrorCodeSize +
3228 kQuicMaxStreamIdSize) { 3237 kQuicMaxStreamIdSize) {
3229 expected_error = "Unable to read last good stream id."; 3238 expected_error = "Unable to read last good stream id.";
3230 } else { 3239 } else {
3231 expected_error = "Unable to read goaway reason."; 3240 expected_error = "Unable to read goaway reason.";
3232 } 3241 }
3233 CheckProcessingFails( 3242 CheckProcessingFails(
3234 packet, 3243 packet,
3235 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3244 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3236 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 3245 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
3237 expected_error, QUIC_INVALID_GOAWAY_DATA); 3246 expected_error, QUIC_INVALID_GOAWAY_DATA);
3238 } 3247 }
3239 } 3248 }
3240 3249
3241 TEST_P(QuicFramerTest, WindowUpdateFrame) { 3250 TEST_P(QuicFramerTest, WindowUpdateFrame) {
3242 unsigned char packet[] = { 3251 unsigned char packet[] = {
3243 // public flags (8 byte guid) 3252 // public flags (8 byte connection_id)
3244 0x3C, 3253 0x3C,
3245 // guid 3254 // connection_id
3246 0x10, 0x32, 0x54, 0x76, 3255 0x10, 0x32, 0x54, 0x76,
3247 0x98, 0xBA, 0xDC, 0xFE, 3256 0x98, 0xBA, 0xDC, 0xFE,
3248 // packet sequence number 3257 // packet sequence number
3249 0xBC, 0x9A, 0x78, 0x56, 3258 0xBC, 0x9A, 0x78, 0x56,
3250 0x34, 0x12, 3259 0x34, 0x12,
3251 // private flags 3260 // private flags
3252 0x00, 3261 0x00,
3253 3262
3254 // frame type (window update frame) 3263 // frame type (window update frame)
3255 0x04, 3264 0x04,
(...skipping 29 matching lines...) Expand all
3285 for (size_t i = kQuicFrameTypeSize; 3294 for (size_t i = kQuicFrameTypeSize;
3286 i < QuicFramer::GetWindowUpdateFrameSize(); ++i) { 3295 i < QuicFramer::GetWindowUpdateFrameSize(); ++i) {
3287 string expected_error; 3296 string expected_error;
3288 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { 3297 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) {
3289 expected_error = "Unable to read stream_id."; 3298 expected_error = "Unable to read stream_id.";
3290 } else { 3299 } else {
3291 expected_error = "Unable to read window byte_offset."; 3300 expected_error = "Unable to read window byte_offset.";
3292 } 3301 }
3293 CheckProcessingFails( 3302 CheckProcessingFails(
3294 packet, 3303 packet,
3295 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3304 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3296 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 3305 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
3297 expected_error, QUIC_INVALID_WINDOW_UPDATE_DATA); 3306 expected_error, QUIC_INVALID_WINDOW_UPDATE_DATA);
3298 } 3307 }
3299 } 3308 }
3300 3309
3301 TEST_P(QuicFramerTest, BlockedFrame) { 3310 TEST_P(QuicFramerTest, BlockedFrame) {
3302 unsigned char packet[] = { 3311 unsigned char packet[] = {
3303 // public flags (8 byte guid) 3312 // public flags (8 byte connection_id)
3304 0x3C, 3313 0x3C,
3305 // guid 3314 // connection_id
3306 0x10, 0x32, 0x54, 0x76, 3315 0x10, 0x32, 0x54, 0x76,
3307 0x98, 0xBA, 0xDC, 0xFE, 3316 0x98, 0xBA, 0xDC, 0xFE,
3308 // packet sequence number 3317 // packet sequence number
3309 0xBC, 0x9A, 0x78, 0x56, 3318 0xBC, 0x9A, 0x78, 0x56,
3310 0x34, 0x12, 3319 0x34, 0x12,
3311 // private flags 3320 // private flags
3312 0x00, 3321 0x00,
3313 3322
3314 // frame type (blocked frame) 3323 // frame type (blocked frame)
3315 0x05, 3324 0x05,
(...skipping 19 matching lines...) Expand all
3335 3344
3336 EXPECT_EQ(GG_UINT64_C(0x01020304), 3345 EXPECT_EQ(GG_UINT64_C(0x01020304),
3337 visitor_.blocked_frame_.stream_id); 3346 visitor_.blocked_frame_.stream_id);
3338 3347
3339 // Now test framing boundaries 3348 // Now test framing boundaries
3340 for (size_t i = kQuicFrameTypeSize; i < QuicFramer::GetBlockedFrameSize(); 3349 for (size_t i = kQuicFrameTypeSize; i < QuicFramer::GetBlockedFrameSize();
3341 ++i) { 3350 ++i) {
3342 string expected_error = "Unable to read stream_id."; 3351 string expected_error = "Unable to read stream_id.";
3343 CheckProcessingFails( 3352 CheckProcessingFails(
3344 packet, 3353 packet,
3345 i + GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3354 i + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3346 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 3355 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
3347 expected_error, QUIC_INVALID_BLOCKED_DATA); 3356 expected_error, QUIC_INVALID_BLOCKED_DATA);
3348 } 3357 }
3349 } 3358 }
3350 3359
3351 TEST_P(QuicFramerTest, PublicResetPacket) { 3360 TEST_P(QuicFramerTest, PublicResetPacket) {
3352 unsigned char packet[] = { 3361 unsigned char packet[] = {
3353 // public flags (public reset, 8 byte guid) 3362 // public flags (public reset, 8 byte connection_id)
3354 0x0E, 3363 0x0E,
3355 // guid 3364 // connection_id
3356 0x10, 0x32, 0x54, 0x76, 3365 0x10, 0x32, 0x54, 0x76,
3357 0x98, 0xBA, 0xDC, 0xFE, 3366 0x98, 0xBA, 0xDC, 0xFE,
3358 // message tag (kPRST) 3367 // message tag (kPRST)
3359 'P', 'R', 'S', 'T', 3368 'P', 'R', 'S', 'T',
3360 // num_entries (2) + padding 3369 // num_entries (2) + padding
3361 0x02, 0x00, 0x00, 0x00, 3370 0x02, 0x00, 0x00, 0x00,
3362 // tag kRNON 3371 // tag kRNON
3363 'R', 'N', 'O', 'N', 3372 'R', 'N', 'O', 'N',
3364 // end offset 8 3373 // end offset 8
3365 0x08, 0x00, 0x00, 0x00, 3374 0x08, 0x00, 0x00, 0x00,
3366 // tag kRSEQ 3375 // tag kRSEQ
3367 'R', 'S', 'E', 'Q', 3376 'R', 'S', 'E', 'Q',
3368 // end offset 16 3377 // end offset 16
3369 0x10, 0x00, 0x00, 0x00, 3378 0x10, 0x00, 0x00, 0x00,
3370 // nonce proof 3379 // nonce proof
3371 0x89, 0x67, 0x45, 0x23, 3380 0x89, 0x67, 0x45, 0x23,
3372 0x01, 0xEF, 0xCD, 0xAB, 3381 0x01, 0xEF, 0xCD, 0xAB,
3373 // rejected sequence number 3382 // rejected sequence number
3374 0xBC, 0x9A, 0x78, 0x56, 3383 0xBC, 0x9A, 0x78, 0x56,
3375 0x34, 0x12, 0x00, 0x00, 3384 0x34, 0x12, 0x00, 0x00,
3376 }; 3385 };
3377 3386
3378 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 3387 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
3379 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 3388 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
3380 ASSERT_EQ(QUIC_NO_ERROR, framer_.error()); 3389 ASSERT_EQ(QUIC_NO_ERROR, framer_.error());
3381 ASSERT_TRUE(visitor_.public_reset_packet_.get()); 3390 ASSERT_TRUE(visitor_.public_reset_packet_.get());
3382 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 3391 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
3383 visitor_.public_reset_packet_->public_header.guid); 3392 visitor_.public_reset_packet_->public_header.connection_id);
3384 EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag); 3393 EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag);
3385 EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag); 3394 EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag);
3386 EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789), 3395 EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789),
3387 visitor_.public_reset_packet_->nonce_proof); 3396 visitor_.public_reset_packet_->nonce_proof);
3388 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 3397 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
3389 visitor_.public_reset_packet_->rejected_sequence_number); 3398 visitor_.public_reset_packet_->rejected_sequence_number);
3390 EXPECT_TRUE( 3399 EXPECT_TRUE(
3391 visitor_.public_reset_packet_->client_address.address().empty()); 3400 visitor_.public_reset_packet_->client_address.address().empty());
3392 3401
3393 // Now test framing boundaries 3402 // Now test framing boundaries
3394 for (size_t i = 0; i < arraysize(packet); ++i) { 3403 for (size_t i = 0; i < arraysize(packet); ++i) {
3395 string expected_error; 3404 string expected_error;
3396 DVLOG(1) << "iteration: " << i; 3405 DVLOG(1) << "iteration: " << i;
3397 if (i < kGuidOffset) { 3406 if (i < kConnectionIdOffset) {
3398 expected_error = "Unable to read public flags."; 3407 expected_error = "Unable to read public flags.";
3399 CheckProcessingFails(packet, i, expected_error, 3408 CheckProcessingFails(packet, i, expected_error,
3400 QUIC_INVALID_PACKET_HEADER); 3409 QUIC_INVALID_PACKET_HEADER);
3401 } else if (i < kPublicResetPacketMessageTagOffset) { 3410 } else if (i < kPublicResetPacketMessageTagOffset) {
3402 expected_error = "Unable to read GUID."; 3411 expected_error = "Unable to read ConnectionId.";
3403 CheckProcessingFails(packet, i, expected_error, 3412 CheckProcessingFails(packet, i, expected_error,
3404 QUIC_INVALID_PACKET_HEADER); 3413 QUIC_INVALID_PACKET_HEADER);
3405 } else { 3414 } else {
3406 expected_error = "Unable to read reset message."; 3415 expected_error = "Unable to read reset message.";
3407 CheckProcessingFails(packet, i, expected_error, 3416 CheckProcessingFails(packet, i, expected_error,
3408 QUIC_INVALID_PUBLIC_RST_PACKET); 3417 QUIC_INVALID_PUBLIC_RST_PACKET);
3409 } 3418 }
3410 } 3419 }
3411 } 3420 }
3412 3421
3413 TEST_P(QuicFramerTest, PublicResetPacketWithTrailingJunk) { 3422 TEST_P(QuicFramerTest, PublicResetPacketWithTrailingJunk) {
3414 unsigned char packet[] = { 3423 unsigned char packet[] = {
3415 // public flags (public reset, 8 byte guid) 3424 // public flags (public reset, 8 byte connection_id)
3416 0x0E, 3425 0x0E,
3417 // guid 3426 // connection_id
3418 0x10, 0x32, 0x54, 0x76, 3427 0x10, 0x32, 0x54, 0x76,
3419 0x98, 0xBA, 0xDC, 0xFE, 3428 0x98, 0xBA, 0xDC, 0xFE,
3420 // message tag (kPRST) 3429 // message tag (kPRST)
3421 'P', 'R', 'S', 'T', 3430 'P', 'R', 'S', 'T',
3422 // num_entries (2) + padding 3431 // num_entries (2) + padding
3423 0x02, 0x00, 0x00, 0x00, 3432 0x02, 0x00, 0x00, 0x00,
3424 // tag kRNON 3433 // tag kRNON
3425 'R', 'N', 'O', 'N', 3434 'R', 'N', 'O', 'N',
3426 // end offset 8 3435 // end offset 8
3427 0x08, 0x00, 0x00, 0x00, 3436 0x08, 0x00, 0x00, 0x00,
(...skipping 11 matching lines...) Expand all
3439 'j', 'u', 'n', 'k', 3448 'j', 'u', 'n', 'k',
3440 }; 3449 };
3441 3450
3442 string expected_error = "Unable to read reset message."; 3451 string expected_error = "Unable to read reset message.";
3443 CheckProcessingFails(packet, arraysize(packet), expected_error, 3452 CheckProcessingFails(packet, arraysize(packet), expected_error,
3444 QUIC_INVALID_PUBLIC_RST_PACKET); 3453 QUIC_INVALID_PUBLIC_RST_PACKET);
3445 } 3454 }
3446 3455
3447 TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) { 3456 TEST_P(QuicFramerTest, PublicResetPacketWithClientAddress) {
3448 unsigned char packet[] = { 3457 unsigned char packet[] = {
3449 // public flags (public reset, 8 byte guid) 3458 // public flags (public reset, 8 byte connection_id)
3450 0x0E, 3459 0x0E,
3451 // guid 3460 // connection_id
3452 0x10, 0x32, 0x54, 0x76, 3461 0x10, 0x32, 0x54, 0x76,
3453 0x98, 0xBA, 0xDC, 0xFE, 3462 0x98, 0xBA, 0xDC, 0xFE,
3454 // message tag (kPRST) 3463 // message tag (kPRST)
3455 'P', 'R', 'S', 'T', 3464 'P', 'R', 'S', 'T',
3456 // num_entries (3) + padding 3465 // num_entries (3) + padding
3457 0x03, 0x00, 0x00, 0x00, 3466 0x03, 0x00, 0x00, 0x00,
3458 // tag kRNON 3467 // tag kRNON
3459 'R', 'N', 'O', 'N', 3468 'R', 'N', 'O', 'N',
3460 // end offset 8 3469 // end offset 8
3461 0x08, 0x00, 0x00, 0x00, 3470 0x08, 0x00, 0x00, 0x00,
(...skipping 15 matching lines...) Expand all
3477 0x02, 0x00, 3486 0x02, 0x00,
3478 0x04, 0x1F, 0xC6, 0x2C, 3487 0x04, 0x1F, 0xC6, 0x2C,
3479 0xBB, 0x01, 3488 0xBB, 0x01,
3480 }; 3489 };
3481 3490
3482 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 3491 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
3483 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 3492 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
3484 ASSERT_EQ(QUIC_NO_ERROR, framer_.error()); 3493 ASSERT_EQ(QUIC_NO_ERROR, framer_.error());
3485 ASSERT_TRUE(visitor_.public_reset_packet_.get()); 3494 ASSERT_TRUE(visitor_.public_reset_packet_.get());
3486 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 3495 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
3487 visitor_.public_reset_packet_->public_header.guid); 3496 visitor_.public_reset_packet_->public_header.connection_id);
3488 EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag); 3497 EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag);
3489 EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag); 3498 EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag);
3490 EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789), 3499 EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789),
3491 visitor_.public_reset_packet_->nonce_proof); 3500 visitor_.public_reset_packet_->nonce_proof);
3492 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 3501 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
3493 visitor_.public_reset_packet_->rejected_sequence_number); 3502 visitor_.public_reset_packet_->rejected_sequence_number);
3494 EXPECT_EQ("4.31.198.44", 3503 EXPECT_EQ("4.31.198.44",
3495 IPAddressToString(visitor_.public_reset_packet_-> 3504 IPAddressToString(visitor_.public_reset_packet_->
3496 client_address.address())); 3505 client_address.address()));
3497 EXPECT_EQ(443, visitor_.public_reset_packet_->client_address.port()); 3506 EXPECT_EQ(443, visitor_.public_reset_packet_->client_address.port());
3498 3507
3499 // Now test framing boundaries 3508 // Now test framing boundaries
3500 for (size_t i = 0; i < arraysize(packet); ++i) { 3509 for (size_t i = 0; i < arraysize(packet); ++i) {
3501 string expected_error; 3510 string expected_error;
3502 DVLOG(1) << "iteration: " << i; 3511 DVLOG(1) << "iteration: " << i;
3503 if (i < kGuidOffset) { 3512 if (i < kConnectionIdOffset) {
3504 expected_error = "Unable to read public flags."; 3513 expected_error = "Unable to read public flags.";
3505 CheckProcessingFails(packet, i, expected_error, 3514 CheckProcessingFails(packet, i, expected_error,
3506 QUIC_INVALID_PACKET_HEADER); 3515 QUIC_INVALID_PACKET_HEADER);
3507 } else if (i < kPublicResetPacketMessageTagOffset) { 3516 } else if (i < kPublicResetPacketMessageTagOffset) {
3508 expected_error = "Unable to read GUID."; 3517 expected_error = "Unable to read ConnectionId.";
3509 CheckProcessingFails(packet, i, expected_error, 3518 CheckProcessingFails(packet, i, expected_error,
3510 QUIC_INVALID_PACKET_HEADER); 3519 QUIC_INVALID_PACKET_HEADER);
3511 } else { 3520 } else {
3512 expected_error = "Unable to read reset message."; 3521 expected_error = "Unable to read reset message.";
3513 CheckProcessingFails(packet, i, expected_error, 3522 CheckProcessingFails(packet, i, expected_error,
3514 QUIC_INVALID_PUBLIC_RST_PACKET); 3523 QUIC_INVALID_PUBLIC_RST_PACKET);
3515 } 3524 }
3516 } 3525 }
3517 } 3526 }
3518 3527
3519 // TODO(wtc): remove this test when we drop support for QUIC_VERSION_13. 3528 // TODO(wtc): remove this test when we drop support for QUIC_VERSION_13.
3520 TEST_P(QuicFramerTest, PublicResetPacketOld) { 3529 TEST_P(QuicFramerTest, PublicResetPacketOld) {
3521 unsigned char packet[] = { 3530 unsigned char packet[] = {
3522 // public flags (public reset, 8 byte guid) 3531 // public flags (public reset, 8 byte connection_id)
3523 0x3E, 3532 0x3E,
3524 // guid 3533 // connection_id
3525 0x10, 0x32, 0x54, 0x76, 3534 0x10, 0x32, 0x54, 0x76,
3526 0x98, 0xBA, 0xDC, 0xFE, 3535 0x98, 0xBA, 0xDC, 0xFE,
3527 // nonce proof 3536 // nonce proof
3528 0x89, 0x67, 0x45, 0x23, 3537 0x89, 0x67, 0x45, 0x23,
3529 0x01, 0xEF, 0xCD, 0xAB, 3538 0x01, 0xEF, 0xCD, 0xAB,
3530 // rejected sequence number 3539 // rejected sequence number
3531 0xBC, 0x9A, 0x78, 0x56, 3540 0xBC, 0x9A, 0x78, 0x56,
3532 0x34, 0x12, 3541 0x34, 0x12,
3533 }; 3542 };
3534 3543
3535 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 3544 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
3536 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 3545 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
3537 ASSERT_EQ(QUIC_NO_ERROR, framer_.error()); 3546 ASSERT_EQ(QUIC_NO_ERROR, framer_.error());
3538 ASSERT_TRUE(visitor_.public_reset_packet_.get()); 3547 ASSERT_TRUE(visitor_.public_reset_packet_.get());
3539 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210), 3548 EXPECT_EQ(GG_UINT64_C(0xFEDCBA9876543210),
3540 visitor_.public_reset_packet_->public_header.guid); 3549 visitor_.public_reset_packet_->public_header.connection_id);
3541 EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag); 3550 EXPECT_TRUE(visitor_.public_reset_packet_->public_header.reset_flag);
3542 EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag); 3551 EXPECT_FALSE(visitor_.public_reset_packet_->public_header.version_flag);
3543 EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789), 3552 EXPECT_EQ(GG_UINT64_C(0xABCDEF0123456789),
3544 visitor_.public_reset_packet_->nonce_proof); 3553 visitor_.public_reset_packet_->nonce_proof);
3545 EXPECT_EQ(GG_UINT64_C(0x123456789ABC), 3554 EXPECT_EQ(GG_UINT64_C(0x123456789ABC),
3546 visitor_.public_reset_packet_->rejected_sequence_number); 3555 visitor_.public_reset_packet_->rejected_sequence_number);
3547 EXPECT_TRUE( 3556 EXPECT_TRUE(
3548 visitor_.public_reset_packet_->client_address.address().empty()); 3557 visitor_.public_reset_packet_->client_address.address().empty());
3549 3558
3550 // Now test framing boundaries 3559 // Now test framing boundaries
3551 for (size_t i = 0; i < arraysize(packet); ++i) { 3560 for (size_t i = 0; i < arraysize(packet); ++i) {
3552 string expected_error; 3561 string expected_error;
3553 DVLOG(1) << "iteration: " << i; 3562 DVLOG(1) << "iteration: " << i;
3554 if (i < kGuidOffset) { 3563 if (i < kConnectionIdOffset) {
3555 expected_error = "Unable to read public flags."; 3564 expected_error = "Unable to read public flags.";
3556 CheckProcessingFails(packet, i, expected_error, 3565 CheckProcessingFails(packet, i, expected_error,
3557 QUIC_INVALID_PACKET_HEADER); 3566 QUIC_INVALID_PACKET_HEADER);
3558 } else if (i < kPublicResetPacketNonceProofOffset) { 3567 } else if (i < kPublicResetPacketNonceProofOffset) {
3559 expected_error = "Unable to read GUID."; 3568 expected_error = "Unable to read ConnectionId.";
3560 CheckProcessingFails(packet, i, expected_error, 3569 CheckProcessingFails(packet, i, expected_error,
3561 QUIC_INVALID_PACKET_HEADER); 3570 QUIC_INVALID_PACKET_HEADER);
3562 } else if (i < kPublicResetPacketRejectedSequenceNumberOffset) { 3571 } else if (i < kPublicResetPacketRejectedSequenceNumberOffset) {
3563 expected_error = "Unable to read nonce proof."; 3572 expected_error = "Unable to read nonce proof.";
3564 CheckProcessingFails(packet, i, expected_error, 3573 CheckProcessingFails(packet, i, expected_error,
3565 QUIC_INVALID_PUBLIC_RST_PACKET); 3574 QUIC_INVALID_PUBLIC_RST_PACKET);
3566 } else { 3575 } else {
3567 expected_error = "Unable to read rejected sequence number."; 3576 expected_error = "Unable to read rejected sequence number.";
3568 CheckProcessingFails(packet, i, expected_error, 3577 CheckProcessingFails(packet, i, expected_error,
3569 QUIC_INVALID_PUBLIC_RST_PACKET); 3578 QUIC_INVALID_PUBLIC_RST_PACKET);
3570 } 3579 }
3571 } 3580 }
3572 } 3581 }
3573 3582
3574 TEST_P(QuicFramerTest, VersionNegotiationPacket) { 3583 TEST_P(QuicFramerTest, VersionNegotiationPacket) {
3575 unsigned char packet[] = { 3584 unsigned char packet[] = {
3576 // public flags (version, 8 byte guid) 3585 // public flags (version, 8 byte connection_id)
3577 0x3D, 3586 0x3D,
3578 // guid 3587 // connection_id
3579 0x10, 0x32, 0x54, 0x76, 3588 0x10, 0x32, 0x54, 0x76,
3580 0x98, 0xBA, 0xDC, 0xFE, 3589 0x98, 0xBA, 0xDC, 0xFE,
3581 // version tag 3590 // version tag
3582 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 3591 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
3583 'Q', '2', '.', '0', 3592 'Q', '2', '.', '0',
3584 }; 3593 };
3585 3594
3586 QuicFramerPeer::SetIsServer(&framer_, false); 3595 QuicFramerPeer::SetIsServer(&framer_, false);
3587 3596
3588 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 3597 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
3589 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 3598 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
3590 ASSERT_EQ(QUIC_NO_ERROR, framer_.error()); 3599 ASSERT_EQ(QUIC_NO_ERROR, framer_.error());
3591 ASSERT_TRUE(visitor_.version_negotiation_packet_.get()); 3600 ASSERT_TRUE(visitor_.version_negotiation_packet_.get());
3592 EXPECT_EQ(2u, visitor_.version_negotiation_packet_->versions.size()); 3601 EXPECT_EQ(2u, visitor_.version_negotiation_packet_->versions.size());
3593 EXPECT_EQ(GetParam(), visitor_.version_negotiation_packet_->versions[0]); 3602 EXPECT_EQ(GetParam(), visitor_.version_negotiation_packet_->versions[0]);
3594 3603
3595 for (size_t i = 0; i <= kPublicFlagsSize + PACKET_8BYTE_GUID; ++i) { 3604 for (size_t i = 0; i <= kPublicFlagsSize + PACKET_8BYTE_CONNECTION_ID; ++i) {
3596 string expected_error; 3605 string expected_error;
3597 QuicErrorCode error_code = QUIC_INVALID_PACKET_HEADER; 3606 QuicErrorCode error_code = QUIC_INVALID_PACKET_HEADER;
3598 if (i < kGuidOffset) { 3607 if (i < kConnectionIdOffset) {
3599 expected_error = "Unable to read public flags."; 3608 expected_error = "Unable to read public flags.";
3600 } else if (i < kVersionOffset) { 3609 } else if (i < kVersionOffset) {
3601 expected_error = "Unable to read GUID."; 3610 expected_error = "Unable to read ConnectionId.";
3602 } else { 3611 } else {
3603 expected_error = "Unable to read supported version in negotiation."; 3612 expected_error = "Unable to read supported version in negotiation.";
3604 error_code = QUIC_INVALID_VERSION_NEGOTIATION_PACKET; 3613 error_code = QUIC_INVALID_VERSION_NEGOTIATION_PACKET;
3605 } 3614 }
3606 CheckProcessingFails(packet, i, expected_error, error_code); 3615 CheckProcessingFails(packet, i, expected_error, error_code);
3607 } 3616 }
3608 } 3617 }
3609 3618
3610 TEST_P(QuicFramerTest, FecPacket) { 3619 TEST_P(QuicFramerTest, FecPacket) {
3611 unsigned char packet[] = { 3620 unsigned char packet[] = {
3612 // public flags (8 byte guid) 3621 // public flags (8 byte connection_id)
3613 0x3C, 3622 0x3C,
3614 // guid 3623 // connection_id
3615 0x10, 0x32, 0x54, 0x76, 3624 0x10, 0x32, 0x54, 0x76,
3616 0x98, 0xBA, 0xDC, 0xFE, 3625 0x98, 0xBA, 0xDC, 0xFE,
3617 // packet sequence number 3626 // packet sequence number
3618 0xBC, 0x9A, 0x78, 0x56, 3627 0xBC, 0x9A, 0x78, 0x56,
3619 0x34, 0x12, 3628 0x34, 0x12,
3620 // private flags (fec group & FEC) 3629 // private flags (fec group & FEC)
3621 0x06, 3630 0x06,
3622 // first fec protected packet offset 3631 // first fec protected packet offset
3623 0x01, 3632 0x01,
3624 3633
(...skipping 14 matching lines...) Expand all
3639 EXPECT_EQ(0u, visitor_.stream_frames_.size()); 3648 EXPECT_EQ(0u, visitor_.stream_frames_.size());
3640 EXPECT_EQ(0u, visitor_.ack_frames_.size()); 3649 EXPECT_EQ(0u, visitor_.ack_frames_.size());
3641 ASSERT_EQ(1, visitor_.fec_count_); 3650 ASSERT_EQ(1, visitor_.fec_count_);
3642 const QuicFecData& fec_data = *visitor_.fec_data_[0]; 3651 const QuicFecData& fec_data = *visitor_.fec_data_[0];
3643 EXPECT_EQ(GG_UINT64_C(0x0123456789ABB), fec_data.fec_group); 3652 EXPECT_EQ(GG_UINT64_C(0x0123456789ABB), fec_data.fec_group);
3644 EXPECT_EQ("abcdefghijklmnop", fec_data.redundancy); 3653 EXPECT_EQ("abcdefghijklmnop", fec_data.redundancy);
3645 } 3654 }
3646 3655
3647 TEST_P(QuicFramerTest, BuildPaddingFramePacket) { 3656 TEST_P(QuicFramerTest, BuildPaddingFramePacket) {
3648 QuicPacketHeader header; 3657 QuicPacketHeader header;
3649 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 3658 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3650 header.public_header.reset_flag = false; 3659 header.public_header.reset_flag = false;
3651 header.public_header.version_flag = false; 3660 header.public_header.version_flag = false;
3652 header.fec_flag = false; 3661 header.fec_flag = false;
3653 header.entropy_flag = false; 3662 header.entropy_flag = false;
3654 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 3663 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
3655 header.fec_group = 0; 3664 header.fec_group = 0;
3656 3665
3657 QuicPaddingFrame padding_frame; 3666 QuicPaddingFrame padding_frame;
3658 3667
3659 QuicFrames frames; 3668 QuicFrames frames;
3660 frames.push_back(QuicFrame(&padding_frame)); 3669 frames.push_back(QuicFrame(&padding_frame));
3661 3670
3662 unsigned char packet[kMaxPacketSize] = { 3671 unsigned char packet[kMaxPacketSize] = {
3663 // public flags (8 byte guid) 3672 // public flags (8 byte connection_id)
3664 0x3C, 3673 0x3C,
3665 // guid 3674 // connection_id
3666 0x10, 0x32, 0x54, 0x76, 3675 0x10, 0x32, 0x54, 0x76,
3667 0x98, 0xBA, 0xDC, 0xFE, 3676 0x98, 0xBA, 0xDC, 0xFE,
3668 // packet sequence number 3677 // packet sequence number
3669 0xBC, 0x9A, 0x78, 0x56, 3678 0xBC, 0x9A, 0x78, 0x56,
3670 0x34, 0x12, 3679 0x34, 0x12,
3671 // private flags 3680 // private flags
3672 0x00, 3681 0x00,
3673 3682
3674 // frame type (padding frame) 3683 // frame type (padding frame)
3675 0x00, 3684 0x00,
3676 0x00, 0x00, 0x00, 0x00 3685 0x00, 0x00, 0x00, 0x00
3677 }; 3686 };
3678 3687
3679 uint64 header_size = 3688 uint64 header_size =
3680 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3689 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3681 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3690 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3682 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3691 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3683 3692
3684 scoped_ptr<QuicPacket> data( 3693 scoped_ptr<QuicPacket> data(
3685 framer_.BuildUnsizedDataPacket(header, frames).packet); 3694 framer_.BuildUnsizedDataPacket(header, frames).packet);
3686 ASSERT_TRUE(data != NULL); 3695 ASSERT_TRUE(data != NULL);
3687 3696
3688 test::CompareCharArraysWithHexError("constructed packet", 3697 test::CompareCharArraysWithHexError("constructed packet",
3689 data->data(), data->length(), 3698 data->data(), data->length(),
3690 AsChars(packet), 3699 AsChars(packet),
3691 arraysize(packet)); 3700 arraysize(packet));
3692 } 3701 }
3693 3702
3694 TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { 3703 TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) {
3695 QuicPacketHeader header; 3704 QuicPacketHeader header;
3696 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 3705 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3697 header.public_header.reset_flag = false; 3706 header.public_header.reset_flag = false;
3698 header.public_header.version_flag = false; 3707 header.public_header.version_flag = false;
3699 header.fec_flag = false; 3708 header.fec_flag = false;
3700 header.entropy_flag = false; 3709 header.entropy_flag = false;
3701 header.public_header.sequence_number_length = PACKET_4BYTE_SEQUENCE_NUMBER; 3710 header.public_header.sequence_number_length = PACKET_4BYTE_SEQUENCE_NUMBER;
3702 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 3711 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
3703 header.fec_group = 0; 3712 header.fec_group = 0;
3704 3713
3705 QuicPaddingFrame padding_frame; 3714 QuicPaddingFrame padding_frame;
3706 3715
3707 QuicFrames frames; 3716 QuicFrames frames;
3708 frames.push_back(QuicFrame(&padding_frame)); 3717 frames.push_back(QuicFrame(&padding_frame));
3709 3718
3710 unsigned char packet[kMaxPacketSize] = { 3719 unsigned char packet[kMaxPacketSize] = {
3711 // public flags (8 byte guid and 4 byte sequence number) 3720 // public flags (8 byte connection_id and 4 byte sequence number)
3712 0x2C, 3721 0x2C,
3713 // guid 3722 // connection_id
3714 0x10, 0x32, 0x54, 0x76, 3723 0x10, 0x32, 0x54, 0x76,
3715 0x98, 0xBA, 0xDC, 0xFE, 3724 0x98, 0xBA, 0xDC, 0xFE,
3716 // packet sequence number 3725 // packet sequence number
3717 0xBC, 0x9A, 0x78, 0x56, 3726 0xBC, 0x9A, 0x78, 0x56,
3718 // private flags 3727 // private flags
3719 0x00, 3728 0x00,
3720 3729
3721 // frame type (padding frame) 3730 // frame type (padding frame)
3722 0x00, 3731 0x00,
3723 0x00, 0x00, 0x00, 0x00 3732 0x00, 0x00, 0x00, 0x00
3724 }; 3733 };
3725 3734
3726 uint64 header_size = 3735 uint64 header_size =
3727 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3736 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3728 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3737 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3729 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3738 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3730 3739
3731 scoped_ptr<QuicPacket> data( 3740 scoped_ptr<QuicPacket> data(
3732 framer_.BuildUnsizedDataPacket(header, frames).packet); 3741 framer_.BuildUnsizedDataPacket(header, frames).packet);
3733 ASSERT_TRUE(data != NULL); 3742 ASSERT_TRUE(data != NULL);
3734 3743
3735 test::CompareCharArraysWithHexError("constructed packet", 3744 test::CompareCharArraysWithHexError("constructed packet",
3736 data->data(), data->length(), 3745 data->data(), data->length(),
3737 AsChars(packet), 3746 AsChars(packet),
3738 arraysize(packet)); 3747 arraysize(packet));
3739 } 3748 }
3740 3749
3741 TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { 3750 TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) {
3742 QuicPacketHeader header; 3751 QuicPacketHeader header;
3743 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 3752 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3744 header.public_header.reset_flag = false; 3753 header.public_header.reset_flag = false;
3745 header.public_header.version_flag = false; 3754 header.public_header.version_flag = false;
3746 header.fec_flag = false; 3755 header.fec_flag = false;
3747 header.entropy_flag = false; 3756 header.entropy_flag = false;
3748 header.public_header.sequence_number_length = PACKET_2BYTE_SEQUENCE_NUMBER; 3757 header.public_header.sequence_number_length = PACKET_2BYTE_SEQUENCE_NUMBER;
3749 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 3758 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
3750 header.fec_group = 0; 3759 header.fec_group = 0;
3751 3760
3752 QuicPaddingFrame padding_frame; 3761 QuicPaddingFrame padding_frame;
3753 3762
3754 QuicFrames frames; 3763 QuicFrames frames;
3755 frames.push_back(QuicFrame(&padding_frame)); 3764 frames.push_back(QuicFrame(&padding_frame));
3756 3765
3757 unsigned char packet[kMaxPacketSize] = { 3766 unsigned char packet[kMaxPacketSize] = {
3758 // public flags (8 byte guid and 2 byte sequence number) 3767 // public flags (8 byte connection_id and 2 byte sequence number)
3759 0x1C, 3768 0x1C,
3760 // guid 3769 // connection_id
3761 0x10, 0x32, 0x54, 0x76, 3770 0x10, 0x32, 0x54, 0x76,
3762 0x98, 0xBA, 0xDC, 0xFE, 3771 0x98, 0xBA, 0xDC, 0xFE,
3763 // packet sequence number 3772 // packet sequence number
3764 0xBC, 0x9A, 3773 0xBC, 0x9A,
3765 // private flags 3774 // private flags
3766 0x00, 3775 0x00,
3767 3776
3768 // frame type (padding frame) 3777 // frame type (padding frame)
3769 0x00, 3778 0x00,
3770 0x00, 0x00, 0x00, 0x00 3779 0x00, 0x00, 0x00, 0x00
3771 }; 3780 };
3772 3781
3773 uint64 header_size = 3782 uint64 header_size =
3774 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3783 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3775 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3784 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3776 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3785 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3777 3786
3778 scoped_ptr<QuicPacket> data( 3787 scoped_ptr<QuicPacket> data(
3779 framer_.BuildUnsizedDataPacket(header, frames).packet); 3788 framer_.BuildUnsizedDataPacket(header, frames).packet);
3780 ASSERT_TRUE(data != NULL); 3789 ASSERT_TRUE(data != NULL);
3781 3790
3782 test::CompareCharArraysWithHexError("constructed packet", 3791 test::CompareCharArraysWithHexError("constructed packet",
3783 data->data(), data->length(), 3792 data->data(), data->length(),
3784 AsChars(packet), 3793 AsChars(packet),
3785 arraysize(packet)); 3794 arraysize(packet));
3786 } 3795 }
3787 3796
3788 TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) { 3797 TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) {
3789 QuicPacketHeader header; 3798 QuicPacketHeader header;
3790 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 3799 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3791 header.public_header.reset_flag = false; 3800 header.public_header.reset_flag = false;
3792 header.public_header.version_flag = false; 3801 header.public_header.version_flag = false;
3793 header.fec_flag = false; 3802 header.fec_flag = false;
3794 header.entropy_flag = false; 3803 header.entropy_flag = false;
3795 header.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER; 3804 header.public_header.sequence_number_length = PACKET_1BYTE_SEQUENCE_NUMBER;
3796 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 3805 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
3797 header.fec_group = 0; 3806 header.fec_group = 0;
3798 3807
3799 QuicPaddingFrame padding_frame; 3808 QuicPaddingFrame padding_frame;
3800 3809
3801 QuicFrames frames; 3810 QuicFrames frames;
3802 frames.push_back(QuicFrame(&padding_frame)); 3811 frames.push_back(QuicFrame(&padding_frame));
3803 3812
3804 unsigned char packet[kMaxPacketSize] = { 3813 unsigned char packet[kMaxPacketSize] = {
3805 // public flags (8 byte guid and 1 byte sequence number) 3814 // public flags (8 byte connection_id and 1 byte sequence number)
3806 0x0C, 3815 0x0C,
3807 // guid 3816 // connection_id
3808 0x10, 0x32, 0x54, 0x76, 3817 0x10, 0x32, 0x54, 0x76,
3809 0x98, 0xBA, 0xDC, 0xFE, 3818 0x98, 0xBA, 0xDC, 0xFE,
3810 // packet sequence number 3819 // packet sequence number
3811 0xBC, 3820 0xBC,
3812 // private flags 3821 // private flags
3813 0x00, 3822 0x00,
3814 3823
3815 // frame type (padding frame) 3824 // frame type (padding frame)
3816 0x00, 3825 0x00,
3817 0x00, 0x00, 0x00, 0x00 3826 0x00, 0x00, 0x00, 0x00
3818 }; 3827 };
3819 3828
3820 uint64 header_size = 3829 uint64 header_size =
3821 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, 3830 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3822 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3831 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3823 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3832 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3824 3833
3825 scoped_ptr<QuicPacket> data( 3834 scoped_ptr<QuicPacket> data(
3826 framer_.BuildUnsizedDataPacket(header, frames).packet); 3835 framer_.BuildUnsizedDataPacket(header, frames).packet);
3827 ASSERT_TRUE(data != NULL); 3836 ASSERT_TRUE(data != NULL);
3828 3837
3829 test::CompareCharArraysWithHexError("constructed packet", 3838 test::CompareCharArraysWithHexError("constructed packet",
3830 data->data(), data->length(), 3839 data->data(), data->length(),
3831 AsChars(packet), 3840 AsChars(packet),
3832 arraysize(packet)); 3841 arraysize(packet));
3833 } 3842 }
3834 3843
3835 TEST_P(QuicFramerTest, BuildStreamFramePacket) { 3844 TEST_P(QuicFramerTest, BuildStreamFramePacket) {
3836 QuicPacketHeader header; 3845 QuicPacketHeader header;
3837 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 3846 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3838 header.public_header.reset_flag = false; 3847 header.public_header.reset_flag = false;
3839 header.public_header.version_flag = false; 3848 header.public_header.version_flag = false;
3840 header.fec_flag = false; 3849 header.fec_flag = false;
3841 header.entropy_flag = true; 3850 header.entropy_flag = true;
3842 header.packet_sequence_number = GG_UINT64_C(0x77123456789ABC); 3851 header.packet_sequence_number = GG_UINT64_C(0x77123456789ABC);
3843 header.fec_group = 0; 3852 header.fec_group = 0;
3844 3853
3845 QuicStreamFrame stream_frame; 3854 QuicStreamFrame stream_frame;
3846 stream_frame.stream_id = 0x01020304; 3855 stream_frame.stream_id = 0x01020304;
3847 stream_frame.fin = true; 3856 stream_frame.fin = true;
3848 stream_frame.offset = GG_UINT64_C(0xBA98FEDC32107654); 3857 stream_frame.offset = GG_UINT64_C(0xBA98FEDC32107654);
3849 stream_frame.data = MakeIOVector("hello world!"); 3858 stream_frame.data = MakeIOVector("hello world!");
3850 3859
3851 QuicFrames frames; 3860 QuicFrames frames;
3852 frames.push_back(QuicFrame(&stream_frame)); 3861 frames.push_back(QuicFrame(&stream_frame));
3853 3862
3854 unsigned char packet[] = { 3863 unsigned char packet[] = {
3855 // public flags (8 byte guid) 3864 // public flags (8 byte connection_id)
3856 0x3C, 3865 0x3C,
3857 // guid 3866 // connection_id
3858 0x10, 0x32, 0x54, 0x76, 3867 0x10, 0x32, 0x54, 0x76,
3859 0x98, 0xBA, 0xDC, 0xFE, 3868 0x98, 0xBA, 0xDC, 0xFE,
3860 // packet sequence number 3869 // packet sequence number
3861 0xBC, 0x9A, 0x78, 0x56, 3870 0xBC, 0x9A, 0x78, 0x56,
3862 0x34, 0x12, 3871 0x34, 0x12,
3863 // private flags (entropy) 3872 // private flags (entropy)
3864 0x01, 3873 0x01,
3865 3874
3866 // frame type (stream frame with fin and no length) 3875 // frame type (stream frame with fin and no length)
3867 0xDF, 3876 0xDF,
(...skipping 12 matching lines...) Expand all
3880 framer_.BuildUnsizedDataPacket(header, frames).packet); 3889 framer_.BuildUnsizedDataPacket(header, frames).packet);
3881 ASSERT_TRUE(data != NULL); 3890 ASSERT_TRUE(data != NULL);
3882 3891
3883 test::CompareCharArraysWithHexError("constructed packet", 3892 test::CompareCharArraysWithHexError("constructed packet",
3884 data->data(), data->length(), 3893 data->data(), data->length(),
3885 AsChars(packet), arraysize(packet)); 3894 AsChars(packet), arraysize(packet));
3886 } 3895 }
3887 3896
3888 TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { 3897 TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) {
3889 QuicPacketHeader header; 3898 QuicPacketHeader header;
3890 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 3899 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3891 header.public_header.reset_flag = false; 3900 header.public_header.reset_flag = false;
3892 header.public_header.version_flag = true; 3901 header.public_header.version_flag = true;
3893 header.fec_flag = false; 3902 header.fec_flag = false;
3894 header.entropy_flag = true; 3903 header.entropy_flag = true;
3895 header.packet_sequence_number = GG_UINT64_C(0x77123456789ABC); 3904 header.packet_sequence_number = GG_UINT64_C(0x77123456789ABC);
3896 header.fec_group = 0; 3905 header.fec_group = 0;
3897 3906
3898 QuicStreamFrame stream_frame; 3907 QuicStreamFrame stream_frame;
3899 stream_frame.stream_id = 0x01020304; 3908 stream_frame.stream_id = 0x01020304;
3900 stream_frame.fin = true; 3909 stream_frame.fin = true;
3901 stream_frame.offset = GG_UINT64_C(0xBA98FEDC32107654); 3910 stream_frame.offset = GG_UINT64_C(0xBA98FEDC32107654);
3902 stream_frame.data = MakeIOVector("hello world!"); 3911 stream_frame.data = MakeIOVector("hello world!");
3903 3912
3904 QuicFrames frames; 3913 QuicFrames frames;
3905 frames.push_back(QuicFrame(&stream_frame)); 3914 frames.push_back(QuicFrame(&stream_frame));
3906 3915
3907 unsigned char packet[] = { 3916 unsigned char packet[] = {
3908 // public flags (version, 8 byte guid) 3917 // public flags (version, 8 byte connection_id)
3909 0x3D, 3918 0x3D,
3910 // guid 3919 // connection_id
3911 0x10, 0x32, 0x54, 0x76, 3920 0x10, 0x32, 0x54, 0x76,
3912 0x98, 0xBA, 0xDC, 0xFE, 3921 0x98, 0xBA, 0xDC, 0xFE,
3913 // version tag 3922 // version tag
3914 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 3923 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
3915 // packet sequence number 3924 // packet sequence number
3916 0xBC, 0x9A, 0x78, 0x56, 3925 0xBC, 0x9A, 0x78, 0x56,
3917 0x34, 0x12, 3926 0x34, 0x12,
3918 // private flags (entropy) 3927 // private flags (entropy)
3919 0x01, 3928 0x01,
3920 3929
(...skipping 15 matching lines...) Expand all
3936 framer_.BuildUnsizedDataPacket(header, frames).packet); 3945 framer_.BuildUnsizedDataPacket(header, frames).packet);
3937 ASSERT_TRUE(data != NULL); 3946 ASSERT_TRUE(data != NULL);
3938 3947
3939 test::CompareCharArraysWithHexError("constructed packet", 3948 test::CompareCharArraysWithHexError("constructed packet",
3940 data->data(), data->length(), 3949 data->data(), data->length(),
3941 AsChars(packet), arraysize(packet)); 3950 AsChars(packet), arraysize(packet));
3942 } 3951 }
3943 3952
3944 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { 3953 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) {
3945 QuicPacketPublicHeader header; 3954 QuicPacketPublicHeader header;
3946 header.guid = GG_UINT64_C(0xFEDCBA9876543210); 3955 header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3947 header.reset_flag = false; 3956 header.reset_flag = false;
3948 header.version_flag = true; 3957 header.version_flag = true;
3949 3958
3950 unsigned char packet[] = { 3959 unsigned char packet[] = {
3951 // public flags (version, 8 byte guid) 3960 // public flags (version, 8 byte connection_id)
3952 0x0D, 3961 0x0D,
3953 // guid 3962 // connection_id
3954 0x10, 0x32, 0x54, 0x76, 3963 0x10, 0x32, 0x54, 0x76,
3955 0x98, 0xBA, 0xDC, 0xFE, 3964 0x98, 0xBA, 0xDC, 0xFE,
3956 // version tag 3965 // version tag
3957 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), 3966 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(),
3958 }; 3967 };
3959 3968
3960 QuicVersionVector versions; 3969 QuicVersionVector versions;
3961 versions.push_back(GetParam()); 3970 versions.push_back(GetParam());
3962 scoped_ptr<QuicEncryptedPacket> data( 3971 scoped_ptr<QuicEncryptedPacket> data(
3963 framer_.BuildVersionNegotiationPacket(header, versions)); 3972 framer_.BuildVersionNegotiationPacket(header, versions));
3964 3973
3965 test::CompareCharArraysWithHexError("constructed packet", 3974 test::CompareCharArraysWithHexError("constructed packet",
3966 data->data(), data->length(), 3975 data->data(), data->length(),
3967 AsChars(packet), arraysize(packet)); 3976 AsChars(packet), arraysize(packet));
3968 } 3977 }
3969 3978
3970 TEST_P(QuicFramerTest, BuildAckFramePacket) { 3979 TEST_P(QuicFramerTest, BuildAckFramePacket) {
3971 if (version_ <= QUIC_VERSION_15) { 3980 if (version_ <= QUIC_VERSION_15) {
3972 return; 3981 return;
3973 } 3982 }
3974 QuicPacketHeader header; 3983 QuicPacketHeader header;
3975 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 3984 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3976 header.public_header.reset_flag = false; 3985 header.public_header.reset_flag = false;
3977 header.public_header.version_flag = false; 3986 header.public_header.version_flag = false;
3978 header.fec_flag = false; 3987 header.fec_flag = false;
3979 header.entropy_flag = true; 3988 header.entropy_flag = true;
3980 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); 3989 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8);
3981 header.fec_group = 0; 3990 header.fec_group = 0;
3982 3991
3983 QuicAckFrame ack_frame; 3992 QuicAckFrame ack_frame;
3984 ack_frame.received_info.entropy_hash = 0x43; 3993 ack_frame.received_info.entropy_hash = 0x43;
3985 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF); 3994 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF);
3986 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero(); 3995 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero();
3987 ack_frame.received_info.missing_packets.insert( 3996 ack_frame.received_info.missing_packets.insert(
3988 GG_UINT64_C(0x770123456789ABE)); 3997 GG_UINT64_C(0x770123456789ABE));
3989 3998
3990 QuicFrames frames; 3999 QuicFrames frames;
3991 frames.push_back(QuicFrame(&ack_frame)); 4000 frames.push_back(QuicFrame(&ack_frame));
3992 4001
3993 unsigned char packet[] = { 4002 unsigned char packet[] = {
3994 // public flags (8 byte guid) 4003 // public flags (8 byte connection_id)
3995 0x3C, 4004 0x3C,
3996 // guid 4005 // connection_id
3997 0x10, 0x32, 0x54, 0x76, 4006 0x10, 0x32, 0x54, 0x76,
3998 0x98, 0xBA, 0xDC, 0xFE, 4007 0x98, 0xBA, 0xDC, 0xFE,
3999 // packet sequence number 4008 // packet sequence number
4000 0xA8, 0x9A, 0x78, 0x56, 4009 0xA8, 0x9A, 0x78, 0x56,
4001 0x34, 0x12, 4010 0x34, 0x12,
4002 // private flags (entropy) 4011 // private flags (entropy)
4003 0x01, 4012 0x01,
4004 4013
4005 // frame type (ack frame) 4014 // frame type (ack frame)
4006 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 4015 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 22 matching lines...) Expand all
4029 test::CompareCharArraysWithHexError("constructed packet", 4038 test::CompareCharArraysWithHexError("constructed packet",
4030 data->data(), data->length(), 4039 data->data(), data->length(),
4031 AsChars(packet), arraysize(packet)); 4040 AsChars(packet), arraysize(packet));
4032 } 4041 }
4033 4042
4034 TEST_P(QuicFramerTest, BuildAckFramePacket15) { 4043 TEST_P(QuicFramerTest, BuildAckFramePacket15) {
4035 if (version_ != QUIC_VERSION_15) { 4044 if (version_ != QUIC_VERSION_15) {
4036 return; 4045 return;
4037 } 4046 }
4038 QuicPacketHeader header; 4047 QuicPacketHeader header;
4039 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4048 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4040 header.public_header.reset_flag = false; 4049 header.public_header.reset_flag = false;
4041 header.public_header.version_flag = false; 4050 header.public_header.version_flag = false;
4042 header.fec_flag = false; 4051 header.fec_flag = false;
4043 header.entropy_flag = true; 4052 header.entropy_flag = true;
4044 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); 4053 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8);
4045 header.fec_group = 0; 4054 header.fec_group = 0;
4046 4055
4047 QuicAckFrame ack_frame; 4056 QuicAckFrame ack_frame;
4048 ack_frame.received_info.entropy_hash = 0x43; 4057 ack_frame.received_info.entropy_hash = 0x43;
4049 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF); 4058 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF);
4050 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero(); 4059 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero();
4051 ack_frame.received_info.missing_packets.insert( 4060 ack_frame.received_info.missing_packets.insert(
4052 GG_UINT64_C(0x770123456789ABE)); 4061 GG_UINT64_C(0x770123456789ABE));
4053 ack_frame.sent_info.entropy_hash = 0x14; 4062 ack_frame.sent_info.entropy_hash = 0x14;
4054 ack_frame.sent_info.least_unacked = GG_UINT64_C(0x770123456789AA0); 4063 ack_frame.sent_info.least_unacked = GG_UINT64_C(0x770123456789AA0);
4055 4064
4056 QuicFrames frames; 4065 QuicFrames frames;
4057 frames.push_back(QuicFrame(&ack_frame)); 4066 frames.push_back(QuicFrame(&ack_frame));
4058 4067
4059 unsigned char packet[] = { 4068 unsigned char packet[] = {
4060 // public flags (8 byte guid) 4069 // public flags (8 byte connection_id)
4061 0x3C, 4070 0x3C,
4062 // guid 4071 // connection_id
4063 0x10, 0x32, 0x54, 0x76, 4072 0x10, 0x32, 0x54, 0x76,
4064 0x98, 0xBA, 0xDC, 0xFE, 4073 0x98, 0xBA, 0xDC, 0xFE,
4065 // packet sequence number 4074 // packet sequence number
4066 0xA8, 0x9A, 0x78, 0x56, 4075 0xA8, 0x9A, 0x78, 0x56,
4067 0x34, 0x12, 4076 0x34, 0x12,
4068 // private flags (entropy) 4077 // private flags (entropy)
4069 0x01, 4078 0x01,
4070 4079
4071 // frame type (ack frame) 4080 // frame type (ack frame)
4072 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 4081 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 27 matching lines...) Expand all
4100 test::CompareCharArraysWithHexError("constructed packet", 4109 test::CompareCharArraysWithHexError("constructed packet",
4101 data->data(), data->length(), 4110 data->data(), data->length(),
4102 AsChars(packet), arraysize(packet)); 4111 AsChars(packet), arraysize(packet));
4103 } 4112 }
4104 4113
4105 TEST_P(QuicFramerTest, BuildAckFramePacketV14) { 4114 TEST_P(QuicFramerTest, BuildAckFramePacketV14) {
4106 if (version_ > QUIC_VERSION_14) { 4115 if (version_ > QUIC_VERSION_14) {
4107 return; 4116 return;
4108 } 4117 }
4109 QuicPacketHeader header; 4118 QuicPacketHeader header;
4110 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4119 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4111 header.public_header.reset_flag = false; 4120 header.public_header.reset_flag = false;
4112 header.public_header.version_flag = false; 4121 header.public_header.version_flag = false;
4113 header.fec_flag = false; 4122 header.fec_flag = false;
4114 header.entropy_flag = true; 4123 header.entropy_flag = true;
4115 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); 4124 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8);
4116 header.fec_group = 0; 4125 header.fec_group = 0;
4117 4126
4118 QuicAckFrame ack_frame; 4127 QuicAckFrame ack_frame;
4119 ack_frame.received_info.entropy_hash = 0x43; 4128 ack_frame.received_info.entropy_hash = 0x43;
4120 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF); 4129 ack_frame.received_info.largest_observed = GG_UINT64_C(0x770123456789ABF);
4121 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero(); 4130 ack_frame.received_info.delta_time_largest_observed = QuicTime::Delta::Zero();
4122 ack_frame.received_info.missing_packets.insert( 4131 ack_frame.received_info.missing_packets.insert(
4123 GG_UINT64_C(0x770123456789ABE)); 4132 GG_UINT64_C(0x770123456789ABE));
4124 ack_frame.sent_info.entropy_hash = 0x14; 4133 ack_frame.sent_info.entropy_hash = 0x14;
4125 ack_frame.sent_info.least_unacked = GG_UINT64_C(0x770123456789AA0); 4134 ack_frame.sent_info.least_unacked = GG_UINT64_C(0x770123456789AA0);
4126 4135
4127 QuicFrames frames; 4136 QuicFrames frames;
4128 frames.push_back(QuicFrame(&ack_frame)); 4137 frames.push_back(QuicFrame(&ack_frame));
4129 4138
4130 unsigned char packet[] = { 4139 unsigned char packet[] = {
4131 // public flags (8 byte guid) 4140 // public flags (8 byte connection_id)
4132 0x3C, 4141 0x3C,
4133 // guid 4142 // connection_id
4134 0x10, 0x32, 0x54, 0x76, 4143 0x10, 0x32, 0x54, 0x76,
4135 0x98, 0xBA, 0xDC, 0xFE, 4144 0x98, 0xBA, 0xDC, 0xFE,
4136 // packet sequence number 4145 // packet sequence number
4137 0xA8, 0x9A, 0x78, 0x56, 4146 0xA8, 0x9A, 0x78, 0x56,
4138 0x34, 0x12, 4147 0x34, 0x12,
4139 // private flags (entropy) 4148 // private flags (entropy)
4140 0x01, 4149 0x01,
4141 4150
4142 // frame type (ack frame) 4151 // frame type (ack frame)
4143 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta) 4152 // (has nacks, not truncated, 6 byte largest observed, 1 byte delta)
(...skipping 25 matching lines...) Expand all
4169 test::CompareCharArraysWithHexError("constructed packet", 4178 test::CompareCharArraysWithHexError("constructed packet",
4170 data->data(), data->length(), 4179 data->data(), data->length(),
4171 AsChars(packet), arraysize(packet)); 4180 AsChars(packet), arraysize(packet));
4172 } 4181 }
4173 4182
4174 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) { 4183 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) {
4175 if (version_ <= QUIC_VERSION_14) { 4184 if (version_ <= QUIC_VERSION_14) {
4176 return; 4185 return;
4177 } 4186 }
4178 QuicPacketHeader header; 4187 QuicPacketHeader header;
4179 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4188 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4180 header.public_header.reset_flag = false; 4189 header.public_header.reset_flag = false;
4181 header.public_header.version_flag = false; 4190 header.public_header.version_flag = false;
4182 header.fec_flag = false; 4191 header.fec_flag = false;
4183 header.entropy_flag = false; 4192 header.entropy_flag = false;
4184 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4193 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4185 header.fec_group = 0; 4194 header.fec_group = 0;
4186 4195
4187 QuicCongestionFeedbackFrame congestion_feedback_frame; 4196 QuicCongestionFeedbackFrame congestion_feedback_frame;
4188 congestion_feedback_frame.type = kTCP; 4197 congestion_feedback_frame.type = kTCP;
4189 congestion_feedback_frame.tcp.receive_window = 0x4030; 4198 congestion_feedback_frame.tcp.receive_window = 0x4030;
4190 4199
4191 QuicFrames frames; 4200 QuicFrames frames;
4192 frames.push_back(QuicFrame(&congestion_feedback_frame)); 4201 frames.push_back(QuicFrame(&congestion_feedback_frame));
4193 4202
4194 unsigned char packet[] = { 4203 unsigned char packet[] = {
4195 // public flags (8 byte guid) 4204 // public flags (8 byte connection_id)
4196 0x3C, 4205 0x3C,
4197 // guid 4206 // connection_id
4198 0x10, 0x32, 0x54, 0x76, 4207 0x10, 0x32, 0x54, 0x76,
4199 0x98, 0xBA, 0xDC, 0xFE, 4208 0x98, 0xBA, 0xDC, 0xFE,
4200 // packet sequence number 4209 // packet sequence number
4201 0xBC, 0x9A, 0x78, 0x56, 4210 0xBC, 0x9A, 0x78, 0x56,
4202 0x34, 0x12, 4211 0x34, 0x12,
4203 // private flags 4212 // private flags
4204 0x00, 4213 0x00,
4205 4214
4206 // frame type (congestion feedback frame) 4215 // frame type (congestion feedback frame)
4207 0x20, 4216 0x20,
(...skipping 10 matching lines...) Expand all
4218 test::CompareCharArraysWithHexError("constructed packet", 4227 test::CompareCharArraysWithHexError("constructed packet",
4219 data->data(), data->length(), 4228 data->data(), data->length(),
4220 AsChars(packet), arraysize(packet)); 4229 AsChars(packet), arraysize(packet));
4221 } 4230 }
4222 4231
4223 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCPV14) { 4232 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCPV14) {
4224 if (version_ > QUIC_VERSION_14) { 4233 if (version_ > QUIC_VERSION_14) {
4225 return; 4234 return;
4226 } 4235 }
4227 QuicPacketHeader header; 4236 QuicPacketHeader header;
4228 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4237 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4229 header.public_header.reset_flag = false; 4238 header.public_header.reset_flag = false;
4230 header.public_header.version_flag = false; 4239 header.public_header.version_flag = false;
4231 header.fec_flag = false; 4240 header.fec_flag = false;
4232 header.entropy_flag = false; 4241 header.entropy_flag = false;
4233 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4242 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4234 header.fec_group = 0; 4243 header.fec_group = 0;
4235 4244
4236 QuicCongestionFeedbackFrame congestion_feedback_frame; 4245 QuicCongestionFeedbackFrame congestion_feedback_frame;
4237 congestion_feedback_frame.type = kTCP; 4246 congestion_feedback_frame.type = kTCP;
4238 congestion_feedback_frame.tcp.receive_window = 0x4030; 4247 congestion_feedback_frame.tcp.receive_window = 0x4030;
4239 4248
4240 QuicFrames frames; 4249 QuicFrames frames;
4241 frames.push_back(QuicFrame(&congestion_feedback_frame)); 4250 frames.push_back(QuicFrame(&congestion_feedback_frame));
4242 4251
4243 unsigned char packet[] = { 4252 unsigned char packet[] = {
4244 // public flags (8 byte guid) 4253 // public flags (8 byte connection_id)
4245 0x3C, 4254 0x3C,
4246 // guid 4255 // connection_id
4247 0x10, 0x32, 0x54, 0x76, 4256 0x10, 0x32, 0x54, 0x76,
4248 0x98, 0xBA, 0xDC, 0xFE, 4257 0x98, 0xBA, 0xDC, 0xFE,
4249 // packet sequence number 4258 // packet sequence number
4250 0xBC, 0x9A, 0x78, 0x56, 4259 0xBC, 0x9A, 0x78, 0x56,
4251 0x34, 0x12, 4260 0x34, 0x12,
4252 // private flags 4261 // private flags
4253 0x00, 4262 0x00,
4254 4263
4255 // frame type (congestion feedback frame) 4264 // frame type (congestion feedback frame)
4256 0x20, 4265 0x20,
(...skipping 12 matching lines...) Expand all
4269 test::CompareCharArraysWithHexError("constructed packet", 4278 test::CompareCharArraysWithHexError("constructed packet",
4270 data->data(), data->length(), 4279 data->data(), data->length(),
4271 AsChars(packet), arraysize(packet)); 4280 AsChars(packet), arraysize(packet));
4272 } 4281 }
4273 4282
4274 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) { 4283 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) {
4275 if (version_ <= QUIC_VERSION_14) { 4284 if (version_ <= QUIC_VERSION_14) {
4276 return; 4285 return;
4277 } 4286 }
4278 QuicPacketHeader header; 4287 QuicPacketHeader header;
4279 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4288 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4280 header.public_header.reset_flag = false; 4289 header.public_header.reset_flag = false;
4281 header.public_header.version_flag = false; 4290 header.public_header.version_flag = false;
4282 header.fec_flag = false; 4291 header.fec_flag = false;
4283 header.entropy_flag = false; 4292 header.entropy_flag = false;
4284 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4293 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4285 header.fec_group = 0; 4294 header.fec_group = 0;
4286 4295
4287 QuicCongestionFeedbackFrame frame; 4296 QuicCongestionFeedbackFrame frame;
4288 frame.type = kInterArrival; 4297 frame.type = kInterArrival;
4289 frame.inter_arrival.received_packet_times.insert( 4298 frame.inter_arrival.received_packet_times.insert(
4290 make_pair(GG_UINT64_C(0x0123456789ABA), 4299 make_pair(GG_UINT64_C(0x0123456789ABA),
4291 start_.Add(QuicTime::Delta::FromMicroseconds( 4300 start_.Add(QuicTime::Delta::FromMicroseconds(
4292 GG_UINT64_C(0x07E1D2C3B4A59687))))); 4301 GG_UINT64_C(0x07E1D2C3B4A59687)))));
4293 frame.inter_arrival.received_packet_times.insert( 4302 frame.inter_arrival.received_packet_times.insert(
4294 make_pair(GG_UINT64_C(0x0123456789ABB), 4303 make_pair(GG_UINT64_C(0x0123456789ABB),
4295 start_.Add(QuicTime::Delta::FromMicroseconds( 4304 start_.Add(QuicTime::Delta::FromMicroseconds(
4296 GG_UINT64_C(0x07E1D2C3B4A59688))))); 4305 GG_UINT64_C(0x07E1D2C3B4A59688)))));
4297 frame.inter_arrival.received_packet_times.insert( 4306 frame.inter_arrival.received_packet_times.insert(
4298 make_pair(GG_UINT64_C(0x0123456789ABD), 4307 make_pair(GG_UINT64_C(0x0123456789ABD),
4299 start_.Add(QuicTime::Delta::FromMicroseconds( 4308 start_.Add(QuicTime::Delta::FromMicroseconds(
4300 GG_UINT64_C(0x07E1D2C3B4A59689))))); 4309 GG_UINT64_C(0x07E1D2C3B4A59689)))));
4301 QuicFrames frames; 4310 QuicFrames frames;
4302 frames.push_back(QuicFrame(&frame)); 4311 frames.push_back(QuicFrame(&frame));
4303 4312
4304 unsigned char packet[] = { 4313 unsigned char packet[] = {
4305 // public flags (8 byte guid) 4314 // public flags (8 byte connection_id)
4306 0x3C, 4315 0x3C,
4307 // guid 4316 // connection_id
4308 0x10, 0x32, 0x54, 0x76, 4317 0x10, 0x32, 0x54, 0x76,
4309 0x98, 0xBA, 0xDC, 0xFE, 4318 0x98, 0xBA, 0xDC, 0xFE,
4310 // packet sequence number 4319 // packet sequence number
4311 0xBC, 0x9A, 0x78, 0x56, 4320 0xBC, 0x9A, 0x78, 0x56,
4312 0x34, 0x12, 4321 0x34, 0x12,
4313 // private flags 4322 // private flags
4314 0x00, 4323 0x00,
4315 4324
4316 // frame type (congestion feedback frame) 4325 // frame type (congestion feedback frame)
4317 0x20, 4326 0x20,
(...skipping 24 matching lines...) Expand all
4342 test::CompareCharArraysWithHexError("constructed packet", 4351 test::CompareCharArraysWithHexError("constructed packet",
4343 data->data(), data->length(), 4352 data->data(), data->length(),
4344 AsChars(packet), arraysize(packet)); 4353 AsChars(packet), arraysize(packet));
4345 } 4354 }
4346 4355
4347 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrivalV14) { 4356 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrivalV14) {
4348 if (version_ > QUIC_VERSION_14) { 4357 if (version_ > QUIC_VERSION_14) {
4349 return; 4358 return;
4350 } 4359 }
4351 QuicPacketHeader header; 4360 QuicPacketHeader header;
4352 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4361 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4353 header.public_header.reset_flag = false; 4362 header.public_header.reset_flag = false;
4354 header.public_header.version_flag = false; 4363 header.public_header.version_flag = false;
4355 header.fec_flag = false; 4364 header.fec_flag = false;
4356 header.entropy_flag = false; 4365 header.entropy_flag = false;
4357 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4366 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4358 header.fec_group = 0; 4367 header.fec_group = 0;
4359 4368
4360 QuicCongestionFeedbackFrame frame; 4369 QuicCongestionFeedbackFrame frame;
4361 frame.type = kInterArrival; 4370 frame.type = kInterArrival;
4362 frame.inter_arrival.received_packet_times.insert( 4371 frame.inter_arrival.received_packet_times.insert(
4363 make_pair(GG_UINT64_C(0x0123456789ABA), 4372 make_pair(GG_UINT64_C(0x0123456789ABA),
4364 start_.Add(QuicTime::Delta::FromMicroseconds( 4373 start_.Add(QuicTime::Delta::FromMicroseconds(
4365 GG_UINT64_C(0x07E1D2C3B4A59687))))); 4374 GG_UINT64_C(0x07E1D2C3B4A59687)))));
4366 frame.inter_arrival.received_packet_times.insert( 4375 frame.inter_arrival.received_packet_times.insert(
4367 make_pair(GG_UINT64_C(0x0123456789ABB), 4376 make_pair(GG_UINT64_C(0x0123456789ABB),
4368 start_.Add(QuicTime::Delta::FromMicroseconds( 4377 start_.Add(QuicTime::Delta::FromMicroseconds(
4369 GG_UINT64_C(0x07E1D2C3B4A59688))))); 4378 GG_UINT64_C(0x07E1D2C3B4A59688)))));
4370 frame.inter_arrival.received_packet_times.insert( 4379 frame.inter_arrival.received_packet_times.insert(
4371 make_pair(GG_UINT64_C(0x0123456789ABD), 4380 make_pair(GG_UINT64_C(0x0123456789ABD),
4372 start_.Add(QuicTime::Delta::FromMicroseconds( 4381 start_.Add(QuicTime::Delta::FromMicroseconds(
4373 GG_UINT64_C(0x07E1D2C3B4A59689))))); 4382 GG_UINT64_C(0x07E1D2C3B4A59689)))));
4374 QuicFrames frames; 4383 QuicFrames frames;
4375 frames.push_back(QuicFrame(&frame)); 4384 frames.push_back(QuicFrame(&frame));
4376 4385
4377 unsigned char packet[] = { 4386 unsigned char packet[] = {
4378 // public flags (8 byte guid) 4387 // public flags (8 byte connection_id)
4379 0x3C, 4388 0x3C,
4380 // guid 4389 // connection_id
4381 0x10, 0x32, 0x54, 0x76, 4390 0x10, 0x32, 0x54, 0x76,
4382 0x98, 0xBA, 0xDC, 0xFE, 4391 0x98, 0xBA, 0xDC, 0xFE,
4383 // packet sequence number 4392 // packet sequence number
4384 0xBC, 0x9A, 0x78, 0x56, 4393 0xBC, 0x9A, 0x78, 0x56,
4385 0x34, 0x12, 4394 0x34, 0x12,
4386 // private flags 4395 // private flags
4387 0x00, 4396 0x00,
4388 4397
4389 // frame type (congestion feedback frame) 4398 // frame type (congestion feedback frame)
4390 0x20, 4399 0x20,
(...skipping 26 matching lines...) Expand all
4417 test::CompareCharArraysWithHexError("constructed packet", 4426 test::CompareCharArraysWithHexError("constructed packet",
4418 data->data(), data->length(), 4427 data->data(), data->length(),
4419 AsChars(packet), arraysize(packet)); 4428 AsChars(packet), arraysize(packet));
4420 } 4429 }
4421 4430
4422 TEST_P(QuicFramerTest, BuildStopWaitingPacket) { 4431 TEST_P(QuicFramerTest, BuildStopWaitingPacket) {
4423 if (version_ <= QUIC_VERSION_15) { 4432 if (version_ <= QUIC_VERSION_15) {
4424 return; 4433 return;
4425 } 4434 }
4426 QuicPacketHeader header; 4435 QuicPacketHeader header;
4427 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4436 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4428 header.public_header.reset_flag = false; 4437 header.public_header.reset_flag = false;
4429 header.public_header.version_flag = false; 4438 header.public_header.version_flag = false;
4430 header.fec_flag = false; 4439 header.fec_flag = false;
4431 header.entropy_flag = true; 4440 header.entropy_flag = true;
4432 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8); 4441 header.packet_sequence_number = GG_UINT64_C(0x770123456789AA8);
4433 header.fec_group = 0; 4442 header.fec_group = 0;
4434 4443
4435 QuicStopWaitingFrame stop_waiting_frame; 4444 QuicStopWaitingFrame stop_waiting_frame;
4436 stop_waiting_frame.entropy_hash = 0x14; 4445 stop_waiting_frame.entropy_hash = 0x14;
4437 stop_waiting_frame.least_unacked = GG_UINT64_C(0x770123456789AA0); 4446 stop_waiting_frame.least_unacked = GG_UINT64_C(0x770123456789AA0);
4438 4447
4439 QuicFrames frames; 4448 QuicFrames frames;
4440 frames.push_back(QuicFrame(&stop_waiting_frame)); 4449 frames.push_back(QuicFrame(&stop_waiting_frame));
4441 4450
4442 unsigned char packet[] = { 4451 unsigned char packet[] = {
4443 // public flags (8 byte guid) 4452 // public flags (8 byte connection_id)
4444 0x3C, 4453 0x3C,
4445 // guid 4454 // connection_id
4446 0x10, 0x32, 0x54, 0x76, 4455 0x10, 0x32, 0x54, 0x76,
4447 0x98, 0xBA, 0xDC, 0xFE, 4456 0x98, 0xBA, 0xDC, 0xFE,
4448 // packet sequence number 4457 // packet sequence number
4449 0xA8, 0x9A, 0x78, 0x56, 4458 0xA8, 0x9A, 0x78, 0x56,
4450 0x34, 0x12, 4459 0x34, 0x12,
4451 // private flags (entropy) 4460 // private flags (entropy)
4452 0x01, 4461 0x01,
4453 4462
4454 // frame type (stop waiting frame) 4463 // frame type (stop waiting frame)
4455 0x06, 4464 0x06,
4456 // entropy hash of sent packets till least awaiting - 1. 4465 // entropy hash of sent packets till least awaiting - 1.
4457 0x14, 4466 0x14,
4458 // least packet sequence number awaiting an ack, delta from sequence number. 4467 // least packet sequence number awaiting an ack, delta from sequence number.
4459 0x08, 0x00, 0x00, 0x00, 4468 0x08, 0x00, 0x00, 0x00,
4460 0x00, 0x00, 4469 0x00, 0x00,
4461 }; 4470 };
4462 4471
4463 scoped_ptr<QuicPacket> data( 4472 scoped_ptr<QuicPacket> data(
4464 framer_.BuildUnsizedDataPacket(header, frames).packet); 4473 framer_.BuildUnsizedDataPacket(header, frames).packet);
4465 ASSERT_TRUE(data != NULL); 4474 ASSERT_TRUE(data != NULL);
4466 4475
4467 test::CompareCharArraysWithHexError("constructed packet", 4476 test::CompareCharArraysWithHexError("constructed packet",
4468 data->data(), data->length(), 4477 data->data(), data->length(),
4469 AsChars(packet), arraysize(packet)); 4478 AsChars(packet), arraysize(packet));
4470 } 4479 }
4471 4480
4472 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) { 4481 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) {
4473 QuicPacketHeader header; 4482 QuicPacketHeader header;
4474 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4483 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4475 header.public_header.reset_flag = false; 4484 header.public_header.reset_flag = false;
4476 header.public_header.version_flag = false; 4485 header.public_header.version_flag = false;
4477 header.fec_flag = false; 4486 header.fec_flag = false;
4478 header.entropy_flag = false; 4487 header.entropy_flag = false;
4479 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4488 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4480 header.fec_group = 0; 4489 header.fec_group = 0;
4481 4490
4482 QuicCongestionFeedbackFrame congestion_feedback_frame; 4491 QuicCongestionFeedbackFrame congestion_feedback_frame;
4483 congestion_feedback_frame.type = kFixRate; 4492 congestion_feedback_frame.type = kFixRate;
4484 congestion_feedback_frame.fix_rate.bitrate 4493 congestion_feedback_frame.fix_rate.bitrate
4485 = QuicBandwidth::FromBytesPerSecond(0x04030201); 4494 = QuicBandwidth::FromBytesPerSecond(0x04030201);
4486 4495
4487 QuicFrames frames; 4496 QuicFrames frames;
4488 frames.push_back(QuicFrame(&congestion_feedback_frame)); 4497 frames.push_back(QuicFrame(&congestion_feedback_frame));
4489 4498
4490 unsigned char packet[] = { 4499 unsigned char packet[] = {
4491 // public flags (8 byte guid) 4500 // public flags (8 byte connection_id)
4492 0x3C, 4501 0x3C,
4493 // guid 4502 // connection_id
4494 0x10, 0x32, 0x54, 0x76, 4503 0x10, 0x32, 0x54, 0x76,
4495 0x98, 0xBA, 0xDC, 0xFE, 4504 0x98, 0xBA, 0xDC, 0xFE,
4496 // packet sequence number 4505 // packet sequence number
4497 0xBC, 0x9A, 0x78, 0x56, 4506 0xBC, 0x9A, 0x78, 0x56,
4498 0x34, 0x12, 4507 0x34, 0x12,
4499 // private flags 4508 // private flags
4500 0x00, 4509 0x00,
4501 4510
4502 // frame type (congestion feedback frame) 4511 // frame type (congestion feedback frame)
4503 0x20, 4512 0x20,
4504 // congestion feedback type (fix rate) 4513 // congestion feedback type (fix rate)
4505 0x02, 4514 0x02,
4506 // bitrate_in_bytes_per_second; 4515 // bitrate_in_bytes_per_second;
4507 0x01, 0x02, 0x03, 0x04, 4516 0x01, 0x02, 0x03, 0x04,
4508 }; 4517 };
4509 4518
4510 scoped_ptr<QuicPacket> data( 4519 scoped_ptr<QuicPacket> data(
4511 framer_.BuildUnsizedDataPacket(header, frames).packet); 4520 framer_.BuildUnsizedDataPacket(header, frames).packet);
4512 ASSERT_TRUE(data != NULL); 4521 ASSERT_TRUE(data != NULL);
4513 4522
4514 test::CompareCharArraysWithHexError("constructed packet", 4523 test::CompareCharArraysWithHexError("constructed packet",
4515 data->data(), data->length(), 4524 data->data(), data->length(),
4516 AsChars(packet), arraysize(packet)); 4525 AsChars(packet), arraysize(packet));
4517 } 4526 }
4518 4527
4519 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInvalidFeedback) { 4528 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInvalidFeedback) {
4520 QuicPacketHeader header; 4529 QuicPacketHeader header;
4521 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4530 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4522 header.public_header.reset_flag = false; 4531 header.public_header.reset_flag = false;
4523 header.public_header.version_flag = false; 4532 header.public_header.version_flag = false;
4524 header.fec_flag = false; 4533 header.fec_flag = false;
4525 header.entropy_flag = false; 4534 header.entropy_flag = false;
4526 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4535 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4527 header.fec_group = 0; 4536 header.fec_group = 0;
4528 4537
4529 QuicCongestionFeedbackFrame congestion_feedback_frame; 4538 QuicCongestionFeedbackFrame congestion_feedback_frame;
4530 congestion_feedback_frame.type = 4539 congestion_feedback_frame.type =
4531 static_cast<CongestionFeedbackType>(kFixRate + 1); 4540 static_cast<CongestionFeedbackType>(kFixRate + 1);
4532 4541
4533 QuicFrames frames; 4542 QuicFrames frames;
4534 frames.push_back(QuicFrame(&congestion_feedback_frame)); 4543 frames.push_back(QuicFrame(&congestion_feedback_frame));
4535 4544
4536 scoped_ptr<QuicPacket> data; 4545 scoped_ptr<QuicPacket> data;
4537 EXPECT_DFATAL( 4546 EXPECT_DFATAL(
4538 data.reset(framer_.BuildUnsizedDataPacket(header, frames).packet), 4547 data.reset(framer_.BuildUnsizedDataPacket(header, frames).packet),
4539 "AppendCongestionFeedbackFrame failed"); 4548 "AppendCongestionFeedbackFrame failed");
4540 ASSERT_TRUE(data == NULL); 4549 ASSERT_TRUE(data == NULL);
4541 } 4550 }
4542 4551
4543 TEST_P(QuicFramerTest, BuildRstFramePacketVersion13) { 4552 TEST_P(QuicFramerTest, BuildRstFramePacketVersion13) {
4544 if (version_ > QUIC_VERSION_13) { 4553 if (version_ > QUIC_VERSION_13) {
4545 return; 4554 return;
4546 } 4555 }
4547 4556
4548 QuicPacketHeader header; 4557 QuicPacketHeader header;
4549 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4558 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4550 header.public_header.reset_flag = false; 4559 header.public_header.reset_flag = false;
4551 header.public_header.version_flag = false; 4560 header.public_header.version_flag = false;
4552 header.fec_flag = false; 4561 header.fec_flag = false;
4553 header.entropy_flag = false; 4562 header.entropy_flag = false;
4554 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4563 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4555 header.fec_group = 0; 4564 header.fec_group = 0;
4556 4565
4557 QuicRstStreamFrame rst_frame; 4566 QuicRstStreamFrame rst_frame;
4558 rst_frame.stream_id = 0x01020304; 4567 rst_frame.stream_id = 0x01020304;
4559 rst_frame.error_code = static_cast<QuicRstStreamErrorCode>(0x05060708); 4568 rst_frame.error_code = static_cast<QuicRstStreamErrorCode>(0x05060708);
4560 rst_frame.error_details = "because I can"; 4569 rst_frame.error_details = "because I can";
4561 4570
4562 unsigned char packet[] = { 4571 unsigned char packet[] = {
4563 // public flags (8 byte guid) 4572 // public flags (8 byte connection_id)
4564 0x3C, 4573 0x3C,
4565 // guid 4574 // connection_id
4566 0x10, 0x32, 0x54, 0x76, 4575 0x10, 0x32, 0x54, 0x76,
4567 0x98, 0xBA, 0xDC, 0xFE, 4576 0x98, 0xBA, 0xDC, 0xFE,
4568 // packet sequence number 4577 // packet sequence number
4569 0xBC, 0x9A, 0x78, 0x56, 4578 0xBC, 0x9A, 0x78, 0x56,
4570 0x34, 0x12, 4579 0x34, 0x12,
4571 // private flags 4580 // private flags
4572 0x00, 4581 0x00,
4573 4582
4574 // frame type (rst stream frame) 4583 // frame type (rst stream frame)
4575 0x01, 4584 0x01,
(...skipping 21 matching lines...) Expand all
4597 data->data(), data->length(), 4606 data->data(), data->length(),
4598 AsChars(packet), arraysize(packet)); 4607 AsChars(packet), arraysize(packet));
4599 } 4608 }
4600 4609
4601 TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { 4610 TEST_P(QuicFramerTest, BuildRstFramePacketQuic) {
4602 if (version_ <= QUIC_VERSION_13) { 4611 if (version_ <= QUIC_VERSION_13) {
4603 return; 4612 return;
4604 } 4613 }
4605 4614
4606 QuicPacketHeader header; 4615 QuicPacketHeader header;
4607 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4616 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4608 header.public_header.reset_flag = false; 4617 header.public_header.reset_flag = false;
4609 header.public_header.version_flag = false; 4618 header.public_header.version_flag = false;
4610 header.fec_flag = false; 4619 header.fec_flag = false;
4611 header.entropy_flag = false; 4620 header.entropy_flag = false;
4612 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4621 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4613 header.fec_group = 0; 4622 header.fec_group = 0;
4614 4623
4615 QuicRstStreamFrame rst_frame; 4624 QuicRstStreamFrame rst_frame;
4616 rst_frame.stream_id = 0x01020304; 4625 rst_frame.stream_id = 0x01020304;
4617 rst_frame.error_code = static_cast<QuicRstStreamErrorCode>(0x05060708); 4626 rst_frame.error_code = static_cast<QuicRstStreamErrorCode>(0x05060708);
4618 rst_frame.error_details = "because I can"; 4627 rst_frame.error_details = "because I can";
4619 rst_frame.byte_offset = 0x0807060504030201; 4628 rst_frame.byte_offset = 0x0807060504030201;
4620 4629
4621 unsigned char packet[] = { 4630 unsigned char packet[] = {
4622 // public flags (8 byte guid) 4631 // public flags (8 byte connection_id)
4623 0x3C, 4632 0x3C,
4624 // guid 4633 // connection_id
4625 0x10, 0x32, 0x54, 0x76, 4634 0x10, 0x32, 0x54, 0x76,
4626 0x98, 0xBA, 0xDC, 0xFE, 4635 0x98, 0xBA, 0xDC, 0xFE,
4627 // packet sequence number 4636 // packet sequence number
4628 0xBC, 0x9A, 0x78, 0x56, 4637 0xBC, 0x9A, 0x78, 0x56,
4629 0x34, 0x12, 4638 0x34, 0x12,
4630 // private flags 4639 // private flags
4631 0x00, 4640 0x00,
4632 4641
4633 // frame type (rst stream frame) 4642 // frame type (rst stream frame)
4634 0x01, 4643 0x01,
(...skipping 20 matching lines...) Expand all
4655 framer_.BuildUnsizedDataPacket(header, frames).packet); 4664 framer_.BuildUnsizedDataPacket(header, frames).packet);
4656 ASSERT_TRUE(data != NULL); 4665 ASSERT_TRUE(data != NULL);
4657 4666
4658 test::CompareCharArraysWithHexError("constructed packet", 4667 test::CompareCharArraysWithHexError("constructed packet",
4659 data->data(), data->length(), 4668 data->data(), data->length(),
4660 AsChars(packet), arraysize(packet)); 4669 AsChars(packet), arraysize(packet));
4661 } 4670 }
4662 4671
4663 TEST_P(QuicFramerTest, BuildCloseFramePacket) { 4672 TEST_P(QuicFramerTest, BuildCloseFramePacket) {
4664 QuicPacketHeader header; 4673 QuicPacketHeader header;
4665 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4674 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4666 header.public_header.reset_flag = false; 4675 header.public_header.reset_flag = false;
4667 header.public_header.version_flag = false; 4676 header.public_header.version_flag = false;
4668 header.fec_flag = false; 4677 header.fec_flag = false;
4669 header.entropy_flag = true; 4678 header.entropy_flag = true;
4670 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4679 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4671 header.fec_group = 0; 4680 header.fec_group = 0;
4672 4681
4673 QuicConnectionCloseFrame close_frame; 4682 QuicConnectionCloseFrame close_frame;
4674 close_frame.error_code = static_cast<QuicErrorCode>(0x05060708); 4683 close_frame.error_code = static_cast<QuicErrorCode>(0x05060708);
4675 close_frame.error_details = "because I can"; 4684 close_frame.error_details = "because I can";
4676 4685
4677 QuicFrames frames; 4686 QuicFrames frames;
4678 frames.push_back(QuicFrame(&close_frame)); 4687 frames.push_back(QuicFrame(&close_frame));
4679 4688
4680 unsigned char packet[] = { 4689 unsigned char packet[] = {
4681 // public flags (8 byte guid) 4690 // public flags (8 byte connection_id)
4682 0x3C, 4691 0x3C,
4683 // guid 4692 // connection_id
4684 0x10, 0x32, 0x54, 0x76, 4693 0x10, 0x32, 0x54, 0x76,
4685 0x98, 0xBA, 0xDC, 0xFE, 4694 0x98, 0xBA, 0xDC, 0xFE,
4686 // packet sequence number 4695 // packet sequence number
4687 0xBC, 0x9A, 0x78, 0x56, 4696 0xBC, 0x9A, 0x78, 0x56,
4688 0x34, 0x12, 4697 0x34, 0x12,
4689 // private flags (entropy) 4698 // private flags (entropy)
4690 0x01, 4699 0x01,
4691 4700
4692 // frame type (connection close frame) 4701 // frame type (connection close frame)
4693 0x02, 4702 0x02,
(...skipping 12 matching lines...) Expand all
4706 framer_.BuildUnsizedDataPacket(header, frames).packet); 4715 framer_.BuildUnsizedDataPacket(header, frames).packet);
4707 ASSERT_TRUE(data != NULL); 4716 ASSERT_TRUE(data != NULL);
4708 4717
4709 test::CompareCharArraysWithHexError("constructed packet", 4718 test::CompareCharArraysWithHexError("constructed packet",
4710 data->data(), data->length(), 4719 data->data(), data->length(),
4711 AsChars(packet), arraysize(packet)); 4720 AsChars(packet), arraysize(packet));
4712 } 4721 }
4713 4722
4714 TEST_P(QuicFramerTest, BuildGoAwayPacket) { 4723 TEST_P(QuicFramerTest, BuildGoAwayPacket) {
4715 QuicPacketHeader header; 4724 QuicPacketHeader header;
4716 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4725 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4717 header.public_header.reset_flag = false; 4726 header.public_header.reset_flag = false;
4718 header.public_header.version_flag = false; 4727 header.public_header.version_flag = false;
4719 header.fec_flag = false; 4728 header.fec_flag = false;
4720 header.entropy_flag = true; 4729 header.entropy_flag = true;
4721 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4730 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4722 header.fec_group = 0; 4731 header.fec_group = 0;
4723 4732
4724 QuicGoAwayFrame goaway_frame; 4733 QuicGoAwayFrame goaway_frame;
4725 goaway_frame.error_code = static_cast<QuicErrorCode>(0x05060708); 4734 goaway_frame.error_code = static_cast<QuicErrorCode>(0x05060708);
4726 goaway_frame.last_good_stream_id = 0x01020304; 4735 goaway_frame.last_good_stream_id = 0x01020304;
4727 goaway_frame.reason_phrase = "because I can"; 4736 goaway_frame.reason_phrase = "because I can";
4728 4737
4729 QuicFrames frames; 4738 QuicFrames frames;
4730 frames.push_back(QuicFrame(&goaway_frame)); 4739 frames.push_back(QuicFrame(&goaway_frame));
4731 4740
4732 unsigned char packet[] = { 4741 unsigned char packet[] = {
4733 // public flags (8 byte guid) 4742 // public flags (8 byte connection_id)
4734 0x3C, 4743 0x3C,
4735 // guid 4744 // connection_id
4736 0x10, 0x32, 0x54, 0x76, 4745 0x10, 0x32, 0x54, 0x76,
4737 0x98, 0xBA, 0xDC, 0xFE, 4746 0x98, 0xBA, 0xDC, 0xFE,
4738 // packet sequence number 4747 // packet sequence number
4739 0xBC, 0x9A, 0x78, 0x56, 4748 0xBC, 0x9A, 0x78, 0x56,
4740 0x34, 0x12, 4749 0x34, 0x12,
4741 // private flags(entropy) 4750 // private flags(entropy)
4742 0x01, 4751 0x01,
4743 4752
4744 // frame type (go away frame) 4753 // frame type (go away frame)
4745 0x03, 4754 0x03,
(...skipping 14 matching lines...) Expand all
4760 framer_.BuildUnsizedDataPacket(header, frames).packet); 4769 framer_.BuildUnsizedDataPacket(header, frames).packet);
4761 ASSERT_TRUE(data != NULL); 4770 ASSERT_TRUE(data != NULL);
4762 4771
4763 test::CompareCharArraysWithHexError("constructed packet", 4772 test::CompareCharArraysWithHexError("constructed packet",
4764 data->data(), data->length(), 4773 data->data(), data->length(),
4765 AsChars(packet), arraysize(packet)); 4774 AsChars(packet), arraysize(packet));
4766 } 4775 }
4767 4776
4768 TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { 4777 TEST_P(QuicFramerTest, BuildWindowUpdatePacket) {
4769 QuicPacketHeader header; 4778 QuicPacketHeader header;
4770 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4779 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4771 header.public_header.reset_flag = false; 4780 header.public_header.reset_flag = false;
4772 header.public_header.version_flag = false; 4781 header.public_header.version_flag = false;
4773 header.fec_flag = false; 4782 header.fec_flag = false;
4774 header.entropy_flag = true; 4783 header.entropy_flag = true;
4775 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4784 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4776 header.fec_group = 0; 4785 header.fec_group = 0;
4777 4786
4778 QuicWindowUpdateFrame window_update_frame; 4787 QuicWindowUpdateFrame window_update_frame;
4779 window_update_frame.stream_id = 0x01020304; 4788 window_update_frame.stream_id = 0x01020304;
4780 window_update_frame.byte_offset = 0x1122334455667788; 4789 window_update_frame.byte_offset = 0x1122334455667788;
4781 4790
4782 QuicFrames frames; 4791 QuicFrames frames;
4783 frames.push_back(QuicFrame(&window_update_frame)); 4792 frames.push_back(QuicFrame(&window_update_frame));
4784 4793
4785 unsigned char packet[] = { 4794 unsigned char packet[] = {
4786 // public flags (8 byte guid) 4795 // public flags (8 byte connection_id)
4787 0x3C, 4796 0x3C,
4788 // guid 4797 // connection_id
4789 0x10, 0x32, 0x54, 0x76, 4798 0x10, 0x32, 0x54, 0x76,
4790 0x98, 0xBA, 0xDC, 0xFE, 4799 0x98, 0xBA, 0xDC, 0xFE,
4791 // packet sequence number 4800 // packet sequence number
4792 0xBC, 0x9A, 0x78, 0x56, 4801 0xBC, 0x9A, 0x78, 0x56,
4793 0x34, 0x12, 4802 0x34, 0x12,
4794 // private flags(entropy) 4803 // private flags(entropy)
4795 0x01, 4804 0x01,
4796 4805
4797 // frame type (window update frame) 4806 // frame type (window update frame)
4798 0x04, 4807 0x04,
(...skipping 16 matching lines...) Expand all
4815 string expected_error = "Attempt to add a WindowUpdateFrame in " + 4824 string expected_error = "Attempt to add a WindowUpdateFrame in " +
4816 QuicVersionToString(version_); 4825 QuicVersionToString(version_);
4817 EXPECT_DFATAL(framer_.BuildUnsizedDataPacket(header, frames), 4826 EXPECT_DFATAL(framer_.BuildUnsizedDataPacket(header, frames),
4818 expected_error); 4827 expected_error);
4819 return; 4828 return;
4820 } 4829 }
4821 } 4830 }
4822 4831
4823 TEST_P(QuicFramerTest, BuildBlockedPacket) { 4832 TEST_P(QuicFramerTest, BuildBlockedPacket) {
4824 QuicPacketHeader header; 4833 QuicPacketHeader header;
4825 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4834 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4826 header.public_header.reset_flag = false; 4835 header.public_header.reset_flag = false;
4827 header.public_header.version_flag = false; 4836 header.public_header.version_flag = false;
4828 header.fec_flag = false; 4837 header.fec_flag = false;
4829 header.entropy_flag = true; 4838 header.entropy_flag = true;
4830 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4839 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4831 header.fec_group = 0; 4840 header.fec_group = 0;
4832 4841
4833 QuicBlockedFrame blocked_frame; 4842 QuicBlockedFrame blocked_frame;
4834 blocked_frame.stream_id = 0x01020304; 4843 blocked_frame.stream_id = 0x01020304;
4835 4844
4836 QuicFrames frames; 4845 QuicFrames frames;
4837 frames.push_back(QuicFrame(&blocked_frame)); 4846 frames.push_back(QuicFrame(&blocked_frame));
4838 4847
4839 unsigned char packet[] = { 4848 unsigned char packet[] = {
4840 // public flags (8 byte guid) 4849 // public flags (8 byte connection_id)
4841 0x3C, 4850 0x3C,
4842 // guid 4851 // connection_id
4843 0x10, 0x32, 0x54, 0x76, 4852 0x10, 0x32, 0x54, 0x76,
4844 0x98, 0xBA, 0xDC, 0xFE, 4853 0x98, 0xBA, 0xDC, 0xFE,
4845 // packet sequence number 4854 // packet sequence number
4846 0xBC, 0x9A, 0x78, 0x56, 4855 0xBC, 0x9A, 0x78, 0x56,
4847 0x34, 0x12, 4856 0x34, 0x12,
4848 // private flags(entropy) 4857 // private flags(entropy)
4849 0x01, 4858 0x01,
4850 4859
4851 // frame type (blocked frame) 4860 // frame type (blocked frame)
4852 0x05, 4861 0x05,
(...skipping 13 matching lines...) Expand all
4866 string expected_error = 4875 string expected_error =
4867 "Attempt to add a BlockedFrame in " + QuicVersionToString(version_); 4876 "Attempt to add a BlockedFrame in " + QuicVersionToString(version_);
4868 EXPECT_DFATAL(framer_.BuildUnsizedDataPacket(header, frames), 4877 EXPECT_DFATAL(framer_.BuildUnsizedDataPacket(header, frames),
4869 expected_error); 4878 expected_error);
4870 return; 4879 return;
4871 } 4880 }
4872 } 4881 }
4873 4882
4874 TEST_P(QuicFramerTest, BuildPublicResetPacket) { 4883 TEST_P(QuicFramerTest, BuildPublicResetPacket) {
4875 QuicPublicResetPacket reset_packet; 4884 QuicPublicResetPacket reset_packet;
4876 reset_packet.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4885 reset_packet.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4877 reset_packet.public_header.reset_flag = true; 4886 reset_packet.public_header.reset_flag = true;
4878 reset_packet.public_header.version_flag = false; 4887 reset_packet.public_header.version_flag = false;
4879 reset_packet.rejected_sequence_number = GG_UINT64_C(0x123456789ABC); 4888 reset_packet.rejected_sequence_number = GG_UINT64_C(0x123456789ABC);
4880 reset_packet.nonce_proof = GG_UINT64_C(0xABCDEF0123456789); 4889 reset_packet.nonce_proof = GG_UINT64_C(0xABCDEF0123456789);
4881 4890
4882 unsigned char packet[] = { 4891 unsigned char packet[] = {
4883 // public flags (public reset, 8 byte GUID) 4892 // public flags (public reset, 8 byte ConnectionId)
4884 0x0E, 4893 0x0E,
4885 // guid 4894 // connection_id
4886 0x10, 0x32, 0x54, 0x76, 4895 0x10, 0x32, 0x54, 0x76,
4887 0x98, 0xBA, 0xDC, 0xFE, 4896 0x98, 0xBA, 0xDC, 0xFE,
4888 // message tag (kPRST) 4897 // message tag (kPRST)
4889 'P', 'R', 'S', 'T', 4898 'P', 'R', 'S', 'T',
4890 // num_entries (2) + padding 4899 // num_entries (2) + padding
4891 0x02, 0x00, 0x00, 0x00, 4900 0x02, 0x00, 0x00, 0x00,
4892 // tag kRNON 4901 // tag kRNON
4893 'R', 'N', 'O', 'N', 4902 'R', 'N', 'O', 'N',
4894 // end offset 8 4903 // end offset 8
4895 0x08, 0x00, 0x00, 0x00, 4904 0x08, 0x00, 0x00, 0x00,
(...skipping 13 matching lines...) Expand all
4909 framer_.BuildPublicResetPacket(reset_packet)); 4918 framer_.BuildPublicResetPacket(reset_packet));
4910 ASSERT_TRUE(data != NULL); 4919 ASSERT_TRUE(data != NULL);
4911 4920
4912 test::CompareCharArraysWithHexError("constructed packet", 4921 test::CompareCharArraysWithHexError("constructed packet",
4913 data->data(), data->length(), 4922 data->data(), data->length(),
4914 AsChars(packet), arraysize(packet)); 4923 AsChars(packet), arraysize(packet));
4915 } 4924 }
4916 4925
4917 TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { 4926 TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) {
4918 QuicPublicResetPacket reset_packet; 4927 QuicPublicResetPacket reset_packet;
4919 reset_packet.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4928 reset_packet.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4920 reset_packet.public_header.reset_flag = true; 4929 reset_packet.public_header.reset_flag = true;
4921 reset_packet.public_header.version_flag = false; 4930 reset_packet.public_header.version_flag = false;
4922 reset_packet.rejected_sequence_number = GG_UINT64_C(0x123456789ABC); 4931 reset_packet.rejected_sequence_number = GG_UINT64_C(0x123456789ABC);
4923 reset_packet.nonce_proof = GG_UINT64_C(0xABCDEF0123456789); 4932 reset_packet.nonce_proof = GG_UINT64_C(0xABCDEF0123456789);
4924 reset_packet.client_address = IPEndPoint(Loopback4(), 0x1234); 4933 reset_packet.client_address = IPEndPoint(Loopback4(), 0x1234);
4925 4934
4926 unsigned char packet[] = { 4935 unsigned char packet[] = {
4927 // public flags (public reset, 8 byte GUID) 4936 // public flags (public reset, 8 byte ConnectionId)
4928 0x0E, 4937 0x0E,
4929 // guid 4938 // connection_id
4930 0x10, 0x32, 0x54, 0x76, 4939 0x10, 0x32, 0x54, 0x76,
4931 0x98, 0xBA, 0xDC, 0xFE, 4940 0x98, 0xBA, 0xDC, 0xFE,
4932 // message tag (kPRST) 4941 // message tag (kPRST)
4933 'P', 'R', 'S', 'T', 4942 'P', 'R', 'S', 'T',
4934 // num_entries (3) + padding 4943 // num_entries (3) + padding
4935 0x03, 0x00, 0x00, 0x00, 4944 0x03, 0x00, 0x00, 0x00,
4936 // tag kRNON 4945 // tag kRNON
4937 'R', 'N', 'O', 'N', 4946 'R', 'N', 'O', 'N',
4938 // end offset 8 4947 // end offset 8
4939 0x08, 0x00, 0x00, 0x00, 4948 0x08, 0x00, 0x00, 0x00,
(...skipping 21 matching lines...) Expand all
4961 framer_.BuildPublicResetPacket(reset_packet)); 4970 framer_.BuildPublicResetPacket(reset_packet));
4962 ASSERT_TRUE(data != NULL); 4971 ASSERT_TRUE(data != NULL);
4963 4972
4964 test::CompareCharArraysWithHexError("constructed packet", 4973 test::CompareCharArraysWithHexError("constructed packet",
4965 data->data(), data->length(), 4974 data->data(), data->length(),
4966 AsChars(packet), arraysize(packet)); 4975 AsChars(packet), arraysize(packet));
4967 } 4976 }
4968 4977
4969 TEST_P(QuicFramerTest, BuildFecPacket) { 4978 TEST_P(QuicFramerTest, BuildFecPacket) {
4970 QuicPacketHeader header; 4979 QuicPacketHeader header;
4971 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 4980 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4972 header.public_header.reset_flag = false; 4981 header.public_header.reset_flag = false;
4973 header.public_header.version_flag = false; 4982 header.public_header.version_flag = false;
4974 header.fec_flag = true; 4983 header.fec_flag = true;
4975 header.entropy_flag = true; 4984 header.entropy_flag = true;
4976 header.packet_sequence_number = (GG_UINT64_C(0x123456789ABC)); 4985 header.packet_sequence_number = (GG_UINT64_C(0x123456789ABC));
4977 header.is_in_fec_group = IN_FEC_GROUP; 4986 header.is_in_fec_group = IN_FEC_GROUP;
4978 header.fec_group = GG_UINT64_C(0x123456789ABB);; 4987 header.fec_group = GG_UINT64_C(0x123456789ABB);;
4979 4988
4980 QuicFecData fec_data; 4989 QuicFecData fec_data;
4981 fec_data.fec_group = 1; 4990 fec_data.fec_group = 1;
4982 fec_data.redundancy = "abcdefghijklmnop"; 4991 fec_data.redundancy = "abcdefghijklmnop";
4983 4992
4984 unsigned char packet[] = { 4993 unsigned char packet[] = {
4985 // public flags (8 byte guid) 4994 // public flags (8 byte connection_id)
4986 0x3C, 4995 0x3C,
4987 // guid 4996 // connection_id
4988 0x10, 0x32, 0x54, 0x76, 4997 0x10, 0x32, 0x54, 0x76,
4989 0x98, 0xBA, 0xDC, 0xFE, 4998 0x98, 0xBA, 0xDC, 0xFE,
4990 // packet sequence number 4999 // packet sequence number
4991 0xBC, 0x9A, 0x78, 0x56, 5000 0xBC, 0x9A, 0x78, 0x56,
4992 0x34, 0x12, 5001 0x34, 0x12,
4993 // private flags (entropy & fec group & fec packet) 5002 // private flags (entropy & fec group & fec packet)
4994 0x07, 5003 0x07,
4995 // first fec protected packet offset 5004 // first fec protected packet offset
4996 0x01, 5005 0x01,
4997 5006
4998 // redundancy 5007 // redundancy
4999 'a', 'b', 'c', 'd', 5008 'a', 'b', 'c', 'd',
5000 'e', 'f', 'g', 'h', 5009 'e', 'f', 'g', 'h',
5001 'i', 'j', 'k', 'l', 5010 'i', 'j', 'k', 'l',
5002 'm', 'n', 'o', 'p', 5011 'm', 'n', 'o', 'p',
5003 }; 5012 };
5004 5013
5005 scoped_ptr<QuicPacket> data( 5014 scoped_ptr<QuicPacket> data(
5006 framer_.BuildFecPacket(header, fec_data).packet); 5015 framer_.BuildFecPacket(header, fec_data).packet);
5007 ASSERT_TRUE(data != NULL); 5016 ASSERT_TRUE(data != NULL);
5008 5017
5009 test::CompareCharArraysWithHexError("constructed packet", 5018 test::CompareCharArraysWithHexError("constructed packet",
5010 data->data(), data->length(), 5019 data->data(), data->length(),
5011 AsChars(packet), arraysize(packet)); 5020 AsChars(packet), arraysize(packet));
5012 } 5021 }
5013 5022
5014 TEST_P(QuicFramerTest, EncryptPacket) { 5023 TEST_P(QuicFramerTest, EncryptPacket) {
5015 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC); 5024 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC);
5016 unsigned char packet[] = { 5025 unsigned char packet[] = {
5017 // public flags (8 byte guid) 5026 // public flags (8 byte connection_id)
5018 0x3C, 5027 0x3C,
5019 // guid 5028 // connection_id
5020 0x10, 0x32, 0x54, 0x76, 5029 0x10, 0x32, 0x54, 0x76,
5021 0x98, 0xBA, 0xDC, 0xFE, 5030 0x98, 0xBA, 0xDC, 0xFE,
5022 // packet sequence number 5031 // packet sequence number
5023 0xBC, 0x9A, 0x78, 0x56, 5032 0xBC, 0x9A, 0x78, 0x56,
5024 0x34, 0x12, 5033 0x34, 0x12,
5025 // private flags (fec group & fec packet) 5034 // private flags (fec group & fec packet)
5026 0x06, 5035 0x06,
5027 // first fec protected packet offset 5036 // first fec protected packet offset
5028 0x01, 5037 0x01,
5029 5038
5030 // redundancy 5039 // redundancy
5031 'a', 'b', 'c', 'd', 5040 'a', 'b', 'c', 'd',
5032 'e', 'f', 'g', 'h', 5041 'e', 'f', 'g', 'h',
5033 'i', 'j', 'k', 'l', 5042 'i', 'j', 'k', 'l',
5034 'm', 'n', 'o', 'p', 5043 'm', 'n', 'o', 'p',
5035 }; 5044 };
5036 5045
5037 scoped_ptr<QuicPacket> raw( 5046 scoped_ptr<QuicPacket> raw(
5038 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false, 5047 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false,
5039 PACKET_8BYTE_GUID, !kIncludeVersion, 5048 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
5040 PACKET_6BYTE_SEQUENCE_NUMBER)); 5049 PACKET_6BYTE_SEQUENCE_NUMBER));
5041 scoped_ptr<QuicEncryptedPacket> encrypted( 5050 scoped_ptr<QuicEncryptedPacket> encrypted(
5042 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw)); 5051 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw));
5043 5052
5044 ASSERT_TRUE(encrypted.get() != NULL); 5053 ASSERT_TRUE(encrypted.get() != NULL);
5045 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get())); 5054 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get()));
5046 } 5055 }
5047 5056
5048 TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) { 5057 TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) {
5049 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC); 5058 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC);
5050 unsigned char packet[] = { 5059 unsigned char packet[] = {
5051 // public flags (version, 8 byte guid) 5060 // public flags (version, 8 byte connection_id)
5052 0x3D, 5061 0x3D,
5053 // guid 5062 // connection_id
5054 0x10, 0x32, 0x54, 0x76, 5063 0x10, 0x32, 0x54, 0x76,
5055 0x98, 0xBA, 0xDC, 0xFE, 5064 0x98, 0xBA, 0xDC, 0xFE,
5056 // version tag 5065 // version tag
5057 'Q', '.', '1', '0', 5066 'Q', '.', '1', '0',
5058 // packet sequence number 5067 // packet sequence number
5059 0xBC, 0x9A, 0x78, 0x56, 5068 0xBC, 0x9A, 0x78, 0x56,
5060 0x34, 0x12, 5069 0x34, 0x12,
5061 // private flags (fec group & fec flags) 5070 // private flags (fec group & fec flags)
5062 0x06, 5071 0x06,
5063 // first fec protected packet offset 5072 // first fec protected packet offset
5064 0x01, 5073 0x01,
5065 5074
5066 // redundancy 5075 // redundancy
5067 'a', 'b', 'c', 'd', 5076 'a', 'b', 'c', 'd',
5068 'e', 'f', 'g', 'h', 5077 'e', 'f', 'g', 'h',
5069 'i', 'j', 'k', 'l', 5078 'i', 'j', 'k', 'l',
5070 'm', 'n', 'o', 'p', 5079 'm', 'n', 'o', 'p',
5071 }; 5080 };
5072 5081
5073 scoped_ptr<QuicPacket> raw( 5082 scoped_ptr<QuicPacket> raw(
5074 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false, 5083 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false,
5075 PACKET_8BYTE_GUID, kIncludeVersion, 5084 PACKET_8BYTE_CONNECTION_ID, kIncludeVersion,
5076 PACKET_6BYTE_SEQUENCE_NUMBER)); 5085 PACKET_6BYTE_SEQUENCE_NUMBER));
5077 scoped_ptr<QuicEncryptedPacket> encrypted( 5086 scoped_ptr<QuicEncryptedPacket> encrypted(
5078 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw)); 5087 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw));
5079 5088
5080 ASSERT_TRUE(encrypted.get() != NULL); 5089 ASSERT_TRUE(encrypted.get() != NULL);
5081 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get())); 5090 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get()));
5082 } 5091 }
5083 5092
5084 TEST_P(QuicFramerTest, Truncation) { 5093 TEST_P(QuicFramerTest, Truncation) {
5085 if (framer_.version() <= QUIC_VERSION_15) { 5094 if (framer_.version() <= QUIC_VERSION_15) {
5086 return; 5095 return;
5087 } 5096 }
5088 QuicPacketHeader header; 5097 QuicPacketHeader header;
5089 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 5098 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
5090 header.public_header.reset_flag = false; 5099 header.public_header.reset_flag = false;
5091 header.public_header.version_flag = false; 5100 header.public_header.version_flag = false;
5092 header.fec_flag = false; 5101 header.fec_flag = false;
5093 header.entropy_flag = false; 5102 header.entropy_flag = false;
5094 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 5103 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
5095 header.fec_group = 0; 5104 header.fec_group = 0;
5096 5105
5097 QuicAckFrame ack_frame; 5106 QuicAckFrame ack_frame;
5098 ack_frame.received_info.largest_observed = 601; 5107 ack_frame.received_info.largest_observed = 601;
5099 for (uint64 i = 1; i < ack_frame.received_info.largest_observed; i += 2) { 5108 for (uint64 i = 1; i < ack_frame.received_info.largest_observed; i += 2) {
(...skipping 28 matching lines...) Expand all
5128 SequenceNumberSet::const_reverse_iterator last_missing_iter = 5137 SequenceNumberSet::const_reverse_iterator last_missing_iter =
5129 processed_ack_frame.received_info.missing_packets.rbegin(); 5138 processed_ack_frame.received_info.missing_packets.rbegin();
5130 EXPECT_EQ(509u, *last_missing_iter); 5139 EXPECT_EQ(509u, *last_missing_iter);
5131 } 5140 }
5132 5141
5133 TEST_P(QuicFramerTest, Truncation15) { 5142 TEST_P(QuicFramerTest, Truncation15) {
5134 if (framer_.version() > QUIC_VERSION_15) { 5143 if (framer_.version() > QUIC_VERSION_15) {
5135 return; 5144 return;
5136 } 5145 }
5137 QuicPacketHeader header; 5146 QuicPacketHeader header;
5138 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 5147 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
5139 header.public_header.reset_flag = false; 5148 header.public_header.reset_flag = false;
5140 header.public_header.version_flag = false; 5149 header.public_header.version_flag = false;
5141 header.fec_flag = false; 5150 header.fec_flag = false;
5142 header.entropy_flag = false; 5151 header.entropy_flag = false;
5143 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 5152 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
5144 header.fec_group = 0; 5153 header.fec_group = 0;
5145 5154
5146 QuicAckFrame ack_frame; 5155 QuicAckFrame ack_frame;
5147 ack_frame.received_info.largest_observed = 601; 5156 ack_frame.received_info.largest_observed = 601;
5148 ack_frame.sent_info.least_unacked = header.packet_sequence_number - 1; 5157 ack_frame.sent_info.least_unacked = header.packet_sequence_number - 1;
(...skipping 28 matching lines...) Expand all
5177 SequenceNumberSet::const_iterator missing_iter = 5186 SequenceNumberSet::const_iterator missing_iter =
5178 processed_ack_frame.received_info.missing_packets.begin(); 5187 processed_ack_frame.received_info.missing_packets.begin();
5179 EXPECT_EQ(1u, *missing_iter); 5188 EXPECT_EQ(1u, *missing_iter);
5180 SequenceNumberSet::const_reverse_iterator last_missing_iter = 5189 SequenceNumberSet::const_reverse_iterator last_missing_iter =
5181 processed_ack_frame.received_info.missing_packets.rbegin(); 5190 processed_ack_frame.received_info.missing_packets.rbegin();
5182 EXPECT_EQ(509u, *last_missing_iter); 5191 EXPECT_EQ(509u, *last_missing_iter);
5183 } 5192 }
5184 5193
5185 TEST_P(QuicFramerTest, CleanTruncation) { 5194 TEST_P(QuicFramerTest, CleanTruncation) {
5186 QuicPacketHeader header; 5195 QuicPacketHeader header;
5187 header.public_header.guid = GG_UINT64_C(0xFEDCBA9876543210); 5196 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
5188 header.public_header.reset_flag = false; 5197 header.public_header.reset_flag = false;
5189 header.public_header.version_flag = false; 5198 header.public_header.version_flag = false;
5190 header.fec_flag = false; 5199 header.fec_flag = false;
5191 header.entropy_flag = true; 5200 header.entropy_flag = true;
5192 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 5201 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
5193 header.fec_group = 0; 5202 header.fec_group = 0;
5194 5203
5195 QuicAckFrame ack_frame; 5204 QuicAckFrame ack_frame;
5196 ack_frame.received_info.largest_observed = 201; 5205 ack_frame.received_info.largest_observed = 201;
5197 ack_frame.sent_info.least_unacked = header.packet_sequence_number - 2; 5206 ack_frame.sent_info.least_unacked = header.packet_sequence_number - 2;
(...skipping 29 matching lines...) Expand all
5227 size_t original_raw_length = raw_ack_packet->length(); 5236 size_t original_raw_length = raw_ack_packet->length();
5228 raw_ack_packet.reset( 5237 raw_ack_packet.reset(
5229 framer_.BuildUnsizedDataPacket(header, frames).packet); 5238 framer_.BuildUnsizedDataPacket(header, frames).packet);
5230 ASSERT_TRUE(raw_ack_packet != NULL); 5239 ASSERT_TRUE(raw_ack_packet != NULL);
5231 EXPECT_EQ(original_raw_length, raw_ack_packet->length()); 5240 EXPECT_EQ(original_raw_length, raw_ack_packet->length());
5232 ASSERT_TRUE(raw_ack_packet != NULL); 5241 ASSERT_TRUE(raw_ack_packet != NULL);
5233 } 5242 }
5234 5243
5235 TEST_P(QuicFramerTest, EntropyFlagTest) { 5244 TEST_P(QuicFramerTest, EntropyFlagTest) {
5236 unsigned char packet[] = { 5245 unsigned char packet[] = {
5237 // public flags (8 byte guid) 5246 // public flags (8 byte connection_id)
5238 0x3C, 5247 0x3C,
5239 // guid 5248 // connection_id
5240 0x10, 0x32, 0x54, 0x76, 5249 0x10, 0x32, 0x54, 0x76,
5241 0x98, 0xBA, 0xDC, 0xFE, 5250 0x98, 0xBA, 0xDC, 0xFE,
5242 // packet sequence number 5251 // packet sequence number
5243 0xBC, 0x9A, 0x78, 0x56, 5252 0xBC, 0x9A, 0x78, 0x56,
5244 0x34, 0x12, 5253 0x34, 0x12,
5245 // private flags (Entropy) 5254 // private flags (Entropy)
5246 0x01, 5255 0x01,
5247 5256
5248 // frame type (stream frame with fin and no length) 5257 // frame type (stream frame with fin and no length)
5249 0xDF, 5258 0xDF,
(...skipping 12 matching lines...) Expand all
5262 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 5271 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
5263 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 5272 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
5264 ASSERT_TRUE(visitor_.header_.get()); 5273 ASSERT_TRUE(visitor_.header_.get());
5265 EXPECT_TRUE(visitor_.header_->entropy_flag); 5274 EXPECT_TRUE(visitor_.header_->entropy_flag);
5266 EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash); 5275 EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash);
5267 EXPECT_FALSE(visitor_.header_->fec_flag); 5276 EXPECT_FALSE(visitor_.header_->fec_flag);
5268 }; 5277 };
5269 5278
5270 TEST_P(QuicFramerTest, FecEntropyTest) { 5279 TEST_P(QuicFramerTest, FecEntropyTest) {
5271 unsigned char packet[] = { 5280 unsigned char packet[] = {
5272 // public flags (8 byte guid) 5281 // public flags (8 byte connection_id)
5273 0x3C, 5282 0x3C,
5274 // guid 5283 // connection_id
5275 0x10, 0x32, 0x54, 0x76, 5284 0x10, 0x32, 0x54, 0x76,
5276 0x98, 0xBA, 0xDC, 0xFE, 5285 0x98, 0xBA, 0xDC, 0xFE,
5277 // packet sequence number 5286 // packet sequence number
5278 0xBC, 0x9A, 0x78, 0x56, 5287 0xBC, 0x9A, 0x78, 0x56,
5279 0x34, 0x12, 5288 0x34, 0x12,
5280 // private flags (Entropy & fec group & FEC) 5289 // private flags (Entropy & fec group & FEC)
5281 0x07, 5290 0x07,
5282 // first fec protected packet offset 5291 // first fec protected packet offset
5283 0xFF, 5292 0xFF,
5284 5293
(...skipping 14 matching lines...) Expand all
5299 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 5308 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
5300 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 5309 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
5301 ASSERT_TRUE(visitor_.header_.get()); 5310 ASSERT_TRUE(visitor_.header_.get());
5302 EXPECT_TRUE(visitor_.header_->fec_flag); 5311 EXPECT_TRUE(visitor_.header_->fec_flag);
5303 EXPECT_TRUE(visitor_.header_->entropy_flag); 5312 EXPECT_TRUE(visitor_.header_->entropy_flag);
5304 EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash); 5313 EXPECT_EQ(1 << 4, visitor_.header_->entropy_hash);
5305 }; 5314 };
5306 5315
5307 TEST_P(QuicFramerTest, StopPacketProcessing) { 5316 TEST_P(QuicFramerTest, StopPacketProcessing) {
5308 unsigned char packet[] = { 5317 unsigned char packet[] = {
5309 // public flags (8 byte guid) 5318 // public flags (8 byte connection_id)
5310 0x3C, 5319 0x3C,
5311 // guid 5320 // connection_id
5312 0x10, 0x32, 0x54, 0x76, 5321 0x10, 0x32, 0x54, 0x76,
5313 0x98, 0xBA, 0xDC, 0xFE, 5322 0x98, 0xBA, 0xDC, 0xFE,
5314 // packet sequence number 5323 // packet sequence number
5315 0xBC, 0x9A, 0x78, 0x56, 5324 0xBC, 0x9A, 0x78, 0x56,
5316 0x34, 0x12, 5325 0x34, 0x12,
5317 // Entropy 5326 // Entropy
5318 0x01, 5327 0x01,
5319 5328
5320 // frame type (stream frame with fin) 5329 // frame type (stream frame with fin)
5321 0xFF, 5330 0xFF,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5359 EXPECT_CALL(visitor, OnPacketComplete()); 5368 EXPECT_CALL(visitor, OnPacketComplete());
5360 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); 5369 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true));
5361 5370
5362 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 5371 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
5363 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 5372 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
5364 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 5373 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
5365 } 5374 }
5366 5375
5367 } // namespace test 5376 } // namespace test
5368 } // namespace net 5377 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698