Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: net/quic/quic_protocol.h

Issue 182523002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed rch's comments in Patch set 1 of CL 181463007 Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_packet_generator_test.cc ('k') | net/quic/quic_protocol.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 #include "net/quic/quic_time.h" 26 #include "net/quic/quic_time.h"
27 27
28 namespace net { 28 namespace net {
29 29
30 using ::operator<<; 30 using ::operator<<;
31 31
32 class QuicAckNotifier; 32 class QuicAckNotifier;
33 class QuicPacket; 33 class QuicPacket;
34 struct QuicPacketHeader; 34 struct QuicPacketHeader;
35 35
36 typedef uint64 QuicGuid; 36 typedef uint64 QuicConnectionId;
37 typedef uint32 QuicStreamId; 37 typedef uint32 QuicStreamId;
38 typedef uint64 QuicStreamOffset; 38 typedef uint64 QuicStreamOffset;
39 typedef uint64 QuicPacketSequenceNumber; 39 typedef uint64 QuicPacketSequenceNumber;
40 typedef QuicPacketSequenceNumber QuicFecGroupNumber; 40 typedef QuicPacketSequenceNumber QuicFecGroupNumber;
41 typedef uint64 QuicPublicResetNonceProof; 41 typedef uint64 QuicPublicResetNonceProof;
42 typedef uint8 QuicPacketEntropyHash; 42 typedef uint8 QuicPacketEntropyHash;
43 typedef uint32 QuicHeaderId; 43 typedef uint32 QuicHeaderId;
44 // QuicTag is the type of a tag in the wire protocol. 44 // QuicTag is the type of a tag in the wire protocol.
45 typedef uint32 QuicTag; 45 typedef uint32 QuicTag;
46 typedef std::vector<QuicTag> QuicTagVector; 46 typedef std::vector<QuicTag> QuicTagVector;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 STOP_WAITING_FRAME = 6, 158 STOP_WAITING_FRAME = 6,
159 159
160 // STREAM, ACK, and CONGESTION_FEEDBACK frames are special frames. They are 160 // STREAM, ACK, and CONGESTION_FEEDBACK frames are special frames. They are
161 // 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.
162 STREAM_FRAME, 162 STREAM_FRAME,
163 ACK_FRAME, 163 ACK_FRAME,
164 CONGESTION_FEEDBACK_FRAME, 164 CONGESTION_FEEDBACK_FRAME,
165 NUM_FRAME_TYPES 165 NUM_FRAME_TYPES
166 }; 166 };
167 167
168 enum QuicGuidLength { 168 enum QuicConnectionIdLength {
169 PACKET_0BYTE_GUID = 0, 169 PACKET_0BYTE_CONNECTION_ID = 0,
170 PACKET_1BYTE_GUID = 1, 170 PACKET_1BYTE_CONNECTION_ID = 1,
171 PACKET_4BYTE_GUID = 4, 171 PACKET_4BYTE_CONNECTION_ID = 4,
172 PACKET_8BYTE_GUID = 8 172 PACKET_8BYTE_CONNECTION_ID = 8
173 }; 173 };
174 174
175 enum InFecGroup { 175 enum InFecGroup {
176 NOT_IN_FEC_GROUP, 176 NOT_IN_FEC_GROUP,
177 IN_FEC_GROUP, 177 IN_FEC_GROUP,
178 }; 178 };
179 179
180 enum QuicSequenceNumberLength { 180 enum QuicSequenceNumberLength {
181 PACKET_1BYTE_SEQUENCE_NUMBER = 1, 181 PACKET_1BYTE_SEQUENCE_NUMBER = 1,
182 PACKET_2BYTE_SEQUENCE_NUMBER = 2, 182 PACKET_2BYTE_SEQUENCE_NUMBER = 2,
(...skipping 12 matching lines...) Expand all
195 // The public flags are specified in one byte. 195 // The public flags are specified in one byte.
196 enum QuicPacketPublicFlags { 196 enum QuicPacketPublicFlags {
197 PACKET_PUBLIC_FLAGS_NONE = 0, 197 PACKET_PUBLIC_FLAGS_NONE = 0,
198 198
199 // Bit 0: Does the packet header contains version info? 199 // Bit 0: Does the packet header contains version info?
200 PACKET_PUBLIC_FLAGS_VERSION = 1 << 0, 200 PACKET_PUBLIC_FLAGS_VERSION = 1 << 0,
201 201
202 // Bit 1: Is this packet a public reset packet? 202 // Bit 1: Is this packet a public reset packet?
203 PACKET_PUBLIC_FLAGS_RST = 1 << 1, 203 PACKET_PUBLIC_FLAGS_RST = 1 << 1,
204 204
205 // Bits 2 and 3 specify the length of the GUID as follows: 205 // Bits 2 and 3 specify the length of the ConnectionId as follows:
206 // ----00--: 0 bytes 206 // ----00--: 0 bytes
207 // ----01--: 1 byte 207 // ----01--: 1 byte
208 // ----10--: 4 bytes 208 // ----10--: 4 bytes
209 // ----11--: 8 bytes 209 // ----11--: 8 bytes
210 PACKET_PUBLIC_FLAGS_0BYTE_GUID = 0, 210 PACKET_PUBLIC_FLAGS_0BYTE_CONNECTION_ID = 0,
211 PACKET_PUBLIC_FLAGS_1BYTE_GUID = 1 << 2, 211 PACKET_PUBLIC_FLAGS_1BYTE_CONNECTION_ID = 1 << 2,
212 PACKET_PUBLIC_FLAGS_4BYTE_GUID = 1 << 3, 212 PACKET_PUBLIC_FLAGS_4BYTE_CONNECTION_ID = 1 << 3,
213 PACKET_PUBLIC_FLAGS_8BYTE_GUID = 1 << 3 | 1 << 2, 213 PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID = 1 << 3 | 1 << 2,
214 214
215 // Bits 4 and 5 describe the packet sequence number length as follows: 215 // Bits 4 and 5 describe the packet sequence number length as follows:
216 // --00----: 1 byte 216 // --00----: 1 byte
217 // --01----: 2 bytes 217 // --01----: 2 bytes
218 // --10----: 4 bytes 218 // --10----: 4 bytes
219 // --11----: 6 bytes 219 // --11----: 6 bytes
220 PACKET_PUBLIC_FLAGS_1BYTE_SEQUENCE = PACKET_FLAGS_1BYTE_SEQUENCE << 4, 220 PACKET_PUBLIC_FLAGS_1BYTE_SEQUENCE = PACKET_FLAGS_1BYTE_SEQUENCE << 4,
221 PACKET_PUBLIC_FLAGS_2BYTE_SEQUENCE = PACKET_FLAGS_2BYTE_SEQUENCE << 4, 221 PACKET_PUBLIC_FLAGS_2BYTE_SEQUENCE = PACKET_FLAGS_2BYTE_SEQUENCE << 4,
222 PACKET_PUBLIC_FLAGS_4BYTE_SEQUENCE = PACKET_FLAGS_4BYTE_SEQUENCE << 4, 222 PACKET_PUBLIC_FLAGS_4BYTE_SEQUENCE = PACKET_FLAGS_4BYTE_SEQUENCE << 4,
223 PACKET_PUBLIC_FLAGS_6BYTE_SEQUENCE = PACKET_FLAGS_6BYTE_SEQUENCE << 4, 223 PACKET_PUBLIC_FLAGS_6BYTE_SEQUENCE = PACKET_FLAGS_6BYTE_SEQUENCE << 4,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // to reverse the order of the bytes. 305 // to reverse the order of the bytes.
306 306
307 // MakeQuicTag returns a value given the four bytes. For example: 307 // MakeQuicTag returns a value given the four bytes. For example:
308 // MakeQuicTag('C', 'H', 'L', 'O'); 308 // MakeQuicTag('C', 'H', 'L', 'O');
309 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d); 309 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d);
310 310
311 // Size in bytes of the data or fec packet header. 311 // Size in bytes of the data or fec packet header.
312 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header); 312 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header);
313 313
314 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize( 314 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(
315 QuicGuidLength guid_length, 315 QuicConnectionIdLength connection_id_length,
316 bool include_version, 316 bool include_version,
317 QuicSequenceNumberLength sequence_number_length, 317 QuicSequenceNumberLength sequence_number_length,
318 InFecGroup is_in_fec_group); 318 InFecGroup is_in_fec_group);
319 319
320 // Index of the first byte in a QUIC packet of FEC protected data. 320 // Index of the first byte in a QUIC packet of FEC protected data.
321 NET_EXPORT_PRIVATE size_t GetStartOfFecProtectedData( 321 NET_EXPORT_PRIVATE size_t GetStartOfFecProtectedData(
322 QuicGuidLength guid_length, 322 QuicConnectionIdLength connection_id_length,
323 bool include_version, 323 bool include_version,
324 QuicSequenceNumberLength sequence_number_length); 324 QuicSequenceNumberLength sequence_number_length);
325 // Index of the first byte in a QUIC packet of encrypted data. 325 // Index of the first byte in a QUIC packet of encrypted data.
326 NET_EXPORT_PRIVATE size_t GetStartOfEncryptedData( 326 NET_EXPORT_PRIVATE size_t GetStartOfEncryptedData(
327 QuicGuidLength guid_length, 327 QuicConnectionIdLength connection_id_length,
328 bool include_version, 328 bool include_version,
329 QuicSequenceNumberLength sequence_number_length); 329 QuicSequenceNumberLength sequence_number_length);
330 330
331 enum QuicRstStreamErrorCode { 331 enum QuicRstStreamErrorCode {
332 QUIC_STREAM_NO_ERROR = 0, 332 QUIC_STREAM_NO_ERROR = 0,
333 333
334 // There was some error which halted stream processing. 334 // There was some error which halted stream processing.
335 QUIC_ERROR_PROCESSING_STREAM, 335 QUIC_ERROR_PROCESSING_STREAM,
336 // We got two fin or reset offsets which did not match. 336 // We got two fin or reset offsets which did not match.
337 QUIC_MULTIPLE_TERMINATION_OFFSETS, 337 QUIC_MULTIPLE_TERMINATION_OFFSETS,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 487
488 // No error. Used as bound while iterating. 488 // No error. Used as bound while iterating.
489 QUIC_LAST_ERROR = 61, 489 QUIC_LAST_ERROR = 61,
490 }; 490 };
491 491
492 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { 492 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader {
493 QuicPacketPublicHeader(); 493 QuicPacketPublicHeader();
494 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); 494 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other);
495 ~QuicPacketPublicHeader(); 495 ~QuicPacketPublicHeader();
496 496
497 // Universal header. All QuicPacket headers will have a guid and public flags. 497 // Universal header. All QuicPacket headers will have a connection_id and
498 QuicGuid guid; 498 // public flags.
499 QuicGuidLength guid_length; 499 QuicConnectionId connection_id;
500 QuicConnectionIdLength connection_id_length;
500 bool reset_flag; 501 bool reset_flag;
501 bool version_flag; 502 bool version_flag;
502 QuicSequenceNumberLength sequence_number_length; 503 QuicSequenceNumberLength sequence_number_length;
503 QuicVersionVector versions; 504 QuicVersionVector versions;
504 }; 505 };
505 506
506 // Header for Data or FEC packets. 507 // Header for Data or FEC packets.
507 struct NET_EXPORT_PRIVATE QuicPacketHeader { 508 struct NET_EXPORT_PRIVATE QuicPacketHeader {
508 QuicPacketHeader(); 509 QuicPacketHeader();
509 explicit QuicPacketHeader(const QuicPacketPublicHeader& header); 510 explicit QuicPacketHeader(const QuicPacketPublicHeader& header);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 862
862 DISALLOW_COPY_AND_ASSIGN(QuicData); 863 DISALLOW_COPY_AND_ASSIGN(QuicData);
863 }; 864 };
864 865
865 class NET_EXPORT_PRIVATE QuicPacket : public QuicData { 866 class NET_EXPORT_PRIVATE QuicPacket : public QuicData {
866 public: 867 public:
867 static QuicPacket* NewDataPacket( 868 static QuicPacket* NewDataPacket(
868 char* buffer, 869 char* buffer,
869 size_t length, 870 size_t length,
870 bool owns_buffer, 871 bool owns_buffer,
871 QuicGuidLength guid_length, 872 QuicConnectionIdLength connection_id_length,
872 bool includes_version, 873 bool includes_version,
873 QuicSequenceNumberLength sequence_number_length) { 874 QuicSequenceNumberLength sequence_number_length) {
874 return new QuicPacket(buffer, length, owns_buffer, guid_length, 875 return new QuicPacket(buffer, length, owns_buffer, connection_id_length,
875 includes_version, sequence_number_length, false); 876 includes_version, sequence_number_length, false);
876 } 877 }
877 878
878 static QuicPacket* NewFecPacket( 879 static QuicPacket* NewFecPacket(
879 char* buffer, 880 char* buffer,
880 size_t length, 881 size_t length,
881 bool owns_buffer, 882 bool owns_buffer,
882 QuicGuidLength guid_length, 883 QuicConnectionIdLength connection_id_length,
883 bool includes_version, 884 bool includes_version,
884 QuicSequenceNumberLength sequence_number_length) { 885 QuicSequenceNumberLength sequence_number_length) {
885 return new QuicPacket(buffer, length, owns_buffer, guid_length, 886 return new QuicPacket(buffer, length, owns_buffer, connection_id_length,
886 includes_version, sequence_number_length, true); 887 includes_version, sequence_number_length, true);
887 } 888 }
888 889
889 base::StringPiece FecProtectedData() const; 890 base::StringPiece FecProtectedData() const;
890 base::StringPiece AssociatedData() const; 891 base::StringPiece AssociatedData() const;
891 base::StringPiece BeforePlaintext() const; 892 base::StringPiece BeforePlaintext() const;
892 base::StringPiece Plaintext() const; 893 base::StringPiece Plaintext() const;
893 894
894 bool is_fec_packet() const { return is_fec_packet_; } 895 bool is_fec_packet() const { return is_fec_packet_; }
895 896
896 char* mutable_data() { return buffer_; } 897 char* mutable_data() { return buffer_; }
897 898
898 private: 899 private:
899 QuicPacket(char* buffer, 900 QuicPacket(char* buffer,
900 size_t length, 901 size_t length,
901 bool owns_buffer, 902 bool owns_buffer,
902 QuicGuidLength guid_length, 903 QuicConnectionIdLength connection_id_length,
903 bool includes_version, 904 bool includes_version,
904 QuicSequenceNumberLength sequence_number_length, 905 QuicSequenceNumberLength sequence_number_length,
905 bool is_fec_packet); 906 bool is_fec_packet);
906 907
907 char* buffer_; 908 char* buffer_;
908 const bool is_fec_packet_; 909 const bool is_fec_packet_;
909 const QuicGuidLength guid_length_; 910 const QuicConnectionIdLength connection_id_length_;
910 const bool includes_version_; 911 const bool includes_version_;
911 const QuicSequenceNumberLength sequence_number_length_; 912 const QuicSequenceNumberLength sequence_number_length_;
912 913
913 DISALLOW_COPY_AND_ASSIGN(QuicPacket); 914 DISALLOW_COPY_AND_ASSIGN(QuicPacket);
914 }; 915 };
915 916
916 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { 917 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData {
917 public: 918 public:
918 QuicEncryptedPacket(const char* buffer, size_t length); 919 QuicEncryptedPacket(const char* buffer, size_t length);
919 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer); 920 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 WriteStatus status; 1012 WriteStatus status;
1012 union { 1013 union {
1013 int bytes_written; // only valid when status is OK 1014 int bytes_written; // only valid when status is OK
1014 int error_code; // only valid when status is ERROR 1015 int error_code; // only valid when status is ERROR
1015 }; 1016 };
1016 }; 1017 };
1017 1018
1018 } // namespace net 1019 } // namespace net
1019 1020
1020 #endif // NET_QUIC_QUIC_PROTOCOL_H_ 1021 #endif // NET_QUIC_QUIC_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/quic/quic_packet_generator_test.cc ('k') | net/quic/quic_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698