| 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 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ | 5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ |
| 6 #define NET_QUIC_QUIC_PROTOCOL_H_ | 6 #define NET_QUIC_QUIC_PROTOCOL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 // | 380 // |
| 381 // IMPORTANT: if you are adding to this list, follow the instructions at | 381 // IMPORTANT: if you are adding to this list, follow the instructions at |
| 382 // http://sites/quic/adding-and-removing-versions | 382 // http://sites/quic/adding-and-removing-versions |
| 383 static const QuicVersion kSupportedQuicVersions[] = { | 383 static const QuicVersion kSupportedQuicVersions[] = { |
| 384 QUIC_VERSION_36, QUIC_VERSION_35, QUIC_VERSION_34, QUIC_VERSION_33, | 384 QUIC_VERSION_36, QUIC_VERSION_35, QUIC_VERSION_34, QUIC_VERSION_33, |
| 385 QUIC_VERSION_32, QUIC_VERSION_31, QUIC_VERSION_30}; | 385 QUIC_VERSION_32, QUIC_VERSION_31, QUIC_VERSION_30}; |
| 386 | 386 |
| 387 typedef std::vector<QuicVersion> QuicVersionVector; | 387 typedef std::vector<QuicVersion> QuicVersionVector; |
| 388 | 388 |
| 389 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 389 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
| 390 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); | 390 NET_EXPORT_PRIVATE QuicVersionVector AllSupportedVersions(); |
| 391 |
| 392 // Returns a vector of QUIC versions from kSupportedQuicVersions which exclude |
| 393 // any versions which are disabled by flags. |
| 394 NET_EXPORT_PRIVATE QuicVersionVector CurrentSupportedVersions(); |
| 391 | 395 |
| 392 // Returns a vector of QUIC versions from |versions| which exclude any versions | 396 // Returns a vector of QUIC versions from |versions| which exclude any versions |
| 393 // which are disabled by flags. | 397 // which are disabled by flags. |
| 394 NET_EXPORT_PRIVATE QuicVersionVector | 398 NET_EXPORT_PRIVATE QuicVersionVector |
| 395 FilterSupportedVersions(QuicVersionVector versions); | 399 FilterSupportedVersions(QuicVersionVector versions); |
| 396 | 400 |
| 401 // Returns QUIC version of |index| in result of |versions|. Returns |
| 402 // QUIC_VERSION_UNSUPPORTED if |index| is out of bounds. |
| 403 NET_EXPORT_PRIVATE QuicVersionVector |
| 404 VersionOfIndex(const QuicVersionVector& versions, int index); |
| 405 |
| 397 // QuicTag is written to and read from the wire, but we prefer to use | 406 // QuicTag is written to and read from the wire, but we prefer to use |
| 398 // the more readable QuicVersion at other levels. | 407 // the more readable QuicVersion at other levels. |
| 399 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 | 408 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 |
| 400 // if QuicVersion is unsupported. | 409 // if QuicVersion is unsupported. |
| 401 NET_EXPORT_PRIVATE QuicTag QuicVersionToQuicTag(const QuicVersion version); | 410 NET_EXPORT_PRIVATE QuicTag QuicVersionToQuicTag(const QuicVersion version); |
| 402 | 411 |
| 403 // Returns appropriate QuicVersion from a QuicTag. | 412 // Returns appropriate QuicVersion from a QuicTag. |
| 404 // Returns QUIC_VERSION_UNSUPPORTED if version_tag cannot be understood. | 413 // Returns QUIC_VERSION_UNSUPPORTED if version_tag cannot be understood. |
| 405 NET_EXPORT_PRIVATE QuicVersion QuicTagToQuicVersion(const QuicTag version_tag); | 414 NET_EXPORT_PRIVATE QuicVersion QuicTagToQuicVersion(const QuicTag version_tag); |
| 406 | 415 |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 }; | 1261 }; |
| 1253 // QuicFrameType consumes 8 bytes with padding. | 1262 // QuicFrameType consumes 8 bytes with padding. |
| 1254 static_assert(sizeof(QuicFrame) <= 16, | 1263 static_assert(sizeof(QuicFrame) <= 16, |
| 1255 "Frames larger than 8 bytes should be referenced by pointer."); | 1264 "Frames larger than 8 bytes should be referenced by pointer."); |
| 1256 | 1265 |
| 1257 typedef std::vector<QuicFrame> QuicFrames; | 1266 typedef std::vector<QuicFrame> QuicFrames; |
| 1258 | 1267 |
| 1259 class NET_EXPORT_PRIVATE QuicData { | 1268 class NET_EXPORT_PRIVATE QuicData { |
| 1260 public: | 1269 public: |
| 1261 QuicData(const char* buffer, size_t length); | 1270 QuicData(const char* buffer, size_t length); |
| 1262 QuicData(char* buffer, size_t length, bool owns_buffer); | 1271 QuicData(const char* buffer, size_t length, bool owns_buffer); |
| 1263 virtual ~QuicData(); | 1272 virtual ~QuicData(); |
| 1264 | 1273 |
| 1265 base::StringPiece AsStringPiece() const { | 1274 base::StringPiece AsStringPiece() const { |
| 1266 return base::StringPiece(data(), length()); | 1275 return base::StringPiece(data(), length()); |
| 1267 } | 1276 } |
| 1268 | 1277 |
| 1269 const char* data() const { return buffer_; } | 1278 const char* data() const { return buffer_; } |
| 1270 size_t length() const { return length_; } | 1279 size_t length() const { return length_; } |
| 1271 bool owns_buffer() const { return owns_buffer_; } | 1280 bool owns_buffer() const { return owns_buffer_; } |
| 1272 | 1281 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 const bool includes_path_id_; | 1313 const bool includes_path_id_; |
| 1305 const bool includes_diversification_nonce_; | 1314 const bool includes_diversification_nonce_; |
| 1306 const QuicPacketNumberLength packet_number_length_; | 1315 const QuicPacketNumberLength packet_number_length_; |
| 1307 | 1316 |
| 1308 DISALLOW_COPY_AND_ASSIGN(QuicPacket); | 1317 DISALLOW_COPY_AND_ASSIGN(QuicPacket); |
| 1309 }; | 1318 }; |
| 1310 | 1319 |
| 1311 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { | 1320 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { |
| 1312 public: | 1321 public: |
| 1313 QuicEncryptedPacket(const char* buffer, size_t length); | 1322 QuicEncryptedPacket(const char* buffer, size_t length); |
| 1314 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer); | 1323 QuicEncryptedPacket(const char* buffer, size_t length, bool owns_buffer); |
| 1315 | 1324 |
| 1316 // Clones the packet into a new packet which owns the buffer. | 1325 // Clones the packet into a new packet which owns the buffer. |
| 1317 QuicEncryptedPacket* Clone() const; | 1326 QuicEncryptedPacket* Clone() const; |
| 1318 | 1327 |
| 1319 // By default, gtest prints the raw bytes of an object. The bool data | 1328 // By default, gtest prints the raw bytes of an object. The bool data |
| 1320 // member (in the base class QuicData) causes this object to have padding | 1329 // member (in the base class QuicData) causes this object to have padding |
| 1321 // bytes, which causes the default gtest object printer to read | 1330 // bytes, which causes the default gtest object printer to read |
| 1322 // uninitialize memory. So we need to teach gtest how to print this object. | 1331 // uninitialize memory. So we need to teach gtest how to print this object. |
| 1323 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 1332 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 1324 std::ostream& os, | 1333 std::ostream& os, |
| 1325 const QuicEncryptedPacket& s); | 1334 const QuicEncryptedPacket& s); |
| 1326 | 1335 |
| 1327 private: | 1336 private: |
| 1328 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); | 1337 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); |
| 1329 }; | 1338 }; |
| 1330 | 1339 |
| 1331 // A received encrypted QUIC packet, with a recorded time of receipt. | 1340 // A received encrypted QUIC packet, with a recorded time of receipt. |
| 1332 class NET_EXPORT_PRIVATE QuicReceivedPacket : public QuicEncryptedPacket { | 1341 class NET_EXPORT_PRIVATE QuicReceivedPacket : public QuicEncryptedPacket { |
| 1333 public: | 1342 public: |
| 1334 QuicReceivedPacket(const char* buffer, size_t length, QuicTime receipt_time); | 1343 QuicReceivedPacket(const char* buffer, size_t length, QuicTime receipt_time); |
| 1335 QuicReceivedPacket(char* buffer, | 1344 QuicReceivedPacket(const char* buffer, |
| 1336 size_t length, | 1345 size_t length, |
| 1337 QuicTime receipt_time, | 1346 QuicTime receipt_time, |
| 1338 bool owns_buffer); | 1347 bool owns_buffer); |
| 1348 QuicReceivedPacket(const char* buffer, |
| 1349 size_t length, |
| 1350 QuicTime receipt_time, |
| 1351 bool owns_buffer, |
| 1352 int ttl, |
| 1353 bool ttl_valid); |
| 1339 | 1354 |
| 1340 // Clones the packet into a new packet which owns the buffer. | 1355 // Clones the packet into a new packet which owns the buffer. |
| 1341 QuicReceivedPacket* Clone() const; | 1356 QuicReceivedPacket* Clone() const; |
| 1342 | 1357 |
| 1343 // Returns the time at which the packet was received. | 1358 // Returns the time at which the packet was received. |
| 1344 QuicTime receipt_time() const { return receipt_time_; } | 1359 QuicTime receipt_time() const { return receipt_time_; } |
| 1345 | 1360 |
| 1361 // This is the TTL of the packet, assuming ttl_vaild_ is true. |
| 1362 int ttl() const { return ttl_; } |
| 1363 |
| 1346 // By default, gtest prints the raw bytes of an object. The bool data | 1364 // By default, gtest prints the raw bytes of an object. The bool data |
| 1347 // member (in the base class QuicData) causes this object to have padding | 1365 // member (in the base class QuicData) causes this object to have padding |
| 1348 // bytes, which causes the default gtest object printer to read | 1366 // bytes, which causes the default gtest object printer to read |
| 1349 // uninitialize memory. So we need to teach gtest how to print this object. | 1367 // uninitialize memory. So we need to teach gtest how to print this object. |
| 1350 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 1368 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 1351 std::ostream& os, | 1369 std::ostream& os, |
| 1352 const QuicReceivedPacket& s); | 1370 const QuicReceivedPacket& s); |
| 1353 | 1371 |
| 1354 private: | 1372 private: |
| 1355 const QuicTime receipt_time_; | 1373 const QuicTime receipt_time_; |
| 1374 int ttl_; |
| 1356 | 1375 |
| 1357 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacket); | 1376 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacket); |
| 1358 }; | 1377 }; |
| 1359 | 1378 |
| 1360 // Pure virtual class to listen for packet acknowledgements. | 1379 // Pure virtual class to listen for packet acknowledgements. |
| 1361 class NET_EXPORT_PRIVATE QuicAckListenerInterface | 1380 class NET_EXPORT_PRIVATE QuicAckListenerInterface |
| 1362 : public base::RefCounted<QuicAckListenerInterface> { | 1381 : public base::RefCounted<QuicAckListenerInterface> { |
| 1363 public: | 1382 public: |
| 1364 QuicAckListenerInterface() {} | 1383 QuicAckListenerInterface() {} |
| 1365 | 1384 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1395 public: | 1414 public: |
| 1396 explicit QuicVersionManager(QuicVersionVector supported_versions); | 1415 explicit QuicVersionManager(QuicVersionVector supported_versions); |
| 1397 ~QuicVersionManager(); | 1416 ~QuicVersionManager(); |
| 1398 | 1417 |
| 1399 // Returns supported versions based on flags. | 1418 // Returns supported versions based on flags. |
| 1400 const QuicVersionVector& GetSupportedVersions(); | 1419 const QuicVersionVector& GetSupportedVersions(); |
| 1401 | 1420 |
| 1402 private: | 1421 private: |
| 1403 // FLAGS_quic_enable_version_35 | 1422 // FLAGS_quic_enable_version_35 |
| 1404 bool enable_quic_version_35_; | 1423 bool enable_quic_version_35_; |
| 1405 // FLAGS_quic_enable_version_36 | 1424 // FLAGS_quic_enable_version_36_v2 |
| 1406 bool enable_quic_version_36_; | 1425 bool enable_quic_version_36_; |
| 1407 // The list of versions that may be supported. | 1426 // The list of versions that may be supported. |
| 1408 QuicVersionVector allowed_supported_versions_; | 1427 QuicVersionVector allowed_supported_versions_; |
| 1409 // This vector contains QUIC versions which are currently supported based | 1428 // This vector contains QUIC versions which are currently supported based |
| 1410 // on flags. | 1429 // on flags. |
| 1411 QuicVersionVector filtered_supported_versions_; | 1430 QuicVersionVector filtered_supported_versions_; |
| 1412 }; | 1431 }; |
| 1413 | 1432 |
| 1414 struct NET_EXPORT_PRIVATE AckListenerWrapper { | 1433 struct NET_EXPORT_PRIVATE AckListenerWrapper { |
| 1415 AckListenerWrapper(QuicAckListenerInterface* listener, | 1434 AckListenerWrapper(QuicAckListenerInterface* listener, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 : iov(iov), iov_count(iov_count), total_length(total_length) {} | 1554 : iov(iov), iov_count(iov_count), total_length(total_length) {} |
| 1536 | 1555 |
| 1537 const struct iovec* iov; | 1556 const struct iovec* iov; |
| 1538 const int iov_count; | 1557 const int iov_count; |
| 1539 const size_t total_length; | 1558 const size_t total_length; |
| 1540 }; | 1559 }; |
| 1541 | 1560 |
| 1542 } // namespace net | 1561 } // namespace net |
| 1543 | 1562 |
| 1544 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1563 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
| OLD | NEW |