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 <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 enum QuicFrameType { | 149 enum QuicFrameType { |
150 // Regular frame types. The values set here cannot change without the | 150 // Regular frame types. The values set here cannot change without the |
151 // introduction of a new QUIC version. | 151 // introduction of a new QUIC version. |
152 PADDING_FRAME = 0, | 152 PADDING_FRAME = 0, |
153 RST_STREAM_FRAME = 1, | 153 RST_STREAM_FRAME = 1, |
154 CONNECTION_CLOSE_FRAME = 2, | 154 CONNECTION_CLOSE_FRAME = 2, |
155 GOAWAY_FRAME = 3, | 155 GOAWAY_FRAME = 3, |
156 WINDOW_UPDATE_FRAME = 4, | 156 WINDOW_UPDATE_FRAME = 4, |
157 BLOCKED_FRAME = 5, | 157 BLOCKED_FRAME = 5, |
| 158 STOP_WAITING_FRAME = 6, |
158 | 159 |
159 // STREAM, ACK, and CONGESTION_FEEDBACK frames are special frames. They are | 160 // STREAM, ACK, and CONGESTION_FEEDBACK frames are special frames. They are |
160 // encoded differently on the wire and their values do not need to be stable. | 161 // encoded differently on the wire and their values do not need to be stable. |
161 STREAM_FRAME, | 162 STREAM_FRAME, |
162 ACK_FRAME, | 163 ACK_FRAME, |
163 CONGESTION_FEEDBACK_FRAME, | 164 CONGESTION_FEEDBACK_FRAME, |
164 NUM_FRAME_TYPES | 165 NUM_FRAME_TYPES |
165 }; | 166 }; |
166 | 167 |
167 enum QuicGuidLength { | 168 enum QuicGuidLength { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // kSupportedQuicVersions (if appropriate), and also add a new case to the | 249 // kSupportedQuicVersions (if appropriate), and also add a new case to the |
249 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and | 250 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
250 // QuicVersionToString. | 251 // QuicVersionToString. |
251 enum QuicVersion { | 252 enum QuicVersion { |
252 // Special case to indicate unknown/unsupported QUIC version. | 253 // Special case to indicate unknown/unsupported QUIC version. |
253 QUIC_VERSION_UNSUPPORTED = 0, | 254 QUIC_VERSION_UNSUPPORTED = 0, |
254 | 255 |
255 QUIC_VERSION_12 = 12, | 256 QUIC_VERSION_12 = 12, |
256 QUIC_VERSION_13 = 13, | 257 QUIC_VERSION_13 = 13, |
257 QUIC_VERSION_14 = 14, | 258 QUIC_VERSION_14 = 14, |
258 QUIC_VERSION_15 = 15, // Current version. | 259 QUIC_VERSION_15 = 15, |
| 260 QUIC_VERSION_16 = 16, // Current version. |
259 }; | 261 }; |
260 | 262 |
261 // This vector contains QUIC versions which we currently support. | 263 // This vector contains QUIC versions which we currently support. |
262 // This should be ordered such that the highest supported version is the first | 264 // This should be ordered such that the highest supported version is the first |
263 // element, with subsequent elements in descending order (versions can be | 265 // element, with subsequent elements in descending order (versions can be |
264 // skipped as necessary). | 266 // skipped as necessary). |
265 // | 267 // |
266 // IMPORTANT: if you are addding to this list, follow the instructions at | 268 // IMPORTANT: if you are addding to this list, follow the instructions at |
267 // http://sites/quic/adding-and-removing-versions | 269 // http://sites/quic/adding-and-removing-versions |
268 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_15, | 270 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_16, |
| 271 QUIC_VERSION_15, |
269 QUIC_VERSION_14, | 272 QUIC_VERSION_14, |
270 QUIC_VERSION_13, | 273 QUIC_VERSION_13, |
271 QUIC_VERSION_12}; | 274 QUIC_VERSION_12}; |
272 | 275 |
273 typedef std::vector<QuicVersion> QuicVersionVector; | 276 typedef std::vector<QuicVersion> QuicVersionVector; |
274 | 277 |
275 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 278 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
276 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); | 279 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); |
277 | 280 |
278 // QuicTag is written to and read from the wire, but we prefer to use | 281 // QuicTag is written to and read from the wire, but we prefer to use |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 // RST_STREAM frame data is malformed. | 372 // RST_STREAM frame data is malformed. |
370 QUIC_INVALID_RST_STREAM_DATA = 6, | 373 QUIC_INVALID_RST_STREAM_DATA = 6, |
371 // CONNECTION_CLOSE frame data is malformed. | 374 // CONNECTION_CLOSE frame data is malformed. |
372 QUIC_INVALID_CONNECTION_CLOSE_DATA = 7, | 375 QUIC_INVALID_CONNECTION_CLOSE_DATA = 7, |
373 // GOAWAY frame data is malformed. | 376 // GOAWAY frame data is malformed. |
374 QUIC_INVALID_GOAWAY_DATA = 8, | 377 QUIC_INVALID_GOAWAY_DATA = 8, |
375 // WINDOW_UPDATE frame data is malformed. | 378 // WINDOW_UPDATE frame data is malformed. |
376 QUIC_INVALID_WINDOW_UPDATE_DATA = 57, | 379 QUIC_INVALID_WINDOW_UPDATE_DATA = 57, |
377 // BLOCKED frame data is malformed. | 380 // BLOCKED frame data is malformed. |
378 QUIC_INVALID_BLOCKED_DATA = 58, | 381 QUIC_INVALID_BLOCKED_DATA = 58, |
| 382 // STOP_WAITING frame data is malformed. |
| 383 QUIC_INVALID_STOP_WAITING_DATA = 60, |
379 // ACK frame data is malformed. | 384 // ACK frame data is malformed. |
380 QUIC_INVALID_ACK_DATA = 9, | 385 QUIC_INVALID_ACK_DATA = 9, |
381 // CONGESTION_FEEDBACK frame data is malformed. | 386 // CONGESTION_FEEDBACK frame data is malformed. |
382 QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47, | 387 QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47, |
383 // Version negotiation packet is malformed. | 388 // Version negotiation packet is malformed. |
384 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, | 389 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, |
385 // Public RST packet is malformed. | 390 // Public RST packet is malformed. |
386 QUIC_INVALID_PUBLIC_RST_PACKET = 11, | 391 QUIC_INVALID_PUBLIC_RST_PACKET = 11, |
387 // There was an error decrypting. | 392 // There was an error decrypting. |
388 QUIC_DECRYPTION_FAILURE = 12, | 393 QUIC_DECRYPTION_FAILURE = 12, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 // We failed to setup the symmetric keys for a connection. | 479 // We failed to setup the symmetric keys for a connection. |
475 QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED = 53, | 480 QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED = 53, |
476 // A handshake message arrived, but we are still validating the | 481 // A handshake message arrived, but we are still validating the |
477 // previous handshake message. | 482 // previous handshake message. |
478 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54, | 483 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54, |
479 // This connection involved a version negotiation which appears to have been | 484 // This connection involved a version negotiation which appears to have been |
480 // tampered with. | 485 // tampered with. |
481 QUIC_VERSION_NEGOTIATION_MISMATCH = 55, | 486 QUIC_VERSION_NEGOTIATION_MISMATCH = 55, |
482 | 487 |
483 // No error. Used as bound while iterating. | 488 // No error. Used as bound while iterating. |
484 QUIC_LAST_ERROR = 60, | 489 QUIC_LAST_ERROR = 61, |
485 }; | 490 }; |
486 | 491 |
487 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { | 492 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { |
488 QuicPacketPublicHeader(); | 493 QuicPacketPublicHeader(); |
489 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); | 494 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); |
490 ~QuicPacketPublicHeader(); | 495 ~QuicPacketPublicHeader(); |
491 | 496 |
492 // Universal header. All QuicPacket headers will have a guid and public flags. | 497 // Universal header. All QuicPacket headers will have a guid and public flags. |
493 QuicGuid guid; | 498 QuicGuid guid; |
494 QuicGuidLength guid_length; | 499 QuicGuidLength guid_length; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 bool NET_EXPORT_PRIVATE IsAwaitingPacket( | 625 bool NET_EXPORT_PRIVATE IsAwaitingPacket( |
621 const ReceivedPacketInfo& received_info, | 626 const ReceivedPacketInfo& received_info, |
622 QuicPacketSequenceNumber sequence_number); | 627 QuicPacketSequenceNumber sequence_number); |
623 | 628 |
624 // Inserts missing packets between [lower, higher). | 629 // Inserts missing packets between [lower, higher). |
625 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( | 630 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( |
626 ReceivedPacketInfo* received_info, | 631 ReceivedPacketInfo* received_info, |
627 QuicPacketSequenceNumber lower, | 632 QuicPacketSequenceNumber lower, |
628 QuicPacketSequenceNumber higher); | 633 QuicPacketSequenceNumber higher); |
629 | 634 |
630 struct NET_EXPORT_PRIVATE SentPacketInfo { | 635 struct NET_EXPORT_PRIVATE QuicStopWaitingFrame { |
631 SentPacketInfo(); | 636 QuicStopWaitingFrame(); |
632 ~SentPacketInfo(); | 637 ~QuicStopWaitingFrame(); |
633 | 638 |
634 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 639 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
635 std::ostream& os, const SentPacketInfo& s); | 640 std::ostream& os, const QuicStopWaitingFrame& s); |
| 641 |
636 // Entropy hash of all packets up to, but not including, the least unacked | 642 // Entropy hash of all packets up to, but not including, the least unacked |
637 // packet. | 643 // packet. |
638 QuicPacketEntropyHash entropy_hash; | 644 QuicPacketEntropyHash entropy_hash; |
639 // The lowest packet we've sent which is unacked, and we expect an ack for. | 645 // The lowest packet we've sent which is unacked, and we expect an ack for. |
640 QuicPacketSequenceNumber least_unacked; | 646 QuicPacketSequenceNumber least_unacked; |
641 }; | 647 }; |
642 | 648 |
643 struct NET_EXPORT_PRIVATE QuicAckFrame { | 649 struct NET_EXPORT_PRIVATE QuicAckFrame { |
644 QuicAckFrame(); | 650 QuicAckFrame(); |
645 // Testing convenience method to construct a QuicAckFrame with all packets | 651 // Testing convenience method to construct a QuicAckFrame with all packets |
646 // from least_unacked to largest_observed acked. | 652 // from least_unacked to largest_observed acked. |
647 QuicAckFrame(QuicPacketSequenceNumber largest_observed, | 653 QuicAckFrame(QuicPacketSequenceNumber largest_observed, |
648 QuicTime largest_observed_receive_time, | 654 QuicTime largest_observed_receive_time, |
649 QuicPacketSequenceNumber least_unacked); | 655 QuicPacketSequenceNumber least_unacked); |
650 | 656 |
651 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 657 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
652 std::ostream& os, const QuicAckFrame& s); | 658 std::ostream& os, const QuicAckFrame& s); |
653 | 659 |
654 SentPacketInfo sent_info; | 660 QuicStopWaitingFrame sent_info; |
655 ReceivedPacketInfo received_info; | 661 ReceivedPacketInfo received_info; |
656 }; | 662 }; |
657 | 663 |
658 // Defines for all types of congestion feedback that will be negotiated in QUIC, | 664 // Defines for all types of congestion feedback that will be negotiated in QUIC, |
659 // kTCP MUST be supported by all QUIC implementations to guarantee 100% | 665 // kTCP MUST be supported by all QUIC implementations to guarantee 100% |
660 // compatibility. | 666 // compatibility. |
661 enum CongestionFeedbackType { | 667 enum CongestionFeedbackType { |
662 kTCP, // Used to mimic TCP. | 668 kTCP, // Used to mimic TCP. |
663 kInterArrival, // Use additional inter arrival information. | 669 kInterArrival, // Use additional inter arrival information. |
664 kFixRate, // Provided for testing. | 670 kFixRate, // Provided for testing. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 }; | 799 }; |
794 | 800 |
795 struct NET_EXPORT_PRIVATE QuicFrame { | 801 struct NET_EXPORT_PRIVATE QuicFrame { |
796 QuicFrame(); | 802 QuicFrame(); |
797 explicit QuicFrame(QuicPaddingFrame* padding_frame); | 803 explicit QuicFrame(QuicPaddingFrame* padding_frame); |
798 explicit QuicFrame(QuicStreamFrame* stream_frame); | 804 explicit QuicFrame(QuicStreamFrame* stream_frame); |
799 explicit QuicFrame(QuicAckFrame* frame); | 805 explicit QuicFrame(QuicAckFrame* frame); |
800 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); | 806 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); |
801 explicit QuicFrame(QuicRstStreamFrame* frame); | 807 explicit QuicFrame(QuicRstStreamFrame* frame); |
802 explicit QuicFrame(QuicConnectionCloseFrame* frame); | 808 explicit QuicFrame(QuicConnectionCloseFrame* frame); |
| 809 explicit QuicFrame(QuicStopWaitingFrame* frame); |
803 explicit QuicFrame(QuicGoAwayFrame* frame); | 810 explicit QuicFrame(QuicGoAwayFrame* frame); |
804 explicit QuicFrame(QuicWindowUpdateFrame* frame); | 811 explicit QuicFrame(QuicWindowUpdateFrame* frame); |
805 explicit QuicFrame(QuicBlockedFrame* frame); | 812 explicit QuicFrame(QuicBlockedFrame* frame); |
806 | 813 |
807 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 814 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
808 std::ostream& os, const QuicFrame& frame); | 815 std::ostream& os, const QuicFrame& frame); |
809 | 816 |
810 QuicFrameType type; | 817 QuicFrameType type; |
811 union { | 818 union { |
812 QuicPaddingFrame* padding_frame; | 819 QuicPaddingFrame* padding_frame; |
813 QuicStreamFrame* stream_frame; | 820 QuicStreamFrame* stream_frame; |
814 QuicAckFrame* ack_frame; | 821 QuicAckFrame* ack_frame; |
815 QuicCongestionFeedbackFrame* congestion_feedback_frame; | 822 QuicCongestionFeedbackFrame* congestion_feedback_frame; |
| 823 QuicStopWaitingFrame* stop_waiting_frame; |
816 QuicRstStreamFrame* rst_stream_frame; | 824 QuicRstStreamFrame* rst_stream_frame; |
817 QuicConnectionCloseFrame* connection_close_frame; | 825 QuicConnectionCloseFrame* connection_close_frame; |
818 QuicGoAwayFrame* goaway_frame; | 826 QuicGoAwayFrame* goaway_frame; |
819 QuicWindowUpdateFrame* window_update_frame; | 827 QuicWindowUpdateFrame* window_update_frame; |
820 QuicBlockedFrame* blocked_frame; | 828 QuicBlockedFrame* blocked_frame; |
821 }; | 829 }; |
822 }; | 830 }; |
823 | 831 |
824 typedef std::vector<QuicFrame> QuicFrames; | 832 typedef std::vector<QuicFrame> QuicFrames; |
825 | 833 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 WriteStatus status; | 1011 WriteStatus status; |
1004 union { | 1012 union { |
1005 int bytes_written; // only valid when status is OK | 1013 int bytes_written; // only valid when status is OK |
1006 int error_code; // only valid when status is ERROR | 1014 int error_code; // only valid when status is ERROR |
1007 }; | 1015 }; |
1008 }; | 1016 }; |
1009 | 1017 |
1010 } // namespace net | 1018 } // namespace net |
1011 | 1019 |
1012 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1020 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
OLD | NEW |