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 <list> | 10 #include <list> |
(...skipping 30 matching lines...) Expand all Loading... |
41 typedef uint8 QuicPacketEntropyHash; | 41 typedef uint8 QuicPacketEntropyHash; |
42 typedef uint32 QuicHeaderId; | 42 typedef uint32 QuicHeaderId; |
43 // QuicTag is the type of a tag in the wire protocol. | 43 // QuicTag is the type of a tag in the wire protocol. |
44 typedef uint32 QuicTag; | 44 typedef uint32 QuicTag; |
45 typedef std::vector<QuicTag> QuicTagVector; | 45 typedef std::vector<QuicTag> QuicTagVector; |
46 typedef std::map<QuicTag, std::string> QuicTagValueMap; | 46 typedef std::map<QuicTag, std::string> QuicTagValueMap; |
47 // TODO(rtenneti): Didn't use SpdyPriority because SpdyPriority is uint8 and | 47 // TODO(rtenneti): Didn't use SpdyPriority because SpdyPriority is uint8 and |
48 // QuicPriority is uint32. Use SpdyPriority when we change the QUIC_VERSION. | 48 // QuicPriority is uint32. Use SpdyPriority when we change the QUIC_VERSION. |
49 typedef uint32 QuicPriority; | 49 typedef uint32 QuicPriority; |
50 | 50 |
51 // TODO(rch): Consider Quic specific names for these constants. | |
52 // Default and initial maximum size in bytes of a QUIC packet. | 51 // Default and initial maximum size in bytes of a QUIC packet. |
53 const QuicByteCount kDefaultMaxPacketSize = 1350; | 52 const QuicByteCount kDefaultMaxPacketSize = 1350; |
| 53 // Default initial maximum size in bytes of a QUIC packet for servers. |
| 54 const QuicByteCount kDefaultServerMaxPacketSize = 1000; |
54 // The maximum packet size of any QUIC packet, based on ethernet's max size, | 55 // The maximum packet size of any QUIC packet, based on ethernet's max size, |
55 // minus the IP and UDP headers. IPv6 has a 40 byte header, UPD adds an | 56 // minus the IP and UDP headers. IPv6 has a 40 byte header, UPD adds an |
56 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's | 57 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's |
57 // max packet size is 1500 bytes, 1500 - 48 = 1452. | 58 // max packet size is 1500 bytes, 1500 - 48 = 1452. |
58 const QuicByteCount kMaxPacketSize = 1452; | 59 const QuicByteCount kMaxPacketSize = 1452; |
59 // Default maximum packet size used in Linux TCP implementations. | 60 // Default maximum packet size used in Linux TCP implementations. |
60 const QuicByteCount kDefaultTCPMSS = 1460; | 61 const QuicByteCount kDefaultTCPMSS = 1460; |
61 | 62 |
62 // We match SPDY's use of 32 when secure (since we'd compete with SPDY). | 63 // We match SPDY's use of 32 when secure (since we'd compete with SPDY). |
63 const QuicPacketCount kInitialCongestionWindowSecure = 32; | 64 const QuicPacketCount kInitialCongestionWindowSecure = 32; |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 // The peer sent too much data, violating flow control. | 507 // The peer sent too much data, violating flow control. |
507 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA = 63, | 508 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA = 63, |
508 // The peer received an invalid flow control window. | 509 // The peer received an invalid flow control window. |
509 QUIC_FLOW_CONTROL_INVALID_WINDOW = 64, | 510 QUIC_FLOW_CONTROL_INVALID_WINDOW = 64, |
510 // The connection has been IP pooled into an existing connection. | 511 // The connection has been IP pooled into an existing connection. |
511 QUIC_CONNECTION_IP_POOLED = 62, | 512 QUIC_CONNECTION_IP_POOLED = 62, |
512 // The connection has too many outstanding sent packets. | 513 // The connection has too many outstanding sent packets. |
513 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS = 68, | 514 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS = 68, |
514 // The connection has too many outstanding received packets. | 515 // The connection has too many outstanding received packets. |
515 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS = 69, | 516 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS = 69, |
| 517 // The quic connection job to load server config is cancelled. |
| 518 QUIC_CONNECTION_CANCELLED = 70, |
516 | 519 |
517 // Crypto errors. | 520 // Crypto errors. |
518 | 521 |
519 // Hanshake failed. | 522 // Hanshake failed. |
520 QUIC_HANDSHAKE_FAILED = 28, | 523 QUIC_HANDSHAKE_FAILED = 28, |
521 // Handshake message contained out of order tags. | 524 // Handshake message contained out of order tags. |
522 QUIC_CRYPTO_TAGS_OUT_OF_ORDER = 29, | 525 QUIC_CRYPTO_TAGS_OUT_OF_ORDER = 29, |
523 // Handshake message contained too many entries. | 526 // Handshake message contained too many entries. |
524 QUIC_CRYPTO_TOO_MANY_ENTRIES = 30, | 527 QUIC_CRYPTO_TOO_MANY_ENTRIES = 30, |
525 // Handshake message contained an invalid value length. | 528 // Handshake message contained an invalid value length. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // A handshake message arrived, but we are still validating the | 566 // A handshake message arrived, but we are still validating the |
564 // previous handshake message. | 567 // previous handshake message. |
565 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54, | 568 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54, |
566 // A server config update arrived before the handshake is complete. | 569 // A server config update arrived before the handshake is complete. |
567 QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE = 65, | 570 QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE = 65, |
568 // This connection involved a version negotiation which appears to have been | 571 // This connection involved a version negotiation which appears to have been |
569 // tampered with. | 572 // tampered with. |
570 QUIC_VERSION_NEGOTIATION_MISMATCH = 55, | 573 QUIC_VERSION_NEGOTIATION_MISMATCH = 55, |
571 | 574 |
572 // No error. Used as bound while iterating. | 575 // No error. Used as bound while iterating. |
573 QUIC_LAST_ERROR = 70, | 576 QUIC_LAST_ERROR = 71, |
574 }; | 577 }; |
575 | 578 |
576 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { | 579 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { |
577 QuicPacketPublicHeader(); | 580 QuicPacketPublicHeader(); |
578 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); | 581 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); |
579 ~QuicPacketPublicHeader(); | 582 ~QuicPacketPublicHeader(); |
580 | 583 |
581 // Universal header. All QuicPacket headers will have a connection_id and | 584 // Universal header. All QuicPacket headers will have a connection_id and |
582 // public flags. | 585 // public flags. |
583 QuicConnectionId connection_id; | 586 QuicConnectionId connection_id; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 private: | 914 private: |
912 const char* buffer_; | 915 const char* buffer_; |
913 size_t length_; | 916 size_t length_; |
914 bool owns_buffer_; | 917 bool owns_buffer_; |
915 | 918 |
916 DISALLOW_COPY_AND_ASSIGN(QuicData); | 919 DISALLOW_COPY_AND_ASSIGN(QuicData); |
917 }; | 920 }; |
918 | 921 |
919 class NET_EXPORT_PRIVATE QuicPacket : public QuicData { | 922 class NET_EXPORT_PRIVATE QuicPacket : public QuicData { |
920 public: | 923 public: |
921 static QuicPacket* NewDataPacket( | 924 QuicPacket(char* buffer, |
922 char* buffer, | 925 size_t length, |
923 size_t length, | 926 bool owns_buffer, |
924 bool owns_buffer, | 927 QuicConnectionIdLength connection_id_length, |
925 QuicConnectionIdLength connection_id_length, | 928 bool includes_version, |
926 bool includes_version, | 929 QuicSequenceNumberLength sequence_number_length); |
927 QuicSequenceNumberLength sequence_number_length) { | |
928 return new QuicPacket(buffer, length, owns_buffer, connection_id_length, | |
929 includes_version, sequence_number_length, false); | |
930 } | |
931 | |
932 static QuicPacket* NewFecPacket( | |
933 char* buffer, | |
934 size_t length, | |
935 bool owns_buffer, | |
936 QuicConnectionIdLength connection_id_length, | |
937 bool includes_version, | |
938 QuicSequenceNumberLength sequence_number_length) { | |
939 return new QuicPacket(buffer, length, owns_buffer, connection_id_length, | |
940 includes_version, sequence_number_length, true); | |
941 } | |
942 | 930 |
943 base::StringPiece FecProtectedData() const; | 931 base::StringPiece FecProtectedData() const; |
944 base::StringPiece AssociatedData() const; | 932 base::StringPiece AssociatedData() const; |
945 base::StringPiece BeforePlaintext() const; | 933 base::StringPiece BeforePlaintext() const; |
946 base::StringPiece Plaintext() const; | 934 base::StringPiece Plaintext() const; |
947 | 935 |
948 bool is_fec_packet() const { return is_fec_packet_; } | |
949 | |
950 char* mutable_data() { return buffer_; } | 936 char* mutable_data() { return buffer_; } |
951 | 937 |
952 private: | 938 private: |
953 QuicPacket(char* buffer, | |
954 size_t length, | |
955 bool owns_buffer, | |
956 QuicConnectionIdLength connection_id_length, | |
957 bool includes_version, | |
958 QuicSequenceNumberLength sequence_number_length, | |
959 bool is_fec_packet); | |
960 | |
961 char* buffer_; | 939 char* buffer_; |
962 const bool is_fec_packet_; | |
963 const QuicConnectionIdLength connection_id_length_; | 940 const QuicConnectionIdLength connection_id_length_; |
964 const bool includes_version_; | 941 const bool includes_version_; |
965 const QuicSequenceNumberLength sequence_number_length_; | 942 const QuicSequenceNumberLength sequence_number_length_; |
966 | 943 |
967 DISALLOW_COPY_AND_ASSIGN(QuicPacket); | 944 DISALLOW_COPY_AND_ASSIGN(QuicPacket); |
968 }; | 945 }; |
969 | 946 |
970 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { | 947 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { |
971 public: | 948 public: |
972 QuicEncryptedPacket(const char* buffer, size_t length); | 949 QuicEncryptedPacket(const char* buffer, size_t length); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 IsHandshake has_crypto_handshake_; | 991 IsHandshake has_crypto_handshake_; |
1015 // Data referenced by the StringPiece of a QuicStreamFrame. | 992 // Data referenced by the StringPiece of a QuicStreamFrame. |
1016 std::vector<std::string*> stream_data_; | 993 std::vector<std::string*> stream_data_; |
1017 | 994 |
1018 DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames); | 995 DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames); |
1019 }; | 996 }; |
1020 | 997 |
1021 struct NET_EXPORT_PRIVATE SerializedPacket { | 998 struct NET_EXPORT_PRIVATE SerializedPacket { |
1022 SerializedPacket(QuicPacketSequenceNumber sequence_number, | 999 SerializedPacket(QuicPacketSequenceNumber sequence_number, |
1023 QuicSequenceNumberLength sequence_number_length, | 1000 QuicSequenceNumberLength sequence_number_length, |
1024 QuicPacket* packet, | 1001 QuicEncryptedPacket* packet, |
1025 QuicPacketEntropyHash entropy_hash, | 1002 QuicPacketEntropyHash entropy_hash, |
1026 RetransmittableFrames* retransmittable_frames); | 1003 RetransmittableFrames* retransmittable_frames); |
1027 ~SerializedPacket(); | 1004 ~SerializedPacket(); |
1028 | 1005 |
1029 QuicPacketSequenceNumber sequence_number; | 1006 QuicPacketSequenceNumber sequence_number; |
1030 QuicSequenceNumberLength sequence_number_length; | 1007 QuicSequenceNumberLength sequence_number_length; |
1031 QuicPacket* packet; | 1008 QuicEncryptedPacket* packet; |
1032 QuicPacketEntropyHash entropy_hash; | 1009 QuicPacketEntropyHash entropy_hash; |
1033 RetransmittableFrames* retransmittable_frames; | 1010 RetransmittableFrames* retransmittable_frames; |
| 1011 bool is_fec_packet; |
1034 | 1012 |
1035 // Optional notifiers which will be informed when this packet has been ACKed. | 1013 // Optional notifiers which will be informed when this packet has been ACKed. |
1036 std::list<QuicAckNotifier*> notifiers; | 1014 std::list<QuicAckNotifier*> notifiers; |
1037 }; | 1015 }; |
1038 | 1016 |
1039 struct NET_EXPORT_PRIVATE TransmissionInfo { | 1017 struct NET_EXPORT_PRIVATE TransmissionInfo { |
1040 // Used by STL when assigning into a map. | 1018 // Used by STL when assigning into a map. |
1041 TransmissionInfo(); | 1019 TransmissionInfo(); |
1042 | 1020 |
1043 // Constructs a Transmission with a new all_tranmissions set | 1021 // Constructs a Transmission with a new all_tranmissions set |
(...skipping 19 matching lines...) Expand all Loading... |
1063 bool in_flight; | 1041 bool in_flight; |
1064 // True if the packet can never be acked, so it can be removed. | 1042 // True if the packet can never be acked, so it can be removed. |
1065 bool is_unackable; | 1043 bool is_unackable; |
1066 // True if the packet is an FEC packet. | 1044 // True if the packet is an FEC packet. |
1067 bool is_fec_packet; | 1045 bool is_fec_packet; |
1068 }; | 1046 }; |
1069 | 1047 |
1070 } // namespace net | 1048 } // namespace net |
1071 | 1049 |
1072 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1050 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
OLD | NEW |