| 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/quic_framer.h" | 5 #include "net/quic/quic_framer.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 3092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3103 StringPiece("hello world!")); | 3103 StringPiece("hello world!")); |
| 3104 | 3104 |
| 3105 QuicFrames frames; | 3105 QuicFrames frames; |
| 3106 frames.push_back(QuicFrame(&stream_frame)); | 3106 frames.push_back(QuicFrame(&stream_frame)); |
| 3107 | 3107 |
| 3108 // clang-format off | 3108 // clang-format off |
| 3109 unsigned char packet[] = { | 3109 unsigned char packet[] = { |
| 3110 // public flags (version, 8 byte connection_id) | 3110 // public flags (version, 8 byte connection_id) |
| 3111 0x3D, | 3111 0x3D, |
| 3112 // connection_id | 3112 // connection_id |
| 3113 0x10, | 3113 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 3114 0x32, | |
| 3115 0x54, | |
| 3116 0x76, | |
| 3117 0x98, | |
| 3118 0xBA, | |
| 3119 0xDC, | |
| 3120 0xFE, | |
| 3121 // version tag | 3114 // version tag |
| 3122 'Q', | 3115 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
| 3123 '0', | |
| 3124 GetQuicVersionDigitTens(), | |
| 3125 GetQuicVersionDigitOnes(), | |
| 3126 // packet number | 3116 // packet number |
| 3127 0xBC, | 3117 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
| 3128 0x9A, | |
| 3129 0x78, | |
| 3130 0x56, | |
| 3131 0x34, | |
| 3132 0x12, | |
| 3133 // private flags (entropy) | 3118 // private flags (entropy) |
| 3134 0x01, | 3119 0x01, |
| 3135 | 3120 |
| 3136 // frame type (stream frame with fin and no length) | 3121 // frame type (stream frame with fin and no length) |
| 3137 0xDF, | 3122 0xDF, |
| 3138 // stream id | 3123 // stream id |
| 3139 0x04, | 3124 0x04, 0x03, 0x02, 0x01, |
| 3140 0x03, | |
| 3141 0x02, | |
| 3142 0x01, | |
| 3143 // offset | 3125 // offset |
| 3144 0x54, | 3126 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA, |
| 3145 0x76, | |
| 3146 0x10, | |
| 3147 0x32, | |
| 3148 0xDC, | |
| 3149 0xFE, | |
| 3150 0x98, | |
| 3151 0xBA, | |
| 3152 // data | 3127 // data |
| 3153 'h', | 3128 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', |
| 3154 'e', | |
| 3155 'l', | |
| 3156 'l', | |
| 3157 'o', | |
| 3158 ' ', | |
| 3159 'w', | |
| 3160 'o', | |
| 3161 'r', | |
| 3162 'l', | |
| 3163 'd', | |
| 3164 '!', | |
| 3165 }; | 3129 }; |
| 3166 // clang-format on | 3130 // clang-format on |
| 3167 | 3131 |
| 3168 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); | 3132 QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); |
| 3169 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); | 3133 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); |
| 3170 ASSERT_TRUE(data != nullptr); | 3134 ASSERT_TRUE(data != nullptr); |
| 3171 | 3135 |
| 3172 test::CompareCharArraysWithHexError("constructed packet", data->data(), | 3136 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
| 3173 data->length(), AsChars(packet), | 3137 data->length(), AsChars(packet), |
| 3174 arraysize(packet)); | 3138 arraysize(packet)); |
| 3175 } | 3139 } |
| 3176 | 3140 |
| 3177 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { | 3141 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { |
| 3178 // clang-format off | 3142 // clang-format off |
| 3179 unsigned char packet[] = { | 3143 unsigned char packet[] = { |
| 3180 // public flags (version, 8 byte connection_id) | 3144 // public flags (version, 8 byte connection_id) |
| 3181 0x0D, | 3145 0x0D, |
| 3182 // connection_id | 3146 // connection_id |
| 3183 0x10, | 3147 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE, |
| 3184 0x32, | |
| 3185 0x54, | |
| 3186 0x76, | |
| 3187 0x98, | |
| 3188 0xBA, | |
| 3189 0xDC, | |
| 3190 0xFE, | |
| 3191 // version tag | 3148 // version tag |
| 3192 'Q', | 3149 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
| 3193 '0', | |
| 3194 GetQuicVersionDigitTens(), | |
| 3195 GetQuicVersionDigitOnes(), | |
| 3196 }; | 3150 }; |
| 3197 // clang-format on | 3151 // clang-format on |
| 3198 | 3152 |
| 3199 QuicConnectionId connection_id = kConnectionId; | 3153 QuicConnectionId connection_id = kConnectionId; |
| 3200 scoped_ptr<QuicEncryptedPacket> data(framer_.BuildVersionNegotiationPacket( | 3154 scoped_ptr<QuicEncryptedPacket> data(framer_.BuildVersionNegotiationPacket( |
| 3201 connection_id, SupportedVersions(GetParam()))); | 3155 connection_id, SupportedVersions(GetParam()))); |
| 3202 test::CompareCharArraysWithHexError("constructed packet", data->data(), | 3156 test::CompareCharArraysWithHexError("constructed packet", data->data(), |
| 3203 data->length(), AsChars(packet), | 3157 data->length(), AsChars(packet), |
| 3204 arraysize(packet)); | 3158 arraysize(packet)); |
| 3205 } | 3159 } |
| (...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4373 EXPECT_CALL(visitor, OnStreamFrame(_)).Times(0); | 4327 EXPECT_CALL(visitor, OnStreamFrame(_)).Times(0); |
| 4374 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0); | 4328 EXPECT_CALL(visitor, OnAckFrame(_)).Times(0); |
| 4375 EXPECT_CALL(visitor, OnPacketComplete()).Times(0); | 4329 EXPECT_CALL(visitor, OnPacketComplete()).Times(0); |
| 4376 | 4330 |
| 4377 EXPECT_FALSE(framer_.ProcessPacket(*packet)); | 4331 EXPECT_FALSE(framer_.ProcessPacket(*packet)); |
| 4378 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error()); | 4332 EXPECT_EQ(QUIC_INVALID_PACKET_HEADER, framer_.error()); |
| 4379 } | 4333 } |
| 4380 | 4334 |
| 4381 } // namespace test | 4335 } // namespace test |
| 4382 } // namespace net | 4336 } // namespace net |
| OLD | NEW |