OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/core/quic_framer.h" | 5 #include "net/quic/core/quic_framer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "net/quic/test_tools/quic_test_utils.h" | 24 #include "net/quic/test_tools/quic_test_utils.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 | 26 |
27 using std::string; | 27 using std::string; |
28 using testing::Return; | 28 using testing::Return; |
29 using testing::Truly; | 29 using testing::Truly; |
30 using testing::_; | 30 using testing::_; |
31 | 31 |
32 namespace net { | 32 namespace net { |
33 namespace test { | 33 namespace test { |
| 34 namespace { |
34 | 35 |
35 const QuicPacketNumber kEpoch = UINT64_C(1) << 48; | 36 const QuicPacketNumber kEpoch = UINT64_C(1) << 48; |
36 const QuicPacketNumber kMask = kEpoch - 1; | 37 const QuicPacketNumber kMask = kEpoch - 1; |
37 | 38 |
38 // Use fields in which each byte is distinct to ensure that every byte is | 39 // Use fields in which each byte is distinct to ensure that every byte is |
39 // framed correctly. The values are otherwise arbitrary. | 40 // framed correctly. The values are otherwise arbitrary. |
40 const QuicConnectionId kConnectionId = UINT64_C(0xFEDCBA9876543210); | 41 const QuicConnectionId kConnectionId = UINT64_C(0xFEDCBA9876543210); |
41 const QuicPacketNumber kPacketNumber = UINT64_C(0x123456789ABC); | 42 const QuicPacketNumber kPacketNumber = UINT64_C(0x123456789ABC); |
42 const QuicPacketNumber kSmallLargestObserved = UINT16_C(0x1234); | 43 const QuicPacketNumber kSmallLargestObserved = UINT16_C(0x1234); |
43 const QuicPacketNumber kSmallMissingPacket = UINT16_C(0x1233); | 44 const QuicPacketNumber kSmallMissingPacket = UINT16_C(0x1233); |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 440 |
440 QuicFlagSaver flags_; // Save/restore all QUIC flag values. | 441 QuicFlagSaver flags_; // Save/restore all QUIC flag values. |
441 test::TestEncrypter* encrypter_; | 442 test::TestEncrypter* encrypter_; |
442 test::TestDecrypter* decrypter_; | 443 test::TestDecrypter* decrypter_; |
443 QuicVersion version_; | 444 QuicVersion version_; |
444 QuicTime start_; | 445 QuicTime start_; |
445 QuicFramer framer_; | 446 QuicFramer framer_; |
446 test::TestQuicVisitor visitor_; | 447 test::TestQuicVisitor visitor_; |
447 }; | 448 }; |
448 | 449 |
| 450 // Helper function to get index of packets in hex format. |
| 451 // For each packet in hex format, integers and floating numbers are in big |
| 452 // endian for v38 and up, and connection ID is in big endian according to |
| 453 // perspective and flags. |
| 454 // There are 4 combinations: |
| 455 // 0 : little endian connection ID, little endian integers/floating numbers. |
| 456 // 1 : big endian connection ID, little endian integers/floating numbers. |
| 457 // 2 : little endian connection ID, big endian integers/floating numbers. |
| 458 // 3 : big endian connection ID, big endian integers/floating numbers. |
| 459 size_t GetPacketIndex(QuicVersion version, Perspective perspective) { |
| 460 size_t index = 0; |
| 461 if (QuicUtils::IsConnectionIdWireFormatBigEndian(perspective)) { |
| 462 index = 1; |
| 463 } |
| 464 if (version > QUIC_VERSION_38) { |
| 465 index += 2; |
| 466 } |
| 467 return index; |
| 468 } |
| 469 |
449 // Run all framer tests with all supported versions of QUIC. | 470 // Run all framer tests with all supported versions of QUIC. |
450 INSTANTIATE_TEST_CASE_P(QuicFramerTests, | 471 INSTANTIATE_TEST_CASE_P(QuicFramerTests, |
451 QuicFramerTest, | 472 QuicFramerTest, |
452 ::testing::ValuesIn(kSupportedQuicVersions)); | 473 ::testing::ValuesIn(kSupportedQuicVersions)); |
453 | 474 |
454 TEST_P(QuicFramerTest, CalculatePacketNumberFromWireNearEpochStart) { | 475 TEST_P(QuicFramerTest, CalculatePacketNumberFromWireNearEpochStart) { |
455 // A few quick manual sanity checks. | 476 // A few quick manual sanity checks. |
456 CheckCalculatePacketNumber(UINT64_C(1), UINT64_C(0)); | 477 CheckCalculatePacketNumber(UINT64_C(1), UINT64_C(0)); |
457 CheckCalculatePacketNumber(kEpoch + 1, kMask); | 478 CheckCalculatePacketNumber(kEpoch + 1, kMask); |
458 CheckCalculatePacketNumber(kEpoch, kMask); | 479 CheckCalculatePacketNumber(kEpoch, kMask); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 }; | 641 }; |
621 | 642 |
622 unsigned char packet_cid_be[] = { | 643 unsigned char packet_cid_be[] = { |
623 // public flags (8 byte connection_id) | 644 // public flags (8 byte connection_id) |
624 0x38, | 645 0x38, |
625 // connection_id | 646 // connection_id |
626 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 647 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
627 // packet number | 648 // packet number |
628 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 649 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
629 }; | 650 }; |
| 651 |
| 652 unsigned char packet39[] = { |
| 653 // public flags (8 byte connection_id) |
| 654 0x38, |
| 655 // connection_id |
| 656 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 657 // packet number |
| 658 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 659 }; |
| 660 |
| 661 unsigned char packet_cid_be39[] = { |
| 662 // public flags (8 byte connection_id) |
| 663 0x38, |
| 664 // connection_id |
| 665 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 666 // packet number |
| 667 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 668 }; |
630 // clang-format on | 669 // clang-format on |
631 | 670 |
632 QuicEncryptedPacket encrypted( | 671 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
633 AsChars( | 672 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
634 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 673 |
635 ? packet_cid_be | 674 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
636 : packet), | 675 false); |
637 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
638 ? arraysize(packet_cid_be) | |
639 : arraysize(packet), | |
640 false); | |
641 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); | 676 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
642 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); | 677 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
643 ASSERT_TRUE(visitor_.header_.get()); | 678 ASSERT_TRUE(visitor_.header_.get()); |
644 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); | 679 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); |
645 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); | 680 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); |
646 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); | 681 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); |
647 EXPECT_FALSE(visitor_.header_->public_header.version_flag); | 682 EXPECT_FALSE(visitor_.header_->public_header.version_flag); |
648 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); | 683 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); |
649 | 684 |
650 // Now test framing boundaries. | 685 // Now test framing boundaries. |
651 for (size_t i = 0; | 686 for (size_t i = 0; |
652 i < GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 687 i < GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
653 !kIncludeVersion, !kIncludeDiversificationNonce, | 688 !kIncludeVersion, !kIncludeDiversificationNonce, |
654 PACKET_6BYTE_PACKET_NUMBER); | 689 PACKET_6BYTE_PACKET_NUMBER); |
655 ++i) { | 690 ++i) { |
656 string expected_error; | 691 string expected_error; |
657 if (i < kConnectionIdOffset) { | 692 if (i < kConnectionIdOffset) { |
658 expected_error = "Unable to read public flags."; | 693 expected_error = "Unable to read public flags."; |
659 } else if (i < GetPacketNumberOffset(!kIncludeVersion)) { | 694 } else if (i < GetPacketNumberOffset(!kIncludeVersion)) { |
660 expected_error = "Unable to read ConnectionId."; | 695 expected_error = "Unable to read ConnectionId."; |
661 } else { | 696 } else { |
662 expected_error = "Unable to read packet number."; | 697 expected_error = "Unable to read packet number."; |
663 } | 698 } |
664 CheckProcessingFails( | 699 CheckProcessingFails(packets[index], i, expected_error, |
665 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 700 QUIC_INVALID_PACKET_HEADER); |
666 ? packet_cid_be | |
667 : packet, | |
668 i, expected_error, QUIC_INVALID_PACKET_HEADER); | |
669 } | 701 } |
670 } | 702 } |
671 | 703 |
672 TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) { | 704 TEST_P(QuicFramerTest, PacketHeaderWith0ByteConnectionId) { |
673 QuicFramerPeer::SetLastSerializedConnectionId(&framer_, kConnectionId); | 705 QuicFramerPeer::SetLastSerializedConnectionId(&framer_, kConnectionId); |
674 | 706 |
675 // clang-format off | 707 // clang-format off |
676 unsigned char packet[] = { | 708 unsigned char packet[] = { |
677 // public flags (0 byte connection_id) | 709 // public flags (0 byte connection_id) |
678 0x30, | 710 0x30, |
679 // connection_id | 711 // connection_id |
680 // packet number | 712 // packet number |
681 0xBC, 0x9A, 0x78, 0x56, | 713 0xBC, 0x9A, 0x78, 0x56, |
682 0x34, 0x12, | 714 0x34, 0x12, |
683 }; | 715 }; |
| 716 |
| 717 unsigned char packet39[] = { |
| 718 // public flags (0 byte connection_id) |
| 719 0x30, |
| 720 // connection_id |
| 721 // packet number |
| 722 0x12, 0x34, 0x56, 0x78, |
| 723 0x9A, 0xBC, |
| 724 }; |
684 // clang-format on | 725 // clang-format on |
685 | 726 |
686 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 727 QuicEncryptedPacket encrypted( |
| 728 AsChars(framer_.version() > QUIC_VERSION_38 ? packet39 : packet), |
| 729 arraysize(packet), false); |
687 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); | 730 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
688 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); | 731 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
689 ASSERT_TRUE(visitor_.header_.get()); | 732 ASSERT_TRUE(visitor_.header_.get()); |
690 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); | 733 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); |
691 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); | 734 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); |
692 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); | 735 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); |
693 EXPECT_FALSE(visitor_.header_->public_header.version_flag); | 736 EXPECT_FALSE(visitor_.header_->public_header.version_flag); |
694 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); | 737 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); |
695 | 738 |
696 // Now test framing boundaries. | 739 // Now test framing boundaries. |
697 for (size_t i = 0; | 740 for (size_t i = 0; |
698 i < GetPacketHeaderSize(framer_.version(), PACKET_0BYTE_CONNECTION_ID, | 741 i < GetPacketHeaderSize(framer_.version(), PACKET_0BYTE_CONNECTION_ID, |
699 !kIncludeVersion, !kIncludeDiversificationNonce, | 742 !kIncludeVersion, !kIncludeDiversificationNonce, |
700 PACKET_6BYTE_PACKET_NUMBER); | 743 PACKET_6BYTE_PACKET_NUMBER); |
701 ++i) { | 744 ++i) { |
702 string expected_error; | 745 string expected_error; |
703 if (i < kConnectionIdOffset) { | 746 if (i < kConnectionIdOffset) { |
704 expected_error = "Unable to read public flags."; | 747 expected_error = "Unable to read public flags."; |
705 } else if (i < GetPacketNumberOffset(PACKET_0BYTE_CONNECTION_ID, | 748 } else if (i < GetPacketNumberOffset(PACKET_0BYTE_CONNECTION_ID, |
706 !kIncludeVersion)) { | 749 !kIncludeVersion)) { |
707 expected_error = "Unable to read ConnectionId."; | 750 expected_error = "Unable to read ConnectionId."; |
708 } else { | 751 } else { |
709 expected_error = "Unable to read packet number."; | 752 expected_error = "Unable to read packet number."; |
710 } | 753 } |
711 CheckProcessingFails(packet, i, expected_error, QUIC_INVALID_PACKET_HEADER); | 754 CheckProcessingFails( |
| 755 framer_.version() > QUIC_VERSION_38 ? packet39 : packet, i, |
| 756 expected_error, QUIC_INVALID_PACKET_HEADER); |
712 } | 757 } |
713 } | 758 } |
714 | 759 |
715 TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { | 760 TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { |
716 // clang-format off | 761 // clang-format off |
717 unsigned char packet[] = { | 762 unsigned char packet[] = { |
718 // public flags (version) | 763 // public flags (version) |
719 0x39, | 764 0x39, |
720 // connection_id | 765 // connection_id |
721 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, | 766 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
722 // version tag | 767 // version tag |
723 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), | 768 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
724 // packet number | 769 // packet number |
725 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 770 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
726 }; | 771 }; |
727 | 772 |
728 unsigned char packet_cid_be[] = { | 773 unsigned char packet_cid_be[] = { |
729 // public flags (version) | 774 // public flags (version) |
730 0x39, | 775 0x39, |
731 // connection_id | 776 // connection_id |
732 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 777 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
733 // version tag | 778 // version tag |
734 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), | 779 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
735 // packet number | 780 // packet number |
736 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 781 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
737 }; | 782 }; |
| 783 |
| 784 unsigned char packet39[] = { |
| 785 // public flags (version) |
| 786 0x39, |
| 787 // connection_id |
| 788 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 789 // version tag |
| 790 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
| 791 // packet number |
| 792 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 793 }; |
| 794 |
| 795 unsigned char packet_cid_be39[] = { |
| 796 // public flags (version) |
| 797 0x39, |
| 798 // connection_id |
| 799 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 800 // version tag |
| 801 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
| 802 // packet number |
| 803 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 804 }; |
738 // clang-format on | 805 // clang-format on |
739 | 806 |
740 QuicEncryptedPacket encrypted( | 807 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
741 AsChars( | 808 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
742 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 809 |
743 ? packet_cid_be | 810 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
744 : packet), | 811 false); |
745 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
746 ? arraysize(packet_cid_be) | |
747 : arraysize(packet), | |
748 false); | |
749 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); | 812 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
750 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); | 813 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
751 ASSERT_TRUE(visitor_.header_.get()); | 814 ASSERT_TRUE(visitor_.header_.get()); |
752 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); | 815 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); |
753 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); | 816 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); |
754 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); | 817 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); |
755 EXPECT_TRUE(visitor_.header_->public_header.version_flag); | 818 EXPECT_TRUE(visitor_.header_->public_header.version_flag); |
756 EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]); | 819 EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]); |
757 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); | 820 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); |
758 | 821 |
759 // Now test framing boundaries. | 822 // Now test framing boundaries. |
760 for (size_t i = 0; | 823 for (size_t i = 0; |
761 i < GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 824 i < GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
762 kIncludeVersion, !kIncludeDiversificationNonce, | 825 kIncludeVersion, !kIncludeDiversificationNonce, |
763 PACKET_6BYTE_PACKET_NUMBER); | 826 PACKET_6BYTE_PACKET_NUMBER); |
764 ++i) { | 827 ++i) { |
765 string expected_error; | 828 string expected_error; |
766 if (i < kConnectionIdOffset) { | 829 if (i < kConnectionIdOffset) { |
767 expected_error = "Unable to read public flags."; | 830 expected_error = "Unable to read public flags."; |
768 } else if (i < kVersionOffset) { | 831 } else if (i < kVersionOffset) { |
769 expected_error = "Unable to read ConnectionId."; | 832 expected_error = "Unable to read ConnectionId."; |
770 } else if (i < GetPacketNumberOffset(kIncludeVersion)) { | 833 } else if (i < GetPacketNumberOffset(kIncludeVersion)) { |
771 expected_error = "Unable to read protocol version."; | 834 expected_error = "Unable to read protocol version."; |
772 } else { | 835 } else { |
773 expected_error = "Unable to read packet number."; | 836 expected_error = "Unable to read packet number."; |
774 } | 837 } |
775 CheckProcessingFails( | 838 CheckProcessingFails(packets[index], i, expected_error, |
776 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 839 QUIC_INVALID_PACKET_HEADER); |
777 ? packet_cid_be | |
778 : packet, | |
779 i, expected_error, QUIC_INVALID_PACKET_HEADER); | |
780 } | 840 } |
781 } | 841 } |
782 | 842 |
783 TEST_P(QuicFramerTest, PacketHeaderWith4BytePacketNumber) { | 843 TEST_P(QuicFramerTest, PacketHeaderWith4BytePacketNumber) { |
784 QuicFramerPeer::SetLargestPacketNumber(&framer_, kPacketNumber - 2); | 844 QuicFramerPeer::SetLargestPacketNumber(&framer_, kPacketNumber - 2); |
785 | 845 |
786 // clang-format off | 846 // clang-format off |
787 unsigned char packet[] = { | 847 unsigned char packet[] = { |
788 // public flags (8 byte connection_id and 4 byte packet number) | 848 // public flags (8 byte connection_id and 4 byte packet number) |
789 0x28, | 849 0x28, |
790 // connection_id | 850 // connection_id |
791 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, | 851 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
792 // packet number | 852 // packet number |
793 0xBC, 0x9A, 0x78, 0x56, | 853 0xBC, 0x9A, 0x78, 0x56, |
794 }; | 854 }; |
795 | 855 |
796 unsigned char packet_cid_be[] = { | 856 unsigned char packet_cid_be[] = { |
797 // public flags (8 byte connection_id and 4 byte packet number) | 857 // public flags (8 byte connection_id and 4 byte packet number) |
798 0x28, | 858 0x28, |
799 // connection_id | 859 // connection_id |
800 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 860 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
801 // packet number | 861 // packet number |
802 0xBC, 0x9A, 0x78, 0x56, | 862 0xBC, 0x9A, 0x78, 0x56, |
803 }; | 863 }; |
| 864 |
| 865 unsigned char packet39[] = { |
| 866 // public flags (8 byte connection_id and 4 byte packet number) |
| 867 0x28, |
| 868 // connection_id |
| 869 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 870 // packet number |
| 871 0x56, 0x78, 0x9A, 0xBC, |
| 872 }; |
| 873 |
| 874 unsigned char packet_cid_be39[] = { |
| 875 // public flags (8 byte connection_id and 4 byte packet number) |
| 876 0x28, |
| 877 // connection_id |
| 878 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 879 // packet number |
| 880 0x56, 0x78, 0x9A, 0xBC, |
| 881 }; |
804 // clang-format on | 882 // clang-format on |
805 | 883 |
806 QuicEncryptedPacket encrypted( | 884 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
807 AsChars( | 885 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
808 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 886 |
809 ? packet_cid_be | 887 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
810 : packet), | 888 false); |
811 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
812 ? arraysize(packet_cid_be) | |
813 : arraysize(packet), | |
814 false); | |
815 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); | 889 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
816 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); | 890 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
817 ASSERT_TRUE(visitor_.header_.get()); | 891 ASSERT_TRUE(visitor_.header_.get()); |
818 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); | 892 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); |
819 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); | 893 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); |
820 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); | 894 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); |
821 EXPECT_FALSE(visitor_.header_->public_header.version_flag); | 895 EXPECT_FALSE(visitor_.header_->public_header.version_flag); |
822 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); | 896 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); |
823 | 897 |
824 // Now test framing boundaries. | 898 // Now test framing boundaries. |
825 for (size_t i = 0; | 899 for (size_t i = 0; |
826 i < GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 900 i < GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
827 !kIncludeVersion, !kIncludeDiversificationNonce, | 901 !kIncludeVersion, !kIncludeDiversificationNonce, |
828 PACKET_4BYTE_PACKET_NUMBER); | 902 PACKET_4BYTE_PACKET_NUMBER); |
829 ++i) { | 903 ++i) { |
830 string expected_error; | 904 string expected_error; |
831 if (i < kConnectionIdOffset) { | 905 if (i < kConnectionIdOffset) { |
832 expected_error = "Unable to read public flags."; | 906 expected_error = "Unable to read public flags."; |
833 } else if (i < GetPacketNumberOffset(!kIncludeVersion)) { | 907 } else if (i < GetPacketNumberOffset(!kIncludeVersion)) { |
834 expected_error = "Unable to read ConnectionId."; | 908 expected_error = "Unable to read ConnectionId."; |
835 } else { | 909 } else { |
836 expected_error = "Unable to read packet number."; | 910 expected_error = "Unable to read packet number."; |
837 } | 911 } |
838 CheckProcessingFails( | 912 CheckProcessingFails(packets[index], i, expected_error, |
839 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 913 QUIC_INVALID_PACKET_HEADER); |
840 ? packet_cid_be | |
841 : packet, | |
842 i, expected_error, QUIC_INVALID_PACKET_HEADER); | |
843 } | 914 } |
844 } | 915 } |
845 | 916 |
846 TEST_P(QuicFramerTest, PacketHeaderWith2BytePacketNumber) { | 917 TEST_P(QuicFramerTest, PacketHeaderWith2BytePacketNumber) { |
847 QuicFramerPeer::SetLargestPacketNumber(&framer_, kPacketNumber - 2); | 918 QuicFramerPeer::SetLargestPacketNumber(&framer_, kPacketNumber - 2); |
848 | 919 |
849 // clang-format off | 920 // clang-format off |
850 unsigned char packet[] = { | 921 unsigned char packet[] = { |
851 // public flags (8 byte connection_id and 2 byte packet number) | 922 // public flags (8 byte connection_id and 2 byte packet number) |
852 0x18, | 923 0x18, |
853 // connection_id | 924 // connection_id |
854 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, | 925 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
855 // packet number | 926 // packet number |
856 0xBC, 0x9A, | 927 0xBC, 0x9A, |
857 }; | 928 }; |
858 | 929 |
859 unsigned char packet_cid_be[] = { | 930 unsigned char packet_cid_be[] = { |
860 // public flags (8 byte connection_id and 2 byte packet number) | 931 // public flags (8 byte connection_id and 2 byte packet number) |
861 0x18, | 932 0x18, |
862 // connection_id | 933 // connection_id |
863 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 934 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
864 // packet number | 935 // packet number |
865 0xBC, 0x9A, | 936 0xBC, 0x9A, |
866 }; | 937 }; |
| 938 |
| 939 unsigned char packet39[] = { |
| 940 // public flags (8 byte connection_id and 2 byte packet number) |
| 941 0x18, |
| 942 // connection_id |
| 943 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 944 // packet number |
| 945 0x9A, 0xBC, |
| 946 }; |
| 947 |
| 948 unsigned char packet_cid_be39[] = { |
| 949 // public flags (8 byte connection_id and 2 byte packet number) |
| 950 0x18, |
| 951 // connection_id |
| 952 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 953 // packet number |
| 954 0x9A, 0xBC, |
| 955 }; |
867 // clang-format on | 956 // clang-format on |
868 | 957 |
869 QuicEncryptedPacket encrypted( | 958 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
870 AsChars( | 959 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
871 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 960 |
872 ? packet_cid_be | 961 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
873 : packet), | 962 false); |
874 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
875 ? arraysize(packet_cid_be) | |
876 : arraysize(packet), | |
877 false); | |
878 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); | 963 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
879 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); | 964 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
880 ASSERT_TRUE(visitor_.header_.get()); | 965 ASSERT_TRUE(visitor_.header_.get()); |
881 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); | 966 EXPECT_EQ(kConnectionId, visitor_.header_->public_header.connection_id); |
882 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); | 967 EXPECT_FALSE(visitor_.header_->public_header.multipath_flag); |
883 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); | 968 EXPECT_FALSE(visitor_.header_->public_header.reset_flag); |
884 EXPECT_FALSE(visitor_.header_->public_header.version_flag); | 969 EXPECT_FALSE(visitor_.header_->public_header.version_flag); |
885 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, | 970 EXPECT_EQ(PACKET_2BYTE_PACKET_NUMBER, |
886 visitor_.header_->public_header.packet_number_length); | 971 visitor_.header_->public_header.packet_number_length); |
887 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); | 972 EXPECT_EQ(kPacketNumber, visitor_.header_->packet_number); |
888 | 973 |
889 // Now test framing boundaries. | 974 // Now test framing boundaries. |
890 for (size_t i = 0; | 975 for (size_t i = 0; |
891 i < GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 976 i < GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
892 !kIncludeVersion, !kIncludeDiversificationNonce, | 977 !kIncludeVersion, !kIncludeDiversificationNonce, |
893 PACKET_2BYTE_PACKET_NUMBER); | 978 PACKET_2BYTE_PACKET_NUMBER); |
894 ++i) { | 979 ++i) { |
895 string expected_error; | 980 string expected_error; |
896 if (i < kConnectionIdOffset) { | 981 if (i < kConnectionIdOffset) { |
897 expected_error = "Unable to read public flags."; | 982 expected_error = "Unable to read public flags."; |
898 } else if (i < GetPacketNumberOffset(!kIncludeVersion)) { | 983 } else if (i < GetPacketNumberOffset(!kIncludeVersion)) { |
899 expected_error = "Unable to read ConnectionId."; | 984 expected_error = "Unable to read ConnectionId."; |
900 } else { | 985 } else { |
901 expected_error = "Unable to read packet number."; | 986 expected_error = "Unable to read packet number."; |
902 } | 987 } |
903 CheckProcessingFails( | 988 CheckProcessingFails(packets[index], i, expected_error, |
904 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 989 QUIC_INVALID_PACKET_HEADER); |
905 ? packet_cid_be | |
906 : packet, | |
907 i, expected_error, QUIC_INVALID_PACKET_HEADER); | |
908 } | 990 } |
909 } | 991 } |
910 | 992 |
911 TEST_P(QuicFramerTest, PacketHeaderWith1BytePacketNumber) { | 993 TEST_P(QuicFramerTest, PacketHeaderWith1BytePacketNumber) { |
912 QuicFramerPeer::SetLargestPacketNumber(&framer_, kPacketNumber - 2); | 994 QuicFramerPeer::SetLargestPacketNumber(&framer_, kPacketNumber - 2); |
913 | 995 |
914 // clang-format off | 996 // clang-format off |
915 unsigned char packet[] = { | 997 unsigned char packet[] = { |
916 // public flags (8 byte connection_id and 1 byte packet number) | 998 // public flags (8 byte connection_id and 1 byte packet number) |
917 0x08, | 999 0x08, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | 1145 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
1064 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, | 1146 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
1065 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, | 1147 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, |
1066 // packet number | 1148 // packet number |
1067 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 1149 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
1068 | 1150 |
1069 // frame type (padding) | 1151 // frame type (padding) |
1070 0x00, | 1152 0x00, |
1071 0x00, 0x00, 0x00, 0x00 | 1153 0x00, 0x00, 0x00, 0x00 |
1072 }; | 1154 }; |
| 1155 |
| 1156 unsigned char packet39[] = { |
| 1157 // public flags: includes nonce flag |
| 1158 static_cast<unsigned char>( |
| 1159 FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x3C : 0x7C), |
| 1160 // connection_id |
| 1161 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 1162 // nonce |
| 1163 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 1164 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 1165 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
| 1166 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, |
| 1167 // packet number |
| 1168 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 1169 |
| 1170 // frame type (padding) |
| 1171 0x00, |
| 1172 0x00, 0x00, 0x00, 0x00 |
| 1173 }; |
| 1174 |
| 1175 unsigned char packet_cid_be39[] = { |
| 1176 // public flags: includes nonce flag |
| 1177 static_cast<unsigned char>( |
| 1178 FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x3C : 0x7C), |
| 1179 // connection_id |
| 1180 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 1181 // nonce |
| 1182 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 1183 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 1184 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
| 1185 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, |
| 1186 // packet number |
| 1187 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 1188 |
| 1189 // frame type (padding) |
| 1190 0x00, |
| 1191 0x00, 0x00, 0x00, 0x00 |
| 1192 }; |
1073 // clang-format on | 1193 // clang-format on |
| 1194 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 1195 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1074 | 1196 |
1075 QuicEncryptedPacket encrypted( | 1197 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1076 AsChars( | 1198 false); |
1077 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1078 ? packet_cid_be | |
1079 : packet), | |
1080 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1081 ? arraysize(packet_cid_be) | |
1082 : arraysize(packet), | |
1083 false); | |
1084 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); | 1199 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); |
1085 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1200 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1086 ASSERT_TRUE(visitor_.public_header_->nonce != nullptr); | 1201 ASSERT_TRUE(visitor_.public_header_->nonce != nullptr); |
1087 for (char i = 0; i < 32; ++i) { | 1202 for (char i = 0; i < 32; ++i) { |
1088 EXPECT_EQ(i, (*visitor_.public_header_->nonce)[static_cast<size_t>(i)]); | 1203 EXPECT_EQ(i, (*visitor_.public_header_->nonce)[static_cast<size_t>(i)]); |
1089 } | 1204 } |
1090 EXPECT_EQ(1u, visitor_.padding_frames_.size()); | 1205 EXPECT_EQ(1u, visitor_.padding_frames_.size()); |
1091 EXPECT_EQ(5, visitor_.padding_frames_[0]->num_padding_bytes); | 1206 EXPECT_EQ(5, visitor_.padding_frames_[0]->num_padding_bytes); |
1092 }; | 1207 }; |
1093 | 1208 |
(...skipping 26 matching lines...) Expand all Loading... |
1120 // version tag | 1235 // version tag |
1121 'Q', '0', '0', '0', | 1236 'Q', '0', '0', '0', |
1122 // packet number | 1237 // packet number |
1123 0xBC, 0x9A, 0x78, 0x56, | 1238 0xBC, 0x9A, 0x78, 0x56, |
1124 0x34, 0x12, | 1239 0x34, 0x12, |
1125 | 1240 |
1126 // frame type (padding frame) | 1241 // frame type (padding frame) |
1127 0x00, | 1242 0x00, |
1128 0x00, 0x00, 0x00, 0x00 | 1243 0x00, 0x00, 0x00, 0x00 |
1129 }; | 1244 }; |
| 1245 |
| 1246 unsigned char packet39[] = { |
| 1247 // public flags (8 byte connection_id, version flag and an unknown flag) |
| 1248 static_cast<unsigned char>( |
| 1249 FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x39 : 0x79), |
| 1250 // connection_id |
| 1251 0x10, 0x32, 0x54, 0x76, |
| 1252 0x98, 0xBA, 0xDC, 0xFE, |
| 1253 // version tag |
| 1254 'Q', '0', '0', '0', |
| 1255 // packet number |
| 1256 0x12, 0x34, 0x56, 0x78, |
| 1257 0x9A, 0xBC, |
| 1258 |
| 1259 // frame type (padding frame) |
| 1260 0x00, |
| 1261 0x00, 0x00, 0x00, 0x00 |
| 1262 }; |
| 1263 |
| 1264 unsigned char packet_cid_be39[] = { |
| 1265 // public flags (8 byte connection_id, version flag and an unknown flag) |
| 1266 static_cast<unsigned char>( |
| 1267 FLAGS_quic_reloadable_flag_quic_remove_multipath_bit ? 0x39 : 0x79), |
| 1268 // connection_id |
| 1269 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 1270 // version tag |
| 1271 'Q', '0', '0', '0', |
| 1272 // packet number |
| 1273 0x12, 0x34, 0x56, 0x78, |
| 1274 0x9A, 0xBC, |
| 1275 |
| 1276 // frame type (padding frame) |
| 1277 0x00, |
| 1278 0x00, 0x00, 0x00, 0x00 |
| 1279 }; |
1130 // clang-format on | 1280 // clang-format on |
1131 QuicEncryptedPacket encrypted( | 1281 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1132 AsChars( | 1282 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1133 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 1283 |
1134 ? packet_cid_be | 1284 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1135 : packet), | 1285 false); |
1136 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1137 ? arraysize(packet_cid_be) | |
1138 : arraysize(packet), | |
1139 false); | |
1140 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1286 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1141 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1287 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1142 ASSERT_TRUE(visitor_.header_.get()); | 1288 ASSERT_TRUE(visitor_.header_.get()); |
1143 EXPECT_EQ(0, visitor_.frame_count_); | 1289 EXPECT_EQ(0, visitor_.frame_count_); |
1144 EXPECT_EQ(1, visitor_.version_mismatch_); | 1290 EXPECT_EQ(1, visitor_.version_mismatch_); |
1145 EXPECT_EQ(1u, visitor_.padding_frames_.size()); | 1291 EXPECT_EQ(1u, visitor_.padding_frames_.size()); |
1146 EXPECT_EQ(5, visitor_.padding_frames_[0]->num_padding_bytes); | 1292 EXPECT_EQ(5, visitor_.padding_frames_[0]->num_padding_bytes); |
1147 }; | 1293 }; |
1148 | 1294 |
1149 TEST_P(QuicFramerTest, PaddingFrame) { | 1295 TEST_P(QuicFramerTest, PaddingFrame) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 0xDC, 0xFE, 0x98, 0xBA, | 1435 0xDC, 0xFE, 0x98, 0xBA, |
1290 // data length | 1436 // data length |
1291 0x0c, 0x00, | 1437 0x0c, 0x00, |
1292 // data | 1438 // data |
1293 'h', 'e', 'l', 'l', | 1439 'h', 'e', 'l', 'l', |
1294 'o', ' ', 'w', 'o', | 1440 'o', ' ', 'w', 'o', |
1295 'r', 'l', 'd', '!', | 1441 'r', 'l', 'd', '!', |
1296 // paddings | 1442 // paddings |
1297 0x00, 0x00, | 1443 0x00, 0x00, |
1298 }; | 1444 }; |
| 1445 |
| 1446 unsigned char packet39[] = { |
| 1447 // public flags (8 byte connection_id) |
| 1448 0x38, |
| 1449 // connection_id |
| 1450 0x10, 0x32, 0x54, 0x76, |
| 1451 0x98, 0xBA, 0xDC, 0xFE, |
| 1452 // packet number |
| 1453 0x12, 0x34, 0x56, 0x78, |
| 1454 0x9A, 0xBC, |
| 1455 |
| 1456 // paddings |
| 1457 0x00, 0x00, |
| 1458 // frame type (stream frame with fin) |
| 1459 0xFF, |
| 1460 // stream id |
| 1461 0x01, 0x02, 0x03, 0x04, |
| 1462 // offset |
| 1463 0xBA, 0x98, 0xFE, 0xDC, |
| 1464 0x32, 0x10, 0x76, 0x54, |
| 1465 // data length |
| 1466 0x00, 0x0c, |
| 1467 // data |
| 1468 'h', 'e', 'l', 'l', |
| 1469 'o', ' ', 'w', 'o', |
| 1470 'r', 'l', 'd', '!', |
| 1471 // paddings |
| 1472 0x00, 0x00, |
| 1473 }; |
| 1474 |
| 1475 unsigned char packet_cid_be39[] = { |
| 1476 // public flags (8 byte connection_id) |
| 1477 0x38, |
| 1478 // connection_id |
| 1479 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 1480 // packet number |
| 1481 0x12, 0x34, 0x56, 0x78, |
| 1482 0x9A, 0xBC, |
| 1483 |
| 1484 // paddings |
| 1485 0x00, 0x00, |
| 1486 // frame type (stream frame with fin) |
| 1487 0xFF, |
| 1488 // stream id |
| 1489 0x01, 0x02, 0x03, 0x04, |
| 1490 // offset |
| 1491 0xBA, 0x98, 0xFE, 0xDC, |
| 1492 0x32, 0x10, 0x76, 0x54, |
| 1493 // data length |
| 1494 0x00, 0x0c, |
| 1495 // data |
| 1496 'h', 'e', 'l', 'l', |
| 1497 'o', ' ', 'w', 'o', |
| 1498 'r', 'l', 'd', '!', |
| 1499 // paddings |
| 1500 0x00, 0x00, |
| 1501 }; |
1299 // clang-format on | 1502 // clang-format on |
1300 | 1503 |
1301 if (framer_.version() <= QUIC_VERSION_37) { | 1504 if (framer_.version() <= QUIC_VERSION_37) { |
1302 return; | 1505 return; |
1303 } | 1506 } |
1304 | 1507 |
1305 QuicEncryptedPacket encrypted( | 1508 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1306 AsChars( | 1509 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1307 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 1510 |
1308 ? packet_cid_be | 1511 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1309 : packet), | 1512 false); |
1310 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1311 ? arraysize(packet_cid_be) | |
1312 : arraysize(packet), | |
1313 false); | |
1314 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1513 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1315 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1514 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1316 ASSERT_TRUE(visitor_.header_.get()); | 1515 ASSERT_TRUE(visitor_.header_.get()); |
1317 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 1516 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
1318 !kIncludeDiversificationNonce)); | 1517 !kIncludeDiversificationNonce)); |
1319 | 1518 |
1320 ASSERT_EQ(1u, visitor_.stream_frames_.size()); | 1519 ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
1321 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 1520 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1322 EXPECT_EQ(2u, visitor_.padding_frames_.size()); | 1521 EXPECT_EQ(2u, visitor_.padding_frames_.size()); |
1323 EXPECT_EQ(2, visitor_.padding_frames_[0]->num_padding_bytes); | 1522 EXPECT_EQ(2, visitor_.padding_frames_[0]->num_padding_bytes); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 // offset | 1570 // offset |
1372 0x54, 0x76, 0x10, 0x32, | 1571 0x54, 0x76, 0x10, 0x32, |
1373 0xDC, 0xFE, 0x98, 0xBA, | 1572 0xDC, 0xFE, 0x98, 0xBA, |
1374 // data length | 1573 // data length |
1375 0x0c, 0x00, | 1574 0x0c, 0x00, |
1376 // data | 1575 // data |
1377 'h', 'e', 'l', 'l', | 1576 'h', 'e', 'l', 'l', |
1378 'o', ' ', 'w', 'o', | 1577 'o', ' ', 'w', 'o', |
1379 'r', 'l', 'd', '!', | 1578 'r', 'l', 'd', '!', |
1380 }; | 1579 }; |
| 1580 |
| 1581 unsigned char packet39[] = { |
| 1582 // public flags (8 byte connection_id) |
| 1583 0x38, |
| 1584 // connection_id |
| 1585 0x10, 0x32, 0x54, 0x76, |
| 1586 0x98, 0xBA, 0xDC, 0xFE, |
| 1587 // packet number |
| 1588 0x12, 0x34, 0x56, 0x78, |
| 1589 0x9A, 0xBC, |
| 1590 |
| 1591 // frame type (stream frame with fin) |
| 1592 0xFF, |
| 1593 // stream id |
| 1594 0x01, 0x02, 0x03, 0x04, |
| 1595 // offset |
| 1596 0xBA, 0x98, 0xFE, 0xDC, |
| 1597 0x32, 0x10, 0x76, 0x54, |
| 1598 // data length |
| 1599 0x00, 0x0c, |
| 1600 // data |
| 1601 'h', 'e', 'l', 'l', |
| 1602 'o', ' ', 'w', 'o', |
| 1603 'r', 'l', 'd', '!', |
| 1604 }; |
| 1605 |
| 1606 unsigned char packet_cid_be39[] = { |
| 1607 // public flags (8 byte connection_id) |
| 1608 0x38, |
| 1609 // connection_id |
| 1610 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 1611 // packet number |
| 1612 0x12, 0x34, 0x56, 0x78, |
| 1613 0x9A, 0xBC, |
| 1614 |
| 1615 // frame type (stream frame with fin) |
| 1616 0xFF, |
| 1617 // stream id |
| 1618 0x01, 0x02, 0x03, 0x04, |
| 1619 // offset |
| 1620 0xBA, 0x98, 0xFE, 0xDC, |
| 1621 0x32, 0x10, 0x76, 0x54, |
| 1622 // data length |
| 1623 0x00, 0x0c, |
| 1624 // data |
| 1625 'h', 'e', 'l', 'l', |
| 1626 'o', ' ', 'w', 'o', |
| 1627 'r', 'l', 'd', '!', |
| 1628 }; |
1381 // clang-format on | 1629 // clang-format on |
| 1630 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 1631 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1382 | 1632 |
1383 QuicEncryptedPacket encrypted( | 1633 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1384 AsChars( | 1634 false); |
1385 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1386 ? packet_cid_be | |
1387 : packet), | |
1388 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1389 ? arraysize(packet_cid_be) | |
1390 : arraysize(packet), | |
1391 false); | |
1392 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1635 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1393 | 1636 |
1394 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1637 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1395 ASSERT_TRUE(visitor_.header_.get()); | 1638 ASSERT_TRUE(visitor_.header_.get()); |
1396 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 1639 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
1397 !kIncludeDiversificationNonce)); | 1640 !kIncludeDiversificationNonce)); |
1398 | 1641 |
1399 ASSERT_EQ(1u, visitor_.stream_frames_.size()); | 1642 ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
1400 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 1643 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1401 EXPECT_EQ(kStreamId, visitor_.stream_frames_[0]->stream_id); | 1644 EXPECT_EQ(kStreamId, visitor_.stream_frames_[0]->stream_id); |
1402 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); | 1645 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); |
1403 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); | 1646 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); |
1404 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); | 1647 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); |
1405 | 1648 |
1406 // Now test framing boundaries. | 1649 // Now test framing boundaries. |
1407 CheckStreamFrameBoundaries( | 1650 CheckStreamFrameBoundaries(packets[index], kQuicMaxStreamIdSize, |
1408 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 1651 !kIncludeVersion); |
1409 ? packet_cid_be | |
1410 : packet, | |
1411 kQuicMaxStreamIdSize, !kIncludeVersion); | |
1412 } | 1652 } |
1413 | 1653 |
1414 TEST_P(QuicFramerTest, MissingDiversificationNonce) { | 1654 TEST_P(QuicFramerTest, MissingDiversificationNonce) { |
1415 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); | 1655 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); |
1416 framer_.SetDecrypter(ENCRYPTION_NONE, | 1656 framer_.SetDecrypter(ENCRYPTION_NONE, |
1417 new NullDecrypter(Perspective::IS_CLIENT)); | 1657 new NullDecrypter(Perspective::IS_CLIENT)); |
1418 decrypter_ = new test::TestDecrypter(); | 1658 decrypter_ = new test::TestDecrypter(); |
1419 framer_.SetAlternativeDecrypter(ENCRYPTION_INITIAL, decrypter_, false); | 1659 framer_.SetAlternativeDecrypter(ENCRYPTION_INITIAL, decrypter_, false); |
1420 | 1660 |
1421 // clang-format off | 1661 // clang-format off |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 // offset | 1700 // offset |
1461 0x54, 0x76, 0x10, 0x32, | 1701 0x54, 0x76, 0x10, 0x32, |
1462 0xDC, 0xFE, 0x98, 0xBA, | 1702 0xDC, 0xFE, 0x98, 0xBA, |
1463 // data length | 1703 // data length |
1464 0x0c, 0x00, | 1704 0x0c, 0x00, |
1465 // data | 1705 // data |
1466 'h', 'e', 'l', 'l', | 1706 'h', 'e', 'l', 'l', |
1467 'o', ' ', 'w', 'o', | 1707 'o', ' ', 'w', 'o', |
1468 'r', 'l', 'd', '!', | 1708 'r', 'l', 'd', '!', |
1469 }; | 1709 }; |
| 1710 |
| 1711 unsigned char packet39[] = { |
| 1712 // public flags (8 byte connection_id) |
| 1713 0x38, |
| 1714 // connection_id |
| 1715 0x10, 0x32, 0x54, 0x76, |
| 1716 0x98, 0xBA, 0xDC, 0xFE, |
| 1717 // packet number |
| 1718 0x12, 0x34, 0x56, 0x78, |
| 1719 0x9A, 0xBC, |
| 1720 |
| 1721 // frame type (stream frame with fin) |
| 1722 0xFF, |
| 1723 // stream id |
| 1724 0x01, 0x02, 0x03, 0x04, |
| 1725 // offset |
| 1726 0xBA, 0x98, 0xFE, 0xDC, |
| 1727 0x32, 0x10, 0x76, 0x54, |
| 1728 // data length |
| 1729 0x00, 0x0c, |
| 1730 // data |
| 1731 'h', 'e', 'l', 'l', |
| 1732 'o', ' ', 'w', 'o', |
| 1733 'r', 'l', 'd', '!', |
| 1734 }; |
| 1735 |
| 1736 unsigned char packet_cid_be39[] = { |
| 1737 // public flags (8 byte connection_id) |
| 1738 0x38, |
| 1739 // connection_id |
| 1740 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 1741 // packet number |
| 1742 0x12, 0x34, 0x56, 0x78, |
| 1743 0x9A, 0xBC, |
| 1744 |
| 1745 // frame type (stream frame with fin) |
| 1746 0xFF, |
| 1747 // stream id |
| 1748 0x01, 0x02, 0x03, 0x04, |
| 1749 // offset |
| 1750 0xBA, 0x98, 0xFE, 0xDC, |
| 1751 0x32, 0x10, 0x76, 0x54, |
| 1752 // data length |
| 1753 0x00, 0x0c, |
| 1754 // data |
| 1755 'h', 'e', 'l', 'l', |
| 1756 'o', ' ', 'w', 'o', |
| 1757 'r', 'l', 'd', '!', |
| 1758 }; |
1470 // clang-format on | 1759 // clang-format on |
1471 | 1760 |
1472 QuicEncryptedPacket encrypted( | 1761 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1473 AsChars( | 1762 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1474 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 1763 |
1475 ? packet_cid_be | 1764 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1476 : packet), | 1765 false); |
1477 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1478 ? arraysize(packet_cid_be) | |
1479 : arraysize(packet), | |
1480 false); | |
1481 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); | 1766 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
1482 EXPECT_EQ(QUIC_DECRYPTION_FAILURE, framer_.error()); | 1767 EXPECT_EQ(QUIC_DECRYPTION_FAILURE, framer_.error()); |
1483 } | 1768 } |
1484 | 1769 |
1485 TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) { | 1770 TEST_P(QuicFramerTest, StreamFrame3ByteStreamId) { |
1486 // clang-format off | 1771 // clang-format off |
1487 unsigned char packet[] = { | 1772 unsigned char packet[] = { |
1488 // public flags (8 byte connection_id) | 1773 // public flags (8 byte connection_id) |
1489 0x38, | 1774 0x38, |
1490 // connection_id | 1775 // connection_id |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 // offset | 1810 // offset |
1526 0x54, 0x76, 0x10, 0x32, | 1811 0x54, 0x76, 0x10, 0x32, |
1527 0xDC, 0xFE, 0x98, 0xBA, | 1812 0xDC, 0xFE, 0x98, 0xBA, |
1528 // data length | 1813 // data length |
1529 0x0c, 0x00, | 1814 0x0c, 0x00, |
1530 // data | 1815 // data |
1531 'h', 'e', 'l', 'l', | 1816 'h', 'e', 'l', 'l', |
1532 'o', ' ', 'w', 'o', | 1817 'o', ' ', 'w', 'o', |
1533 'r', 'l', 'd', '!', | 1818 'r', 'l', 'd', '!', |
1534 }; | 1819 }; |
| 1820 |
| 1821 unsigned char packet39[] = { |
| 1822 // public flags (8 byte connection_id) |
| 1823 0x38, |
| 1824 // connection_id |
| 1825 0x10, 0x32, 0x54, 0x76, |
| 1826 0x98, 0xBA, 0xDC, 0xFE, |
| 1827 // packet number |
| 1828 0x12, 0x34, 0x56, 0x78, |
| 1829 0x9A, 0xBC, |
| 1830 |
| 1831 // frame type (stream frame with fin) |
| 1832 0xFE, |
| 1833 // stream id |
| 1834 0x02, 0x03, 0x04, |
| 1835 // offset |
| 1836 0xBA, 0x98, 0xFE, 0xDC, |
| 1837 0x32, 0x10, 0x76, 0x54, |
| 1838 // data length |
| 1839 0x00, 0x0c, |
| 1840 // data |
| 1841 'h', 'e', 'l', 'l', |
| 1842 'o', ' ', 'w', 'o', |
| 1843 'r', 'l', 'd', '!', |
| 1844 }; |
| 1845 |
| 1846 unsigned char packet_cid_be39[] = { |
| 1847 // public flags (8 byte connection_id) |
| 1848 0x38, |
| 1849 // connection_id |
| 1850 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 1851 // packet number |
| 1852 0x12, 0x34, 0x56, 0x78, |
| 1853 0x9A, 0xBC, |
| 1854 |
| 1855 // frame type (stream frame with fin) |
| 1856 0xFE, |
| 1857 // stream id |
| 1858 0x02, 0x03, 0x04, |
| 1859 // offset |
| 1860 0xBA, 0x98, 0xFE, 0xDC, |
| 1861 0x32, 0x10, 0x76, 0x54, |
| 1862 // data length |
| 1863 0x00, 0x0c, |
| 1864 // data |
| 1865 'h', 'e', 'l', 'l', |
| 1866 'o', ' ', 'w', 'o', |
| 1867 'r', 'l', 'd', '!', |
| 1868 }; |
1535 // clang-format on | 1869 // clang-format on |
1536 | 1870 |
1537 QuicEncryptedPacket encrypted( | 1871 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1538 AsChars( | 1872 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1539 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 1873 |
1540 ? packet_cid_be | 1874 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1541 : packet), | 1875 false); |
1542 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1543 ? arraysize(packet_cid_be) | |
1544 : arraysize(packet), | |
1545 false); | |
1546 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1876 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1547 | 1877 |
1548 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1878 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1549 ASSERT_TRUE(visitor_.header_.get()); | 1879 ASSERT_TRUE(visitor_.header_.get()); |
1550 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 1880 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
1551 !kIncludeDiversificationNonce)); | 1881 !kIncludeDiversificationNonce)); |
1552 | 1882 |
1553 ASSERT_EQ(1u, visitor_.stream_frames_.size()); | 1883 ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
1554 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 1884 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1555 // Stream ID should be the last 3 bytes of kStreamId. | 1885 // Stream ID should be the last 3 bytes of kStreamId. |
1556 EXPECT_EQ(0x00FFFFFF & kStreamId, visitor_.stream_frames_[0]->stream_id); | 1886 EXPECT_EQ(0x00FFFFFF & kStreamId, visitor_.stream_frames_[0]->stream_id); |
1557 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); | 1887 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); |
1558 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); | 1888 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); |
1559 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); | 1889 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); |
1560 | 1890 |
1561 // Now test framing boundaries. | 1891 // Now test framing boundaries. |
1562 const size_t stream_id_size = 3; | 1892 const size_t stream_id_size = 3; |
1563 CheckStreamFrameBoundaries( | 1893 CheckStreamFrameBoundaries(packets[index], stream_id_size, !kIncludeVersion); |
1564 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1565 ? packet_cid_be | |
1566 : packet, | |
1567 stream_id_size, !kIncludeVersion); | |
1568 } | 1894 } |
1569 | 1895 |
1570 TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { | 1896 TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { |
1571 // clang-format off | 1897 // clang-format off |
1572 unsigned char packet[] = { | 1898 unsigned char packet[] = { |
1573 // public flags (8 byte connection_id) | 1899 // public flags (8 byte connection_id) |
1574 0x38, | 1900 0x38, |
1575 // connection_id | 1901 // connection_id |
1576 0x10, 0x32, 0x54, 0x76, | 1902 0x10, 0x32, 0x54, 0x76, |
1577 0x98, 0xBA, 0xDC, 0xFE, | 1903 0x98, 0xBA, 0xDC, 0xFE, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 // offset | 1936 // offset |
1611 0x54, 0x76, 0x10, 0x32, | 1937 0x54, 0x76, 0x10, 0x32, |
1612 0xDC, 0xFE, 0x98, 0xBA, | 1938 0xDC, 0xFE, 0x98, 0xBA, |
1613 // data length | 1939 // data length |
1614 0x0c, 0x00, | 1940 0x0c, 0x00, |
1615 // data | 1941 // data |
1616 'h', 'e', 'l', 'l', | 1942 'h', 'e', 'l', 'l', |
1617 'o', ' ', 'w', 'o', | 1943 'o', ' ', 'w', 'o', |
1618 'r', 'l', 'd', '!', | 1944 'r', 'l', 'd', '!', |
1619 }; | 1945 }; |
| 1946 |
| 1947 unsigned char packet39[] = { |
| 1948 // public flags (8 byte connection_id) |
| 1949 0x38, |
| 1950 // connection_id |
| 1951 0x10, 0x32, 0x54, 0x76, |
| 1952 0x98, 0xBA, 0xDC, 0xFE, |
| 1953 // packet number |
| 1954 0x12, 0x34, 0x56, 0x78, |
| 1955 0x9A, 0xBC, |
| 1956 |
| 1957 // frame type (stream frame with fin) |
| 1958 0xFD, |
| 1959 // stream id |
| 1960 0x03, 0x04, |
| 1961 // offset |
| 1962 0xBA, 0x98, 0xFE, 0xDC, |
| 1963 0x32, 0x10, 0x76, 0x54, |
| 1964 // data length |
| 1965 0x00, 0x0c, |
| 1966 // data |
| 1967 'h', 'e', 'l', 'l', |
| 1968 'o', ' ', 'w', 'o', |
| 1969 'r', 'l', 'd', '!', |
| 1970 }; |
| 1971 |
| 1972 unsigned char packet_cid_be39[] = { |
| 1973 // public flags (8 byte connection_id) |
| 1974 0x38, |
| 1975 // connection_id |
| 1976 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 1977 // packet number |
| 1978 0x12, 0x34, 0x56, 0x78, |
| 1979 0x9A, 0xBC, |
| 1980 |
| 1981 // frame type (stream frame with fin) |
| 1982 0xFD, |
| 1983 // stream id |
| 1984 0x03, 0x04, |
| 1985 // offset |
| 1986 0xBA, 0x98, 0xFE, 0xDC, |
| 1987 0x32, 0x10, 0x76, 0x54, |
| 1988 // data length |
| 1989 0x00, 0x0c, |
| 1990 // data |
| 1991 'h', 'e', 'l', 'l', |
| 1992 'o', ' ', 'w', 'o', |
| 1993 'r', 'l', 'd', '!', |
| 1994 }; |
1620 // clang-format on | 1995 // clang-format on |
1621 | 1996 |
1622 QuicEncryptedPacket encrypted( | 1997 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1623 AsChars( | 1998 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1624 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 1999 |
1625 ? packet_cid_be | 2000 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1626 : packet), | 2001 false); |
1627 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1628 ? arraysize(packet_cid_be) | |
1629 : arraysize(packet), | |
1630 false); | |
1631 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 2002 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1632 | 2003 |
1633 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 2004 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1634 ASSERT_TRUE(visitor_.header_.get()); | 2005 ASSERT_TRUE(visitor_.header_.get()); |
1635 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 2006 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
1636 !kIncludeDiversificationNonce)); | 2007 !kIncludeDiversificationNonce)); |
1637 | 2008 |
1638 ASSERT_EQ(1u, visitor_.stream_frames_.size()); | 2009 ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
1639 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 2010 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1640 // Stream ID should be the last 2 bytes of kStreamId. | 2011 // Stream ID should be the last 2 bytes of kStreamId. |
1641 EXPECT_EQ(0x0000FFFF & kStreamId, visitor_.stream_frames_[0]->stream_id); | 2012 EXPECT_EQ(0x0000FFFF & kStreamId, visitor_.stream_frames_[0]->stream_id); |
1642 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); | 2013 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); |
1643 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); | 2014 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); |
1644 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); | 2015 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); |
1645 | 2016 |
1646 // Now test framing boundaries. | 2017 // Now test framing boundaries. |
1647 const size_t stream_id_size = 2; | 2018 const size_t stream_id_size = 2; |
1648 CheckStreamFrameBoundaries( | 2019 CheckStreamFrameBoundaries(packets[index], stream_id_size, !kIncludeVersion); |
1649 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1650 ? packet_cid_be | |
1651 : packet, | |
1652 stream_id_size, !kIncludeVersion); | |
1653 } | 2020 } |
1654 | 2021 |
1655 TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) { | 2022 TEST_P(QuicFramerTest, StreamFrame1ByteStreamId) { |
1656 // clang-format off | 2023 // clang-format off |
1657 unsigned char packet[] = { | 2024 unsigned char packet[] = { |
1658 // public flags (8 byte connection_id) | 2025 // public flags (8 byte connection_id) |
1659 0x38, | 2026 0x38, |
1660 // connection_id | 2027 // connection_id |
1661 0x10, 0x32, 0x54, 0x76, | 2028 0x10, 0x32, 0x54, 0x76, |
1662 0x98, 0xBA, 0xDC, 0xFE, | 2029 0x98, 0xBA, 0xDC, 0xFE, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1695 // offset | 2062 // offset |
1696 0x54, 0x76, 0x10, 0x32, | 2063 0x54, 0x76, 0x10, 0x32, |
1697 0xDC, 0xFE, 0x98, 0xBA, | 2064 0xDC, 0xFE, 0x98, 0xBA, |
1698 // data length | 2065 // data length |
1699 0x0c, 0x00, | 2066 0x0c, 0x00, |
1700 // data | 2067 // data |
1701 'h', 'e', 'l', 'l', | 2068 'h', 'e', 'l', 'l', |
1702 'o', ' ', 'w', 'o', | 2069 'o', ' ', 'w', 'o', |
1703 'r', 'l', 'd', '!', | 2070 'r', 'l', 'd', '!', |
1704 }; | 2071 }; |
| 2072 |
| 2073 unsigned char packet39[] = { |
| 2074 // public flags (8 byte connection_id) |
| 2075 0x38, |
| 2076 // connection_id |
| 2077 0x10, 0x32, 0x54, 0x76, |
| 2078 0x98, 0xBA, 0xDC, 0xFE, |
| 2079 // packet number |
| 2080 0x12, 0x34, 0x56, 0x78, |
| 2081 0x9A, 0xBC, |
| 2082 |
| 2083 // frame type (stream frame with fin) |
| 2084 0xFC, |
| 2085 // stream id |
| 2086 0x04, |
| 2087 // offset |
| 2088 0xBA, 0x98, 0xFE, 0xDC, |
| 2089 0x32, 0x10, 0x76, 0x54, |
| 2090 // data length |
| 2091 0x00, 0x0c, |
| 2092 // data |
| 2093 'h', 'e', 'l', 'l', |
| 2094 'o', ' ', 'w', 'o', |
| 2095 'r', 'l', 'd', '!', |
| 2096 }; |
| 2097 |
| 2098 unsigned char packet_cid_be39[] = { |
| 2099 // public flags (8 byte connection_id) |
| 2100 0x38, |
| 2101 // connection_id |
| 2102 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 2103 // packet number |
| 2104 0x12, 0x34, 0x56, 0x78, |
| 2105 0x9A, 0xBC, |
| 2106 |
| 2107 // frame type (stream frame with fin) |
| 2108 0xFC, |
| 2109 // stream id |
| 2110 0x04, |
| 2111 // offset |
| 2112 0xBA, 0x98, 0xFE, 0xDC, |
| 2113 0x32, 0x10, 0x76, 0x54, |
| 2114 // data length |
| 2115 0x00, 0x0c, |
| 2116 // data |
| 2117 'h', 'e', 'l', 'l', |
| 2118 'o', ' ', 'w', 'o', |
| 2119 'r', 'l', 'd', '!', |
| 2120 }; |
1705 // clang-format on | 2121 // clang-format on |
1706 | 2122 |
1707 QuicEncryptedPacket encrypted( | 2123 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1708 AsChars( | 2124 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1709 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2125 |
1710 ? packet_cid_be | 2126 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1711 : packet), | 2127 false); |
1712 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1713 ? arraysize(packet_cid_be) | |
1714 : arraysize(packet), | |
1715 false); | |
1716 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 2128 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1717 | 2129 |
1718 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 2130 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1719 ASSERT_TRUE(visitor_.header_.get()); | 2131 ASSERT_TRUE(visitor_.header_.get()); |
1720 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 2132 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
1721 !kIncludeDiversificationNonce)); | 2133 !kIncludeDiversificationNonce)); |
1722 | 2134 |
1723 ASSERT_EQ(1u, visitor_.stream_frames_.size()); | 2135 ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
1724 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 2136 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1725 // Stream ID should be the last byte of kStreamId. | 2137 // Stream ID should be the last byte of kStreamId. |
1726 EXPECT_EQ(0x000000FF & kStreamId, visitor_.stream_frames_[0]->stream_id); | 2138 EXPECT_EQ(0x000000FF & kStreamId, visitor_.stream_frames_[0]->stream_id); |
1727 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); | 2139 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); |
1728 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); | 2140 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); |
1729 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); | 2141 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); |
1730 | 2142 |
1731 // Now test framing boundaries. | 2143 // Now test framing boundaries. |
1732 const size_t stream_id_size = 1; | 2144 const size_t stream_id_size = 1; |
1733 CheckStreamFrameBoundaries( | 2145 CheckStreamFrameBoundaries(packets[index], stream_id_size, !kIncludeVersion); |
1734 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1735 ? packet_cid_be | |
1736 : packet, | |
1737 stream_id_size, !kIncludeVersion); | |
1738 } | 2146 } |
1739 | 2147 |
1740 TEST_P(QuicFramerTest, StreamFrameWithVersion) { | 2148 TEST_P(QuicFramerTest, StreamFrameWithVersion) { |
1741 // clang-format off | 2149 // clang-format off |
1742 unsigned char packet[] = { | 2150 unsigned char packet[] = { |
1743 // public flags (version, 8 byte connection_id) | 2151 // public flags (version, 8 byte connection_id) |
1744 0x39, | 2152 0x39, |
1745 // connection_id | 2153 // connection_id |
1746 0x10, 0x32, 0x54, 0x76, | 2154 0x10, 0x32, 0x54, 0x76, |
1747 0x98, 0xBA, 0xDC, 0xFE, | 2155 0x98, 0xBA, 0xDC, 0xFE, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 // offset | 2192 // offset |
1785 0x54, 0x76, 0x10, 0x32, | 2193 0x54, 0x76, 0x10, 0x32, |
1786 0xDC, 0xFE, 0x98, 0xBA, | 2194 0xDC, 0xFE, 0x98, 0xBA, |
1787 // data length | 2195 // data length |
1788 0x0c, 0x00, | 2196 0x0c, 0x00, |
1789 // data | 2197 // data |
1790 'h', 'e', 'l', 'l', | 2198 'h', 'e', 'l', 'l', |
1791 'o', ' ', 'w', 'o', | 2199 'o', ' ', 'w', 'o', |
1792 'r', 'l', 'd', '!', | 2200 'r', 'l', 'd', '!', |
1793 }; | 2201 }; |
| 2202 |
| 2203 unsigned char packet39[] = { |
| 2204 // public flags (version, 8 byte connection_id) |
| 2205 0x39, |
| 2206 // connection_id |
| 2207 0x10, 0x32, 0x54, 0x76, |
| 2208 0x98, 0xBA, 0xDC, 0xFE, |
| 2209 // version tag |
| 2210 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
| 2211 // packet number |
| 2212 0x12, 0x34, 0x56, 0x78, |
| 2213 0x9A, 0xBC, |
| 2214 |
| 2215 // frame type (stream frame with fin) |
| 2216 0xFF, |
| 2217 // stream id |
| 2218 0x01, 0x02, 0x03, 0x04, |
| 2219 // offset |
| 2220 0xBA, 0x98, 0xFE, 0xDC, |
| 2221 0x32, 0x10, 0x76, 0x54, |
| 2222 // data length |
| 2223 0x00, 0x0c, |
| 2224 // data |
| 2225 'h', 'e', 'l', 'l', |
| 2226 'o', ' ', 'w', 'o', |
| 2227 'r', 'l', 'd', '!', |
| 2228 }; |
| 2229 |
| 2230 unsigned char packet_cid_be39[] = { |
| 2231 // public flags (version, 8 byte connection_id) |
| 2232 0x39, |
| 2233 // connection_id |
| 2234 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 2235 // version tag |
| 2236 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
| 2237 // packet number |
| 2238 0x12, 0x34, 0x56, 0x78, |
| 2239 0x9A, 0xBC, |
| 2240 |
| 2241 // frame type (stream frame with fin) |
| 2242 0xFF, |
| 2243 // stream id |
| 2244 0x01, 0x02, 0x03, 0x04, |
| 2245 // offset |
| 2246 0xBA, 0x98, 0xFE, 0xDC, |
| 2247 0x32, 0x10, 0x76, 0x54, |
| 2248 // data length |
| 2249 0x00, 0x0c, |
| 2250 // data |
| 2251 'h', 'e', 'l', 'l', |
| 2252 'o', ' ', 'w', 'o', |
| 2253 'r', 'l', 'd', '!', |
| 2254 }; |
1794 // clang-format on | 2255 // clang-format on |
1795 | 2256 |
1796 QuicEncryptedPacket encrypted( | 2257 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1797 AsChars( | 2258 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1798 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2259 |
1799 ? packet_cid_be | 2260 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1800 : packet), | 2261 false); |
1801 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1802 ? arraysize(packet_cid_be) | |
1803 : arraysize(packet), | |
1804 false); | |
1805 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 2262 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1806 | 2263 |
1807 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 2264 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1808 ASSERT_TRUE(visitor_.header_.get()); | 2265 ASSERT_TRUE(visitor_.header_.get()); |
1809 EXPECT_TRUE(visitor_.header_->public_header.version_flag); | 2266 EXPECT_TRUE(visitor_.header_->public_header.version_flag); |
1810 EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]); | 2267 EXPECT_EQ(GetParam(), visitor_.header_->public_header.versions[0]); |
1811 EXPECT_TRUE(CheckDecryption(encrypted, kIncludeVersion, | 2268 EXPECT_TRUE(CheckDecryption(encrypted, kIncludeVersion, |
1812 !kIncludeDiversificationNonce)); | 2269 !kIncludeDiversificationNonce)); |
1813 | 2270 |
1814 ASSERT_EQ(1u, visitor_.stream_frames_.size()); | 2271 ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
1815 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 2272 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1816 EXPECT_EQ(kStreamId, visitor_.stream_frames_[0]->stream_id); | 2273 EXPECT_EQ(kStreamId, visitor_.stream_frames_[0]->stream_id); |
1817 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); | 2274 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); |
1818 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); | 2275 EXPECT_EQ(kStreamOffset, visitor_.stream_frames_[0]->offset); |
1819 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); | 2276 CheckStreamFrameData("hello world!", visitor_.stream_frames_[0].get()); |
1820 | 2277 |
1821 // Now test framing boundaries. | 2278 // Now test framing boundaries. |
1822 CheckStreamFrameBoundaries( | 2279 CheckStreamFrameBoundaries(packets[index], kQuicMaxStreamIdSize, |
1823 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2280 kIncludeVersion); |
1824 ? packet_cid_be | |
1825 : packet, | |
1826 kQuicMaxStreamIdSize, kIncludeVersion); | |
1827 } | 2281 } |
1828 | 2282 |
1829 TEST_P(QuicFramerTest, RejectPacket) { | 2283 TEST_P(QuicFramerTest, RejectPacket) { |
1830 visitor_.accept_packet_ = false; | 2284 visitor_.accept_packet_ = false; |
1831 | 2285 |
1832 // clang-format off | 2286 // clang-format off |
1833 unsigned char packet[] = { | 2287 unsigned char packet[] = { |
1834 // public flags (8 byte connection_id) | 2288 // public flags (8 byte connection_id) |
1835 0x38, | 2289 0x38, |
1836 // connection_id | 2290 // connection_id |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 // offset | 2325 // offset |
1872 0x54, 0x76, 0x10, 0x32, | 2326 0x54, 0x76, 0x10, 0x32, |
1873 0xDC, 0xFE, 0x98, 0xBA, | 2327 0xDC, 0xFE, 0x98, 0xBA, |
1874 // data length | 2328 // data length |
1875 0x0c, 0x00, | 2329 0x0c, 0x00, |
1876 // data | 2330 // data |
1877 'h', 'e', 'l', 'l', | 2331 'h', 'e', 'l', 'l', |
1878 'o', ' ', 'w', 'o', | 2332 'o', ' ', 'w', 'o', |
1879 'r', 'l', 'd', '!', | 2333 'r', 'l', 'd', '!', |
1880 }; | 2334 }; |
| 2335 |
| 2336 unsigned char packet39[] = { |
| 2337 // public flags (8 byte connection_id) |
| 2338 0x38, |
| 2339 // connection_id |
| 2340 0x10, 0x32, 0x54, 0x76, |
| 2341 0x98, 0xBA, 0xDC, 0xFE, |
| 2342 // packet number |
| 2343 0x12, 0x34, 0x56, 0x78, |
| 2344 0x9A, 0xBC, |
| 2345 |
| 2346 // frame type (stream frame with fin) |
| 2347 0xFF, |
| 2348 // stream id |
| 2349 0x01, 0x02, 0x03, 0x04, |
| 2350 // offset |
| 2351 0xBA, 0x98, 0xFE, 0xDC, |
| 2352 0x32, 0x10, 0x76, 0x54, |
| 2353 // data length |
| 2354 0x00, 0x0c, |
| 2355 // data |
| 2356 'h', 'e', 'l', 'l', |
| 2357 'o', ' ', 'w', 'o', |
| 2358 'r', 'l', 'd', '!', |
| 2359 }; |
| 2360 |
| 2361 unsigned char packet_cid_be39[] = { |
| 2362 // public flags (8 byte connection_id) |
| 2363 0x38, |
| 2364 // connection_id |
| 2365 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 2366 // packet number |
| 2367 0x12, 0x34, 0x56, 0x78, |
| 2368 0x9A, 0xBC, |
| 2369 |
| 2370 // frame type (stream frame with fin) |
| 2371 0xFF, |
| 2372 // stream id |
| 2373 0x01, 0x02, 0x03, 0x04, |
| 2374 // offset |
| 2375 0xBA, 0x98, 0xFE, 0xDC, |
| 2376 0x32, 0x10, 0x76, 0x54, |
| 2377 // data length |
| 2378 0x00, 0x0c, |
| 2379 // data |
| 2380 'h', 'e', 'l', 'l', |
| 2381 'o', ' ', 'w', 'o', |
| 2382 'r', 'l', 'd', '!', |
| 2383 }; |
1881 // clang-format on | 2384 // clang-format on |
1882 | 2385 |
1883 QuicEncryptedPacket encrypted( | 2386 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1884 AsChars( | 2387 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1885 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2388 |
1886 ? packet_cid_be | 2389 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1887 : packet), | 2390 false); |
1888 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1889 ? arraysize(packet_cid_be) | |
1890 : arraysize(packet), | |
1891 false); | |
1892 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 2391 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1893 | 2392 |
1894 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 2393 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1895 ASSERT_TRUE(visitor_.header_.get()); | 2394 ASSERT_TRUE(visitor_.header_.get()); |
1896 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 2395 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
1897 !kIncludeDiversificationNonce)); | 2396 !kIncludeDiversificationNonce)); |
1898 | 2397 |
1899 ASSERT_EQ(0u, visitor_.stream_frames_.size()); | 2398 ASSERT_EQ(0u, visitor_.stream_frames_.size()); |
1900 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 2399 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1901 } | 2400 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 0x45, | 2470 0x45, |
1972 // largest acked | 2471 // largest acked |
1973 0x34, 0x12, | 2472 0x34, 0x12, |
1974 // Zero delta time. | 2473 // Zero delta time. |
1975 0x00, 0x00, | 2474 0x00, 0x00, |
1976 // first ack block length. | 2475 // first ack block length. |
1977 0x34, 0x12, | 2476 0x34, 0x12, |
1978 // num timestamps. | 2477 // num timestamps. |
1979 0x00, | 2478 0x00, |
1980 }; | 2479 }; |
| 2480 |
| 2481 unsigned char packet39[] = { |
| 2482 // public flags (8 byte connection_id) |
| 2483 0x3C, |
| 2484 // connection_id |
| 2485 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 2486 // packet number |
| 2487 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 2488 |
| 2489 // frame type (ack frame) |
| 2490 // (one ack block, 2 byte largest observed, 2 byte block length) |
| 2491 0x45, |
| 2492 // largest acked |
| 2493 0x12, 0x34, |
| 2494 // Zero delta time. |
| 2495 0x00, 0x00, |
| 2496 // first ack block length. |
| 2497 0x12, 0x34, |
| 2498 // num timestamps. |
| 2499 0x00, |
| 2500 }; |
| 2501 |
| 2502 unsigned char packet_cid_be39[] = { |
| 2503 // public flags (8 byte connection_id) |
| 2504 0x3C, |
| 2505 // connection_id |
| 2506 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 2507 // packet number |
| 2508 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 2509 |
| 2510 // frame type (ack frame) |
| 2511 // (one ack block, 2 byte largest observed, 2 byte block length) |
| 2512 0x45, |
| 2513 // largest acked |
| 2514 0x12, 0x34, |
| 2515 // Zero delta time. |
| 2516 0x00, 0x00, |
| 2517 // first ack block length. |
| 2518 0x12, 0x34, |
| 2519 // num timestamps. |
| 2520 0x00, |
| 2521 }; |
1981 // clang-format on | 2522 // clang-format on |
1982 | 2523 |
1983 QuicEncryptedPacket encrypted( | 2524 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
1984 AsChars( | 2525 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
1985 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2526 |
1986 ? packet_cid_be | 2527 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
1987 : packet), | 2528 false); |
1988 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
1989 ? arraysize(packet_cid_be) | |
1990 : arraysize(packet), | |
1991 false); | |
1992 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 2529 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1993 | 2530 |
1994 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 2531 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1995 ASSERT_TRUE(visitor_.header_.get()); | 2532 ASSERT_TRUE(visitor_.header_.get()); |
1996 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 2533 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
1997 !kIncludeDiversificationNonce)); | 2534 !kIncludeDiversificationNonce)); |
1998 | 2535 |
1999 EXPECT_EQ(0u, visitor_.stream_frames_.size()); | 2536 EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
2000 ASSERT_EQ(1u, visitor_.ack_frames_.size()); | 2537 ASSERT_EQ(1u, visitor_.ack_frames_.size()); |
2001 const QuicAckFrame& frame = *visitor_.ack_frames_[0]; | 2538 const QuicAckFrame& frame = *visitor_.ack_frames_[0]; |
(...skipping 15 matching lines...) Expand all Loading... |
2017 if (i < kLargestAckedDeltaTimeOffset) { | 2554 if (i < kLargestAckedDeltaTimeOffset) { |
2018 expected_error = "Unable to read largest acked."; | 2555 expected_error = "Unable to read largest acked."; |
2019 } else if (i < kFirstAckBlockLengthOffset) { | 2556 } else if (i < kFirstAckBlockLengthOffset) { |
2020 expected_error = "Unable to read ack delay time."; | 2557 expected_error = "Unable to read ack delay time."; |
2021 } else if (i < kNumTimestampsOffset) { | 2558 } else if (i < kNumTimestampsOffset) { |
2022 expected_error = "Unable to read first ack block length."; | 2559 expected_error = "Unable to read first ack block length."; |
2023 } else { | 2560 } else { |
2024 expected_error = "Unable to read num received packets."; | 2561 expected_error = "Unable to read num received packets."; |
2025 } | 2562 } |
2026 CheckProcessingFails( | 2563 CheckProcessingFails( |
2027 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2564 packets[index], |
2028 ? packet_cid_be | |
2029 : packet, | |
2030 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 2565 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
2031 !kIncludeVersion, !kIncludeDiversificationNonce, | 2566 !kIncludeVersion, !kIncludeDiversificationNonce, |
2032 PACKET_6BYTE_PACKET_NUMBER), | 2567 PACKET_6BYTE_PACKET_NUMBER), |
2033 expected_error, QUIC_INVALID_ACK_DATA); | 2568 expected_error, QUIC_INVALID_ACK_DATA); |
2034 } | 2569 } |
2035 } | 2570 } |
2036 | 2571 |
2037 TEST_P(QuicFramerTest, AckFrameTwoTimeStampsMultipleAckBlocks) { | 2572 TEST_P(QuicFramerTest, AckFrameTwoTimeStampsMultipleAckBlocks) { |
2038 // clang-format off | 2573 // clang-format off |
2039 unsigned char packet[] = { | 2574 unsigned char packet[] = { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 0x02, | 2657 0x02, |
2123 // Delta from largest observed. | 2658 // Delta from largest observed. |
2124 0x01, | 2659 0x01, |
2125 // Delta time. | 2660 // Delta time. |
2126 0x10, 0x32, 0x54, 0x76, | 2661 0x10, 0x32, 0x54, 0x76, |
2127 // Delta from largest observed. | 2662 // Delta from largest observed. |
2128 0x02, | 2663 0x02, |
2129 // Delta time. | 2664 // Delta time. |
2130 0x10, 0x32, | 2665 0x10, 0x32, |
2131 }; | 2666 }; |
| 2667 |
| 2668 unsigned char packet39[] = { |
| 2669 // public flags (8 byte connection_id) |
| 2670 0x3C, |
| 2671 // connection_id |
| 2672 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 2673 // packet number |
| 2674 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 2675 |
| 2676 // frame type (ack frame) |
| 2677 // (more than one ack block, 2 byte largest observed, 2 byte block length) |
| 2678 0x65, |
| 2679 // largest acked |
| 2680 0x12, 0x34, |
| 2681 // Zero delta time. |
| 2682 0x00, 0x00, |
| 2683 // num ack blocks ranges. |
| 2684 0x04, |
| 2685 // first ack block length. |
| 2686 0x00, 0x01, |
| 2687 // gap to next block. |
| 2688 0x01, |
| 2689 // ack block length. |
| 2690 0x0e, 0xaf, |
| 2691 // gap to next block. |
| 2692 0xff, |
| 2693 // ack block length. |
| 2694 0x00, 0x00, |
| 2695 // gap to next block. |
| 2696 0x91, |
| 2697 // ack block length. |
| 2698 0x01, 0xea, |
| 2699 // gap to next block. |
| 2700 0x05, |
| 2701 // ack block length. |
| 2702 0x00, 0x04, |
| 2703 // Number of timestamps. |
| 2704 0x02, |
| 2705 // Delta from largest observed. |
| 2706 0x01, |
| 2707 // Delta time. |
| 2708 0x76, 0x54, 0x32, 0x10, |
| 2709 // Delta from largest observed. |
| 2710 0x02, |
| 2711 // Delta time. |
| 2712 0x32, 0x10, |
| 2713 }; |
| 2714 |
| 2715 unsigned char packet_cid_be39[] = { |
| 2716 // public flags (8 byte connection_id) |
| 2717 0x3C, |
| 2718 // connection_id |
| 2719 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 2720 // packet number |
| 2721 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 2722 |
| 2723 // frame type (ack frame) |
| 2724 // (more than one ack block, 2 byte largest observed, 2 byte block length) |
| 2725 0x65, |
| 2726 // largest acked |
| 2727 0x12, 0x34, |
| 2728 // Zero delta time. |
| 2729 0x00, 0x00, |
| 2730 // num ack blocks ranges. |
| 2731 0x04, |
| 2732 // first ack block length. |
| 2733 0x00, 0x01, |
| 2734 // gap to next block. |
| 2735 0x01, |
| 2736 // ack block length. |
| 2737 0x0e, 0xaf, |
| 2738 // gap to next block. |
| 2739 0xff, |
| 2740 // ack block length. |
| 2741 0x00, 0x00, |
| 2742 // gap to next block. |
| 2743 0x91, |
| 2744 // ack block length. |
| 2745 0x01, 0xea, |
| 2746 // gap to next block. |
| 2747 0x05, |
| 2748 // ack block length. |
| 2749 0x00, 0x04, |
| 2750 // Number of timestamps. |
| 2751 0x02, |
| 2752 // Delta from largest observed. |
| 2753 0x01, |
| 2754 // Delta time. |
| 2755 0x76, 0x54, 0x32, 0x10, |
| 2756 // Delta from largest observed. |
| 2757 0x02, |
| 2758 // Delta time. |
| 2759 0x32, 0x10, |
| 2760 }; |
2132 // clang-format on | 2761 // clang-format on |
2133 | 2762 |
2134 QuicEncryptedPacket encrypted( | 2763 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
2135 AsChars( | 2764 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
2136 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2765 |
2137 ? packet_cid_be | 2766 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
2138 : packet), | 2767 false); |
2139 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
2140 ? arraysize(packet_cid_be) | |
2141 : arraysize(packet), | |
2142 false); | |
2143 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 2768 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2144 | 2769 |
2145 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 2770 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
2146 ASSERT_TRUE(visitor_.header_.get()); | 2771 ASSERT_TRUE(visitor_.header_.get()); |
2147 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 2772 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
2148 !kIncludeDiversificationNonce)); | 2773 !kIncludeDiversificationNonce)); |
2149 | 2774 |
2150 EXPECT_EQ(0u, visitor_.stream_frames_.size()); | 2775 EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
2151 ASSERT_EQ(1u, visitor_.ack_frames_.size()); | 2776 ASSERT_EQ(1u, visitor_.ack_frames_.size()); |
2152 const QuicAckFrame& frame = *visitor_.ack_frames_[0]; | 2777 const QuicAckFrame& frame = *visitor_.ack_frames_[0]; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2219 } else if (i < kTimestampDeltaLargestObserved2) { | 2844 } else if (i < kTimestampDeltaLargestObserved2) { |
2220 expected_error = "Unable to read time delta in received packets."; | 2845 expected_error = "Unable to read time delta in received packets."; |
2221 } else if (i < kTimestampTimeDeltaLargestObserved2) { | 2846 } else if (i < kTimestampTimeDeltaLargestObserved2) { |
2222 expected_error = "Unable to read sequence delta in received packets."; | 2847 expected_error = "Unable to read sequence delta in received packets."; |
2223 } else { | 2848 } else { |
2224 expected_error = | 2849 expected_error = |
2225 "Unable to read incremental time delta in received packets."; | 2850 "Unable to read incremental time delta in received packets."; |
2226 } | 2851 } |
2227 | 2852 |
2228 CheckProcessingFails( | 2853 CheckProcessingFails( |
2229 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2854 packets[index], |
2230 ? packet_cid_be | |
2231 : packet, | |
2232 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 2855 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
2233 !kIncludeVersion, !kIncludeDiversificationNonce, | 2856 !kIncludeVersion, !kIncludeDiversificationNonce, |
2234 PACKET_6BYTE_PACKET_NUMBER), | 2857 PACKET_6BYTE_PACKET_NUMBER), |
2235 expected_error, QUIC_INVALID_ACK_DATA); | 2858 expected_error, QUIC_INVALID_ACK_DATA); |
2236 } | 2859 } |
2237 } | 2860 } |
2238 | 2861 |
2239 TEST_P(QuicFramerTest, NewStopWaitingFrame) { | 2862 TEST_P(QuicFramerTest, NewStopWaitingFrame) { |
2240 // clang-format off | 2863 // clang-format off |
2241 unsigned char packet[] = { | 2864 unsigned char packet[] = { |
(...skipping 19 matching lines...) Expand all Loading... |
2261 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 2884 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
2262 // packet number | 2885 // packet number |
2263 0xA8, 0x9A, 0x78, 0x56, | 2886 0xA8, 0x9A, 0x78, 0x56, |
2264 0x34, 0x12, | 2887 0x34, 0x12, |
2265 // frame type (stop waiting frame) | 2888 // frame type (stop waiting frame) |
2266 0x06, | 2889 0x06, |
2267 // least packet number awaiting an ack, delta from packet number. | 2890 // least packet number awaiting an ack, delta from packet number. |
2268 0x08, 0x00, 0x00, 0x00, | 2891 0x08, 0x00, 0x00, 0x00, |
2269 0x00, 0x00, | 2892 0x00, 0x00, |
2270 }; | 2893 }; |
| 2894 |
| 2895 unsigned char packet39[] = { |
| 2896 // public flags (8 byte connection_id) |
| 2897 0x3C, |
| 2898 // connection_id |
| 2899 0x10, 0x32, 0x54, 0x76, |
| 2900 0x98, 0xBA, 0xDC, 0xFE, |
| 2901 // packet number |
| 2902 0x12, 0x34, 0x56, 0x78, |
| 2903 0x9A, 0xA8, |
| 2904 // frame type (stop waiting frame) |
| 2905 0x06, |
| 2906 // least packet number awaiting an ack, delta from packet number. |
| 2907 0x00, 0x00, 0x00, 0x00, |
| 2908 0x00, 0x08, |
| 2909 }; |
| 2910 |
| 2911 unsigned char packet_cid_be39[] = { |
| 2912 // public flags (8 byte connection_id) |
| 2913 0x3C, |
| 2914 // connection_id |
| 2915 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 2916 // packet number |
| 2917 0x12, 0x34, 0x56, 0x78, |
| 2918 0x9A, 0xA8, |
| 2919 // frame type (stop waiting frame) |
| 2920 0x06, |
| 2921 // least packet number awaiting an ack, delta from packet number. |
| 2922 0x00, 0x00, 0x00, 0x00, |
| 2923 0x00, 0x08, |
| 2924 }; |
2271 // clang-format on | 2925 // clang-format on |
2272 | 2926 |
2273 QuicEncryptedPacket encrypted( | 2927 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
2274 AsChars( | 2928 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
2275 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2929 |
2276 ? packet_cid_be | 2930 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
2277 : packet), | 2931 false); |
2278 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
2279 ? arraysize(packet_cid_be) | |
2280 : arraysize(packet), | |
2281 false); | |
2282 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 2932 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2283 | 2933 |
2284 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 2934 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
2285 ASSERT_TRUE(visitor_.header_.get()); | 2935 ASSERT_TRUE(visitor_.header_.get()); |
2286 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 2936 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
2287 !kIncludeDiversificationNonce)); | 2937 !kIncludeDiversificationNonce)); |
2288 | 2938 |
2289 EXPECT_EQ(0u, visitor_.stream_frames_.size()); | 2939 EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
2290 ASSERT_EQ(1u, visitor_.stop_waiting_frames_.size()); | 2940 ASSERT_EQ(1u, visitor_.stop_waiting_frames_.size()); |
2291 const QuicStopWaitingFrame& frame = *visitor_.stop_waiting_frames_[0]; | 2941 const QuicStopWaitingFrame& frame = *visitor_.stop_waiting_frames_[0]; |
2292 EXPECT_EQ(kLeastUnacked, frame.least_unacked); | 2942 EXPECT_EQ(kLeastUnacked, frame.least_unacked); |
2293 | 2943 |
2294 const size_t frame_size = 7; | 2944 const size_t frame_size = 7; |
2295 for (size_t i = kQuicFrameTypeSize; i < frame_size; ++i) { | 2945 for (size_t i = kQuicFrameTypeSize; i < frame_size; ++i) { |
2296 string expected_error; | 2946 string expected_error; |
2297 expected_error = "Unable to read least unacked delta."; | 2947 expected_error = "Unable to read least unacked delta."; |
2298 CheckProcessingFails( | 2948 CheckProcessingFails( |
2299 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 2949 packets[index], |
2300 ? packet_cid_be | |
2301 : packet, | |
2302 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 2950 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
2303 !kIncludeVersion, !kIncludeDiversificationNonce, | 2951 !kIncludeVersion, !kIncludeDiversificationNonce, |
2304 PACKET_6BYTE_PACKET_NUMBER), | 2952 PACKET_6BYTE_PACKET_NUMBER), |
2305 expected_error, QUIC_INVALID_STOP_WAITING_DATA); | 2953 expected_error, QUIC_INVALID_STOP_WAITING_DATA); |
2306 } | 2954 } |
2307 } | 2955 } |
2308 | 2956 |
2309 TEST_P(QuicFramerTest, RstStreamFrameQuic) { | 2957 TEST_P(QuicFramerTest, RstStreamFrameQuic) { |
2310 // clang-format off | 2958 // clang-format off |
2311 unsigned char packet[] = { | 2959 unsigned char packet[] = { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2345 // stream id | 2993 // stream id |
2346 0x04, 0x03, 0x02, 0x01, | 2994 0x04, 0x03, 0x02, 0x01, |
2347 | 2995 |
2348 // sent byte offset | 2996 // sent byte offset |
2349 0x54, 0x76, 0x10, 0x32, | 2997 0x54, 0x76, 0x10, 0x32, |
2350 0xDC, 0xFE, 0x98, 0xBA, | 2998 0xDC, 0xFE, 0x98, 0xBA, |
2351 | 2999 |
2352 // error code | 3000 // error code |
2353 0x01, 0x00, 0x00, 0x00, | 3001 0x01, 0x00, 0x00, 0x00, |
2354 }; | 3002 }; |
| 3003 |
| 3004 unsigned char packet39[] = { |
| 3005 // public flags (8 byte connection_id) |
| 3006 0x38, |
| 3007 // connection_id |
| 3008 0x10, 0x32, 0x54, 0x76, |
| 3009 0x98, 0xBA, 0xDC, 0xFE, |
| 3010 // packet number |
| 3011 0x12, 0x34, 0x56, 0x78, |
| 3012 0x9A, 0xBC, |
| 3013 |
| 3014 // frame type (rst stream frame) |
| 3015 0x01, |
| 3016 // stream id |
| 3017 0x01, 0x02, 0x03, 0x04, |
| 3018 |
| 3019 // sent byte offset |
| 3020 0xBA, 0x98, 0xFE, 0xDC, |
| 3021 0x32, 0x10, 0x76, 0x54, |
| 3022 |
| 3023 // error code |
| 3024 0x00, 0x00, 0x00, 0x01, |
| 3025 }; |
| 3026 |
| 3027 unsigned char packet_cid_be39[] = { |
| 3028 // public flags (8 byte connection_id) |
| 3029 0x38, |
| 3030 // connection_id |
| 3031 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 3032 // packet number |
| 3033 0x12, 0x34, 0x56, 0x78, |
| 3034 0x9A, 0xBC, |
| 3035 |
| 3036 // frame type (rst stream frame) |
| 3037 0x01, |
| 3038 // stream id |
| 3039 0x01, 0x02, 0x03, 0x04, |
| 3040 |
| 3041 // sent byte offset |
| 3042 0xBA, 0x98, 0xFE, 0xDC, |
| 3043 0x32, 0x10, 0x76, 0x54, |
| 3044 |
| 3045 // error code |
| 3046 0x00, 0x00, 0x00, 0x01, |
| 3047 }; |
2355 // clang-format on | 3048 // clang-format on |
2356 | 3049 |
2357 QuicEncryptedPacket encrypted( | 3050 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
2358 AsChars( | 3051 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
2359 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3052 |
2360 ? packet_cid_be | 3053 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
2361 : packet), | 3054 false); |
2362 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
2363 ? arraysize(packet_cid_be) | |
2364 : arraysize(packet), | |
2365 false); | |
2366 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 3055 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2367 | 3056 |
2368 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 3057 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
2369 ASSERT_TRUE(visitor_.header_.get()); | 3058 ASSERT_TRUE(visitor_.header_.get()); |
2370 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 3059 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
2371 !kIncludeDiversificationNonce)); | 3060 !kIncludeDiversificationNonce)); |
2372 | 3061 |
2373 EXPECT_EQ(kStreamId, visitor_.rst_stream_frame_.stream_id); | 3062 EXPECT_EQ(kStreamId, visitor_.rst_stream_frame_.stream_id); |
2374 EXPECT_EQ(0x01, visitor_.rst_stream_frame_.error_code); | 3063 EXPECT_EQ(0x01, visitor_.rst_stream_frame_.error_code); |
2375 EXPECT_EQ(kStreamOffset, visitor_.rst_stream_frame_.byte_offset); | 3064 EXPECT_EQ(kStreamOffset, visitor_.rst_stream_frame_.byte_offset); |
2376 | 3065 |
2377 // Now test framing boundaries. | 3066 // Now test framing boundaries. |
2378 for (size_t i = kQuicFrameTypeSize; i < QuicFramer::GetRstStreamFrameSize(); | 3067 for (size_t i = kQuicFrameTypeSize; i < QuicFramer::GetRstStreamFrameSize(); |
2379 ++i) { | 3068 ++i) { |
2380 string expected_error; | 3069 string expected_error; |
2381 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { | 3070 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { |
2382 expected_error = "Unable to read stream_id."; | 3071 expected_error = "Unable to read stream_id."; |
2383 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + | 3072 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + |
2384 kQuicMaxStreamOffsetSize) { | 3073 kQuicMaxStreamOffsetSize) { |
2385 expected_error = "Unable to read rst stream sent byte offset."; | 3074 expected_error = "Unable to read rst stream sent byte offset."; |
2386 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + | 3075 } else if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize + |
2387 kQuicMaxStreamOffsetSize + kQuicErrorCodeSize) { | 3076 kQuicMaxStreamOffsetSize + kQuicErrorCodeSize) { |
2388 expected_error = "Unable to read rst stream error code."; | 3077 expected_error = "Unable to read rst stream error code."; |
2389 } | 3078 } |
2390 CheckProcessingFails( | 3079 CheckProcessingFails( |
2391 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3080 packets[index], |
2392 ? packet_cid_be | |
2393 : packet, | |
2394 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 3081 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
2395 !kIncludeVersion, !kIncludeDiversificationNonce, | 3082 !kIncludeVersion, !kIncludeDiversificationNonce, |
2396 PACKET_6BYTE_PACKET_NUMBER), | 3083 PACKET_6BYTE_PACKET_NUMBER), |
2397 expected_error, QUIC_INVALID_RST_STREAM_DATA); | 3084 expected_error, QUIC_INVALID_RST_STREAM_DATA); |
2398 } | 3085 } |
2399 } | 3086 } |
2400 | 3087 |
2401 TEST_P(QuicFramerTest, ConnectionCloseFrame) { | 3088 TEST_P(QuicFramerTest, ConnectionCloseFrame) { |
2402 // clang-format off | 3089 // clang-format off |
2403 unsigned char packet[] = { | 3090 unsigned char packet[] = { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 0x11, 0x00, 0x00, 0x00, | 3126 0x11, 0x00, 0x00, 0x00, |
2440 | 3127 |
2441 // error details length | 3128 // error details length |
2442 0x0d, 0x00, | 3129 0x0d, 0x00, |
2443 // error details | 3130 // error details |
2444 'b', 'e', 'c', 'a', | 3131 'b', 'e', 'c', 'a', |
2445 'u', 's', 'e', ' ', | 3132 'u', 's', 'e', ' ', |
2446 'I', ' ', 'c', 'a', | 3133 'I', ' ', 'c', 'a', |
2447 'n', | 3134 'n', |
2448 }; | 3135 }; |
| 3136 |
| 3137 unsigned char packet39[] = { |
| 3138 // public flags (8 byte connection_id) |
| 3139 0x38, |
| 3140 // connection_id |
| 3141 0x10, 0x32, 0x54, 0x76, |
| 3142 0x98, 0xBA, 0xDC, 0xFE, |
| 3143 // packet number |
| 3144 0x12, 0x34, 0x56, 0x78, |
| 3145 0x9A, 0xBC, |
| 3146 |
| 3147 // frame type (connection close frame) |
| 3148 0x02, |
| 3149 // error code |
| 3150 0x00, 0x00, 0x00, 0x11, |
| 3151 |
| 3152 // error details length |
| 3153 0x00, 0x0d, |
| 3154 // error details |
| 3155 'b', 'e', 'c', 'a', |
| 3156 'u', 's', 'e', ' ', |
| 3157 'I', ' ', 'c', 'a', |
| 3158 'n', |
| 3159 }; |
| 3160 |
| 3161 unsigned char packet_cid_be39[] = { |
| 3162 // public flags (8 byte connection_id) |
| 3163 0x38, |
| 3164 // connection_id |
| 3165 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 3166 // packet number |
| 3167 0x12, 0x34, 0x56, 0x78, |
| 3168 0x9A, 0xBC, |
| 3169 |
| 3170 // frame type (connection close frame) |
| 3171 0x02, |
| 3172 // error code |
| 3173 0x00, 0x00, 0x00, 0x11, |
| 3174 |
| 3175 // error details length |
| 3176 0x00, 0x0d, |
| 3177 // error details |
| 3178 'b', 'e', 'c', 'a', |
| 3179 'u', 's', 'e', ' ', |
| 3180 'I', ' ', 'c', 'a', |
| 3181 'n', |
| 3182 }; |
2449 // clang-format on | 3183 // clang-format on |
2450 | 3184 |
2451 QuicEncryptedPacket encrypted( | 3185 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
2452 AsChars( | 3186 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
2453 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3187 |
2454 ? packet_cid_be | 3188 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
2455 : packet), | 3189 false); |
2456 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
2457 ? arraysize(packet_cid_be) | |
2458 : arraysize(packet), | |
2459 false); | |
2460 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 3190 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2461 | 3191 |
2462 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 3192 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
2463 ASSERT_TRUE(visitor_.header_.get()); | 3193 ASSERT_TRUE(visitor_.header_.get()); |
2464 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 3194 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
2465 !kIncludeDiversificationNonce)); | 3195 !kIncludeDiversificationNonce)); |
2466 | 3196 |
2467 EXPECT_EQ(0u, visitor_.stream_frames_.size()); | 3197 EXPECT_EQ(0u, visitor_.stream_frames_.size()); |
2468 | 3198 |
2469 EXPECT_EQ(0x11, visitor_.connection_close_frame_.error_code); | 3199 EXPECT_EQ(0x11, visitor_.connection_close_frame_.error_code); |
2470 EXPECT_EQ("because I can", visitor_.connection_close_frame_.error_details); | 3200 EXPECT_EQ("because I can", visitor_.connection_close_frame_.error_details); |
2471 | 3201 |
2472 ASSERT_EQ(0u, visitor_.ack_frames_.size()); | 3202 ASSERT_EQ(0u, visitor_.ack_frames_.size()); |
2473 | 3203 |
2474 // Now test framing boundaries. | 3204 // Now test framing boundaries. |
2475 for (size_t i = kQuicFrameTypeSize; | 3205 for (size_t i = kQuicFrameTypeSize; |
2476 i < QuicFramer::GetMinConnectionCloseFrameSize(); ++i) { | 3206 i < QuicFramer::GetMinConnectionCloseFrameSize(); ++i) { |
2477 string expected_error; | 3207 string expected_error; |
2478 if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) { | 3208 if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) { |
2479 expected_error = "Unable to read connection close error code."; | 3209 expected_error = "Unable to read connection close error code."; |
2480 } else { | 3210 } else { |
2481 expected_error = "Unable to read connection close error details."; | 3211 expected_error = "Unable to read connection close error details."; |
2482 } | 3212 } |
2483 CheckProcessingFails( | 3213 CheckProcessingFails( |
2484 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3214 packets[index], |
2485 ? packet_cid_be | |
2486 : packet, | |
2487 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 3215 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
2488 !kIncludeVersion, !kIncludeDiversificationNonce, | 3216 !kIncludeVersion, !kIncludeDiversificationNonce, |
2489 PACKET_6BYTE_PACKET_NUMBER), | 3217 PACKET_6BYTE_PACKET_NUMBER), |
2490 expected_error, QUIC_INVALID_CONNECTION_CLOSE_DATA); | 3218 expected_error, QUIC_INVALID_CONNECTION_CLOSE_DATA); |
2491 } | 3219 } |
2492 } | 3220 } |
2493 | 3221 |
2494 TEST_P(QuicFramerTest, GoAwayFrame) { | 3222 TEST_P(QuicFramerTest, GoAwayFrame) { |
2495 // clang-format off | 3223 // clang-format off |
2496 unsigned char packet[] = { | 3224 unsigned char packet[] = { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 // stream id | 3262 // stream id |
2535 0x04, 0x03, 0x02, 0x01, | 3263 0x04, 0x03, 0x02, 0x01, |
2536 // error details length | 3264 // error details length |
2537 0x0d, 0x00, | 3265 0x0d, 0x00, |
2538 // error details | 3266 // error details |
2539 'b', 'e', 'c', 'a', | 3267 'b', 'e', 'c', 'a', |
2540 'u', 's', 'e', ' ', | 3268 'u', 's', 'e', ' ', |
2541 'I', ' ', 'c', 'a', | 3269 'I', ' ', 'c', 'a', |
2542 'n', | 3270 'n', |
2543 }; | 3271 }; |
| 3272 |
| 3273 unsigned char packet39[] = { |
| 3274 // public flags (8 byte connection_id) |
| 3275 0x38, |
| 3276 // connection_id |
| 3277 0x10, 0x32, 0x54, 0x76, |
| 3278 0x98, 0xBA, 0xDC, 0xFE, |
| 3279 // packet number |
| 3280 0x12, 0x34, 0x56, 0x78, |
| 3281 0x9A, 0xBC, |
| 3282 |
| 3283 // frame type (go away frame) |
| 3284 0x03, |
| 3285 // error code |
| 3286 0x00, 0x00, 0x00, 0x09, |
| 3287 // stream id |
| 3288 0x01, 0x02, 0x03, 0x04, |
| 3289 // error details length |
| 3290 0x00, 0x0d, |
| 3291 // error details |
| 3292 'b', 'e', 'c', 'a', |
| 3293 'u', 's', 'e', ' ', |
| 3294 'I', ' ', 'c', 'a', |
| 3295 'n', |
| 3296 }; |
| 3297 |
| 3298 unsigned char packet_cid_be39[] = { |
| 3299 // public flags (8 byte connection_id) |
| 3300 0x38, |
| 3301 // connection_id |
| 3302 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 3303 // packet number |
| 3304 0x12, 0x34, 0x56, 0x78, |
| 3305 0x9A, 0xBC, |
| 3306 |
| 3307 // frame type (go away frame) |
| 3308 0x03, |
| 3309 // error code |
| 3310 0x00, 0x00, 0x00, 0x09, |
| 3311 // stream id |
| 3312 0x01, 0x02, 0x03, 0x04, |
| 3313 // error details length |
| 3314 0x00, 0x0d, |
| 3315 // error details |
| 3316 'b', 'e', 'c', 'a', |
| 3317 'u', 's', 'e', ' ', |
| 3318 'I', ' ', 'c', 'a', |
| 3319 'n', |
| 3320 }; |
2544 // clang-format on | 3321 // clang-format on |
2545 | 3322 |
2546 QuicEncryptedPacket encrypted( | 3323 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
2547 AsChars( | 3324 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
2548 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3325 |
2549 ? packet_cid_be | 3326 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
2550 : packet), | 3327 false); |
2551 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
2552 ? arraysize(packet_cid_be) | |
2553 : arraysize(packet), | |
2554 false); | |
2555 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 3328 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2556 | 3329 |
2557 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 3330 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
2558 ASSERT_TRUE(visitor_.header_.get()); | 3331 ASSERT_TRUE(visitor_.header_.get()); |
2559 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 3332 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
2560 !kIncludeDiversificationNonce)); | 3333 !kIncludeDiversificationNonce)); |
2561 | 3334 |
2562 EXPECT_EQ(kStreamId, visitor_.goaway_frame_.last_good_stream_id); | 3335 EXPECT_EQ(kStreamId, visitor_.goaway_frame_.last_good_stream_id); |
2563 EXPECT_EQ(0x9, visitor_.goaway_frame_.error_code); | 3336 EXPECT_EQ(0x9, visitor_.goaway_frame_.error_code); |
2564 EXPECT_EQ("because I can", visitor_.goaway_frame_.reason_phrase); | 3337 EXPECT_EQ("because I can", visitor_.goaway_frame_.reason_phrase); |
2565 | 3338 |
2566 const size_t reason_size = arraysize("because I can") - 1; | 3339 const size_t reason_size = arraysize("because I can") - 1; |
2567 // Now test framing boundaries. | 3340 // Now test framing boundaries. |
2568 for (size_t i = kQuicFrameTypeSize; | 3341 for (size_t i = kQuicFrameTypeSize; |
2569 i < QuicFramer::GetMinGoAwayFrameSize() + reason_size; ++i) { | 3342 i < QuicFramer::GetMinGoAwayFrameSize() + reason_size; ++i) { |
2570 string expected_error; | 3343 string expected_error; |
2571 if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) { | 3344 if (i < kQuicFrameTypeSize + kQuicErrorCodeSize) { |
2572 expected_error = "Unable to read go away error code."; | 3345 expected_error = "Unable to read go away error code."; |
2573 } else if (i < | 3346 } else if (i < |
2574 kQuicFrameTypeSize + kQuicErrorCodeSize + kQuicMaxStreamIdSize) { | 3347 kQuicFrameTypeSize + kQuicErrorCodeSize + kQuicMaxStreamIdSize) { |
2575 expected_error = "Unable to read last good stream id."; | 3348 expected_error = "Unable to read last good stream id."; |
2576 } else { | 3349 } else { |
2577 expected_error = "Unable to read goaway reason."; | 3350 expected_error = "Unable to read goaway reason."; |
2578 } | 3351 } |
2579 CheckProcessingFails( | 3352 CheckProcessingFails( |
2580 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3353 packets[index], |
2581 ? packet_cid_be | |
2582 : packet, | |
2583 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 3354 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
2584 !kIncludeVersion, !kIncludeDiversificationNonce, | 3355 !kIncludeVersion, !kIncludeDiversificationNonce, |
2585 PACKET_6BYTE_PACKET_NUMBER), | 3356 PACKET_6BYTE_PACKET_NUMBER), |
2586 expected_error, QUIC_INVALID_GOAWAY_DATA); | 3357 expected_error, QUIC_INVALID_GOAWAY_DATA); |
2587 } | 3358 } |
2588 } | 3359 } |
2589 | 3360 |
2590 TEST_P(QuicFramerTest, WindowUpdateFrame) { | 3361 TEST_P(QuicFramerTest, WindowUpdateFrame) { |
2591 // clang-format off | 3362 // clang-format off |
2592 unsigned char packet[] = { | 3363 unsigned char packet[] = { |
(...skipping 25 matching lines...) Expand all Loading... |
2618 0x34, 0x12, | 3389 0x34, 0x12, |
2619 | 3390 |
2620 // frame type (window update frame) | 3391 // frame type (window update frame) |
2621 0x04, | 3392 0x04, |
2622 // stream id | 3393 // stream id |
2623 0x04, 0x03, 0x02, 0x01, | 3394 0x04, 0x03, 0x02, 0x01, |
2624 // byte offset | 3395 // byte offset |
2625 0x54, 0x76, 0x10, 0x32, | 3396 0x54, 0x76, 0x10, 0x32, |
2626 0xDC, 0xFE, 0x98, 0xBA, | 3397 0xDC, 0xFE, 0x98, 0xBA, |
2627 }; | 3398 }; |
| 3399 |
| 3400 unsigned char packet39[] = { |
| 3401 // public flags (8 byte connection_id) |
| 3402 0x38, |
| 3403 // connection_id |
| 3404 0x10, 0x32, 0x54, 0x76, |
| 3405 0x98, 0xBA, 0xDC, 0xFE, |
| 3406 // packet number |
| 3407 0x12, 0x34, 0x56, 0x78, |
| 3408 0x9A, 0xBC, |
| 3409 |
| 3410 // frame type (window update frame) |
| 3411 0x04, |
| 3412 // stream id |
| 3413 0x01, 0x02, 0x03, 0x04, |
| 3414 // byte offset |
| 3415 0xBA, 0x98, 0xFE, 0xDC, |
| 3416 0x32, 0x10, 0x76, 0x54, |
| 3417 }; |
| 3418 |
| 3419 unsigned char packet_cid_be39[] = { |
| 3420 // public flags (8 byte connection_id) |
| 3421 0x38, |
| 3422 // connection_id |
| 3423 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 3424 // packet number |
| 3425 0x12, 0x34, 0x56, 0x78, |
| 3426 0x9A, 0xBC, |
| 3427 |
| 3428 // frame type (window update frame) |
| 3429 0x04, |
| 3430 // stream id |
| 3431 0x01, 0x02, 0x03, 0x04, |
| 3432 // byte offset |
| 3433 0xBA, 0x98, 0xFE, 0xDC, |
| 3434 0x32, 0x10, 0x76, 0x54, |
| 3435 }; |
2628 // clang-format on | 3436 // clang-format on |
2629 | 3437 |
2630 QuicEncryptedPacket encrypted( | 3438 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
2631 AsChars( | 3439 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
2632 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3440 |
2633 ? packet_cid_be | 3441 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
2634 : packet), | 3442 false); |
2635 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
2636 ? arraysize(packet_cid_be) | |
2637 : arraysize(packet), | |
2638 false); | |
2639 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 3443 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2640 | 3444 |
2641 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 3445 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
2642 ASSERT_TRUE(visitor_.header_.get()); | 3446 ASSERT_TRUE(visitor_.header_.get()); |
2643 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 3447 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
2644 !kIncludeDiversificationNonce)); | 3448 !kIncludeDiversificationNonce)); |
2645 | 3449 |
2646 EXPECT_EQ(kStreamId, visitor_.window_update_frame_.stream_id); | 3450 EXPECT_EQ(kStreamId, visitor_.window_update_frame_.stream_id); |
2647 EXPECT_EQ(kStreamOffset, visitor_.window_update_frame_.byte_offset); | 3451 EXPECT_EQ(kStreamOffset, visitor_.window_update_frame_.byte_offset); |
2648 | 3452 |
2649 // Now test framing boundaries. | 3453 // Now test framing boundaries. |
2650 for (size_t i = kQuicFrameTypeSize; | 3454 for (size_t i = kQuicFrameTypeSize; |
2651 i < QuicFramer::GetWindowUpdateFrameSize(); ++i) { | 3455 i < QuicFramer::GetWindowUpdateFrameSize(); ++i) { |
2652 string expected_error; | 3456 string expected_error; |
2653 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { | 3457 if (i < kQuicFrameTypeSize + kQuicMaxStreamIdSize) { |
2654 expected_error = "Unable to read stream_id."; | 3458 expected_error = "Unable to read stream_id."; |
2655 } else { | 3459 } else { |
2656 expected_error = "Unable to read window byte_offset."; | 3460 expected_error = "Unable to read window byte_offset."; |
2657 } | 3461 } |
2658 CheckProcessingFails( | 3462 CheckProcessingFails( |
2659 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3463 packets[index], |
2660 ? packet_cid_be | |
2661 : packet, | |
2662 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 3464 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
2663 !kIncludeVersion, !kIncludeDiversificationNonce, | 3465 !kIncludeVersion, !kIncludeDiversificationNonce, |
2664 PACKET_6BYTE_PACKET_NUMBER), | 3466 PACKET_6BYTE_PACKET_NUMBER), |
2665 expected_error, QUIC_INVALID_WINDOW_UPDATE_DATA); | 3467 expected_error, QUIC_INVALID_WINDOW_UPDATE_DATA); |
2666 } | 3468 } |
2667 } | 3469 } |
2668 | 3470 |
2669 TEST_P(QuicFramerTest, BlockedFrame) { | 3471 TEST_P(QuicFramerTest, BlockedFrame) { |
2670 // clang-format off | 3472 // clang-format off |
2671 unsigned char packet[] = { | 3473 unsigned char packet[] = { |
(...skipping 19 matching lines...) Expand all Loading... |
2691 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 3493 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
2692 // packet number | 3494 // packet number |
2693 0xBC, 0x9A, 0x78, 0x56, | 3495 0xBC, 0x9A, 0x78, 0x56, |
2694 0x34, 0x12, | 3496 0x34, 0x12, |
2695 | 3497 |
2696 // frame type (blocked frame) | 3498 // frame type (blocked frame) |
2697 0x05, | 3499 0x05, |
2698 // stream id | 3500 // stream id |
2699 0x04, 0x03, 0x02, 0x01, | 3501 0x04, 0x03, 0x02, 0x01, |
2700 }; | 3502 }; |
| 3503 |
| 3504 unsigned char packet39[] = { |
| 3505 // public flags (8 byte connection_id) |
| 3506 0x38, |
| 3507 // connection_id |
| 3508 0x10, 0x32, 0x54, 0x76, |
| 3509 0x98, 0xBA, 0xDC, 0xFE, |
| 3510 // packet number |
| 3511 0x12, 0x34, 0x56, 0x78, |
| 3512 0x9A, 0xBC, |
| 3513 |
| 3514 // frame type (blocked frame) |
| 3515 0x05, |
| 3516 // stream id |
| 3517 0x01, 0x02, 0x03, 0x04, |
| 3518 }; |
| 3519 |
| 3520 unsigned char packet_cid_be39[] = { |
| 3521 // public flags (8 byte connection_id) |
| 3522 0x38, |
| 3523 // connection_id |
| 3524 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 3525 // packet number |
| 3526 0x12, 0x34, 0x56, 0x78, |
| 3527 0x9A, 0xBC, |
| 3528 |
| 3529 // frame type (blocked frame) |
| 3530 0x05, |
| 3531 // stream id |
| 3532 0x01, 0x02, 0x03, 0x04, |
| 3533 }; |
2701 // clang-format on | 3534 // clang-format on |
2702 | 3535 |
2703 QuicEncryptedPacket encrypted( | 3536 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
2704 AsChars( | 3537 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
2705 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3538 |
2706 ? packet_cid_be | 3539 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
2707 : packet), | 3540 false); |
2708 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
2709 ? arraysize(packet_cid_be) | |
2710 : arraysize(packet), | |
2711 false); | |
2712 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 3541 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2713 | 3542 |
2714 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 3543 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
2715 ASSERT_TRUE(visitor_.header_.get()); | 3544 ASSERT_TRUE(visitor_.header_.get()); |
2716 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 3545 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
2717 !kIncludeDiversificationNonce)); | 3546 !kIncludeDiversificationNonce)); |
2718 | 3547 |
2719 EXPECT_EQ(kStreamId, visitor_.blocked_frame_.stream_id); | 3548 EXPECT_EQ(kStreamId, visitor_.blocked_frame_.stream_id); |
2720 | 3549 |
2721 // Now test framing boundaries. | 3550 // Now test framing boundaries. |
2722 for (size_t i = kQuicFrameTypeSize; i < QuicFramer::GetBlockedFrameSize(); | 3551 for (size_t i = kQuicFrameTypeSize; i < QuicFramer::GetBlockedFrameSize(); |
2723 ++i) { | 3552 ++i) { |
2724 string expected_error = "Unable to read stream_id."; | 3553 string expected_error = "Unable to read stream_id."; |
2725 CheckProcessingFails( | 3554 CheckProcessingFails( |
2726 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3555 packets[index], |
2727 ? packet_cid_be | |
2728 : packet, | |
2729 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, | 3556 i + GetPacketHeaderSize(framer_.version(), PACKET_8BYTE_CONNECTION_ID, |
2730 !kIncludeVersion, !kIncludeDiversificationNonce, | 3557 !kIncludeVersion, !kIncludeDiversificationNonce, |
2731 PACKET_6BYTE_PACKET_NUMBER), | 3558 PACKET_6BYTE_PACKET_NUMBER), |
2732 expected_error, QUIC_INVALID_BLOCKED_DATA); | 3559 expected_error, QUIC_INVALID_BLOCKED_DATA); |
2733 } | 3560 } |
2734 } | 3561 } |
2735 | 3562 |
2736 TEST_P(QuicFramerTest, PingFrame) { | 3563 TEST_P(QuicFramerTest, PingFrame) { |
2737 // clang-format off | 3564 // clang-format off |
2738 unsigned char packet[] = { | 3565 unsigned char packet[] = { |
(...skipping 15 matching lines...) Expand all Loading... |
2754 0x38, | 3581 0x38, |
2755 // connection_id | 3582 // connection_id |
2756 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 3583 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
2757 // packet number | 3584 // packet number |
2758 0xBC, 0x9A, 0x78, 0x56, | 3585 0xBC, 0x9A, 0x78, 0x56, |
2759 0x34, 0x12, | 3586 0x34, 0x12, |
2760 | 3587 |
2761 // frame type (ping frame) | 3588 // frame type (ping frame) |
2762 0x07, | 3589 0x07, |
2763 }; | 3590 }; |
| 3591 |
| 3592 unsigned char packet39[] = { |
| 3593 // public flags (8 byte connection_id) |
| 3594 0x38, |
| 3595 // connection_id |
| 3596 0x10, 0x32, 0x54, 0x76, |
| 3597 0x98, 0xBA, 0xDC, 0xFE, |
| 3598 // packet number |
| 3599 0x12, 0x34, 0x56, 0x78, |
| 3600 0x9A, 0xBC, |
| 3601 |
| 3602 // frame type (ping frame) |
| 3603 0x07, |
| 3604 }; |
| 3605 |
| 3606 unsigned char packet_cid_be39[] = { |
| 3607 // public flags (8 byte connection_id) |
| 3608 0x38, |
| 3609 // connection_id |
| 3610 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 3611 // packet number |
| 3612 0x12, 0x34, 0x56, 0x78, |
| 3613 0x9A, 0xBC, |
| 3614 |
| 3615 // frame type (ping frame) |
| 3616 0x07, |
| 3617 }; |
2764 // clang-format on | 3618 // clang-format on |
2765 | 3619 |
2766 QuicEncryptedPacket encrypted( | 3620 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
2767 AsChars( | 3621 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
2768 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 3622 |
2769 ? packet_cid_be | 3623 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
2770 : packet), | 3624 false); |
2771 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
2772 ? arraysize(packet_cid_be) | |
2773 : arraysize(packet), | |
2774 false); | |
2775 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 3625 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2776 | 3626 |
2777 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 3627 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
2778 ASSERT_TRUE(visitor_.header_.get()); | 3628 ASSERT_TRUE(visitor_.header_.get()); |
2779 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, | 3629 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion, |
2780 !kIncludeDiversificationNonce)); | 3630 !kIncludeDiversificationNonce)); |
2781 | 3631 |
2782 EXPECT_EQ(1u, visitor_.ping_frames_.size()); | 3632 EXPECT_EQ(1u, visitor_.ping_frames_.size()); |
2783 | 3633 |
2784 // No need to check the PING frame boundaries because it has no payload. | 3634 // No need to check the PING frame boundaries because it has no payload. |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3370 // connection_id | 4220 // connection_id |
3371 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 4221 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
3372 // packet number | 4222 // packet number |
3373 0xBC, 0x9A, 0x78, 0x56, | 4223 0xBC, 0x9A, 0x78, 0x56, |
3374 0x34, 0x12, | 4224 0x34, 0x12, |
3375 | 4225 |
3376 // frame type (padding frame) | 4226 // frame type (padding frame) |
3377 0x00, | 4227 0x00, |
3378 0x00, 0x00, 0x00, 0x00 | 4228 0x00, 0x00, 0x00, 0x00 |
3379 }; | 4229 }; |
| 4230 |
| 4231 unsigned char packet39[kMaxPacketSize] = { |
| 4232 // public flags (8 byte connection_id) |
| 4233 0x38, |
| 4234 // connection_id |
| 4235 0x10, 0x32, 0x54, 0x76, |
| 4236 0x98, 0xBA, 0xDC, 0xFE, |
| 4237 // packet number |
| 4238 0x12, 0x34, 0x56, 0x78, |
| 4239 0x9A, 0xBC, |
| 4240 |
| 4241 // frame type (padding frame) |
| 4242 0x00, |
| 4243 0x00, 0x00, 0x00, 0x00 |
| 4244 }; |
| 4245 |
| 4246 unsigned char packet_cid_be39[kMaxPacketSize] = { |
| 4247 // public flags (8 byte connection_id) |
| 4248 0x38, |
| 4249 // connection_id |
| 4250 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 4251 // packet number |
| 4252 0x12, 0x34, 0x56, 0x78, |
| 4253 0x9A, 0xBC, |
| 4254 |
| 4255 // frame type (padding frame) |
| 4256 0x00, |
| 4257 0x00, 0x00, 0x00, 0x00 |
| 4258 }; |
3380 // clang-format on | 4259 // clang-format on |
3381 | 4260 |
| 4261 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 4262 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 4263 |
3382 uint64_t header_size = GetPacketHeaderSize( | 4264 uint64_t header_size = GetPacketHeaderSize( |
3383 framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, | 4265 framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
3384 !kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER); | 4266 !kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER); |
3385 memset((QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 4267 memset((packets[index]) + header_size + 1, 0x00, |
3386 ? packet_cid_be | 4268 kMaxPacketSize - header_size - 1); |
3387 : packet) + | |
3388 header_size + 1, | |
3389 0x00, kMaxPacketSize - header_size - 1); | |
3390 | 4269 |
3391 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 4270 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
3392 ASSERT_TRUE(data != nullptr); | 4271 ASSERT_TRUE(data != nullptr); |
3393 | 4272 |
3394 test::CompareCharArraysWithHexError( | 4273 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
3395 "constructed packet", data->data(), data->length(), | 4274 data->length(), AsChars(packets[index]), |
3396 AsChars( | 4275 arraysize(packet)); |
3397 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3398 ? packet_cid_be | |
3399 : packet), | |
3400 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3401 ? arraysize(packet_cid_be) | |
3402 : arraysize(packet)); | |
3403 } | 4276 } |
3404 | 4277 |
3405 TEST_P(QuicFramerTest, BuildStreamFramePacketWithNewPaddingFrame) { | 4278 TEST_P(QuicFramerTest, BuildStreamFramePacketWithNewPaddingFrame) { |
3406 if (framer_.version() <= QUIC_VERSION_37) { | 4279 if (framer_.version() <= QUIC_VERSION_37) { |
3407 return; | 4280 return; |
3408 } | 4281 } |
3409 QuicPacketHeader header; | 4282 QuicPacketHeader header; |
3410 header.public_header.connection_id = kConnectionId; | 4283 header.public_header.connection_id = kConnectionId; |
3411 header.public_header.reset_flag = false; | 4284 header.public_header.reset_flag = false; |
3412 header.public_header.version_flag = false; | 4285 header.public_header.version_flag = false; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3468 0xDC, 0xFE, 0x98, 0xBA, | 4341 0xDC, 0xFE, 0x98, 0xBA, |
3469 // data length | 4342 // data length |
3470 0x0c, 0x00, | 4343 0x0c, 0x00, |
3471 // data | 4344 // data |
3472 'h', 'e', 'l', 'l', | 4345 'h', 'e', 'l', 'l', |
3473 'o', ' ', 'w', 'o', | 4346 'o', ' ', 'w', 'o', |
3474 'r', 'l', 'd', '!', | 4347 'r', 'l', 'd', '!', |
3475 // paddings | 4348 // paddings |
3476 0x00, 0x00, | 4349 0x00, 0x00, |
3477 }; | 4350 }; |
| 4351 |
| 4352 unsigned char packet39[] = { |
| 4353 // public flags (8 byte connection_id) |
| 4354 0x38, |
| 4355 // connection_id |
| 4356 0x10, 0x32, 0x54, 0x76, |
| 4357 0x98, 0xBA, 0xDC, 0xFE, |
| 4358 // packet number |
| 4359 0x12, 0x34, 0x56, 0x78, |
| 4360 0x9A, 0xBC, |
| 4361 |
| 4362 // paddings |
| 4363 0x00, 0x00, |
| 4364 // frame type (stream frame with fin) |
| 4365 0xFF, |
| 4366 // stream id |
| 4367 0x01, 0x02, 0x03, 0x04, |
| 4368 // offset |
| 4369 0xBA, 0x98, 0xFE, 0xDC, |
| 4370 0x32, 0x10, 0x76, 0x54, |
| 4371 // data length |
| 4372 0x00, 0x0c, |
| 4373 // data |
| 4374 'h', 'e', 'l', 'l', |
| 4375 'o', ' ', 'w', 'o', |
| 4376 'r', 'l', 'd', '!', |
| 4377 // paddings |
| 4378 0x00, 0x00, |
| 4379 }; |
| 4380 |
| 4381 unsigned char packet_cid_be39[] = { |
| 4382 // public flags (8 byte connection_id) |
| 4383 0x38, |
| 4384 // connection_id |
| 4385 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 4386 // packet number |
| 4387 0x12, 0x34, 0x56, 0x78, |
| 4388 0x9A, 0xBC, |
| 4389 |
| 4390 // paddings |
| 4391 0x00, 0x00, |
| 4392 // frame type (stream frame with fin) |
| 4393 0xFF, |
| 4394 // stream id |
| 4395 0x01, 0x02, 0x03, 0x04, |
| 4396 // offset |
| 4397 0xBA, 0x98, 0xFE, 0xDC, |
| 4398 0x32, 0x10, 0x76, 0x54, |
| 4399 // data length |
| 4400 0x00, 0x0c, |
| 4401 // data |
| 4402 'h', 'e', 'l', 'l', |
| 4403 'o', ' ', 'w', 'o', |
| 4404 'r', 'l', 'd', '!', |
| 4405 // paddings |
| 4406 0x00, 0x00, |
| 4407 }; |
3478 // clang-format on | 4408 // clang-format on |
3479 | 4409 |
| 4410 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 4411 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 4412 |
3480 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 4413 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
3481 ASSERT_TRUE(data != nullptr); | 4414 ASSERT_TRUE(data != nullptr); |
3482 | 4415 |
3483 test::CompareCharArraysWithHexError( | 4416 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
3484 "constructed packet", data->data(), data->length(), | 4417 data->length(), AsChars(packets[index]), |
3485 AsChars( | 4418 arraysize(packet)); |
3486 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3487 ? packet_cid_be | |
3488 : packet), | |
3489 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3490 ? arraysize(packet_cid_be) | |
3491 : arraysize(packet)); | |
3492 } | 4419 } |
3493 | 4420 |
3494 TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { | 4421 TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { |
3495 QuicPacketHeader header; | 4422 QuicPacketHeader header; |
3496 header.public_header.connection_id = kConnectionId; | 4423 header.public_header.connection_id = kConnectionId; |
3497 header.public_header.reset_flag = false; | 4424 header.public_header.reset_flag = false; |
3498 header.public_header.version_flag = false; | 4425 header.public_header.version_flag = false; |
3499 header.public_header.packet_number_length = PACKET_4BYTE_PACKET_NUMBER; | 4426 header.public_header.packet_number_length = PACKET_4BYTE_PACKET_NUMBER; |
3500 header.packet_number = kPacketNumber; | 4427 header.packet_number = kPacketNumber; |
3501 | 4428 |
(...skipping 19 matching lines...) Expand all Loading... |
3521 0x28, | 4448 0x28, |
3522 // connection_id | 4449 // connection_id |
3523 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 4450 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
3524 // packet number | 4451 // packet number |
3525 0xBC, 0x9A, 0x78, 0x56, | 4452 0xBC, 0x9A, 0x78, 0x56, |
3526 | 4453 |
3527 // frame type (padding frame) | 4454 // frame type (padding frame) |
3528 0x00, | 4455 0x00, |
3529 0x00, 0x00, 0x00, 0x00 | 4456 0x00, 0x00, 0x00, 0x00 |
3530 }; | 4457 }; |
| 4458 |
| 4459 unsigned char packet39[kMaxPacketSize] = { |
| 4460 // public flags (8 byte connection_id and 4 byte packet number) |
| 4461 0x28, |
| 4462 // connection_id |
| 4463 0x10, 0x32, 0x54, 0x76, |
| 4464 0x98, 0xBA, 0xDC, 0xFE, |
| 4465 // packet number |
| 4466 0x56, 0x78, 0x9A, 0xBC, |
| 4467 |
| 4468 // frame type (padding frame) |
| 4469 0x00, |
| 4470 0x00, 0x00, 0x00, 0x00 |
| 4471 }; |
| 4472 |
| 4473 unsigned char packet_cid_be39[kMaxPacketSize] = { |
| 4474 // public flags (8 byte connection_id and 4 byte packet number) |
| 4475 0x28, |
| 4476 // connection_id |
| 4477 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 4478 // packet number |
| 4479 0x56, 0x78, 0x9A, 0xBC, |
| 4480 |
| 4481 // frame type (padding frame) |
| 4482 0x00, |
| 4483 0x00, 0x00, 0x00, 0x00 |
| 4484 }; |
3531 // clang-format on | 4485 // clang-format on |
3532 | 4486 |
| 4487 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 4488 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 4489 |
3533 uint64_t header_size = GetPacketHeaderSize( | 4490 uint64_t header_size = GetPacketHeaderSize( |
3534 framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, | 4491 framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
3535 !kIncludeDiversificationNonce, PACKET_4BYTE_PACKET_NUMBER); | 4492 !kIncludeDiversificationNonce, PACKET_4BYTE_PACKET_NUMBER); |
3536 memset((QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 4493 memset((packets[index]) + header_size + 1, 0x00, |
3537 ? packet_cid_be | 4494 kMaxPacketSize - header_size - 1); |
3538 : packet) + | |
3539 header_size + 1, | |
3540 0x00, kMaxPacketSize - header_size - 1); | |
3541 | 4495 |
3542 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 4496 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
3543 ASSERT_TRUE(data != nullptr); | 4497 ASSERT_TRUE(data != nullptr); |
3544 | 4498 |
3545 test::CompareCharArraysWithHexError( | 4499 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
3546 "constructed packet", data->data(), data->length(), | 4500 data->length(), AsChars(packets[index]), |
3547 AsChars( | 4501 arraysize(packet)); |
3548 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3549 ? packet_cid_be | |
3550 : packet), | |
3551 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3552 ? arraysize(packet_cid_be) | |
3553 : arraysize(packet)); | |
3554 } | 4502 } |
3555 | 4503 |
3556 TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { | 4504 TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { |
3557 QuicPacketHeader header; | 4505 QuicPacketHeader header; |
3558 header.public_header.connection_id = kConnectionId; | 4506 header.public_header.connection_id = kConnectionId; |
3559 header.public_header.reset_flag = false; | 4507 header.public_header.reset_flag = false; |
3560 header.public_header.version_flag = false; | 4508 header.public_header.version_flag = false; |
3561 header.public_header.packet_number_length = PACKET_2BYTE_PACKET_NUMBER; | 4509 header.public_header.packet_number_length = PACKET_2BYTE_PACKET_NUMBER; |
3562 header.packet_number = kPacketNumber; | 4510 header.packet_number = kPacketNumber; |
3563 | 4511 |
(...skipping 19 matching lines...) Expand all Loading... |
3583 0x18, | 4531 0x18, |
3584 // connection_id | 4532 // connection_id |
3585 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 4533 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
3586 // packet number | 4534 // packet number |
3587 0xBC, 0x9A, | 4535 0xBC, 0x9A, |
3588 | 4536 |
3589 // frame type (padding frame) | 4537 // frame type (padding frame) |
3590 0x00, | 4538 0x00, |
3591 0x00, 0x00, 0x00, 0x00 | 4539 0x00, 0x00, 0x00, 0x00 |
3592 }; | 4540 }; |
| 4541 |
| 4542 unsigned char packet39[kMaxPacketSize] = { |
| 4543 // public flags (8 byte connection_id and 2 byte packet number) |
| 4544 0x18, |
| 4545 // connection_id |
| 4546 0x10, 0x32, 0x54, 0x76, |
| 4547 0x98, 0xBA, 0xDC, 0xFE, |
| 4548 // packet number |
| 4549 0x9A, 0xBC, |
| 4550 |
| 4551 // frame type (padding frame) |
| 4552 0x00, |
| 4553 0x00, 0x00, 0x00, 0x00 |
| 4554 }; |
| 4555 |
| 4556 unsigned char packet_cid_be39[kMaxPacketSize] = { |
| 4557 // public flags (8 byte connection_id and 2 byte packet number) |
| 4558 0x18, |
| 4559 // connection_id |
| 4560 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 4561 // packet number |
| 4562 0x9A, 0xBC, |
| 4563 |
| 4564 // frame type (padding frame) |
| 4565 0x00, |
| 4566 0x00, 0x00, 0x00, 0x00 |
| 4567 }; |
3593 // clang-format on | 4568 // clang-format on |
3594 | 4569 |
| 4570 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 4571 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 4572 |
3595 uint64_t header_size = GetPacketHeaderSize( | 4573 uint64_t header_size = GetPacketHeaderSize( |
3596 framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, | 4574 framer_.version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
3597 !kIncludeDiversificationNonce, PACKET_2BYTE_PACKET_NUMBER); | 4575 !kIncludeDiversificationNonce, PACKET_2BYTE_PACKET_NUMBER); |
3598 memset((QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 4576 memset((packets[index]) + header_size + 1, 0x00, |
3599 ? packet_cid_be | 4577 kMaxPacketSize - header_size - 1); |
3600 : packet) + | |
3601 header_size + 1, | |
3602 0x00, kMaxPacketSize - header_size - 1); | |
3603 | 4578 |
3604 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 4579 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
3605 ASSERT_TRUE(data != nullptr); | 4580 ASSERT_TRUE(data != nullptr); |
3606 | 4581 |
3607 test::CompareCharArraysWithHexError( | 4582 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
3608 "constructed packet", data->data(), data->length(), | 4583 data->length(), AsChars(packets[index]), |
3609 AsChars( | 4584 arraysize(packet)); |
3610 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3611 ? packet_cid_be | |
3612 : packet), | |
3613 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3614 ? arraysize(packet_cid_be) | |
3615 : arraysize(packet)); | |
3616 } | 4585 } |
3617 | 4586 |
3618 TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) { | 4587 TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) { |
3619 QuicPacketHeader header; | 4588 QuicPacketHeader header; |
3620 header.public_header.connection_id = kConnectionId; | 4589 header.public_header.connection_id = kConnectionId; |
3621 header.public_header.reset_flag = false; | 4590 header.public_header.reset_flag = false; |
3622 header.public_header.version_flag = false; | 4591 header.public_header.version_flag = false; |
3623 header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER; | 4592 header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER; |
3624 header.packet_number = kPacketNumber; | 4593 header.packet_number = kPacketNumber; |
3625 | 4594 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3727 // stream id | 4696 // stream id |
3728 0x04, 0x03, 0x02, 0x01, | 4697 0x04, 0x03, 0x02, 0x01, |
3729 // offset | 4698 // offset |
3730 0x54, 0x76, 0x10, 0x32, | 4699 0x54, 0x76, 0x10, 0x32, |
3731 0xDC, 0xFE, 0x98, 0xBA, | 4700 0xDC, 0xFE, 0x98, 0xBA, |
3732 // data | 4701 // data |
3733 'h', 'e', 'l', 'l', | 4702 'h', 'e', 'l', 'l', |
3734 'o', ' ', 'w', 'o', | 4703 'o', ' ', 'w', 'o', |
3735 'r', 'l', 'd', '!', | 4704 'r', 'l', 'd', '!', |
3736 }; | 4705 }; |
| 4706 |
| 4707 unsigned char packet39[] = { |
| 4708 // public flags (8 byte connection_id) |
| 4709 0x38, |
| 4710 // connection_id |
| 4711 0x10, 0x32, 0x54, 0x76, |
| 4712 0x98, 0xBA, 0xDC, 0xFE, |
| 4713 // packet number |
| 4714 0x12, 0x34, 0x56, 0x78, |
| 4715 0x9A, 0xBC, |
| 4716 |
| 4717 // frame type (stream frame with fin and no length) |
| 4718 0xDF, |
| 4719 // stream id |
| 4720 0x01, 0x02, 0x03, 0x04, |
| 4721 // offset |
| 4722 0xBA, 0x98, 0xFE, 0xDC, |
| 4723 0x32, 0x10, 0x76, 0x54, |
| 4724 // data |
| 4725 'h', 'e', 'l', 'l', |
| 4726 'o', ' ', 'w', 'o', |
| 4727 'r', 'l', 'd', '!', |
| 4728 }; |
| 4729 |
| 4730 unsigned char packet_cid_be39[] = { |
| 4731 // public flags (8 byte connection_id) |
| 4732 0x38, |
| 4733 // connection_id |
| 4734 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 4735 // packet number |
| 4736 0x12, 0x34, 0x56, 0x78, |
| 4737 0x9A, 0xBC, |
| 4738 |
| 4739 // frame type (stream frame with fin and no length) |
| 4740 0xDF, |
| 4741 // stream id |
| 4742 0x01, 0x02, 0x03, 0x04, |
| 4743 // offset |
| 4744 0xBA, 0x98, 0xFE, 0xDC, |
| 4745 0x32, 0x10, 0x76, 0x54, |
| 4746 // data |
| 4747 'h', 'e', 'l', 'l', |
| 4748 'o', ' ', 'w', 'o', |
| 4749 'r', 'l', 'd', '!', |
| 4750 }; |
3737 // clang-format on | 4751 // clang-format on |
3738 | 4752 |
| 4753 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 4754 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 4755 |
3739 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 4756 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
3740 ASSERT_TRUE(data != nullptr); | 4757 ASSERT_TRUE(data != nullptr); |
3741 | 4758 |
3742 test::CompareCharArraysWithHexError( | 4759 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
3743 "constructed packet", data->data(), data->length(), | 4760 data->length(), AsChars(packets[index]), |
3744 AsChars( | 4761 arraysize(packet)); |
3745 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3746 ? packet_cid_be | |
3747 : packet), | |
3748 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3749 ? arraysize(packet_cid_be) | |
3750 : arraysize(packet)); | |
3751 } | 4762 } |
3752 | 4763 |
3753 TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { | 4764 TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { |
3754 QuicPacketHeader header; | 4765 QuicPacketHeader header; |
3755 header.public_header.connection_id = kConnectionId; | 4766 header.public_header.connection_id = kConnectionId; |
3756 header.public_header.reset_flag = false; | 4767 header.public_header.reset_flag = false; |
3757 header.public_header.version_flag = true; | 4768 header.public_header.version_flag = true; |
3758 header.packet_number = kPacketNumber; | 4769 header.packet_number = kPacketNumber; |
3759 | 4770 |
3760 QuicStreamFrame stream_frame(kStreamId, true, kStreamOffset, | 4771 QuicStreamFrame stream_frame(kStreamId, true, kStreamOffset, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3796 | 4807 |
3797 // frame type (stream frame with fin and no length) | 4808 // frame type (stream frame with fin and no length) |
3798 0xDF, | 4809 0xDF, |
3799 // stream id | 4810 // stream id |
3800 0x04, 0x03, 0x02, 0x01, | 4811 0x04, 0x03, 0x02, 0x01, |
3801 // offset | 4812 // offset |
3802 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, | 4813 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
3803 // data | 4814 // data |
3804 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', | 4815 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
3805 }; | 4816 }; |
| 4817 |
| 4818 unsigned char packet39[] = { |
| 4819 // public flags (version, 8 byte connection_id) |
| 4820 static_cast<unsigned char>( |
| 4821 FLAGS_quic_reloadable_flag_quic_remove_v33_hacks2 ? 0x39 : 0x3D), |
| 4822 // connection_id |
| 4823 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 4824 // version tag |
| 4825 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
| 4826 // packet number |
| 4827 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 4828 |
| 4829 // frame type (stream frame with fin and no length) |
| 4830 0xDF, |
| 4831 // stream id |
| 4832 0x01, 0x02, 0x03, 0x04, |
| 4833 // offset |
| 4834 0xBA, 0x98, 0xFE, 0xDC, 0x32, 0x10, 0x76, 0x54, |
| 4835 // data |
| 4836 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
| 4837 }; |
| 4838 |
| 4839 unsigned char packet_cid_be39[] = { |
| 4840 // public flags (version, 8 byte connection_id) |
| 4841 static_cast<unsigned char>( |
| 4842 FLAGS_quic_reloadable_flag_quic_remove_v33_hacks2 ? 0x39 : 0x3D), |
| 4843 // connection_id |
| 4844 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 4845 // version tag |
| 4846 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
| 4847 // packet number |
| 4848 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 4849 |
| 4850 // frame type (stream frame with fin and no length) |
| 4851 0xDF, |
| 4852 // stream id |
| 4853 0x01, 0x02, 0x03, 0x04, |
| 4854 // offset |
| 4855 0xBA, 0x98, 0xFE, 0xDC, 0x32, 0x10, 0x76, 0x54, |
| 4856 // data |
| 4857 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
| 4858 }; |
3806 // clang-format on | 4859 // clang-format on |
3807 | 4860 |
| 4861 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 4862 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 4863 |
3808 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); | 4864 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); |
3809 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 4865 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
3810 ASSERT_TRUE(data != nullptr); | 4866 ASSERT_TRUE(data != nullptr); |
3811 | 4867 |
3812 test::CompareCharArraysWithHexError( | 4868 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
3813 "constructed packet", data->data(), data->length(), | 4869 data->length(), AsChars(packets[index]), |
3814 AsChars( | 4870 arraysize(packet)); |
3815 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3816 ? packet_cid_be | |
3817 : packet), | |
3818 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3819 ? arraysize(packet_cid_be) | |
3820 : arraysize(packet)); | |
3821 } | 4871 } |
3822 | 4872 |
3823 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { | 4873 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { |
3824 // clang-format off | 4874 // clang-format off |
3825 unsigned char packet[] = { | 4875 unsigned char packet[] = { |
3826 // public flags (version, 8 byte connection_id) | 4876 // public flags (version, 8 byte connection_id) |
3827 0x0D, | 4877 0x0D, |
3828 // connection_id | 4878 // connection_id |
3829 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, | 4879 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
3830 // version tag | 4880 // version tag |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3906 0x45, | 4956 0x45, |
3907 // largest acked | 4957 // largest acked |
3908 0x34, 0x12, | 4958 0x34, 0x12, |
3909 // Zero delta time. | 4959 // Zero delta time. |
3910 0x00, 0x00, | 4960 0x00, 0x00, |
3911 // first ack block length. | 4961 // first ack block length. |
3912 0x34, 0x12, | 4962 0x34, 0x12, |
3913 // num timestamps. | 4963 // num timestamps. |
3914 0x00, | 4964 0x00, |
3915 }; | 4965 }; |
| 4966 |
| 4967 unsigned char packet39[] = { |
| 4968 // public flags (8 byte connection_id) |
| 4969 0x38, |
| 4970 // connection_id |
| 4971 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 4972 // packet number |
| 4973 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 4974 |
| 4975 // frame type (ack frame) |
| 4976 // (no ack blocks, 2 byte largest observed, 2 byte block length) |
| 4977 0x45, |
| 4978 // largest acked |
| 4979 0x12, 0x34, |
| 4980 // Zero delta time. |
| 4981 0x00, 0x00, |
| 4982 // first ack block length. |
| 4983 0x12, 0x34, |
| 4984 // num timestamps. |
| 4985 0x00, |
| 4986 }; |
| 4987 |
| 4988 unsigned char packet_cid_be39[] = { |
| 4989 // public flags (8 byte connection_id) |
| 4990 0x38, |
| 4991 // connection_id |
| 4992 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 4993 // packet number |
| 4994 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 4995 |
| 4996 // frame type (ack frame) |
| 4997 // (no ack blocks, 2 byte largest observed, 2 byte block length) |
| 4998 0x45, |
| 4999 // largest acked |
| 5000 0x12, 0x34, |
| 5001 // Zero delta time. |
| 5002 0x00, 0x00, |
| 5003 // first ack block length. |
| 5004 0x12, 0x34, |
| 5005 // num timestamps. |
| 5006 0x00, |
| 5007 }; |
3916 // clang-format on | 5008 // clang-format on |
3917 | 5009 |
| 5010 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 5011 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 5012 |
3918 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 5013 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
3919 ASSERT_TRUE(data != nullptr); | 5014 ASSERT_TRUE(data != nullptr); |
3920 | 5015 |
3921 test::CompareCharArraysWithHexError( | 5016 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
3922 "constructed packet", data->data(), data->length(), | 5017 data->length(), AsChars(packets[index]), |
3923 AsChars( | 5018 arraysize(packet)); |
3924 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3925 ? packet_cid_be | |
3926 : packet), | |
3927 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
3928 ? arraysize(packet_cid_be) | |
3929 : arraysize(packet)); | |
3930 } | 5019 } |
3931 | 5020 |
3932 TEST_P(QuicFramerTest, BuildAckFramePacketMultipleAckBlocks) { | 5021 TEST_P(QuicFramerTest, BuildAckFramePacketMultipleAckBlocks) { |
3933 QuicPacketHeader header; | 5022 QuicPacketHeader header; |
3934 header.public_header.connection_id = kConnectionId; | 5023 header.public_header.connection_id = kConnectionId; |
3935 header.public_header.reset_flag = false; | 5024 header.public_header.reset_flag = false; |
3936 header.public_header.version_flag = false; | 5025 header.public_header.version_flag = false; |
3937 header.packet_number = kPacketNumber; | 5026 header.packet_number = kPacketNumber; |
3938 | 5027 |
3939 // Use kSmallLargestObserved to make this test finished in a short time. | 5028 // Use kSmallLargestObserved to make this test finished in a short time. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4018 0x91, | 5107 0x91, |
4019 // ack block length. | 5108 // ack block length. |
4020 0xea, 0x01, | 5109 0xea, 0x01, |
4021 // gap to next block. | 5110 // gap to next block. |
4022 0x05, | 5111 0x05, |
4023 // ack block length. | 5112 // ack block length. |
4024 0x04, 0x00, | 5113 0x04, 0x00, |
4025 // num timestamps. | 5114 // num timestamps. |
4026 0x00, | 5115 0x00, |
4027 }; | 5116 }; |
| 5117 |
| 5118 unsigned char packet39[] = { |
| 5119 // public flags (8 byte connection_id) |
| 5120 0x38, |
| 5121 // connection_id |
| 5122 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 5123 // packet number |
| 5124 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 5125 |
| 5126 // frame type (ack frame) |
| 5127 // (has ack blocks, 2 byte largest observed, 2 byte block length) |
| 5128 0x65, |
| 5129 // largest acked |
| 5130 0x12, 0x34, |
| 5131 // Zero delta time. |
| 5132 0x00, 0x00, |
| 5133 // num ack blocks ranges. |
| 5134 0x04, |
| 5135 // first ack block length. |
| 5136 0x00, 0x01, |
| 5137 // gap to next block. |
| 5138 0x01, |
| 5139 // ack block length. |
| 5140 0x0e, 0xaf, |
| 5141 // gap to next block. |
| 5142 0xff, |
| 5143 // ack block length. |
| 5144 0x00, 0x00, |
| 5145 // gap to next block. |
| 5146 0x91, |
| 5147 // ack block length. |
| 5148 0x01, 0xea, |
| 5149 // gap to next block. |
| 5150 0x05, |
| 5151 // ack block length. |
| 5152 0x00, 0x04, |
| 5153 // num timestamps. |
| 5154 0x00, |
| 5155 }; |
| 5156 |
| 5157 unsigned char packet_cid_be39[] = { |
| 5158 // public flags (8 byte connection_id) |
| 5159 0x38, |
| 5160 // connection_id |
| 5161 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 5162 // packet number |
| 5163 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 5164 |
| 5165 // frame type (ack frame) |
| 5166 // (has ack blocks, 2 byte largest observed, 2 byte block length) |
| 5167 0x65, |
| 5168 // largest acked |
| 5169 0x12, 0x34, |
| 5170 // Zero delta time. |
| 5171 0x00, 0x00, |
| 5172 // num ack blocks ranges. |
| 5173 0x04, |
| 5174 // first ack block length. |
| 5175 0x00, 0x01, |
| 5176 // gap to next block. |
| 5177 0x01, |
| 5178 // ack block length. |
| 5179 0x0e, 0xaf, |
| 5180 // gap to next block. |
| 5181 0xff, |
| 5182 // ack block length. |
| 5183 0x00, 0x00, |
| 5184 // gap to next block. |
| 5185 0x91, |
| 5186 // ack block length. |
| 5187 0x01, 0xea, |
| 5188 // gap to next block. |
| 5189 0x05, |
| 5190 // ack block length. |
| 5191 0x00, 0x04, |
| 5192 // num timestamps. |
| 5193 0x00, |
| 5194 }; |
4028 // clang-format on | 5195 // clang-format on |
4029 | 5196 |
| 5197 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 5198 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 5199 |
4030 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 5200 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4031 ASSERT_TRUE(data != nullptr); | 5201 ASSERT_TRUE(data != nullptr); |
4032 | 5202 |
4033 test::CompareCharArraysWithHexError( | 5203 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4034 "constructed packet", data->data(), data->length(), | 5204 data->length(), AsChars(packets[index]), |
4035 AsChars( | 5205 arraysize(packet)); |
4036 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4037 ? packet_cid_be | |
4038 : packet), | |
4039 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4040 ? arraysize(packet_cid_be) | |
4041 : arraysize(packet)); | |
4042 } | 5206 } |
4043 | 5207 |
4044 TEST_P(QuicFramerTest, BuildAckFramePacketMaxAckBlocks) { | 5208 TEST_P(QuicFramerTest, BuildAckFramePacketMaxAckBlocks) { |
4045 QuicPacketHeader header; | 5209 QuicPacketHeader header; |
4046 header.public_header.connection_id = kConnectionId; | 5210 header.public_header.connection_id = kConnectionId; |
4047 header.public_header.reset_flag = false; | 5211 header.public_header.reset_flag = false; |
4048 header.public_header.version_flag = false; | 5212 header.public_header.version_flag = false; |
4049 header.packet_number = kPacketNumber; | 5213 header.packet_number = kPacketNumber; |
4050 | 5214 |
4051 // Use kSmallLargestObservedto make this test finished in a short time. | 5215 // Use kSmallLargestObservedto make this test finished in a short time. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4239 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, | 5403 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, |
4240 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, | 5404 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, |
4241 | 5405 |
4242 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, | 5406 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, |
4243 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, | 5407 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, |
4244 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, | 5408 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, |
4245 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, | 5409 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, |
4246 // num timestamps. | 5410 // num timestamps. |
4247 0x00, | 5411 0x00, |
4248 }; | 5412 }; |
| 5413 |
| 5414 unsigned char packet39[] = { |
| 5415 // public flags (8 byte connection_id) |
| 5416 0x38, |
| 5417 // connection_id |
| 5418 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 5419 // packet number |
| 5420 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 5421 // frame type (ack frame) |
| 5422 // (has ack blocks, 2 byte largest observed, 2 byte block length) |
| 5423 0x65, |
| 5424 // largest acked |
| 5425 0x12, 0x34, |
| 5426 // Zero delta time. |
| 5427 0x00, 0x00, |
| 5428 // num ack blocks ranges. |
| 5429 0xff, |
| 5430 // first ack block length. |
| 5431 0x0f, 0xdd, |
| 5432 // 255 = 4 * 63 + 3 |
| 5433 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5434 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5435 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5436 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5437 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5438 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5439 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5440 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5441 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5442 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5443 |
| 5444 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5445 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5446 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5447 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5448 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5449 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5450 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5451 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5452 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5453 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5454 |
| 5455 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5456 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5457 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5458 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5459 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5460 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5461 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5462 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5463 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5464 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5465 |
| 5466 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5467 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5468 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5469 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5470 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5471 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5472 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5473 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5474 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5475 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5476 |
| 5477 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5478 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5479 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5480 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5481 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5482 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5483 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5484 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5485 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5486 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5487 |
| 5488 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5489 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5490 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5491 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5492 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5493 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5494 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5495 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5496 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5497 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5498 |
| 5499 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5500 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5501 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5502 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5503 // num timestamps. |
| 5504 0x00, |
| 5505 }; |
| 5506 |
| 5507 unsigned char packet_cid_be39[] = { |
| 5508 // public flags (8 byte connection_id) |
| 5509 0x38, |
| 5510 // connection_id |
| 5511 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 5512 // packet number |
| 5513 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 5514 // frame type (ack frame) |
| 5515 // (has ack blocks, 2 byte largest observed, 2 byte block length) |
| 5516 0x65, |
| 5517 // largest acked |
| 5518 0x12, 0x34, |
| 5519 // Zero delta time. |
| 5520 0x00, 0x00, |
| 5521 // num ack blocks ranges. |
| 5522 0xff, |
| 5523 // first ack block length. |
| 5524 0x0f, 0xdd, |
| 5525 // 255 = 4 * 63 + 3 |
| 5526 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5527 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5528 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5529 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5530 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5531 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5532 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5533 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5534 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5535 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5536 |
| 5537 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5538 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5539 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5540 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5541 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5542 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5543 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5544 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5545 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5546 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5547 |
| 5548 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5549 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5550 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5551 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5552 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5553 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5554 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5555 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5556 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5557 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5558 |
| 5559 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5560 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5561 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5562 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5563 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5564 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5565 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5566 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5567 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5568 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5569 |
| 5570 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5571 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5572 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5573 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5574 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5575 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5576 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5577 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5578 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5579 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5580 |
| 5581 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5582 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5583 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5584 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5585 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5586 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5587 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5588 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5589 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5590 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5591 |
| 5592 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5593 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5594 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5595 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, |
| 5596 // num timestamps. |
| 5597 0x00, |
| 5598 }; |
4249 // clang-format on | 5599 // clang-format on |
4250 | 5600 |
| 5601 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 5602 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 5603 |
4251 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 5604 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4252 ASSERT_TRUE(data != nullptr); | 5605 ASSERT_TRUE(data != nullptr); |
4253 | 5606 |
4254 test::CompareCharArraysWithHexError( | 5607 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4255 "constructed packet", data->data(), data->length(), | 5608 data->length(), AsChars(packets[index]), |
4256 AsChars( | 5609 arraysize(packet)); |
4257 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4258 ? packet_cid_be | |
4259 : packet), | |
4260 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4261 ? arraysize(packet_cid_be) | |
4262 : arraysize(packet)); | |
4263 } | 5610 } |
4264 | 5611 |
4265 TEST_P(QuicFramerTest, BuildNewStopWaitingPacket) { | 5612 TEST_P(QuicFramerTest, BuildNewStopWaitingPacket) { |
4266 QuicPacketHeader header; | 5613 QuicPacketHeader header; |
4267 header.public_header.connection_id = kConnectionId; | 5614 header.public_header.connection_id = kConnectionId; |
4268 header.public_header.reset_flag = false; | 5615 header.public_header.reset_flag = false; |
4269 header.public_header.version_flag = false; | 5616 header.public_header.version_flag = false; |
4270 header.packet_number = kPacketNumber; | 5617 header.packet_number = kPacketNumber; |
4271 | 5618 |
4272 QuicStopWaitingFrame stop_waiting_frame; | 5619 QuicStopWaitingFrame stop_waiting_frame; |
(...skipping 25 matching lines...) Expand all Loading... |
4298 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 5645 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
4299 // packet number | 5646 // packet number |
4300 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 5647 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
4301 | 5648 |
4302 // frame type (stop waiting frame) | 5649 // frame type (stop waiting frame) |
4303 0x06, | 5650 0x06, |
4304 // least packet number awaiting an ack, delta from packet number. | 5651 // least packet number awaiting an ack, delta from packet number. |
4305 0x1C, 0x00, 0x00, 0x00, | 5652 0x1C, 0x00, 0x00, 0x00, |
4306 0x00, 0x00, | 5653 0x00, 0x00, |
4307 }; | 5654 }; |
| 5655 |
| 5656 unsigned char packet39[] = { |
| 5657 // public flags (8 byte connection_id) |
| 5658 0x38, |
| 5659 // connection_id |
| 5660 0x10, 0x32, 0x54, 0x76, |
| 5661 0x98, 0xBA, 0xDC, 0xFE, |
| 5662 // packet number |
| 5663 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 5664 |
| 5665 // frame type (stop waiting frame) |
| 5666 0x06, |
| 5667 // least packet number awaiting an ack, delta from packet number. |
| 5668 0x00, 0x00, 0x00, 0x00, |
| 5669 0x00, 0x1C, |
| 5670 }; |
| 5671 |
| 5672 unsigned char packet_cid_be39[] = { |
| 5673 // public flags (8 byte connection_id) |
| 5674 0x38, |
| 5675 // connection_id |
| 5676 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 5677 // packet number |
| 5678 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, |
| 5679 |
| 5680 // frame type (stop waiting frame) |
| 5681 0x06, |
| 5682 // least packet number awaiting an ack, delta from packet number. |
| 5683 0x00, 0x00, 0x00, 0x00, |
| 5684 0x00, 0x1C, |
| 5685 }; |
4308 // clang-format on | 5686 // clang-format on |
4309 | 5687 |
| 5688 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 5689 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 5690 |
4310 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 5691 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4311 ASSERT_TRUE(data != nullptr); | 5692 ASSERT_TRUE(data != nullptr); |
4312 | 5693 |
4313 test::CompareCharArraysWithHexError( | 5694 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4314 "constructed packet", data->data(), data->length(), | 5695 data->length(), AsChars(packets[index]), |
4315 AsChars( | 5696 arraysize(packet)); |
4316 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4317 ? packet_cid_be | |
4318 : packet), | |
4319 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4320 ? arraysize(packet_cid_be) | |
4321 : arraysize(packet)); | |
4322 } | 5697 } |
4323 | 5698 |
4324 TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { | 5699 TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { |
4325 QuicPacketHeader header; | 5700 QuicPacketHeader header; |
4326 header.public_header.connection_id = kConnectionId; | 5701 header.public_header.connection_id = kConnectionId; |
4327 header.public_header.reset_flag = false; | 5702 header.public_header.reset_flag = false; |
4328 header.public_header.version_flag = false; | 5703 header.public_header.version_flag = false; |
4329 header.packet_number = kPacketNumber; | 5704 header.packet_number = kPacketNumber; |
4330 | 5705 |
4331 QuicRstStreamFrame rst_frame; | 5706 QuicRstStreamFrame rst_frame; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4367 // frame type (rst stream frame) | 5742 // frame type (rst stream frame) |
4368 0x01, | 5743 0x01, |
4369 // stream id | 5744 // stream id |
4370 0x04, 0x03, 0x02, 0x01, | 5745 0x04, 0x03, 0x02, 0x01, |
4371 // sent byte offset | 5746 // sent byte offset |
4372 0x01, 0x02, 0x03, 0x04, | 5747 0x01, 0x02, 0x03, 0x04, |
4373 0x05, 0x06, 0x07, 0x08, | 5748 0x05, 0x06, 0x07, 0x08, |
4374 // error code | 5749 // error code |
4375 0x08, 0x07, 0x06, 0x05, | 5750 0x08, 0x07, 0x06, 0x05, |
4376 }; | 5751 }; |
| 5752 |
| 5753 unsigned char packet39[] = { |
| 5754 // public flags (8 byte connection_id) |
| 5755 0x38, |
| 5756 // connection_id |
| 5757 0x10, 0x32, 0x54, 0x76, |
| 5758 0x98, 0xBA, 0xDC, 0xFE, |
| 5759 // packet number |
| 5760 0x12, 0x34, 0x56, 0x78, |
| 5761 0x9A, 0xBC, |
| 5762 |
| 5763 // frame type (rst stream frame) |
| 5764 0x01, |
| 5765 // stream id |
| 5766 0x01, 0x02, 0x03, 0x04, |
| 5767 // sent byte offset |
| 5768 0x08, 0x07, 0x06, 0x05, |
| 5769 0x04, 0x03, 0x02, 0x01, |
| 5770 // error code |
| 5771 0x05, 0x06, 0x07, 0x08, |
| 5772 }; |
| 5773 |
| 5774 unsigned char packet_cid_be39[] = { |
| 5775 // public flags (8 byte connection_id) |
| 5776 0x38, |
| 5777 // connection_id |
| 5778 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 5779 // packet number |
| 5780 0x12, 0x34, 0x56, 0x78, |
| 5781 0x9A, 0xBC, |
| 5782 |
| 5783 // frame type (rst stream frame) |
| 5784 0x01, |
| 5785 // stream id |
| 5786 0x01, 0x02, 0x03, 0x04, |
| 5787 // sent byte offset |
| 5788 0x08, 0x07, 0x06, 0x05, |
| 5789 0x04, 0x03, 0x02, 0x01, |
| 5790 // error code |
| 5791 0x05, 0x06, 0x07, 0x08, |
| 5792 }; |
4377 // clang-format on | 5793 // clang-format on |
4378 | 5794 |
| 5795 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 5796 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 5797 |
4379 QuicFrames frames = {QuicFrame(&rst_frame)}; | 5798 QuicFrames frames = {QuicFrame(&rst_frame)}; |
4380 | 5799 |
4381 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 5800 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4382 ASSERT_TRUE(data != nullptr); | 5801 ASSERT_TRUE(data != nullptr); |
4383 | 5802 |
4384 test::CompareCharArraysWithHexError( | 5803 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4385 "constructed packet", data->data(), data->length(), | 5804 data->length(), AsChars(packets[index]), |
4386 AsChars( | 5805 arraysize(packet)); |
4387 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4388 ? packet_cid_be | |
4389 : packet), | |
4390 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4391 ? arraysize(packet_cid_be) | |
4392 : arraysize(packet)); | |
4393 } | 5806 } |
4394 | 5807 |
4395 TEST_P(QuicFramerTest, BuildCloseFramePacket) { | 5808 TEST_P(QuicFramerTest, BuildCloseFramePacket) { |
4396 QuicPacketHeader header; | 5809 QuicPacketHeader header; |
4397 header.public_header.connection_id = kConnectionId; | 5810 header.public_header.connection_id = kConnectionId; |
4398 header.public_header.reset_flag = false; | 5811 header.public_header.reset_flag = false; |
4399 header.public_header.version_flag = false; | 5812 header.public_header.version_flag = false; |
4400 header.packet_number = kPacketNumber; | 5813 header.packet_number = kPacketNumber; |
4401 | 5814 |
4402 QuicConnectionCloseFrame close_frame; | 5815 QuicConnectionCloseFrame close_frame; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4443 // error code | 5856 // error code |
4444 0x08, 0x07, 0x06, 0x05, | 5857 0x08, 0x07, 0x06, 0x05, |
4445 // error details length | 5858 // error details length |
4446 0x0d, 0x00, | 5859 0x0d, 0x00, |
4447 // error details | 5860 // error details |
4448 'b', 'e', 'c', 'a', | 5861 'b', 'e', 'c', 'a', |
4449 'u', 's', 'e', ' ', | 5862 'u', 's', 'e', ' ', |
4450 'I', ' ', 'c', 'a', | 5863 'I', ' ', 'c', 'a', |
4451 'n', | 5864 'n', |
4452 }; | 5865 }; |
| 5866 |
| 5867 unsigned char packet39[] = { |
| 5868 // public flags (8 byte connection_id) |
| 5869 0x38, |
| 5870 // connection_id |
| 5871 0x10, 0x32, 0x54, 0x76, |
| 5872 0x98, 0xBA, 0xDC, 0xFE, |
| 5873 // packet number |
| 5874 0x12, 0x34, 0x56, 0x78, |
| 5875 0x9A, 0xBC, |
| 5876 |
| 5877 // frame type (connection close frame) |
| 5878 0x02, |
| 5879 // error code |
| 5880 0x05, 0x06, 0x07, 0x08, |
| 5881 // error details length |
| 5882 0x00, 0x0d, |
| 5883 // error details |
| 5884 'b', 'e', 'c', 'a', |
| 5885 'u', 's', 'e', ' ', |
| 5886 'I', ' ', 'c', 'a', |
| 5887 'n', |
| 5888 }; |
| 5889 |
| 5890 unsigned char packet_cid_be39[] = { |
| 5891 // public flags (8 byte connection_id) |
| 5892 0x38, |
| 5893 // connection_id |
| 5894 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 5895 // packet number |
| 5896 0x12, 0x34, 0x56, 0x78, |
| 5897 0x9A, 0xBC, |
| 5898 |
| 5899 // frame type (connection close frame) |
| 5900 0x02, |
| 5901 // error code |
| 5902 0x05, 0x06, 0x07, 0x08, |
| 5903 // error details length |
| 5904 0x00, 0x0d, |
| 5905 // error details |
| 5906 'b', 'e', 'c', 'a', |
| 5907 'u', 's', 'e', ' ', |
| 5908 'I', ' ', 'c', 'a', |
| 5909 'n', |
| 5910 }; |
4453 // clang-format on | 5911 // clang-format on |
4454 | 5912 |
| 5913 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 5914 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 5915 |
4455 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 5916 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4456 ASSERT_TRUE(data != nullptr); | 5917 ASSERT_TRUE(data != nullptr); |
4457 | 5918 |
4458 test::CompareCharArraysWithHexError( | 5919 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4459 "constructed packet", data->data(), data->length(), | 5920 data->length(), AsChars(packets[index]), |
4460 AsChars( | 5921 arraysize(packet)); |
4461 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4462 ? packet_cid_be | |
4463 : packet), | |
4464 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4465 ? arraysize(packet_cid_be) | |
4466 : arraysize(packet)); | |
4467 } | 5922 } |
4468 | 5923 |
4469 TEST_P(QuicFramerTest, BuildGoAwayPacket) { | 5924 TEST_P(QuicFramerTest, BuildGoAwayPacket) { |
4470 QuicPacketHeader header; | 5925 QuicPacketHeader header; |
4471 header.public_header.connection_id = kConnectionId; | 5926 header.public_header.connection_id = kConnectionId; |
4472 header.public_header.reset_flag = false; | 5927 header.public_header.reset_flag = false; |
4473 header.public_header.version_flag = false; | 5928 header.public_header.version_flag = false; |
4474 header.packet_number = kPacketNumber; | 5929 header.packet_number = kPacketNumber; |
4475 | 5930 |
4476 QuicGoAwayFrame goaway_frame; | 5931 QuicGoAwayFrame goaway_frame; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4522 // stream id | 5977 // stream id |
4523 0x04, 0x03, 0x02, 0x01, | 5978 0x04, 0x03, 0x02, 0x01, |
4524 // error details length | 5979 // error details length |
4525 0x0d, 0x00, | 5980 0x0d, 0x00, |
4526 // error details | 5981 // error details |
4527 'b', 'e', 'c', 'a', | 5982 'b', 'e', 'c', 'a', |
4528 'u', 's', 'e', ' ', | 5983 'u', 's', 'e', ' ', |
4529 'I', ' ', 'c', 'a', | 5984 'I', ' ', 'c', 'a', |
4530 'n', | 5985 'n', |
4531 }; | 5986 }; |
| 5987 |
| 5988 unsigned char packet39[] = { |
| 5989 // public flags (8 byte connection_id) |
| 5990 0x38, |
| 5991 // connection_id |
| 5992 0x10, 0x32, 0x54, 0x76, |
| 5993 0x98, 0xBA, 0xDC, 0xFE, |
| 5994 // packet number |
| 5995 0x12, 0x34, 0x56, 0x78, |
| 5996 0x9A, 0xBC, |
| 5997 |
| 5998 // frame type (go away frame) |
| 5999 0x03, |
| 6000 // error code |
| 6001 0x05, 0x06, 0x07, 0x08, |
| 6002 // stream id |
| 6003 0x01, 0x02, 0x03, 0x04, |
| 6004 // error details length |
| 6005 0x00, 0x0d, |
| 6006 // error details |
| 6007 'b', 'e', 'c', 'a', |
| 6008 'u', 's', 'e', ' ', |
| 6009 'I', ' ', 'c', 'a', |
| 6010 'n', |
| 6011 }; |
| 6012 |
| 6013 unsigned char packet_cid_be39[] = { |
| 6014 // public flags (8 byte connection_id) |
| 6015 0x38, |
| 6016 // connection_id |
| 6017 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 6018 // packet number |
| 6019 0x12, 0x34, 0x56, 0x78, |
| 6020 0x9A, 0xBC, |
| 6021 |
| 6022 // frame type (go away frame) |
| 6023 0x03, |
| 6024 // error code |
| 6025 0x05, 0x06, 0x07, 0x08, |
| 6026 // stream id |
| 6027 0x01, 0x02, 0x03, 0x04, |
| 6028 // error details length |
| 6029 0x00, 0x0d, |
| 6030 // error details |
| 6031 'b', 'e', 'c', 'a', |
| 6032 'u', 's', 'e', ' ', |
| 6033 'I', ' ', 'c', 'a', |
| 6034 'n', |
| 6035 }; |
4532 // clang-format on | 6036 // clang-format on |
4533 | 6037 |
| 6038 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 6039 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 6040 |
4534 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 6041 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4535 ASSERT_TRUE(data != nullptr); | 6042 ASSERT_TRUE(data != nullptr); |
4536 | 6043 |
4537 test::CompareCharArraysWithHexError( | 6044 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4538 "constructed packet", data->data(), data->length(), | 6045 data->length(), AsChars(packets[index]), |
4539 AsChars( | 6046 arraysize(packet)); |
4540 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4541 ? packet_cid_be | |
4542 : packet), | |
4543 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4544 ? arraysize(packet_cid_be) | |
4545 : arraysize(packet)); | |
4546 } | 6047 } |
4547 | 6048 |
4548 TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { | 6049 TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { |
4549 QuicPacketHeader header; | 6050 QuicPacketHeader header; |
4550 header.public_header.connection_id = kConnectionId; | 6051 header.public_header.connection_id = kConnectionId; |
4551 header.public_header.reset_flag = false; | 6052 header.public_header.reset_flag = false; |
4552 header.public_header.version_flag = false; | 6053 header.public_header.version_flag = false; |
4553 header.packet_number = kPacketNumber; | 6054 header.packet_number = kPacketNumber; |
4554 | 6055 |
4555 QuicWindowUpdateFrame window_update_frame; | 6056 QuicWindowUpdateFrame window_update_frame; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4588 0x34, 0x12, | 6089 0x34, 0x12, |
4589 | 6090 |
4590 // frame type (window update frame) | 6091 // frame type (window update frame) |
4591 0x04, | 6092 0x04, |
4592 // stream id | 6093 // stream id |
4593 0x04, 0x03, 0x02, 0x01, | 6094 0x04, 0x03, 0x02, 0x01, |
4594 // byte offset | 6095 // byte offset |
4595 0x88, 0x77, 0x66, 0x55, | 6096 0x88, 0x77, 0x66, 0x55, |
4596 0x44, 0x33, 0x22, 0x11, | 6097 0x44, 0x33, 0x22, 0x11, |
4597 }; | 6098 }; |
| 6099 |
| 6100 unsigned char packet39[] = { |
| 6101 // public flags (8 byte connection_id) |
| 6102 0x38, |
| 6103 // connection_id |
| 6104 0x10, 0x32, 0x54, 0x76, |
| 6105 0x98, 0xBA, 0xDC, 0xFE, |
| 6106 // packet number |
| 6107 0x12, 0x34, 0x56, 0x78, |
| 6108 0x9A, 0xBC, |
| 6109 |
| 6110 // frame type (window update frame) |
| 6111 0x04, |
| 6112 // stream id |
| 6113 0x01, 0x02, 0x03, 0x04, |
| 6114 // byte offset |
| 6115 0x11, 0x22, 0x33, 0x44, |
| 6116 0x55, 0x66, 0x77, 0x88, |
| 6117 }; |
| 6118 |
| 6119 unsigned char packet_cid_be39[] = { |
| 6120 // public flags (8 byte connection_id) |
| 6121 0x38, |
| 6122 // connection_id |
| 6123 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 6124 // packet number |
| 6125 0x12, 0x34, 0x56, 0x78, |
| 6126 0x9A, 0xBC, |
| 6127 |
| 6128 // frame type (window update frame) |
| 6129 0x04, |
| 6130 // stream id |
| 6131 0x01, 0x02, 0x03, 0x04, |
| 6132 // byte offset |
| 6133 0x11, 0x22, 0x33, 0x44, |
| 6134 0x55, 0x66, 0x77, 0x88, |
| 6135 }; |
4598 // clang-format on | 6136 // clang-format on |
4599 | 6137 |
| 6138 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 6139 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 6140 |
4600 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 6141 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4601 ASSERT_TRUE(data != nullptr); | 6142 ASSERT_TRUE(data != nullptr); |
4602 | 6143 |
4603 test::CompareCharArraysWithHexError( | 6144 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4604 "constructed packet", data->data(), data->length(), | 6145 data->length(), AsChars(packets[index]), |
4605 AsChars( | 6146 arraysize(packet)); |
4606 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4607 ? packet_cid_be | |
4608 : packet), | |
4609 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4610 ? arraysize(packet_cid_be) | |
4611 : arraysize(packet)); | |
4612 } | 6147 } |
4613 | 6148 |
4614 TEST_P(QuicFramerTest, BuildBlockedPacket) { | 6149 TEST_P(QuicFramerTest, BuildBlockedPacket) { |
4615 QuicPacketHeader header; | 6150 QuicPacketHeader header; |
4616 header.public_header.connection_id = kConnectionId; | 6151 header.public_header.connection_id = kConnectionId; |
4617 header.public_header.reset_flag = false; | 6152 header.public_header.reset_flag = false; |
4618 header.public_header.version_flag = false; | 6153 header.public_header.version_flag = false; |
4619 header.packet_number = kPacketNumber; | 6154 header.packet_number = kPacketNumber; |
4620 | 6155 |
4621 QuicBlockedFrame blocked_frame; | 6156 QuicBlockedFrame blocked_frame; |
(...skipping 25 matching lines...) Expand all Loading... |
4647 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 6182 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
4648 // packet number | 6183 // packet number |
4649 0xBC, 0x9A, 0x78, 0x56, | 6184 0xBC, 0x9A, 0x78, 0x56, |
4650 0x34, 0x12, | 6185 0x34, 0x12, |
4651 | 6186 |
4652 // frame type (blocked frame) | 6187 // frame type (blocked frame) |
4653 0x05, | 6188 0x05, |
4654 // stream id | 6189 // stream id |
4655 0x04, 0x03, 0x02, 0x01, | 6190 0x04, 0x03, 0x02, 0x01, |
4656 }; | 6191 }; |
| 6192 |
| 6193 unsigned char packet39[] = { |
| 6194 // public flags (8 byte connection_id) |
| 6195 0x38, |
| 6196 // connection_id |
| 6197 0x10, 0x32, 0x54, 0x76, |
| 6198 0x98, 0xBA, 0xDC, 0xFE, |
| 6199 // packet number |
| 6200 0x12, 0x34, 0x56, 0x78, |
| 6201 0x9A, 0xBC, |
| 6202 |
| 6203 // frame type (blocked frame) |
| 6204 0x05, |
| 6205 // stream id |
| 6206 0x01, 0x02, 0x03, 0x04, |
| 6207 }; |
| 6208 |
| 6209 unsigned char packet_cid_be39[] = { |
| 6210 // public flags (8 byte connection_id) |
| 6211 0x38, |
| 6212 // connection_id |
| 6213 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 6214 // packet number |
| 6215 0x12, 0x34, 0x56, 0x78, |
| 6216 0x9A, 0xBC, |
| 6217 |
| 6218 // frame type (blocked frame) |
| 6219 0x05, |
| 6220 // stream id |
| 6221 0x01, 0x02, 0x03, 0x04, |
| 6222 }; |
4657 // clang-format on | 6223 // clang-format on |
4658 | 6224 |
| 6225 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 6226 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 6227 |
4659 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 6228 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4660 ASSERT_TRUE(data != nullptr); | 6229 ASSERT_TRUE(data != nullptr); |
4661 | 6230 |
4662 test::CompareCharArraysWithHexError( | 6231 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4663 "constructed packet", data->data(), data->length(), | 6232 data->length(), AsChars(packets[index]), |
4664 AsChars( | 6233 arraysize(packet)); |
4665 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4666 ? packet_cid_be | |
4667 : packet), | |
4668 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4669 ? arraysize(packet_cid_be) | |
4670 : arraysize(packet)); | |
4671 } | 6234 } |
4672 | 6235 |
4673 TEST_P(QuicFramerTest, BuildPingPacket) { | 6236 TEST_P(QuicFramerTest, BuildPingPacket) { |
4674 QuicPacketHeader header; | 6237 QuicPacketHeader header; |
4675 header.public_header.connection_id = kConnectionId; | 6238 header.public_header.connection_id = kConnectionId; |
4676 header.public_header.reset_flag = false; | 6239 header.public_header.reset_flag = false; |
4677 header.public_header.version_flag = false; | 6240 header.public_header.version_flag = false; |
4678 header.packet_number = kPacketNumber; | 6241 header.packet_number = kPacketNumber; |
4679 | 6242 |
4680 QuicFrames frames = {QuicFrame(QuicPingFrame())}; | 6243 QuicFrames frames = {QuicFrame(QuicPingFrame())}; |
(...skipping 18 matching lines...) Expand all Loading... |
4699 0x38, | 6262 0x38, |
4700 // connection_id | 6263 // connection_id |
4701 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 6264 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
4702 // packet number | 6265 // packet number |
4703 0xBC, 0x9A, 0x78, 0x56, | 6266 0xBC, 0x9A, 0x78, 0x56, |
4704 0x34, 0x12, | 6267 0x34, 0x12, |
4705 | 6268 |
4706 // frame type (ping frame) | 6269 // frame type (ping frame) |
4707 0x07, | 6270 0x07, |
4708 }; | 6271 }; |
| 6272 |
| 6273 unsigned char packet39[] = { |
| 6274 // public flags (8 byte connection_id) |
| 6275 0x38, |
| 6276 // connection_id |
| 6277 0x10, 0x32, 0x54, 0x76, |
| 6278 0x98, 0xBA, 0xDC, 0xFE, |
| 6279 // packet number |
| 6280 0x12, 0x34, 0x56, 0x78, |
| 6281 0x9A, 0xBC, |
| 6282 |
| 6283 // frame type (ping frame) |
| 6284 0x07, |
| 6285 }; |
| 6286 |
| 6287 unsigned char packet_cid_be39[] = { |
| 6288 // public flags (8 byte connection_id) |
| 6289 0x38, |
| 6290 // connection_id |
| 6291 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 6292 // packet number |
| 6293 0x12, 0x34, 0x56, 0x78, |
| 6294 0x9A, 0xBC, |
| 6295 |
| 6296 // frame type (ping frame) |
| 6297 0x07, |
| 6298 }; |
4709 // clang-format on | 6299 // clang-format on |
4710 | 6300 |
| 6301 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 6302 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 6303 |
4711 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 6304 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4712 ASSERT_TRUE(data != nullptr); | 6305 ASSERT_TRUE(data != nullptr); |
4713 | 6306 |
4714 test::CompareCharArraysWithHexError( | 6307 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4715 "constructed packet", data->data(), data->length(), | 6308 data->length(), AsChars(packets[index]), |
4716 AsChars( | 6309 arraysize(packet)); |
4717 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4718 ? packet_cid_be | |
4719 : packet), | |
4720 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4721 ? arraysize(packet_cid_be) | |
4722 : arraysize(packet)); | |
4723 } | 6310 } |
4724 | 6311 |
4725 // Test that the MTU discovery packet is serialized correctly as a PING packet. | 6312 // Test that the MTU discovery packet is serialized correctly as a PING packet. |
4726 TEST_P(QuicFramerTest, BuildMtuDiscoveryPacket) { | 6313 TEST_P(QuicFramerTest, BuildMtuDiscoveryPacket) { |
4727 QuicPacketHeader header; | 6314 QuicPacketHeader header; |
4728 header.public_header.connection_id = kConnectionId; | 6315 header.public_header.connection_id = kConnectionId; |
4729 header.public_header.reset_flag = false; | 6316 header.public_header.reset_flag = false; |
4730 header.public_header.version_flag = false; | 6317 header.public_header.version_flag = false; |
4731 header.packet_number = kPacketNumber; | 6318 header.packet_number = kPacketNumber; |
4732 | 6319 |
(...skipping 19 matching lines...) Expand all Loading... |
4752 0x38, | 6339 0x38, |
4753 // connection_id | 6340 // connection_id |
4754 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, | 6341 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
4755 // packet number | 6342 // packet number |
4756 0xBC, 0x9A, 0x78, 0x56, | 6343 0xBC, 0x9A, 0x78, 0x56, |
4757 0x34, 0x12, | 6344 0x34, 0x12, |
4758 | 6345 |
4759 // frame type (ping frame) | 6346 // frame type (ping frame) |
4760 0x07, | 6347 0x07, |
4761 }; | 6348 }; |
| 6349 |
| 6350 unsigned char packet39[] = { |
| 6351 // public flags (8 byte connection_id) |
| 6352 0x38, |
| 6353 // connection_id |
| 6354 0x10, 0x32, 0x54, 0x76, |
| 6355 0x98, 0xBA, 0xDC, 0xFE, |
| 6356 // packet number |
| 6357 0x12, 0x34, 0x56, 0x78, |
| 6358 0x9A, 0xBC, |
| 6359 |
| 6360 // frame type (ping frame) |
| 6361 0x07, |
| 6362 }; |
| 6363 |
| 6364 unsigned char packet_cid_be39[] = { |
| 6365 // public flags (8 byte connection_id) |
| 6366 0x38, |
| 6367 // connection_id |
| 6368 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 6369 // packet number |
| 6370 0x12, 0x34, 0x56, 0x78, |
| 6371 0x9A, 0xBC, |
| 6372 |
| 6373 // frame type (ping frame) |
| 6374 0x07, |
| 6375 }; |
4762 // clang-format on | 6376 // clang-format on |
4763 | 6377 |
| 6378 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 6379 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 6380 |
4764 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 6381 std::unique_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
4765 ASSERT_TRUE(data != nullptr); | 6382 ASSERT_TRUE(data != nullptr); |
4766 | 6383 |
4767 test::CompareCharArraysWithHexError( | 6384 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
4768 "constructed packet", data->data(), data->length(), | 6385 data->length(), AsChars(packets[index]), |
4769 AsChars( | 6386 arraysize(packet)); |
4770 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4771 ? packet_cid_be | |
4772 : packet), | |
4773 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
4774 ? arraysize(packet_cid_be) | |
4775 : arraysize(packet)); | |
4776 } | 6387 } |
4777 | 6388 |
4778 TEST_P(QuicFramerTest, BuildPublicResetPacketOld) { | 6389 TEST_P(QuicFramerTest, BuildPublicResetPacketOld) { |
4779 FLAGS_quic_reloadable_flag_quic_use_old_public_reset_packets = true; | 6390 FLAGS_quic_reloadable_flag_quic_use_old_public_reset_packets = true; |
4780 QuicPublicResetPacket reset_packet; | 6391 QuicPublicResetPacket reset_packet; |
4781 reset_packet.public_header.connection_id = kConnectionId; | 6392 reset_packet.public_header.connection_id = kConnectionId; |
4782 reset_packet.public_header.reset_flag = true; | 6393 reset_packet.public_header.reset_flag = true; |
4783 reset_packet.public_header.version_flag = false; | 6394 reset_packet.public_header.version_flag = false; |
4784 reset_packet.nonce_proof = kNonceProof; | 6395 reset_packet.nonce_proof = kNonceProof; |
4785 | 6396 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5009 // packet number | 6620 // packet number |
5010 0xBC, 0x9A, 0x78, 0x56, | 6621 0xBC, 0x9A, 0x78, 0x56, |
5011 0x34, 0x12, | 6622 0x34, 0x12, |
5012 | 6623 |
5013 // redundancy | 6624 // redundancy |
5014 'a', 'b', 'c', 'd', | 6625 'a', 'b', 'c', 'd', |
5015 'e', 'f', 'g', 'h', | 6626 'e', 'f', 'g', 'h', |
5016 'i', 'j', 'k', 'l', | 6627 'i', 'j', 'k', 'l', |
5017 'm', 'n', 'o', 'p', | 6628 'm', 'n', 'o', 'p', |
5018 }; | 6629 }; |
| 6630 |
| 6631 unsigned char packet39[] = { |
| 6632 // public flags (8 byte connection_id) |
| 6633 0x38, |
| 6634 // connection_id |
| 6635 0x10, 0x32, 0x54, 0x76, |
| 6636 0x98, 0xBA, 0xDC, 0xFE, |
| 6637 // packet number |
| 6638 0x12, 0x34, 0x56, 0x78, |
| 6639 0x9A, 0xBC, |
| 6640 |
| 6641 // redundancy |
| 6642 'a', 'b', 'c', 'd', |
| 6643 'e', 'f', 'g', 'h', |
| 6644 'i', 'j', 'k', 'l', |
| 6645 'm', 'n', 'o', 'p', |
| 6646 }; |
| 6647 |
| 6648 unsigned char packet_cid_be39[] = { |
| 6649 // public flags (8 byte connection_id) |
| 6650 0x38, |
| 6651 // connection_id |
| 6652 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 6653 // packet number |
| 6654 0x12, 0x34, 0x56, 0x78, |
| 6655 0x9A, 0xBC, |
| 6656 |
| 6657 // redundancy |
| 6658 'a', 'b', 'c', 'd', |
| 6659 'e', 'f', 'g', 'h', |
| 6660 'i', 'j', 'k', 'l', |
| 6661 'm', 'n', 'o', 'p', |
| 6662 }; |
5019 // clang-format on | 6663 // clang-format on |
| 6664 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 6665 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
5020 | 6666 |
5021 std::unique_ptr<QuicPacket> raw(new QuicPacket( | 6667 std::unique_ptr<QuicPacket> raw(new QuicPacket( |
5022 AsChars( | 6668 AsChars(packets[index]), arraysize(packet), false, |
5023 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 6669 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
5024 ? packet_cid_be | |
5025 : packet), | |
5026 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
5027 ? arraysize(packet_cid_be) | |
5028 : arraysize(packet), | |
5029 false, PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, | |
5030 !kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER)); | 6670 !kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER)); |
5031 char buffer[kMaxPacketSize]; | 6671 char buffer[kMaxPacketSize]; |
5032 size_t encrypted_length = framer_.EncryptPayload( | 6672 size_t encrypted_length = framer_.EncryptPayload( |
5033 ENCRYPTION_NONE, packet_number, *raw, buffer, kMaxPacketSize); | 6673 ENCRYPTION_NONE, packet_number, *raw, buffer, kMaxPacketSize); |
5034 | 6674 |
5035 ASSERT_NE(0u, encrypted_length); | 6675 ASSERT_NE(0u, encrypted_length); |
5036 EXPECT_TRUE(CheckEncryption(packet_number, raw.get())); | 6676 EXPECT_TRUE(CheckEncryption(packet_number, raw.get())); |
5037 } | 6677 } |
5038 | 6678 |
5039 TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) { | 6679 TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) { |
(...skipping 28 matching lines...) Expand all Loading... |
5068 // packet number | 6708 // packet number |
5069 0xBC, 0x9A, 0x78, 0x56, | 6709 0xBC, 0x9A, 0x78, 0x56, |
5070 0x34, 0x12, | 6710 0x34, 0x12, |
5071 | 6711 |
5072 // redundancy | 6712 // redundancy |
5073 'a', 'b', 'c', 'd', | 6713 'a', 'b', 'c', 'd', |
5074 'e', 'f', 'g', 'h', | 6714 'e', 'f', 'g', 'h', |
5075 'i', 'j', 'k', 'l', | 6715 'i', 'j', 'k', 'l', |
5076 'm', 'n', 'o', 'p', | 6716 'm', 'n', 'o', 'p', |
5077 }; | 6717 }; |
| 6718 |
| 6719 unsigned char packet39[] = { |
| 6720 // public flags (version, 8 byte connection_id) |
| 6721 0x39, |
| 6722 // connection_id |
| 6723 0x10, 0x32, 0x54, 0x76, |
| 6724 0x98, 0xBA, 0xDC, 0xFE, |
| 6725 // version tag |
| 6726 'Q', '.', '1', '0', |
| 6727 // packet number |
| 6728 0x12, 0x34, 0x56, 0x78, |
| 6729 0x9A, 0xBC, |
| 6730 |
| 6731 // redundancy |
| 6732 'a', 'b', 'c', 'd', |
| 6733 'e', 'f', 'g', 'h', |
| 6734 'i', 'j', 'k', 'l', |
| 6735 'm', 'n', 'o', 'p', |
| 6736 }; |
| 6737 |
| 6738 unsigned char packet_cid_be39[] = { |
| 6739 // public flags (version, 8 byte connection_id) |
| 6740 0x39, |
| 6741 // connection_id |
| 6742 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 6743 // version tag |
| 6744 'Q', '.', '1', '0', |
| 6745 // packet number |
| 6746 0x12, 0x34, 0x56, 0x78, |
| 6747 0x9A, 0xBC, |
| 6748 |
| 6749 // redundancy |
| 6750 'a', 'b', 'c', 'd', |
| 6751 'e', 'f', 'g', 'h', |
| 6752 'i', 'j', 'k', 'l', |
| 6753 'm', 'n', 'o', 'p', |
| 6754 }; |
5078 // clang-format on | 6755 // clang-format on |
5079 | 6756 |
| 6757 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 6758 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 6759 |
5080 std::unique_ptr<QuicPacket> raw(new QuicPacket( | 6760 std::unique_ptr<QuicPacket> raw(new QuicPacket( |
5081 AsChars( | 6761 AsChars(packets[index]), arraysize(packet), false, |
5082 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 6762 PACKET_8BYTE_CONNECTION_ID, kIncludeVersion, |
5083 ? packet_cid_be | |
5084 : packet), | |
5085 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
5086 ? arraysize(packet_cid_be) | |
5087 : arraysize(packet), | |
5088 false, PACKET_8BYTE_CONNECTION_ID, kIncludeVersion, | |
5089 !kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER)); | 6763 !kIncludeDiversificationNonce, PACKET_6BYTE_PACKET_NUMBER)); |
5090 char buffer[kMaxPacketSize]; | 6764 char buffer[kMaxPacketSize]; |
5091 size_t encrypted_length = framer_.EncryptPayload( | 6765 size_t encrypted_length = framer_.EncryptPayload( |
5092 ENCRYPTION_NONE, packet_number, *raw, buffer, kMaxPacketSize); | 6766 ENCRYPTION_NONE, packet_number, *raw, buffer, kMaxPacketSize); |
5093 | 6767 |
5094 ASSERT_NE(0u, encrypted_length); | 6768 ASSERT_NE(0u, encrypted_length); |
5095 EXPECT_TRUE(CheckEncryption(packet_number, raw.get())); | 6769 EXPECT_TRUE(CheckEncryption(packet_number, raw.get())); |
5096 } | 6770 } |
5097 | 6771 |
5098 TEST_P(QuicFramerTest, AckTruncationLargePacket) { | 6772 TEST_P(QuicFramerTest, AckTruncationLargePacket) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5268 0x34, 0x12, | 6942 0x34, 0x12, |
5269 // largest observed packet number | 6943 // largest observed packet number |
5270 0xBF, 0x9A, 0x78, 0x56, | 6944 0xBF, 0x9A, 0x78, 0x56, |
5271 0x34, 0x12, | 6945 0x34, 0x12, |
5272 // num missing packets | 6946 // num missing packets |
5273 0x01, | 6947 0x01, |
5274 // missing packet | 6948 // missing packet |
5275 0xBE, 0x9A, 0x78, 0x56, | 6949 0xBE, 0x9A, 0x78, 0x56, |
5276 0x34, 0x12, | 6950 0x34, 0x12, |
5277 }; | 6951 }; |
| 6952 |
| 6953 unsigned char packet39[] = { |
| 6954 // public flags (8 byte connection_id) |
| 6955 0x38, |
| 6956 // connection_id |
| 6957 0x10, 0x32, 0x54, 0x76, |
| 6958 0x98, 0xBA, 0xDC, 0xFE, |
| 6959 // packet number |
| 6960 0x12, 0x34, 0x56, 0x78, |
| 6961 0x9A, 0xBC, |
| 6962 |
| 6963 // frame type (stream frame with fin) |
| 6964 0xFF, |
| 6965 // stream id |
| 6966 0x01, 0x02, 0x03, 0x04, |
| 6967 // offset |
| 6968 0xBA, 0x98, 0xFE, 0xDC, |
| 6969 0x32, 0x10, 0x76, 0x54, |
| 6970 // data length |
| 6971 0x00, 0x0c, |
| 6972 // data |
| 6973 'h', 'e', 'l', 'l', |
| 6974 'o', ' ', 'w', 'o', |
| 6975 'r', 'l', 'd', '!', |
| 6976 |
| 6977 // frame type (ack frame) |
| 6978 0x40, |
| 6979 // least packet number awaiting an ack |
| 6980 0x12, 0x34, 0x56, 0x78, |
| 6981 0x9A, 0xA0, |
| 6982 // largest observed packet number |
| 6983 0x12, 0x34, 0x56, 0x78, |
| 6984 0x9A, 0xBF, |
| 6985 // num missing packets |
| 6986 0x01, |
| 6987 // missing packet |
| 6988 0x12, 0x34, 0x56, 0x78, |
| 6989 0x9A, 0xBE, |
| 6990 }; |
| 6991 |
| 6992 unsigned char packet_cid_be39[] = { |
| 6993 // public flags (8 byte connection_id) |
| 6994 0x38, |
| 6995 // connection_id |
| 6996 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 6997 // packet number |
| 6998 0x12, 0x34, 0x56, 0x78, |
| 6999 0x9A, 0xBC, |
| 7000 |
| 7001 // frame type (stream frame with fin) |
| 7002 0xFF, |
| 7003 // stream id |
| 7004 0x01, 0x02, 0x03, 0x04, |
| 7005 // offset |
| 7006 0xBA, 0x98, 0xFE, 0xDC, |
| 7007 0x32, 0x10, 0x76, 0x54, |
| 7008 // data length |
| 7009 0x00, 0x0c, |
| 7010 // data |
| 7011 'h', 'e', 'l', 'l', |
| 7012 'o', ' ', 'w', 'o', |
| 7013 'r', 'l', 'd', '!', |
| 7014 |
| 7015 // frame type (ack frame) |
| 7016 0x40, |
| 7017 // least packet number awaiting an ack |
| 7018 0x12, 0x34, 0x56, 0x78, |
| 7019 0x9A, 0xA0, |
| 7020 // largest observed packet number |
| 7021 0x12, 0x34, 0x56, 0x78, |
| 7022 0x9A, 0xBF, |
| 7023 // num missing packets |
| 7024 0x01, |
| 7025 // missing packet |
| 7026 0x12, 0x34, 0x56, 0x78, |
| 7027 0x9A, 0xBE, |
| 7028 }; |
5278 // clang-format on | 7029 // clang-format on |
5279 | 7030 |
| 7031 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
| 7032 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
| 7033 |
5280 MockFramerVisitor visitor; | 7034 MockFramerVisitor visitor; |
5281 framer_.set_visitor(&visitor); | 7035 framer_.set_visitor(&visitor); |
5282 EXPECT_CALL(visitor, OnPacket()); | 7036 EXPECT_CALL(visitor, OnPacket()); |
5283 EXPECT_CALL(visitor, OnPacketHeader(_)); | 7037 EXPECT_CALL(visitor, OnPacketHeader(_)); |
5284 EXPECT_CALL(visitor, OnStreamFrame(_)).WillOnce(Return(false)); | 7038 EXPECT_CALL(visitor, OnStreamFrame(_)).WillOnce(Return(false)); |
5285 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0); | 7039 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0); |
5286 EXPECT_CALL(visitor, OnPacketComplete()); | 7040 EXPECT_CALL(visitor, OnPacketComplete()); |
5287 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); | 7041 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); |
5288 EXPECT_CALL(visitor, OnUnauthenticatedHeader(_)).WillOnce(Return(true)); | 7042 EXPECT_CALL(visitor, OnUnauthenticatedHeader(_)).WillOnce(Return(true)); |
5289 EXPECT_CALL(visitor, OnDecryptedPacket(_)); | 7043 EXPECT_CALL(visitor, OnDecryptedPacket(_)); |
5290 | 7044 |
5291 QuicEncryptedPacket encrypted( | 7045 QuicEncryptedPacket encrypted(AsChars(packets[index]), arraysize(packet), |
5292 AsChars( | 7046 false); |
5293 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
5294 ? packet_cid_be | |
5295 : packet), | |
5296 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
5297 ? arraysize(packet_cid_be) | |
5298 : arraysize(packet), | |
5299 false); | |
5300 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 7047 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
5301 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 7048 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
5302 } | 7049 } |
5303 | 7050 |
5304 static char kTestString[] = "At least 20 characters."; | 7051 static char kTestString[] = "At least 20 characters."; |
5305 static QuicStreamId kTestQuicStreamId = 1; | 7052 static QuicStreamId kTestQuicStreamId = 1; |
5306 static bool ExpectedStreamFrame(const QuicStreamFrame& frame) { | 7053 static bool ExpectedStreamFrame(const QuicStreamFrame& frame) { |
5307 return frame.stream_id == kTestQuicStreamId && !frame.fin && | 7054 return frame.stream_id == kTestQuicStreamId && !frame.fin && |
5308 frame.offset == 0 && | 7055 frame.offset == 0 && |
5309 string(frame.data_buffer, frame.data_length) == kTestString; | 7056 string(frame.data_buffer, frame.data_length) == kTestString; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5458 // offset | 7205 // offset |
5459 0x54, 0x76, 0x10, 0x32, | 7206 0x54, 0x76, 0x10, 0x32, |
5460 0xDC, 0xFE, 0x98, 0xBA, | 7207 0xDC, 0xFE, 0x98, 0xBA, |
5461 // data length | 7208 // data length |
5462 0x0c, 0x00, | 7209 0x0c, 0x00, |
5463 // data | 7210 // data |
5464 'h', 'e', 'l', 'l', | 7211 'h', 'e', 'l', 'l', |
5465 'o', ' ', 'w', 'o', | 7212 'o', ' ', 'w', 'o', |
5466 'r', 'l', 'd', '!', | 7213 'r', 'l', 'd', '!', |
5467 }; | 7214 }; |
| 7215 |
| 7216 unsigned char packet39[] = { |
| 7217 // public flags (8 byte connection_id) |
| 7218 0x3C, |
| 7219 // connection_id |
| 7220 0x10, 0x32, 0x54, 0x76, |
| 7221 0x98, 0xBA, 0xDC, 0xFE, |
| 7222 // packet number |
| 7223 0x12, 0x34, 0x56, 0x78, |
| 7224 0x9A, 0xBC, |
| 7225 // private flags |
| 7226 0x00, |
| 7227 |
| 7228 // frame type (stream frame with fin) |
| 7229 0xFF, |
| 7230 // stream id |
| 7231 0x01, 0x02, 0x03, 0x04, |
| 7232 // offset |
| 7233 0xBA, 0x98, 0xFE, 0xDC, |
| 7234 0x32, 0x10, 0x76, 0x54, |
| 7235 // data length |
| 7236 0x00, 0x0c, |
| 7237 // data |
| 7238 'h', 'e', 'l', 'l', |
| 7239 'o', ' ', 'w', 'o', |
| 7240 'r', 'l', 'd', '!', |
| 7241 }; |
| 7242 |
| 7243 unsigned char packet_cid_be39[] = { |
| 7244 // public flags (8 byte connection_id) |
| 7245 0x3C, |
| 7246 // connection_id |
| 7247 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, |
| 7248 // packet number |
| 7249 0x12, 0x34, 0x56, 0x78, |
| 7250 0x9A, 0xBC, |
| 7251 // private flags |
| 7252 0x00, |
| 7253 |
| 7254 // frame type (stream frame with fin) |
| 7255 0xFF, |
| 7256 // stream id |
| 7257 0x01, 0x02, 0x03, 0x04, |
| 7258 // offset |
| 7259 0xBA, 0x98, 0xFE, 0xDC, |
| 7260 0x32, 0x10, 0x76, 0x54, |
| 7261 // data length |
| 7262 0x00, 0x0c, |
| 7263 // data |
| 7264 'h', 'e', 'l', 'l', |
| 7265 'o', ' ', 'w', 'o', |
| 7266 'r', 'l', 'd', '!', |
| 7267 }; |
5468 // clang-format on | 7268 // clang-format on |
5469 | 7269 |
5470 QuicFramerFuzzFunc( | 7270 unsigned char* packets[] = {packet, packet_cid_be, packet39, packet_cid_be39}; |
5471 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | 7271 size_t index = GetPacketIndex(framer_.version(), framer_.perspective()); |
5472 ? packet_cid_be | 7272 |
5473 : packet, | 7273 QuicFramerFuzzFunc(packets[index], arraysize(packet)); |
5474 QuicUtils::IsConnectionIdWireFormatBigEndian(framer_.perspective()) | |
5475 ? arraysize(packet_cid_be) | |
5476 : arraysize(packet)); | |
5477 } | 7274 } |
5478 | 7275 |
| 7276 } // namespace |
5479 } // namespace test | 7277 } // namespace test |
5480 } // namespace net | 7278 } // namespace net |
OLD | NEW |