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 <algorithm> | 5 #include <algorithm> |
6 #include <map> | 6 #include <map> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 framer_(QuicVersionMax(), start_, true) { | 312 framer_(QuicVersionMax(), start_, true) { |
313 framer_.SetDecrypter(decrypter_); | 313 framer_.SetDecrypter(decrypter_); |
314 framer_.SetEncrypter(ENCRYPTION_NONE, encrypter_); | 314 framer_.SetEncrypter(ENCRYPTION_NONE, encrypter_); |
315 framer_.set_visitor(&visitor_); | 315 framer_.set_visitor(&visitor_); |
316 framer_.set_received_entropy_calculator(&entropy_calculator_); | 316 framer_.set_received_entropy_calculator(&entropy_calculator_); |
317 | 317 |
318 version_ = GetParam(); | 318 version_ = GetParam(); |
319 framer_.set_version(version_); | 319 framer_.set_version(version_); |
320 } | 320 } |
321 | 321 |
| 322 // Helper function to get unsigned char representation of digit in the |
| 323 // units place of the current QUIC version number. |
| 324 unsigned char GetQuicVersionDigitOnes() { |
| 325 return static_cast<unsigned char> ('0' + version_%10); |
| 326 } |
| 327 |
| 328 // Helper function to get unsigned char representation of digit in the |
| 329 // tens place of the current QUIC version number. |
| 330 unsigned char GetQuicVersionDigitTens() { |
| 331 return static_cast<unsigned char> ('0' + (version_/10)%10); |
| 332 } |
| 333 |
322 bool CheckEncryption(QuicPacketSequenceNumber sequence_number, | 334 bool CheckEncryption(QuicPacketSequenceNumber sequence_number, |
323 QuicPacket* packet) { | 335 QuicPacket* packet) { |
324 if (sequence_number != encrypter_->sequence_number_) { | 336 if (sequence_number != encrypter_->sequence_number_) { |
325 LOG(ERROR) << "Encrypted incorrect packet sequence number. expected " | 337 LOG(ERROR) << "Encrypted incorrect packet sequence number. expected " |
326 << sequence_number << " actual: " | 338 << sequence_number << " actual: " |
327 << encrypter_->sequence_number_; | 339 << encrypter_->sequence_number_; |
328 return false; | 340 return false; |
329 } | 341 } |
330 if (packet->AssociatedData() != encrypter_->associated_data_) { | 342 if (packet->AssociatedData() != encrypter_->associated_data_) { |
331 LOG(ERROR) << "Encrypted incorrect associated data. expected " | 343 LOG(ERROR) << "Encrypted incorrect associated data. expected " |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 QuicPacketSequenceNumber wire_sequence_number = | 430 QuicPacketSequenceNumber wire_sequence_number = |
419 expected_sequence_number & kMask; | 431 expected_sequence_number & kMask; |
420 QuicFramerPeer::SetLastSequenceNumber(&framer_, last_sequence_number); | 432 QuicFramerPeer::SetLastSequenceNumber(&framer_, last_sequence_number); |
421 EXPECT_EQ(expected_sequence_number, | 433 EXPECT_EQ(expected_sequence_number, |
422 QuicFramerPeer::CalculatePacketSequenceNumberFromWire( | 434 QuicFramerPeer::CalculatePacketSequenceNumberFromWire( |
423 &framer_, PACKET_6BYTE_SEQUENCE_NUMBER, wire_sequence_number)) | 435 &framer_, PACKET_6BYTE_SEQUENCE_NUMBER, wire_sequence_number)) |
424 << "last_sequence_number: " << last_sequence_number | 436 << "last_sequence_number: " << last_sequence_number |
425 << " wire_sequence_number: " << wire_sequence_number; | 437 << " wire_sequence_number: " << wire_sequence_number; |
426 } | 438 } |
427 | 439 |
428 char LastCharOfVersion() { | |
429 switch (GetParam()) { | |
430 case QUIC_VERSION_7: | |
431 return '7'; | |
432 case QUIC_VERSION_8: | |
433 return '8'; | |
434 case QUIC_VERSION_9: | |
435 return '9'; | |
436 default: | |
437 CHECK(0) << "Invalid version"; | |
438 return 0; | |
439 } | |
440 } | |
441 | |
442 test::TestEncrypter* encrypter_; | 440 test::TestEncrypter* encrypter_; |
443 test::TestDecrypter* decrypter_; | 441 test::TestDecrypter* decrypter_; |
444 QuicVersion version_; | 442 QuicVersion version_; |
445 QuicTime start_; | 443 QuicTime start_; |
446 QuicFramer framer_; | 444 QuicFramer framer_; |
447 test::TestQuicVisitor visitor_; | 445 test::TestQuicVisitor visitor_; |
448 test::TestEntropyCalculator entropy_calculator_; | 446 test::TestEntropyCalculator entropy_calculator_; |
449 }; | 447 }; |
450 | 448 |
451 // Run all framer tests with all supported versions of QUIC. | 449 // Run all framer tests with all supported versions of QUIC. |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 } | 805 } |
808 | 806 |
809 TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { | 807 TEST_P(QuicFramerTest, PacketHeaderWithVersionFlag) { |
810 unsigned char packet[] = { | 808 unsigned char packet[] = { |
811 // public flags (version) | 809 // public flags (version) |
812 0x3D, | 810 0x3D, |
813 // guid | 811 // guid |
814 0x10, 0x32, 0x54, 0x76, | 812 0x10, 0x32, 0x54, 0x76, |
815 0x98, 0xBA, 0xDC, 0xFE, | 813 0x98, 0xBA, 0xDC, 0xFE, |
816 // version tag | 814 // version tag |
817 'Q', '0', '0', LastCharOfVersion(), | 815 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
818 // packet sequence number | 816 // packet sequence number |
819 0xBC, 0x9A, 0x78, 0x56, | 817 0xBC, 0x9A, 0x78, 0x56, |
820 0x34, 0x12, | 818 0x34, 0x12, |
821 // private flags | 819 // private flags |
822 0x00, | 820 0x00, |
823 }; | 821 }; |
824 | 822 |
825 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 823 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
826 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); | 824 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
827 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); | 825 EXPECT_EQ(QUIC_MISSING_PAYLOAD, framer_.error()); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 0x40, | 1031 0x40, |
1034 // guid | 1032 // guid |
1035 0x10, 0x32, 0x54, 0x76, | 1033 0x10, 0x32, 0x54, 0x76, |
1036 0x98, 0xBA, 0xDC, 0xFE, | 1034 0x98, 0xBA, 0xDC, 0xFE, |
1037 // packet sequence number | 1035 // packet sequence number |
1038 0xBC, 0x9A, 0x78, 0x56, | 1036 0xBC, 0x9A, 0x78, 0x56, |
1039 0x34, 0x12, | 1037 0x34, 0x12, |
1040 // private flags | 1038 // private flags |
1041 0x00, | 1039 0x00, |
1042 | 1040 |
1043 // frame count | 1041 // frame type (padding) |
1044 0x01, | 1042 static_cast<unsigned char>( |
1045 // frame type (stream frame) | 1043 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
1046 0x01, | 1044 0x00, 0x00, 0x00, 0x00 |
1047 // stream id | |
1048 0x04, 0x03, 0x02, 0x01, | |
1049 // fin | |
1050 0x01, | |
1051 // offset | |
1052 0x54, 0x76, 0x10, 0x32, | |
1053 0xDC, 0xFE, 0x98, 0xBA, | |
1054 // data length | |
1055 0x0c, 0x00, | |
1056 // data | |
1057 'h', 'e', 'l', 'l', | |
1058 'o', ' ', 'w', 'o', | |
1059 'r', 'l', 'd', '!', | |
1060 }; | 1045 }; |
1061 CheckProcessingFails(packet, | 1046 CheckProcessingFails(packet, |
1062 arraysize(packet), | 1047 arraysize(packet), |
1063 "Illegal public flags value.", | 1048 "Illegal public flags value.", |
1064 QUIC_INVALID_PACKET_HEADER); | 1049 QUIC_INVALID_PACKET_HEADER); |
1065 }; | 1050 }; |
1066 | 1051 |
1067 TEST_P(QuicFramerTest, InvalidPublicFlagWithMatchingVersions) { | 1052 TEST_P(QuicFramerTest, InvalidPublicFlagWithMatchingVersions) { |
1068 unsigned char packet[] = { | 1053 unsigned char packet[] = { |
1069 // public flags (8 byte guid and version flag and an unknown flag) | 1054 // public flags (8 byte guid and version flag and an unknown flag) |
1070 0x4D, | 1055 0x4D, |
1071 // guid | 1056 // guid |
1072 0x10, 0x32, 0x54, 0x76, | 1057 0x10, 0x32, 0x54, 0x76, |
1073 0x98, 0xBA, 0xDC, 0xFE, | 1058 0x98, 0xBA, 0xDC, 0xFE, |
1074 // version tag | 1059 // version tag |
1075 'Q', '0', '0', LastCharOfVersion(), | 1060 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
1076 // packet sequence number | 1061 // packet sequence number |
1077 0xBC, 0x9A, 0x78, 0x56, | 1062 0xBC, 0x9A, 0x78, 0x56, |
1078 0x34, 0x12, | 1063 0x34, 0x12, |
1079 // private flags | 1064 // private flags |
1080 0x00, | 1065 0x00, |
1081 | 1066 |
1082 // frame count | 1067 // frame type (padding) |
1083 0x01, | 1068 static_cast<unsigned char>( |
1084 // frame type (stream frame) | 1069 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
1085 0x01, | 1070 0x00, 0x00, 0x00, 0x00 |
1086 // stream id | |
1087 0x04, 0x03, 0x02, 0x01, | |
1088 // fin | |
1089 0x01, | |
1090 // offset | |
1091 0x54, 0x76, 0x10, 0x32, | |
1092 0xDC, 0xFE, 0x98, 0xBA, | |
1093 // data length | |
1094 0x0c, 0x00, | |
1095 // data | |
1096 'h', 'e', 'l', 'l', | |
1097 'o', ' ', 'w', 'o', | |
1098 'r', 'l', 'd', '!', | |
1099 }; | 1071 }; |
1100 CheckProcessingFails(packet, | 1072 CheckProcessingFails(packet, |
1101 arraysize(packet), | 1073 arraysize(packet), |
1102 "Illegal public flags value.", | 1074 "Illegal public flags value.", |
1103 QUIC_INVALID_PACKET_HEADER); | 1075 QUIC_INVALID_PACKET_HEADER); |
1104 }; | 1076 }; |
1105 | 1077 |
1106 TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) { | 1078 TEST_P(QuicFramerTest, LargePublicFlagWithMismatchedVersions) { |
1107 unsigned char packet[] = { | 1079 unsigned char packet[] = { |
1108 // public flags (8 byte guid, version flag and an unknown flag) | 1080 // public flags (8 byte guid, version flag and an unknown flag) |
1109 0x7D, | 1081 0x7D, |
1110 // guid | 1082 // guid |
1111 0x10, 0x32, 0x54, 0x76, | 1083 0x10, 0x32, 0x54, 0x76, |
1112 0x98, 0xBA, 0xDC, 0xFE, | 1084 0x98, 0xBA, 0xDC, 0xFE, |
1113 // version tag | 1085 // version tag |
1114 'Q', '0', '0', '0', | 1086 'Q', '0', '0', '0', |
1115 // packet sequence number | 1087 // packet sequence number |
1116 0xBC, 0x9A, 0x78, 0x56, | 1088 0xBC, 0x9A, 0x78, 0x56, |
1117 0x34, 0x12, | 1089 0x34, 0x12, |
1118 // private flags | 1090 // private flags |
1119 0x00, | 1091 0x00, |
1120 | 1092 |
1121 // frame type (padding frame) | 1093 // frame type (padding frame) |
1122 0x07, | 1094 static_cast<unsigned char>( |
| 1095 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
| 1096 0x00, 0x00, 0x00, 0x00 |
1123 }; | 1097 }; |
1124 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1098 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1125 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1099 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1126 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1100 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1127 ASSERT_TRUE(visitor_.header_.get()); | 1101 ASSERT_TRUE(visitor_.header_.get()); |
1128 EXPECT_EQ(0, visitor_.frame_count_); | 1102 EXPECT_EQ(0, visitor_.frame_count_); |
1129 EXPECT_EQ(1, visitor_.version_mismatch_); | 1103 EXPECT_EQ(1, visitor_.version_mismatch_); |
1130 }; | 1104 }; |
1131 | 1105 |
1132 TEST_P(QuicFramerTest, InvalidPrivateFlag) { | 1106 TEST_P(QuicFramerTest, InvalidPrivateFlag) { |
1133 unsigned char packet[] = { | 1107 unsigned char packet[] = { |
1134 // public flags (8 byte guid) | 1108 // public flags (8 byte guid) |
1135 0x3C, | 1109 0x3C, |
1136 // guid | 1110 // guid |
1137 0x10, 0x32, 0x54, 0x76, | 1111 0x10, 0x32, 0x54, 0x76, |
1138 0x98, 0xBA, 0xDC, 0xFE, | 1112 0x98, 0xBA, 0xDC, 0xFE, |
1139 // packet sequence number | 1113 // packet sequence number |
1140 0xBC, 0x9A, 0x78, 0x56, | 1114 0xBC, 0x9A, 0x78, 0x56, |
1141 0x34, 0x12, | 1115 0x34, 0x12, |
1142 // private flags | 1116 // private flags |
1143 0x10, | 1117 0x10, |
1144 | 1118 |
1145 // frame count | 1119 // frame type (padding) |
1146 0x01, | 1120 static_cast<unsigned char>( |
1147 // frame type (stream frame) | 1121 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
1148 0x01, | 1122 0x00, 0x00, 0x00, 0x00 |
1149 // stream id | |
1150 0x04, 0x03, 0x02, 0x01, | |
1151 // fin | |
1152 0x01, | |
1153 // offset | |
1154 0x54, 0x76, 0x10, 0x32, | |
1155 0xDC, 0xFE, 0x98, 0xBA, | |
1156 // data length | |
1157 0x0c, 0x00, | |
1158 // data | |
1159 'h', 'e', 'l', 'l', | |
1160 'o', ' ', 'w', 'o', | |
1161 'r', 'l', 'd', '!', | |
1162 }; | 1123 }; |
1163 CheckProcessingFails(packet, | 1124 CheckProcessingFails(packet, |
1164 arraysize(packet), | 1125 arraysize(packet), |
1165 "Illegal private flags value.", | 1126 "Illegal private flags value.", |
1166 QUIC_INVALID_PACKET_HEADER); | 1127 QUIC_INVALID_PACKET_HEADER); |
1167 }; | 1128 }; |
1168 | 1129 |
1169 TEST_P(QuicFramerTest, InvalidFECGroupOffset) { | 1130 TEST_P(QuicFramerTest, InvalidFECGroupOffset) { |
1170 unsigned char packet[] = { | 1131 unsigned char packet[] = { |
1171 // public flags (8 byte guid) | 1132 // public flags (8 byte guid) |
(...skipping 23 matching lines...) Expand all Loading... |
1195 // guid | 1156 // guid |
1196 0x10, 0x32, 0x54, 0x76, | 1157 0x10, 0x32, 0x54, 0x76, |
1197 0x98, 0xBA, 0xDC, 0xFE, | 1158 0x98, 0xBA, 0xDC, 0xFE, |
1198 // packet sequence number | 1159 // packet sequence number |
1199 0xBC, 0x9A, 0x78, 0x56, | 1160 0xBC, 0x9A, 0x78, 0x56, |
1200 0x34, 0x12, | 1161 0x34, 0x12, |
1201 // private flags | 1162 // private flags |
1202 0x00, | 1163 0x00, |
1203 | 1164 |
1204 // frame type (padding frame) | 1165 // frame type (padding frame) |
1205 0x07, | 1166 static_cast<unsigned char>( |
| 1167 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
1206 // Ignored data (which in this case is a stream frame) | 1168 // Ignored data (which in this case is a stream frame) |
1207 0x01, | 1169 // frame type (stream frame with fin) |
| 1170 static_cast<unsigned char>( |
| 1171 GetParam() < QUIC_VERSION_10 ? 0xFE : 0xFF), |
| 1172 // stream id |
1208 0x04, 0x03, 0x02, 0x01, | 1173 0x04, 0x03, 0x02, 0x01, |
1209 0x01, | 1174 // offset |
1210 0x54, 0x76, 0x10, 0x32, | 1175 0x54, 0x76, 0x10, 0x32, |
1211 0xDC, 0xFE, 0x98, 0xBA, | 1176 0xDC, 0xFE, 0x98, 0xBA, |
| 1177 // data length |
1212 0x0c, 0x00, | 1178 0x0c, 0x00, |
| 1179 // data |
1213 'h', 'e', 'l', 'l', | 1180 'h', 'e', 'l', 'l', |
1214 'o', ' ', 'w', 'o', | 1181 'o', ' ', 'w', 'o', |
1215 'r', 'l', 'd', '!', | 1182 'r', 'l', 'd', '!', |
1216 }; | 1183 }; |
1217 | 1184 |
1218 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1185 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1219 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1186 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1220 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1187 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1221 ASSERT_TRUE(visitor_.header_.get()); | 1188 ASSERT_TRUE(visitor_.header_.get()); |
1222 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 1189 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
(...skipping 15 matching lines...) Expand all Loading... |
1238 // guid | 1205 // guid |
1239 0x10, 0x32, 0x54, 0x76, | 1206 0x10, 0x32, 0x54, 0x76, |
1240 0x98, 0xBA, 0xDC, 0xFE, | 1207 0x98, 0xBA, 0xDC, 0xFE, |
1241 // packet sequence number | 1208 // packet sequence number |
1242 0xBC, 0x9A, 0x78, 0x56, | 1209 0xBC, 0x9A, 0x78, 0x56, |
1243 0x34, 0x12, | 1210 0x34, 0x12, |
1244 // private flags | 1211 // private flags |
1245 0x00, | 1212 0x00, |
1246 | 1213 |
1247 // frame type (stream frame with fin) | 1214 // frame type (stream frame with fin) |
1248 0xFE, | 1215 static_cast<unsigned char>( |
| 1216 GetParam() < QUIC_VERSION_10 ? 0xFE : 0xFF), |
1249 // stream id | 1217 // stream id |
1250 0x04, 0x03, 0x02, 0x01, | 1218 0x04, 0x03, 0x02, 0x01, |
1251 // offset | 1219 // offset |
1252 0x54, 0x76, 0x10, 0x32, | 1220 0x54, 0x76, 0x10, 0x32, |
1253 0xDC, 0xFE, 0x98, 0xBA, | 1221 0xDC, 0xFE, 0x98, 0xBA, |
1254 // data length | 1222 // data length |
1255 0x0c, 0x00, | 1223 0x0c, 0x00, |
1256 // data | 1224 // data |
1257 'h', 'e', 'l', 'l', | 1225 'h', 'e', 'l', 'l', |
1258 'o', ' ', 'w', 'o', | 1226 'o', ' ', 'w', 'o', |
(...skipping 27 matching lines...) Expand all Loading... |
1286 // guid | 1254 // guid |
1287 0x10, 0x32, 0x54, 0x76, | 1255 0x10, 0x32, 0x54, 0x76, |
1288 0x98, 0xBA, 0xDC, 0xFE, | 1256 0x98, 0xBA, 0xDC, 0xFE, |
1289 // packet sequence number | 1257 // packet sequence number |
1290 0xBC, 0x9A, 0x78, 0x56, | 1258 0xBC, 0x9A, 0x78, 0x56, |
1291 0x34, 0x12, | 1259 0x34, 0x12, |
1292 // private flags | 1260 // private flags |
1293 0x00, | 1261 0x00, |
1294 | 1262 |
1295 // frame type (stream frame with fin) | 1263 // frame type (stream frame with fin) |
1296 0xFC, | 1264 static_cast<unsigned char>( |
| 1265 GetParam() < QUIC_VERSION_10 ? 0xFC : 0xFE), |
1297 // stream id | 1266 // stream id |
1298 0x04, 0x03, 0x02, | 1267 0x04, 0x03, 0x02, |
1299 // offset | 1268 // offset |
1300 0x54, 0x76, 0x10, 0x32, | 1269 0x54, 0x76, 0x10, 0x32, |
1301 0xDC, 0xFE, 0x98, 0xBA, | 1270 0xDC, 0xFE, 0x98, 0xBA, |
1302 // data length | 1271 // data length |
1303 0x0c, 0x00, | 1272 0x0c, 0x00, |
1304 // data | 1273 // data |
1305 'h', 'e', 'l', 'l', | 1274 'h', 'e', 'l', 'l', |
1306 'o', ' ', 'w', 'o', | 1275 'o', ' ', 'w', 'o', |
1307 'r', 'l', 'd', '!', | 1276 'r', 'l', 'd', '!', |
1308 }; | 1277 }; |
1309 | 1278 |
1310 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1279 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1311 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1280 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1312 | 1281 |
1313 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1282 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1314 ASSERT_TRUE(visitor_.header_.get()); | 1283 ASSERT_TRUE(visitor_.header_.get()); |
1315 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 1284 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
1316 | 1285 |
1317 ASSERT_EQ(1u, visitor_.stream_frames_.size()); | 1286 ASSERT_EQ(1u, visitor_.stream_frames_.size()); |
1318 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 1287 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1319 EXPECT_EQ(static_cast<uint64>(0x00020304), | 1288 EXPECT_EQ(GG_UINT64_C(0x00020304), |
1320 visitor_.stream_frames_[0]->stream_id); | 1289 visitor_.stream_frames_[0]->stream_id); |
1321 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); | 1290 EXPECT_TRUE(visitor_.stream_frames_[0]->fin); |
1322 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654), | 1291 EXPECT_EQ(GG_UINT64_C(0xBA98FEDC32107654), |
1323 visitor_.stream_frames_[0]->offset); | 1292 visitor_.stream_frames_[0]->offset); |
1324 EXPECT_EQ("hello world!", visitor_.stream_frames_[0]->data); | 1293 EXPECT_EQ("hello world!", visitor_.stream_frames_[0]->data); |
1325 | 1294 |
1326 // Now test framing boundaries | 1295 // Now test framing boundaries |
1327 const size_t stream_id_size = 3; | 1296 const size_t stream_id_size = 3; |
1328 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion); | 1297 CheckStreamFrameBoundaries(packet, stream_id_size, !kIncludeVersion); |
1329 } | 1298 } |
1330 | 1299 |
1331 TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { | 1300 TEST_P(QuicFramerTest, StreamFrame2ByteStreamId) { |
1332 unsigned char packet[] = { | 1301 unsigned char packet[] = { |
1333 // public flags (8 byte guid) | 1302 // public flags (8 byte guid) |
1334 0x3C, | 1303 0x3C, |
1335 // guid | 1304 // guid |
1336 0x10, 0x32, 0x54, 0x76, | 1305 0x10, 0x32, 0x54, 0x76, |
1337 0x98, 0xBA, 0xDC, 0xFE, | 1306 0x98, 0xBA, 0xDC, 0xFE, |
1338 // packet sequence number | 1307 // packet sequence number |
1339 0xBC, 0x9A, 0x78, 0x56, | 1308 0xBC, 0x9A, 0x78, 0x56, |
1340 0x34, 0x12, | 1309 0x34, 0x12, |
1341 // private flags | 1310 // private flags |
1342 0x00, | 1311 0x00, |
1343 | 1312 |
1344 // frame type (stream frame with fin) | 1313 // frame type (stream frame with fin) |
1345 0xFA, | 1314 static_cast<unsigned char>( |
| 1315 GetParam() < QUIC_VERSION_10 ? 0xFA : 0xFD), |
1346 // stream id | 1316 // stream id |
1347 0x04, 0x03, | 1317 0x04, 0x03, |
1348 // offset | 1318 // offset |
1349 0x54, 0x76, 0x10, 0x32, | 1319 0x54, 0x76, 0x10, 0x32, |
1350 0xDC, 0xFE, 0x98, 0xBA, | 1320 0xDC, 0xFE, 0x98, 0xBA, |
1351 // data length | 1321 // data length |
1352 0x0c, 0x00, | 1322 0x0c, 0x00, |
1353 // data | 1323 // data |
1354 'h', 'e', 'l', 'l', | 1324 'h', 'e', 'l', 'l', |
1355 'o', ' ', 'w', 'o', | 1325 'o', ' ', 'w', 'o', |
(...skipping 28 matching lines...) Expand all Loading... |
1384 // guid | 1354 // guid |
1385 0x10, 0x32, 0x54, 0x76, | 1355 0x10, 0x32, 0x54, 0x76, |
1386 0x98, 0xBA, 0xDC, 0xFE, | 1356 0x98, 0xBA, 0xDC, 0xFE, |
1387 // packet sequence number | 1357 // packet sequence number |
1388 0xBC, 0x9A, 0x78, 0x56, | 1358 0xBC, 0x9A, 0x78, 0x56, |
1389 0x34, 0x12, | 1359 0x34, 0x12, |
1390 // private flags | 1360 // private flags |
1391 0x00, | 1361 0x00, |
1392 | 1362 |
1393 // frame type (stream frame with fin) | 1363 // frame type (stream frame with fin) |
1394 0xF8, | 1364 static_cast<unsigned char>( |
| 1365 GetParam() < QUIC_VERSION_10 ? 0xF8 : 0xFC), |
1395 // stream id | 1366 // stream id |
1396 0x04, | 1367 0x04, |
1397 // offset | 1368 // offset |
1398 0x54, 0x76, 0x10, 0x32, | 1369 0x54, 0x76, 0x10, 0x32, |
1399 0xDC, 0xFE, 0x98, 0xBA, | 1370 0xDC, 0xFE, 0x98, 0xBA, |
1400 // data length | 1371 // data length |
1401 0x0c, 0x00, | 1372 0x0c, 0x00, |
1402 // data | 1373 // data |
1403 'h', 'e', 'l', 'l', | 1374 'h', 'e', 'l', 'l', |
1404 'o', ' ', 'w', 'o', | 1375 'o', ' ', 'w', 'o', |
(...skipping 22 matching lines...) Expand all Loading... |
1427 } | 1398 } |
1428 | 1399 |
1429 TEST_P(QuicFramerTest, StreamFrameWithVersion) { | 1400 TEST_P(QuicFramerTest, StreamFrameWithVersion) { |
1430 unsigned char packet[] = { | 1401 unsigned char packet[] = { |
1431 // public flags (version, 8 byte guid) | 1402 // public flags (version, 8 byte guid) |
1432 0x3D, | 1403 0x3D, |
1433 // guid | 1404 // guid |
1434 0x10, 0x32, 0x54, 0x76, | 1405 0x10, 0x32, 0x54, 0x76, |
1435 0x98, 0xBA, 0xDC, 0xFE, | 1406 0x98, 0xBA, 0xDC, 0xFE, |
1436 // version tag | 1407 // version tag |
1437 'Q', '0', '0', LastCharOfVersion(), | 1408 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
1438 // packet sequence number | 1409 // packet sequence number |
1439 0xBC, 0x9A, 0x78, 0x56, | 1410 0xBC, 0x9A, 0x78, 0x56, |
1440 0x34, 0x12, | 1411 0x34, 0x12, |
1441 // private flags | 1412 // private flags |
1442 0x00, | 1413 0x00, |
1443 | 1414 |
1444 // frame type (stream frame with fin) | 1415 // frame type (stream frame with fin) |
1445 0xFE, | 1416 static_cast<unsigned char>( |
| 1417 GetParam() < QUIC_VERSION_10 ? 0xFE : 0xFF), |
1446 // stream id | 1418 // stream id |
1447 0x04, 0x03, 0x02, 0x01, | 1419 0x04, 0x03, 0x02, 0x01, |
1448 // offset | 1420 // offset |
1449 0x54, 0x76, 0x10, 0x32, | 1421 0x54, 0x76, 0x10, 0x32, |
1450 0xDC, 0xFE, 0x98, 0xBA, | 1422 0xDC, 0xFE, 0x98, 0xBA, |
1451 // data length | 1423 // data length |
1452 0x0c, 0x00, | 1424 0x0c, 0x00, |
1453 // data | 1425 // data |
1454 'h', 'e', 'l', 'l', | 1426 'h', 'e', 'l', 'l', |
1455 'o', ' ', 'w', 'o', | 1427 'o', ' ', 'w', 'o', |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 // guid | 1459 // guid |
1488 0x10, 0x32, 0x54, 0x76, | 1460 0x10, 0x32, 0x54, 0x76, |
1489 0x98, 0xBA, 0xDC, 0xFE, | 1461 0x98, 0xBA, 0xDC, 0xFE, |
1490 // packet sequence number | 1462 // packet sequence number |
1491 0xBC, 0x9A, 0x78, 0x56, | 1463 0xBC, 0x9A, 0x78, 0x56, |
1492 0x34, 0x12, | 1464 0x34, 0x12, |
1493 // private flags | 1465 // private flags |
1494 0x00, | 1466 0x00, |
1495 | 1467 |
1496 // frame type (stream frame with fin) | 1468 // frame type (stream frame with fin) |
1497 0xFE, | 1469 static_cast<unsigned char>( |
| 1470 GetParam() < QUIC_VERSION_10 ? 0xFE : 0xFF), |
1498 // stream id | 1471 // stream id |
1499 0x04, 0x03, 0x02, 0x01, | 1472 0x04, 0x03, 0x02, 0x01, |
1500 // offset | 1473 // offset |
1501 0x54, 0x76, 0x10, 0x32, | 1474 0x54, 0x76, 0x10, 0x32, |
1502 0xDC, 0xFE, 0x98, 0xBA, | 1475 0xDC, 0xFE, 0x98, 0xBA, |
1503 // data length | 1476 // data length |
1504 0x0c, 0x00, | 1477 0x0c, 0x00, |
1505 // data | 1478 // data |
1506 'h', 'e', 'l', 'l', | 1479 'h', 'e', 'l', 'l', |
1507 'o', ' ', 'w', 'o', | 1480 'o', ' ', 'w', 'o', |
1508 'r', 'l', 'd', '!', | 1481 'r', 'l', 'd', '!', |
1509 }; | 1482 }; |
1510 | 1483 |
1511 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1484 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1512 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1485 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1513 | 1486 |
1514 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1487 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
1515 ASSERT_TRUE(visitor_.header_.get()); | 1488 ASSERT_TRUE(visitor_.header_.get()); |
1516 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 1489 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
1517 | 1490 |
1518 ASSERT_EQ(0u, visitor_.stream_frames_.size()); | 1491 ASSERT_EQ(0u, visitor_.stream_frames_.size()); |
1519 EXPECT_EQ(0u, visitor_.ack_frames_.size()); | 1492 EXPECT_EQ(0u, visitor_.ack_frames_.size()); |
1520 } | 1493 } |
1521 | 1494 |
1522 TEST_P(QuicFramerTest, RevivedStreamFrame) { | 1495 TEST_P(QuicFramerTest, RevivedStreamFrame) { |
1523 unsigned char payload[] = { | 1496 unsigned char payload[] = { |
1524 // frame type (stream frame with fin) | 1497 // frame type (stream frame with fin) |
1525 0xFE, | 1498 static_cast<unsigned char>( |
| 1499 GetParam() < QUIC_VERSION_10 ? 0xFE : 0xFF), |
1526 // stream id | 1500 // stream id |
1527 0x04, 0x03, 0x02, 0x01, | 1501 0x04, 0x03, 0x02, 0x01, |
1528 // offset | 1502 // offset |
1529 0x54, 0x76, 0x10, 0x32, | 1503 0x54, 0x76, 0x10, 0x32, |
1530 0xDC, 0xFE, 0x98, 0xBA, | 1504 0xDC, 0xFE, 0x98, 0xBA, |
1531 // data length | 1505 // data length |
1532 0x0c, 0x00, | 1506 0x0c, 0x00, |
1533 // data | 1507 // data |
1534 'h', 'e', 'l', 'l', | 1508 'h', 'e', 'l', 'l', |
1535 'o', ' ', 'w', 'o', | 1509 'o', ' ', 'w', 'o', |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 0x98, 0xBA, 0xDC, 0xFE, | 1558 0x98, 0xBA, 0xDC, 0xFE, |
1585 // packet sequence number | 1559 // packet sequence number |
1586 0xBC, 0x9A, 0x78, 0x56, | 1560 0xBC, 0x9A, 0x78, 0x56, |
1587 0x12, 0x34, | 1561 0x12, 0x34, |
1588 // private flags (fec group) | 1562 // private flags (fec group) |
1589 0x02, | 1563 0x02, |
1590 // first fec protected packet offset | 1564 // first fec protected packet offset |
1591 0x02, | 1565 0x02, |
1592 | 1566 |
1593 // frame type (stream frame with fin) | 1567 // frame type (stream frame with fin) |
1594 0xFE, | 1568 static_cast<unsigned char>( |
| 1569 GetParam() < QUIC_VERSION_10 ? 0xFE : 0xFF), |
1595 // stream id | 1570 // stream id |
1596 0x04, 0x03, 0x02, 0x01, | 1571 0x04, 0x03, 0x02, 0x01, |
1597 // offset | 1572 // offset |
1598 0x54, 0x76, 0x10, 0x32, | 1573 0x54, 0x76, 0x10, 0x32, |
1599 0xDC, 0xFE, 0x98, 0xBA, | 1574 0xDC, 0xFE, 0x98, 0xBA, |
1600 // data length | 1575 // data length |
1601 0x0c, 0x00, | 1576 0x0c, 0x00, |
1602 // data | 1577 // data |
1603 'h', 'e', 'l', 'l', | 1578 'h', 'e', 'l', 'l', |
1604 'o', ' ', 'w', 'o', | 1579 'o', ' ', 'w', 'o', |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 // guid | 1611 // guid |
1637 0x10, 0x32, 0x54, 0x76, | 1612 0x10, 0x32, 0x54, 0x76, |
1638 0x98, 0xBA, 0xDC, 0xFE, | 1613 0x98, 0xBA, 0xDC, 0xFE, |
1639 // packet sequence number | 1614 // packet sequence number |
1640 0xBC, 0x9A, 0x78, 0x56, | 1615 0xBC, 0x9A, 0x78, 0x56, |
1641 0x34, 0x12, | 1616 0x34, 0x12, |
1642 // private flags | 1617 // private flags |
1643 0x00, | 1618 0x00, |
1644 | 1619 |
1645 // frame type (ack frame) | 1620 // frame type (ack frame) |
1646 static_cast<unsigned char>(0x01), | 1621 static_cast<unsigned char>( |
| 1622 GetParam() < QUIC_VERSION_10 ? 0x01 : 0x40), |
1647 // entropy hash of sent packets till least awaiting - 1. | 1623 // entropy hash of sent packets till least awaiting - 1. |
1648 0xAB, | 1624 0xAB, |
1649 // least packet sequence number awaiting an ack | 1625 // least packet sequence number awaiting an ack |
1650 0xA0, 0x9A, 0x78, 0x56, | 1626 0xA0, 0x9A, 0x78, 0x56, |
1651 0x34, 0x12, | 1627 0x34, 0x12, |
1652 // entropy hash of all received packets. | 1628 // entropy hash of all received packets. |
1653 0xBA, | 1629 0xBA, |
1654 // largest observed packet sequence number | 1630 // largest observed packet sequence number |
1655 0xBF, 0x9A, 0x78, 0x56, | 1631 0xBF, 0x9A, 0x78, 0x56, |
1656 0x34, 0x12, | 1632 0x34, 0x12, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 // guid | 1705 // guid |
1730 0x10, 0x32, 0x54, 0x76, | 1706 0x10, 0x32, 0x54, 0x76, |
1731 0x98, 0xBA, 0xDC, 0xFE, | 1707 0x98, 0xBA, 0xDC, 0xFE, |
1732 // packet sequence number | 1708 // packet sequence number |
1733 0xBC, 0x9A, 0x78, 0x56, | 1709 0xBC, 0x9A, 0x78, 0x56, |
1734 0x34, 0x12, | 1710 0x34, 0x12, |
1735 // private flags | 1711 // private flags |
1736 0x00, | 1712 0x00, |
1737 | 1713 |
1738 // frame type (congestion feedback frame) | 1714 // frame type (congestion feedback frame) |
1739 0x03, | 1715 static_cast<unsigned char>( |
| 1716 GetParam() < QUIC_VERSION_10 ? 0x03 : 0x20), |
1740 // congestion feedback type (tcp) | 1717 // congestion feedback type (tcp) |
1741 0x00, | 1718 0x00, |
1742 // ack_frame.feedback.tcp.accumulated_number_of_lost_packets | 1719 // ack_frame.feedback.tcp.accumulated_number_of_lost_packets |
1743 0x01, 0x02, | 1720 0x01, 0x02, |
1744 // ack_frame.feedback.tcp.receive_window | 1721 // ack_frame.feedback.tcp.receive_window |
1745 0x03, 0x04, | 1722 0x03, 0x04, |
1746 }; | 1723 }; |
1747 | 1724 |
1748 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1725 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1749 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1726 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 // guid | 1763 // guid |
1787 0x10, 0x32, 0x54, 0x76, | 1764 0x10, 0x32, 0x54, 0x76, |
1788 0x98, 0xBA, 0xDC, 0xFE, | 1765 0x98, 0xBA, 0xDC, 0xFE, |
1789 // packet sequence number | 1766 // packet sequence number |
1790 0xBC, 0x9A, 0x78, 0x56, | 1767 0xBC, 0x9A, 0x78, 0x56, |
1791 0x34, 0x12, | 1768 0x34, 0x12, |
1792 // private flags | 1769 // private flags |
1793 0x00, | 1770 0x00, |
1794 | 1771 |
1795 // frame type (congestion feedback frame) | 1772 // frame type (congestion feedback frame) |
1796 0x03, | 1773 static_cast<unsigned char>( |
| 1774 GetParam() < QUIC_VERSION_10 ? 0x03 : 0x20), |
1797 // congestion feedback type (inter arrival) | 1775 // congestion feedback type (inter arrival) |
1798 0x01, | 1776 0x01, |
1799 // accumulated_number_of_lost_packets | 1777 // accumulated_number_of_lost_packets |
1800 0x02, 0x03, | 1778 0x02, 0x03, |
1801 // num received packets | 1779 // num received packets |
1802 0x03, | 1780 0x03, |
1803 // lowest sequence number | 1781 // lowest sequence number |
1804 0xBA, 0x9A, 0x78, 0x56, | 1782 0xBA, 0x9A, 0x78, 0x56, |
1805 0x34, 0x12, | 1783 0x34, 0x12, |
1806 // receive time | 1784 // receive time |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 // guid | 1860 // guid |
1883 0x10, 0x32, 0x54, 0x76, | 1861 0x10, 0x32, 0x54, 0x76, |
1884 0x98, 0xBA, 0xDC, 0xFE, | 1862 0x98, 0xBA, 0xDC, 0xFE, |
1885 // packet sequence number | 1863 // packet sequence number |
1886 0xBC, 0x9A, 0x78, 0x56, | 1864 0xBC, 0x9A, 0x78, 0x56, |
1887 0x34, 0x12, | 1865 0x34, 0x12, |
1888 // private flags | 1866 // private flags |
1889 0x00, | 1867 0x00, |
1890 | 1868 |
1891 // frame type (congestion feedback frame) | 1869 // frame type (congestion feedback frame) |
1892 0x03, | 1870 static_cast<unsigned char>( |
| 1871 GetParam() < QUIC_VERSION_10 ? 0x03 : 0x20), |
1893 // congestion feedback type (fix rate) | 1872 // congestion feedback type (fix rate) |
1894 0x02, | 1873 0x02, |
1895 // bitrate_in_bytes_per_second; | 1874 // bitrate_in_bytes_per_second; |
1896 0x01, 0x02, 0x03, 0x04, | 1875 0x01, 0x02, 0x03, 0x04, |
1897 }; | 1876 }; |
1898 | 1877 |
1899 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1878 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1900 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 1879 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
1901 | 1880 |
1902 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 1881 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 // guid | 1913 // guid |
1935 0x10, 0x32, 0x54, 0x76, | 1914 0x10, 0x32, 0x54, 0x76, |
1936 0x98, 0xBA, 0xDC, 0xFE, | 1915 0x98, 0xBA, 0xDC, 0xFE, |
1937 // packet sequence number | 1916 // packet sequence number |
1938 0xBC, 0x9A, 0x78, 0x56, | 1917 0xBC, 0x9A, 0x78, 0x56, |
1939 0x34, 0x12, | 1918 0x34, 0x12, |
1940 // private flags | 1919 // private flags |
1941 0x00, | 1920 0x00, |
1942 | 1921 |
1943 // frame type (congestion feedback frame) | 1922 // frame type (congestion feedback frame) |
1944 0x03, | 1923 static_cast<unsigned char>( |
| 1924 GetParam() < QUIC_VERSION_10 ? 0x03 : 0x20), |
1945 // congestion feedback type (invalid) | 1925 // congestion feedback type (invalid) |
1946 0x03, | 1926 0x03, |
1947 }; | 1927 }; |
1948 | 1928 |
1949 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 1929 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
1950 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); | 1930 EXPECT_FALSE(framer_.ProcessPacket(encrypted)); |
1951 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); | 1931 EXPECT_TRUE(CheckDecryption(encrypted, !kIncludeVersion)); |
1952 EXPECT_EQ(QUIC_INVALID_CONGESTION_FEEDBACK_DATA, framer_.error()); | 1932 EXPECT_EQ(QUIC_INVALID_CONGESTION_FEEDBACK_DATA, framer_.error()); |
1953 } | 1933 } |
1954 | 1934 |
1955 TEST_P(QuicFramerTest, RstStreamFrame) { | 1935 TEST_P(QuicFramerTest, RstStreamFrame) { |
1956 unsigned char packet[] = { | 1936 unsigned char packet[] = { |
1957 // public flags (8 byte guid) | 1937 // public flags (8 byte guid) |
1958 0x3C, | 1938 0x3C, |
1959 // guid | 1939 // guid |
1960 0x10, 0x32, 0x54, 0x76, | 1940 0x10, 0x32, 0x54, 0x76, |
1961 0x98, 0xBA, 0xDC, 0xFE, | 1941 0x98, 0xBA, 0xDC, 0xFE, |
1962 // packet sequence number | 1942 // packet sequence number |
1963 0xBC, 0x9A, 0x78, 0x56, | 1943 0xBC, 0x9A, 0x78, 0x56, |
1964 0x34, 0x12, | 1944 0x34, 0x12, |
1965 // private flags | 1945 // private flags |
1966 0x00, | 1946 0x00, |
1967 | 1947 |
1968 // frame type (rst stream frame) | 1948 // frame type (rst stream frame) |
1969 static_cast<unsigned char>(0x27), | 1949 static_cast<unsigned char>( |
| 1950 GetParam() < QUIC_VERSION_10 ? 0x27 : 0x01), |
1970 // stream id | 1951 // stream id |
1971 0x04, 0x03, 0x02, 0x01, | 1952 0x04, 0x03, 0x02, 0x01, |
1972 // error code | 1953 // error code |
1973 0x01, 0x00, 0x00, 0x00, | 1954 0x01, 0x00, 0x00, 0x00, |
1974 | 1955 |
1975 // error details length | 1956 // error details length |
1976 0x0d, 0x00, | 1957 0x0d, 0x00, |
1977 // error details | 1958 // error details |
1978 'b', 'e', 'c', 'a', | 1959 'b', 'e', 'c', 'a', |
1979 'u', 's', 'e', ' ', | 1960 'u', 's', 'e', ' ', |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 // guid | 1999 // guid |
2019 0x10, 0x32, 0x54, 0x76, | 2000 0x10, 0x32, 0x54, 0x76, |
2020 0x98, 0xBA, 0xDC, 0xFE, | 2001 0x98, 0xBA, 0xDC, 0xFE, |
2021 // packet sequence number | 2002 // packet sequence number |
2022 0xBC, 0x9A, 0x78, 0x56, | 2003 0xBC, 0x9A, 0x78, 0x56, |
2023 0x34, 0x12, | 2004 0x34, 0x12, |
2024 // private flags | 2005 // private flags |
2025 0x00, | 2006 0x00, |
2026 | 2007 |
2027 // frame type (connection close frame) | 2008 // frame type (connection close frame) |
2028 static_cast<unsigned char>(0x2F), | 2009 static_cast<unsigned char>( |
| 2010 GetParam() < QUIC_VERSION_10 ? 0x2F : 0x02), |
2029 // error code | 2011 // error code |
2030 0x11, 0x00, 0x00, 0x00, | 2012 0x11, 0x00, 0x00, 0x00, |
2031 | 2013 |
2032 // error details length | 2014 // error details length |
2033 0x0d, 0x00, | 2015 0x0d, 0x00, |
2034 // error details | 2016 // error details |
2035 'b', 'e', 'c', 'a', | 2017 'b', 'e', 'c', 'a', |
2036 'u', 's', 'e', ' ', | 2018 'u', 's', 'e', ' ', |
2037 'I', ' ', 'c', 'a', | 2019 'I', ' ', 'c', 'a', |
2038 'n', | 2020 'n', |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 // guid | 2087 // guid |
2106 0x10, 0x32, 0x54, 0x76, | 2088 0x10, 0x32, 0x54, 0x76, |
2107 0x98, 0xBA, 0xDC, 0xFE, | 2089 0x98, 0xBA, 0xDC, 0xFE, |
2108 // packet sequence number | 2090 // packet sequence number |
2109 0xBC, 0x9A, 0x78, 0x56, | 2091 0xBC, 0x9A, 0x78, 0x56, |
2110 0x34, 0x12, | 2092 0x34, 0x12, |
2111 // private flags | 2093 // private flags |
2112 0x00, | 2094 0x00, |
2113 | 2095 |
2114 // frame type (go away frame) | 2096 // frame type (go away frame) |
2115 static_cast<unsigned char>(0x37), | 2097 static_cast<unsigned char>( |
| 2098 GetParam() < QUIC_VERSION_10 ? 0x37 : 0x03), |
2116 // error code | 2099 // error code |
2117 0x09, 0x00, 0x00, 0x00, | 2100 0x09, 0x00, 0x00, 0x00, |
2118 // stream id | 2101 // stream id |
2119 0x04, 0x03, 0x02, 0x01, | 2102 0x04, 0x03, 0x02, 0x01, |
2120 // error details length | 2103 // error details length |
2121 0x0d, 0x00, | 2104 0x0d, 0x00, |
2122 // error details | 2105 // error details |
2123 'b', 'e', 'c', 'a', | 2106 'b', 'e', 'c', 'a', |
2124 'u', 's', 'e', ' ', | 2107 'u', 's', 'e', ' ', |
2125 'I', ' ', 'c', 'a', | 2108 'I', ' ', 'c', 'a', |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2212 } | 2195 } |
2213 | 2196 |
2214 TEST_P(QuicFramerTest, VersionNegotiationPacket) { | 2197 TEST_P(QuicFramerTest, VersionNegotiationPacket) { |
2215 unsigned char packet[] = { | 2198 unsigned char packet[] = { |
2216 // public flags (version, 8 byte guid) | 2199 // public flags (version, 8 byte guid) |
2217 0x3D, | 2200 0x3D, |
2218 // guid | 2201 // guid |
2219 0x10, 0x32, 0x54, 0x76, | 2202 0x10, 0x32, 0x54, 0x76, |
2220 0x98, 0xBA, 0xDC, 0xFE, | 2203 0x98, 0xBA, 0xDC, 0xFE, |
2221 // version tag | 2204 // version tag |
2222 'Q', '0', '0', LastCharOfVersion(), | 2205 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
2223 'Q', '2', '.', '0', | 2206 'Q', '2', '.', '0', |
2224 }; | 2207 }; |
2225 | 2208 |
2226 QuicFramerPeer::SetIsServer(&framer_, false); | 2209 QuicFramerPeer::SetIsServer(&framer_, false); |
2227 | 2210 |
2228 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 2211 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
2229 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 2212 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
2230 ASSERT_EQ(QUIC_NO_ERROR, framer_.error()); | 2213 ASSERT_EQ(QUIC_NO_ERROR, framer_.error()); |
2231 ASSERT_TRUE(visitor_.version_negotiation_packet_.get()); | 2214 ASSERT_TRUE(visitor_.version_negotiation_packet_.get()); |
2232 EXPECT_EQ(2u, visitor_.version_negotiation_packet_->versions.size()); | 2215 EXPECT_EQ(2u, visitor_.version_negotiation_packet_->versions.size()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 // guid | 2288 // guid |
2306 0x10, 0x32, 0x54, 0x76, | 2289 0x10, 0x32, 0x54, 0x76, |
2307 0x98, 0xBA, 0xDC, 0xFE, | 2290 0x98, 0xBA, 0xDC, 0xFE, |
2308 // packet sequence number | 2291 // packet sequence number |
2309 0xBC, 0x9A, 0x78, 0x56, | 2292 0xBC, 0x9A, 0x78, 0x56, |
2310 0x34, 0x12, | 2293 0x34, 0x12, |
2311 // private flags | 2294 // private flags |
2312 0x00, | 2295 0x00, |
2313 | 2296 |
2314 // frame type (padding frame) | 2297 // frame type (padding frame) |
2315 static_cast<unsigned char>(0x07), | 2298 static_cast<unsigned char>( |
| 2299 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
| 2300 0x00, 0x00, 0x00, 0x00 |
2316 }; | 2301 }; |
2317 | 2302 |
2318 uint64 header_size = | 2303 uint64 header_size = |
2319 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, | 2304 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, |
2320 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); | 2305 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
2321 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); | 2306 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); |
2322 | 2307 |
2323 scoped_ptr<QuicPacket> data( | 2308 scoped_ptr<QuicPacket> data( |
2324 framer_.BuildUnsizedDataPacket(header, frames).packet); | 2309 framer_.BuildUnsizedDataPacket(header, frames).packet); |
2325 ASSERT_TRUE(data != NULL); | 2310 ASSERT_TRUE(data != NULL); |
(...skipping 24 matching lines...) Expand all Loading... |
2350 0x2C, | 2335 0x2C, |
2351 // guid | 2336 // guid |
2352 0x10, 0x32, 0x54, 0x76, | 2337 0x10, 0x32, 0x54, 0x76, |
2353 0x98, 0xBA, 0xDC, 0xFE, | 2338 0x98, 0xBA, 0xDC, 0xFE, |
2354 // packet sequence number | 2339 // packet sequence number |
2355 0xBC, 0x9A, 0x78, 0x56, | 2340 0xBC, 0x9A, 0x78, 0x56, |
2356 // private flags | 2341 // private flags |
2357 0x00, | 2342 0x00, |
2358 | 2343 |
2359 // frame type (padding frame) | 2344 // frame type (padding frame) |
2360 static_cast<unsigned char>(0x07), | 2345 static_cast<unsigned char>( |
| 2346 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
| 2347 0x00, 0x00, 0x00, 0x00 |
2361 }; | 2348 }; |
2362 | 2349 |
2363 uint64 header_size = | 2350 uint64 header_size = |
2364 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, | 2351 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, |
2365 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); | 2352 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
2366 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); | 2353 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); |
2367 | 2354 |
2368 scoped_ptr<QuicPacket> data( | 2355 scoped_ptr<QuicPacket> data( |
2369 framer_.BuildUnsizedDataPacket(header, frames).packet); | 2356 framer_.BuildUnsizedDataPacket(header, frames).packet); |
2370 ASSERT_TRUE(data != NULL); | 2357 ASSERT_TRUE(data != NULL); |
(...skipping 24 matching lines...) Expand all Loading... |
2395 0x1C, | 2382 0x1C, |
2396 // guid | 2383 // guid |
2397 0x10, 0x32, 0x54, 0x76, | 2384 0x10, 0x32, 0x54, 0x76, |
2398 0x98, 0xBA, 0xDC, 0xFE, | 2385 0x98, 0xBA, 0xDC, 0xFE, |
2399 // packet sequence number | 2386 // packet sequence number |
2400 0xBC, 0x9A, | 2387 0xBC, 0x9A, |
2401 // private flags | 2388 // private flags |
2402 0x00, | 2389 0x00, |
2403 | 2390 |
2404 // frame type (padding frame) | 2391 // frame type (padding frame) |
2405 static_cast<unsigned char>(0x07), | 2392 static_cast<unsigned char>( |
| 2393 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
| 2394 0x00, 0x00, 0x00, 0x00 |
2406 }; | 2395 }; |
2407 | 2396 |
2408 uint64 header_size = | 2397 uint64 header_size = |
2409 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, | 2398 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, |
2410 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); | 2399 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
2411 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); | 2400 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); |
2412 | 2401 |
2413 scoped_ptr<QuicPacket> data( | 2402 scoped_ptr<QuicPacket> data( |
2414 framer_.BuildUnsizedDataPacket(header, frames).packet); | 2403 framer_.BuildUnsizedDataPacket(header, frames).packet); |
2415 ASSERT_TRUE(data != NULL); | 2404 ASSERT_TRUE(data != NULL); |
(...skipping 24 matching lines...) Expand all Loading... |
2440 0x0C, | 2429 0x0C, |
2441 // guid | 2430 // guid |
2442 0x10, 0x32, 0x54, 0x76, | 2431 0x10, 0x32, 0x54, 0x76, |
2443 0x98, 0xBA, 0xDC, 0xFE, | 2432 0x98, 0xBA, 0xDC, 0xFE, |
2444 // packet sequence number | 2433 // packet sequence number |
2445 0xBC, | 2434 0xBC, |
2446 // private flags | 2435 // private flags |
2447 0x00, | 2436 0x00, |
2448 | 2437 |
2449 // frame type (padding frame) | 2438 // frame type (padding frame) |
2450 static_cast<unsigned char>(0x07), | 2439 static_cast<unsigned char>( |
| 2440 GetParam() < QUIC_VERSION_10 ? 0x07 : 0x00), |
| 2441 0x00, 0x00, 0x00, 0x00 |
2451 }; | 2442 }; |
2452 | 2443 |
2453 uint64 header_size = | 2444 uint64 header_size = |
2454 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, | 2445 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, |
2455 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); | 2446 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); |
2456 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); | 2447 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); |
2457 | 2448 |
2458 scoped_ptr<QuicPacket> data( | 2449 scoped_ptr<QuicPacket> data( |
2459 framer_.BuildUnsizedDataPacket(header, frames).packet); | 2450 framer_.BuildUnsizedDataPacket(header, frames).packet); |
2460 ASSERT_TRUE(data != NULL); | 2451 ASSERT_TRUE(data != NULL); |
(...skipping 28 matching lines...) Expand all Loading... |
2489 // guid | 2480 // guid |
2490 0x10, 0x32, 0x54, 0x76, | 2481 0x10, 0x32, 0x54, 0x76, |
2491 0x98, 0xBA, 0xDC, 0xFE, | 2482 0x98, 0xBA, 0xDC, 0xFE, |
2492 // packet sequence number | 2483 // packet sequence number |
2493 0xBC, 0x9A, 0x78, 0x56, | 2484 0xBC, 0x9A, 0x78, 0x56, |
2494 0x34, 0x12, | 2485 0x34, 0x12, |
2495 // private flags (entropy) | 2486 // private flags (entropy) |
2496 0x01, | 2487 0x01, |
2497 | 2488 |
2498 // frame type (stream frame with fin and no length) | 2489 // frame type (stream frame with fin and no length) |
2499 0xBE, | 2490 static_cast<unsigned char>( |
| 2491 GetParam() < QUIC_VERSION_10 ? 0xBE : 0xDF), |
2500 // stream id | 2492 // stream id |
2501 0x04, 0x03, 0x02, 0x01, | 2493 0x04, 0x03, 0x02, 0x01, |
2502 // offset | 2494 // offset |
2503 0x54, 0x76, 0x10, 0x32, | 2495 0x54, 0x76, 0x10, 0x32, |
2504 0xDC, 0xFE, 0x98, 0xBA, | 2496 0xDC, 0xFE, 0x98, 0xBA, |
2505 // data | 2497 // data |
2506 'h', 'e', 'l', 'l', | 2498 'h', 'e', 'l', 'l', |
2507 'o', ' ', 'w', 'o', | 2499 'o', ' ', 'w', 'o', |
2508 'r', 'l', 'd', '!', | 2500 'r', 'l', 'd', '!', |
2509 }; | 2501 }; |
(...skipping 26 matching lines...) Expand all Loading... |
2536 QuicFrames frames; | 2528 QuicFrames frames; |
2537 frames.push_back(QuicFrame(&stream_frame)); | 2529 frames.push_back(QuicFrame(&stream_frame)); |
2538 | 2530 |
2539 unsigned char packet[] = { | 2531 unsigned char packet[] = { |
2540 // public flags (version, 8 byte guid) | 2532 // public flags (version, 8 byte guid) |
2541 0x3D, | 2533 0x3D, |
2542 // guid | 2534 // guid |
2543 0x10, 0x32, 0x54, 0x76, | 2535 0x10, 0x32, 0x54, 0x76, |
2544 0x98, 0xBA, 0xDC, 0xFE, | 2536 0x98, 0xBA, 0xDC, 0xFE, |
2545 // version tag | 2537 // version tag |
2546 'Q', '0', '0', LastCharOfVersion(), | 2538 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
2547 // packet sequence number | 2539 // packet sequence number |
2548 0xBC, 0x9A, 0x78, 0x56, | 2540 0xBC, 0x9A, 0x78, 0x56, |
2549 0x34, 0x12, | 2541 0x34, 0x12, |
2550 // private flags (entropy) | 2542 // private flags (entropy) |
2551 0x01, | 2543 0x01, |
2552 | 2544 |
2553 // frame type (stream frame with fin and no length) | 2545 // frame type (stream frame with fin and no length) |
2554 0xBE, | 2546 static_cast<unsigned char>( |
| 2547 GetParam() < QUIC_VERSION_10 ? 0xBE : 0xDF), |
2555 // stream id | 2548 // stream id |
2556 0x04, 0x03, 0x02, 0x01, | 2549 0x04, 0x03, 0x02, 0x01, |
2557 // offset | 2550 // offset |
2558 0x54, 0x76, 0x10, 0x32, | 2551 0x54, 0x76, 0x10, 0x32, |
2559 0xDC, 0xFE, 0x98, 0xBA, | 2552 0xDC, 0xFE, 0x98, 0xBA, |
2560 // data | 2553 // data |
2561 'h', 'e', 'l', 'l', | 2554 'h', 'e', 'l', 'l', |
2562 'o', ' ', 'w', 'o', | 2555 'o', ' ', 'w', 'o', |
2563 'r', 'l', 'd', '!', | 2556 'r', 'l', 'd', '!', |
2564 }; | 2557 }; |
(...skipping 14 matching lines...) Expand all Loading... |
2579 header.reset_flag = false; | 2572 header.reset_flag = false; |
2580 header.version_flag = true; | 2573 header.version_flag = true; |
2581 | 2574 |
2582 unsigned char packet[] = { | 2575 unsigned char packet[] = { |
2583 // public flags (version, 8 byte guid) | 2576 // public flags (version, 8 byte guid) |
2584 0x3D, | 2577 0x3D, |
2585 // guid | 2578 // guid |
2586 0x10, 0x32, 0x54, 0x76, | 2579 0x10, 0x32, 0x54, 0x76, |
2587 0x98, 0xBA, 0xDC, 0xFE, | 2580 0x98, 0xBA, 0xDC, 0xFE, |
2588 // version tag | 2581 // version tag |
2589 'Q', '0', '0', LastCharOfVersion(), | 2582 'Q', '0', GetQuicVersionDigitTens(), GetQuicVersionDigitOnes(), |
2590 }; | 2583 }; |
2591 | 2584 |
2592 QuicVersionVector versions; | 2585 QuicVersionVector versions; |
2593 versions.push_back(GetParam()); | 2586 versions.push_back(GetParam()); |
2594 scoped_ptr<QuicEncryptedPacket> data( | 2587 scoped_ptr<QuicEncryptedPacket> data( |
2595 framer_.BuildVersionNegotiationPacket(header, versions)); | 2588 framer_.BuildVersionNegotiationPacket(header, versions)); |
2596 | 2589 |
2597 test::CompareCharArraysWithHexError("constructed packet", | 2590 test::CompareCharArraysWithHexError("constructed packet", |
2598 data->data(), data->length(), | 2591 data->data(), data->length(), |
2599 AsChars(packet), arraysize(packet)); | 2592 AsChars(packet), arraysize(packet)); |
(...skipping 27 matching lines...) Expand all Loading... |
2627 // guid | 2620 // guid |
2628 0x10, 0x32, 0x54, 0x76, | 2621 0x10, 0x32, 0x54, 0x76, |
2629 0x98, 0xBA, 0xDC, 0xFE, | 2622 0x98, 0xBA, 0xDC, 0xFE, |
2630 // packet sequence number | 2623 // packet sequence number |
2631 0xBC, 0x9A, 0x78, 0x56, | 2624 0xBC, 0x9A, 0x78, 0x56, |
2632 0x34, 0x12, | 2625 0x34, 0x12, |
2633 // private flags (entropy) | 2626 // private flags (entropy) |
2634 0x01, | 2627 0x01, |
2635 | 2628 |
2636 // frame type (ack frame) | 2629 // frame type (ack frame) |
2637 static_cast<unsigned char>(0x01), | 2630 static_cast<unsigned char>( |
| 2631 GetParam() < QUIC_VERSION_10 ? 0x01 : 0x40), |
2638 // entropy hash of sent packets till least awaiting - 1. | 2632 // entropy hash of sent packets till least awaiting - 1. |
2639 0x14, | 2633 0x14, |
2640 // least packet sequence number awaiting an ack | 2634 // least packet sequence number awaiting an ack |
2641 0xA0, 0x9A, 0x78, 0x56, | 2635 0xA0, 0x9A, 0x78, 0x56, |
2642 0x34, 0x12, | 2636 0x34, 0x12, |
2643 // entropy hash of all received packets. | 2637 // entropy hash of all received packets. |
2644 0x43, | 2638 0x43, |
2645 // largest observed packet sequence number | 2639 // largest observed packet sequence number |
2646 0xBF, 0x9A, 0x78, 0x56, | 2640 0xBF, 0x9A, 0x78, 0x56, |
2647 0x34, 0x12, | 2641 0x34, 0x12, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2687 // guid | 2681 // guid |
2688 0x10, 0x32, 0x54, 0x76, | 2682 0x10, 0x32, 0x54, 0x76, |
2689 0x98, 0xBA, 0xDC, 0xFE, | 2683 0x98, 0xBA, 0xDC, 0xFE, |
2690 // packet sequence number | 2684 // packet sequence number |
2691 0xBC, 0x9A, 0x78, 0x56, | 2685 0xBC, 0x9A, 0x78, 0x56, |
2692 0x34, 0x12, | 2686 0x34, 0x12, |
2693 // private flags | 2687 // private flags |
2694 0x00, | 2688 0x00, |
2695 | 2689 |
2696 // frame type (congestion feedback frame) | 2690 // frame type (congestion feedback frame) |
2697 0x03, | 2691 static_cast<unsigned char>( |
| 2692 GetParam() < QUIC_VERSION_10 ? 0x03 : 0x20), |
2698 // congestion feedback type (TCP) | 2693 // congestion feedback type (TCP) |
2699 0x00, | 2694 0x00, |
2700 // accumulated number of lost packets | 2695 // accumulated number of lost packets |
2701 0x01, 0x02, | 2696 0x01, 0x02, |
2702 // TCP receive window | 2697 // TCP receive window |
2703 0x03, 0x04, | 2698 0x03, 0x04, |
2704 }; | 2699 }; |
2705 | 2700 |
2706 scoped_ptr<QuicPacket> data( | 2701 scoped_ptr<QuicPacket> data( |
2707 framer_.BuildUnsizedDataPacket(header, frames).packet); | 2702 framer_.BuildUnsizedDataPacket(header, frames).packet); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 // guid | 2741 // guid |
2747 0x10, 0x32, 0x54, 0x76, | 2742 0x10, 0x32, 0x54, 0x76, |
2748 0x98, 0xBA, 0xDC, 0xFE, | 2743 0x98, 0xBA, 0xDC, 0xFE, |
2749 // packet sequence number | 2744 // packet sequence number |
2750 0xBC, 0x9A, 0x78, 0x56, | 2745 0xBC, 0x9A, 0x78, 0x56, |
2751 0x34, 0x12, | 2746 0x34, 0x12, |
2752 // private flags | 2747 // private flags |
2753 0x00, | 2748 0x00, |
2754 | 2749 |
2755 // frame type (congestion feedback frame) | 2750 // frame type (congestion feedback frame) |
2756 0x03, | 2751 static_cast<unsigned char>( |
| 2752 GetParam() < QUIC_VERSION_10 ? 0x03 : 0x20), |
2757 // congestion feedback type (inter arrival) | 2753 // congestion feedback type (inter arrival) |
2758 0x01, | 2754 0x01, |
2759 // accumulated_number_of_lost_packets | 2755 // accumulated_number_of_lost_packets |
2760 0x02, 0x03, | 2756 0x02, 0x03, |
2761 // num received packets | 2757 // num received packets |
2762 0x03, | 2758 0x03, |
2763 // lowest sequence number | 2759 // lowest sequence number |
2764 0xBA, 0x9A, 0x78, 0x56, | 2760 0xBA, 0x9A, 0x78, 0x56, |
2765 0x34, 0x12, | 2761 0x34, 0x12, |
2766 // receive time | 2762 // receive time |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2809 // guid | 2805 // guid |
2810 0x10, 0x32, 0x54, 0x76, | 2806 0x10, 0x32, 0x54, 0x76, |
2811 0x98, 0xBA, 0xDC, 0xFE, | 2807 0x98, 0xBA, 0xDC, 0xFE, |
2812 // packet sequence number | 2808 // packet sequence number |
2813 0xBC, 0x9A, 0x78, 0x56, | 2809 0xBC, 0x9A, 0x78, 0x56, |
2814 0x34, 0x12, | 2810 0x34, 0x12, |
2815 // private flags | 2811 // private flags |
2816 0x00, | 2812 0x00, |
2817 | 2813 |
2818 // frame type (congestion feedback frame) | 2814 // frame type (congestion feedback frame) |
2819 0x03, | 2815 static_cast<unsigned char>( |
| 2816 GetParam() < QUIC_VERSION_10 ? 0x03 : 0x20), |
2820 // congestion feedback type (fix rate) | 2817 // congestion feedback type (fix rate) |
2821 0x02, | 2818 0x02, |
2822 // bitrate_in_bytes_per_second; | 2819 // bitrate_in_bytes_per_second; |
2823 0x01, 0x02, 0x03, 0x04, | 2820 0x01, 0x02, 0x03, 0x04, |
2824 }; | 2821 }; |
2825 | 2822 |
2826 scoped_ptr<QuicPacket> data( | 2823 scoped_ptr<QuicPacket> data( |
2827 framer_.BuildUnsizedDataPacket(header, frames).packet); | 2824 framer_.BuildUnsizedDataPacket(header, frames).packet); |
2828 ASSERT_TRUE(data != NULL); | 2825 ASSERT_TRUE(data != NULL); |
2829 | 2826 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2875 // guid | 2872 // guid |
2876 0x10, 0x32, 0x54, 0x76, | 2873 0x10, 0x32, 0x54, 0x76, |
2877 0x98, 0xBA, 0xDC, 0xFE, | 2874 0x98, 0xBA, 0xDC, 0xFE, |
2878 // packet sequence number | 2875 // packet sequence number |
2879 0xBC, 0x9A, 0x78, 0x56, | 2876 0xBC, 0x9A, 0x78, 0x56, |
2880 0x34, 0x12, | 2877 0x34, 0x12, |
2881 // private flags | 2878 // private flags |
2882 0x00, | 2879 0x00, |
2883 | 2880 |
2884 // frame type (rst stream frame) | 2881 // frame type (rst stream frame) |
2885 static_cast<unsigned char>(0x27), | 2882 static_cast<unsigned char>( |
| 2883 GetParam() < QUIC_VERSION_10 ? 0x27 : 0x01), |
2886 // stream id | 2884 // stream id |
2887 0x04, 0x03, 0x02, 0x01, | 2885 0x04, 0x03, 0x02, 0x01, |
2888 // error code | 2886 // error code |
2889 0x08, 0x07, 0x06, 0x05, | 2887 0x08, 0x07, 0x06, 0x05, |
2890 // error details length | 2888 // error details length |
2891 0x0d, 0x00, | 2889 0x0d, 0x00, |
2892 // error details | 2890 // error details |
2893 'b', 'e', 'c', 'a', | 2891 'b', 'e', 'c', 'a', |
2894 'u', 's', 'e', ' ', | 2892 'u', 's', 'e', ' ', |
2895 'I', ' ', 'c', 'a', | 2893 'I', ' ', 'c', 'a', |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 // guid | 2936 // guid |
2939 0x10, 0x32, 0x54, 0x76, | 2937 0x10, 0x32, 0x54, 0x76, |
2940 0x98, 0xBA, 0xDC, 0xFE, | 2938 0x98, 0xBA, 0xDC, 0xFE, |
2941 // packet sequence number | 2939 // packet sequence number |
2942 0xBC, 0x9A, 0x78, 0x56, | 2940 0xBC, 0x9A, 0x78, 0x56, |
2943 0x34, 0x12, | 2941 0x34, 0x12, |
2944 // private flags (entropy) | 2942 // private flags (entropy) |
2945 0x01, | 2943 0x01, |
2946 | 2944 |
2947 // frame type (connection close frame) | 2945 // frame type (connection close frame) |
2948 static_cast<unsigned char>(0x2F), | 2946 static_cast<unsigned char>( |
| 2947 GetParam() < QUIC_VERSION_10 ? 0x2F : 0x02), |
2949 // error code | 2948 // error code |
2950 0x08, 0x07, 0x06, 0x05, | 2949 0x08, 0x07, 0x06, 0x05, |
2951 // error details length | 2950 // error details length |
2952 0x0d, 0x00, | 2951 0x0d, 0x00, |
2953 // error details | 2952 // error details |
2954 'b', 'e', 'c', 'a', | 2953 'b', 'e', 'c', 'a', |
2955 'u', 's', 'e', ' ', | 2954 'u', 's', 'e', ' ', |
2956 'I', ' ', 'c', 'a', | 2955 'I', ' ', 'c', 'a', |
2957 'n', | 2956 'n', |
2958 | 2957 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3009 // guid | 3008 // guid |
3010 0x10, 0x32, 0x54, 0x76, | 3009 0x10, 0x32, 0x54, 0x76, |
3011 0x98, 0xBA, 0xDC, 0xFE, | 3010 0x98, 0xBA, 0xDC, 0xFE, |
3012 // packet sequence number | 3011 // packet sequence number |
3013 0xBC, 0x9A, 0x78, 0x56, | 3012 0xBC, 0x9A, 0x78, 0x56, |
3014 0x34, 0x12, | 3013 0x34, 0x12, |
3015 // private flags(entropy) | 3014 // private flags(entropy) |
3016 0x01, | 3015 0x01, |
3017 | 3016 |
3018 // frame type (go away frame) | 3017 // frame type (go away frame) |
3019 static_cast<unsigned char>(0x37), | 3018 static_cast<unsigned char>( |
| 3019 GetParam() < QUIC_VERSION_10 ? 0x37 : 0x03), |
3020 // error code | 3020 // error code |
3021 0x08, 0x07, 0x06, 0x05, | 3021 0x08, 0x07, 0x06, 0x05, |
3022 // stream id | 3022 // stream id |
3023 0x04, 0x03, 0x02, 0x01, | 3023 0x04, 0x03, 0x02, 0x01, |
3024 // error details length | 3024 // error details length |
3025 0x0d, 0x00, | 3025 0x0d, 0x00, |
3026 // error details | 3026 // error details |
3027 'b', 'e', 'c', 'a', | 3027 'b', 'e', 'c', 'a', |
3028 'u', 's', 'e', ' ', | 3028 'u', 's', 'e', ' ', |
3029 'I', ' ', 'c', 'a', | 3029 'I', ' ', 'c', 'a', |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3350 // guid | 3350 // guid |
3351 0x10, 0x32, 0x54, 0x76, | 3351 0x10, 0x32, 0x54, 0x76, |
3352 0x98, 0xBA, 0xDC, 0xFE, | 3352 0x98, 0xBA, 0xDC, 0xFE, |
3353 // packet sequence number | 3353 // packet sequence number |
3354 0xBC, 0x9A, 0x78, 0x56, | 3354 0xBC, 0x9A, 0x78, 0x56, |
3355 0x34, 0x12, | 3355 0x34, 0x12, |
3356 // private flags (Entropy) | 3356 // private flags (Entropy) |
3357 0x01, | 3357 0x01, |
3358 | 3358 |
3359 // frame type (stream frame with fin and no length) | 3359 // frame type (stream frame with fin and no length) |
3360 0xBE, | 3360 static_cast<unsigned char>( |
| 3361 GetParam() < QUIC_VERSION_10 ? 0xBE : 0xDF), |
3361 // stream id | 3362 // stream id |
3362 0x04, 0x03, 0x02, 0x01, | 3363 0x04, 0x03, 0x02, 0x01, |
3363 // offset | 3364 // offset |
3364 0x54, 0x76, 0x10, 0x32, | 3365 0x54, 0x76, 0x10, 0x32, |
3365 0xDC, 0xFE, 0x98, 0xBA, | 3366 0xDC, 0xFE, 0x98, 0xBA, |
3366 // data | 3367 // data |
3367 'h', 'e', 'l', 'l', | 3368 'h', 'e', 'l', 'l', |
3368 'o', ' ', 'w', 'o', | 3369 'o', ' ', 'w', 'o', |
3369 'r', 'l', 'd', '!', | 3370 'r', 'l', 'd', '!', |
3370 }; | 3371 }; |
(...skipping 16 matching lines...) Expand all Loading... |
3387 0x98, 0xBA, 0xDC, 0xFE, | 3388 0x98, 0xBA, 0xDC, 0xFE, |
3388 // packet sequence number | 3389 // packet sequence number |
3389 0xBC, 0x9A, 0x78, 0x56, | 3390 0xBC, 0x9A, 0x78, 0x56, |
3390 0x34, 0x12, | 3391 0x34, 0x12, |
3391 // private flags (Entropy & fec group & FEC) | 3392 // private flags (Entropy & fec group & FEC) |
3392 0x07, | 3393 0x07, |
3393 // first fec protected packet offset | 3394 // first fec protected packet offset |
3394 0xFF, | 3395 0xFF, |
3395 | 3396 |
3396 // frame type (stream frame with fin and no length) | 3397 // frame type (stream frame with fin and no length) |
3397 0xBE, | 3398 static_cast<unsigned char>( |
| 3399 GetParam() < QUIC_VERSION_10 ? 0xBE : 0xDF), |
3398 // stream id | 3400 // stream id |
3399 0x04, 0x03, 0x02, 0x01, | 3401 0x04, 0x03, 0x02, 0x01, |
3400 // offset | 3402 // offset |
3401 0x54, 0x76, 0x10, 0x32, | 3403 0x54, 0x76, 0x10, 0x32, |
3402 0xDC, 0xFE, 0x98, 0xBA, | 3404 0xDC, 0xFE, 0x98, 0xBA, |
3403 // data | 3405 // data |
3404 'h', 'e', 'l', 'l', | 3406 'h', 'e', 'l', 'l', |
3405 'o', ' ', 'w', 'o', | 3407 'o', ' ', 'w', 'o', |
3406 'r', 'l', 'd', '!', | 3408 'r', 'l', 'd', '!', |
3407 }; | 3409 }; |
(...skipping 14 matching lines...) Expand all Loading... |
3422 // guid | 3424 // guid |
3423 0x10, 0x32, 0x54, 0x76, | 3425 0x10, 0x32, 0x54, 0x76, |
3424 0x98, 0xBA, 0xDC, 0xFE, | 3426 0x98, 0xBA, 0xDC, 0xFE, |
3425 // packet sequence number | 3427 // packet sequence number |
3426 0xBC, 0x9A, 0x78, 0x56, | 3428 0xBC, 0x9A, 0x78, 0x56, |
3427 0x34, 0x12, | 3429 0x34, 0x12, |
3428 // Entropy | 3430 // Entropy |
3429 0x01, | 3431 0x01, |
3430 | 3432 |
3431 // frame type (stream frame with fin) | 3433 // frame type (stream frame with fin) |
3432 0xFE, | 3434 static_cast<unsigned char>( |
| 3435 GetParam() < QUIC_VERSION_10 ? 0xFE : 0xFF), |
3433 // stream id | 3436 // stream id |
3434 0x04, 0x03, 0x02, 0x01, | 3437 0x04, 0x03, 0x02, 0x01, |
3435 // offset | 3438 // offset |
3436 0x54, 0x76, 0x10, 0x32, | 3439 0x54, 0x76, 0x10, 0x32, |
3437 0xDC, 0xFE, 0x98, 0xBA, | 3440 0xDC, 0xFE, 0x98, 0xBA, |
3438 // data length | 3441 // data length |
3439 0x0c, 0x00, | 3442 0x0c, 0x00, |
3440 // data | 3443 // data |
3441 'h', 'e', 'l', 'l', | 3444 'h', 'e', 'l', 'l', |
3442 'o', ' ', 'w', 'o', | 3445 'o', ' ', 'w', 'o', |
3443 'r', 'l', 'd', '!', | 3446 'r', 'l', 'd', '!', |
3444 | 3447 |
3445 // frame type (ack frame) | 3448 // frame type (ack frame) |
3446 0x02, | 3449 static_cast<unsigned char>( |
| 3450 GetParam() < QUIC_VERSION_10 ? 0x01 : 0x40), |
3447 // entropy hash of sent packets till least awaiting - 1. | 3451 // entropy hash of sent packets till least awaiting - 1. |
3448 0x14, | 3452 0x14, |
3449 // least packet sequence number awaiting an ack | 3453 // least packet sequence number awaiting an ack |
3450 0xA0, 0x9A, 0x78, 0x56, | 3454 0xA0, 0x9A, 0x78, 0x56, |
3451 0x34, 0x12, | 3455 0x34, 0x12, |
3452 // entropy hash of all received packets. | 3456 // entropy hash of all received packets. |
3453 0x43, | 3457 0x43, |
3454 // largest observed packet sequence number | 3458 // largest observed packet sequence number |
3455 0xBF, 0x9A, 0x78, 0x56, | 3459 0xBF, 0x9A, 0x78, 0x56, |
3456 0x34, 0x12, | 3460 0x34, 0x12, |
(...skipping 24 matching lines...) Expand all Loading... |
3481 // guid | 3485 // guid |
3482 0x10, 0x32, 0x54, 0x76, | 3486 0x10, 0x32, 0x54, 0x76, |
3483 0x98, 0xBA, 0xDC, 0xFE, | 3487 0x98, 0xBA, 0xDC, 0xFE, |
3484 // packet sequence number | 3488 // packet sequence number |
3485 0xBC, 0x9A, 0x78, 0x56, | 3489 0xBC, 0x9A, 0x78, 0x56, |
3486 0x34, 0x12, | 3490 0x34, 0x12, |
3487 // private flags | 3491 // private flags |
3488 0x00, | 3492 0x00, |
3489 | 3493 |
3490 // frame type (connection close frame) | 3494 // frame type (connection close frame) |
3491 static_cast<unsigned char>(0x2F), | 3495 static_cast<unsigned char>( |
| 3496 GetParam() < QUIC_VERSION_10 ? 0x2F : 0x02), |
3492 // error code | 3497 // error code |
3493 0x11, 0x00, 0x00, 0x00, | 3498 0x11, 0x00, 0x00, 0x00, |
3494 // error details length | 3499 // error details length |
3495 0x0d, 0x00, | 3500 0x0d, 0x00, |
3496 // error details | 3501 // error details |
3497 'b', 'e', 'c', 'a', | 3502 'b', 'e', 'c', 'a', |
3498 'u', 's', 'e', ' ', | 3503 'u', 's', 'e', ' ', |
3499 'I', ' ', 'c', 'a', | 3504 'I', ' ', 'c', 'a', |
3500 'n', | 3505 'n', |
3501 | 3506 |
(...skipping 25 matching lines...) Expand all Loading... |
3527 EXPECT_CALL(visitor, OnConnectionCloseFrame(_)).Times(0); | 3532 EXPECT_CALL(visitor, OnConnectionCloseFrame(_)).Times(0); |
3528 EXPECT_CALL(visitor, OnPacketComplete()); | 3533 EXPECT_CALL(visitor, OnPacketComplete()); |
3529 | 3534 |
3530 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 3535 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
3531 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 3536 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
3532 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 3537 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
3533 } | 3538 } |
3534 | 3539 |
3535 } // namespace test | 3540 } // namespace test |
3536 } // namespace net | 3541 } // namespace net |
OLD | NEW |