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

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

Issue 19858003: * Removed QuicTag kQuicVersion1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comments from rch Created 7 years, 5 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Number of bytes reserved for private flags in the packet header. 56 // Number of bytes reserved for private flags in the packet header.
57 const size_t kPrivateFlagsSize = 1; 57 const size_t kPrivateFlagsSize = 1;
58 // Number of bytes reserved for FEC group in the packet header. 58 // Number of bytes reserved for FEC group in the packet header.
59 const size_t kFecGroupSize = 1; 59 const size_t kFecGroupSize = 1;
60 // Number of bytes reserved for the nonce proof in public reset packet. 60 // Number of bytes reserved for the nonce proof in public reset packet.
61 const size_t kPublicResetNonceSize = 8; 61 const size_t kPublicResetNonceSize = 8;
62 62
63 // Signifies that the QuicPacket will contain version of the protocol. 63 // Signifies that the QuicPacket will contain version of the protocol.
64 const bool kIncludeVersion = true; 64 const bool kIncludeVersion = true;
65 65
66 // Returns true if |version| is a supported protocol version.
67 NET_EXPORT_PRIVATE bool IsSupportedVersion(QuicTag version);
68
69 // Index of the first byte in a QUIC packet which is used in hash calculation. 66 // Index of the first byte in a QUIC packet which is used in hash calculation.
70 const size_t kStartOfHashData = 0; 67 const size_t kStartOfHashData = 0;
71 68
72 // Limit on the delta between stream IDs. 69 // Limit on the delta between stream IDs.
73 const QuicStreamId kMaxStreamIdDelta = 100; 70 const QuicStreamId kMaxStreamIdDelta = 100;
74 // Limit on the delta between header IDs. 71 // Limit on the delta between header IDs.
75 const QuicHeaderId kMaxHeaderIdDelta = 100; 72 const QuicHeaderId kMaxHeaderIdDelta = 100;
76 73
77 // Reserved ID for the crypto stream. 74 // Reserved ID for the crypto stream.
78 // TODO(rch): ensure that this is not usable by any other streams. 75 // TODO(rch): ensure that this is not usable by any other streams.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // Bit 1: Payload is part of an FEC group? 165 // Bit 1: Payload is part of an FEC group?
169 PACKET_PRIVATE_FLAGS_FEC_GROUP = 1 << 1, 166 PACKET_PRIVATE_FLAGS_FEC_GROUP = 1 << 1,
170 167
171 // Bit 2: Payload is FEC as opposed to frames? 168 // Bit 2: Payload is FEC as opposed to frames?
172 PACKET_PRIVATE_FLAGS_FEC = 1 << 2, 169 PACKET_PRIVATE_FLAGS_FEC = 1 << 2,
173 170
174 // All bits set (bits 3-7 are not currently used): 00000111 171 // All bits set (bits 3-7 are not currently used): 00000111
175 PACKET_PRIVATE_FLAGS_MAX = (1 << 3) - 1 172 PACKET_PRIVATE_FLAGS_MAX = (1 << 3) - 1
176 }; 173 };
177 174
175 // The available versions of QUIC. Guaranteed that the integer value of the enum
176 // will match the version number.
177 // When adding a new version to this enum you should add it to
178 // kSupportedVersions (if appropriate), and also add a new case to the helper
179 // methods QuicVersionToQuicTag, and QuicTagToQuicVersion.
180 enum QuicVersion {
181 // Special case to indicate unknown/unsupported QUIC version.
182 QUIC_VERSION_UNSUPPORTED = 0,
183
184 QUIC_VERSION_6 = 6, // Current version.
185 };
186
187 // This vector contains QUIC versions which we currently support.
188 // This should be ordered such that the highest supported version is the first
189 // element, with subsequent elements in descending order (versions can be
190 // skipped as necessary).
191 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_6};
192
193 typedef std::vector<QuicVersion> QuicVersionVector;
194
195 // Upper limit on versions we support.
196 NET_EXPORT_PRIVATE QuicVersion QuicVersionMax();
197
198 // QuicTag is written to and read from the wire, but we prefer to use
199 // the more readable QuicVersion at other levels.
200 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0
201 // if QuicVersion is unsupported.
202 NET_EXPORT_PRIVATE QuicTag QuicVersionToQuicTag(const QuicVersion version);
203
204 // Returns appropriate QuicVersion from a QuicTag.
205 // Returns QUIC_VERSION_UNSUPPORTED if version_tag cannot be understood.
206 NET_EXPORT_PRIVATE QuicVersion QuicTagToQuicVersion(const QuicTag version_tag);
207
208 // Helper function which translates from a QuicVersion to a string.
209 // Returns strings corresponding to enum names (e.g. QUIC_VERSION_6).
210 NET_EXPORT_PRIVATE std::string QuicVersionToString(const QuicVersion version);
211
212 // Returns comma separated list of string representations of QuicVersion enum
213 // values in the supplied QuicVersionArray.
214 NET_EXPORT_PRIVATE std::string QuicVersionArrayToString(
215 const QuicVersion versions[], int num_versions);
216
217 // Version and Crypto tags are written to the wire with a big-endian
218 // representation of the name of the tag. For example
219 // the client hello tag (CHLO) will be written as the
220 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is
221 // stored in memory as a little endian uint32, we need
222 // to reverse the order of the bytes.
223
224 // MakeQuicTag returns a value given the four bytes. For example:
225 // MakeQuicTag('C', 'H', 'L', 'O');
226 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d);
227
178 // Size in bytes of the data or fec packet header. 228 // Size in bytes of the data or fec packet header.
179 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(QuicPacketHeader header); 229 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(QuicPacketHeader header);
180 230
181 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize( 231 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(
182 QuicGuidLength guid_length, 232 QuicGuidLength guid_length,
183 bool include_version, 233 bool include_version,
184 QuicSequenceNumberLength sequence_number_length, 234 QuicSequenceNumberLength sequence_number_length,
185 InFecGroup is_in_fec_group); 235 InFecGroup is_in_fec_group);
186 236
187 // Size in bytes of the public reset packet. 237 // Size in bytes of the public reset packet.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // A crypto message was received with the wrong encryption level (i.e. it 366 // A crypto message was received with the wrong encryption level (i.e. it
317 // should have been encrypted but was not.) 367 // should have been encrypted but was not.)
318 QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT, 368 QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT,
319 // The server config for a server has expired. 369 // The server config for a server has expired.
320 QUIC_CRYPTO_SERVER_CONFIG_EXPIRED, 370 QUIC_CRYPTO_SERVER_CONFIG_EXPIRED,
321 371
322 // No error. Used as bound while iterating. 372 // No error. Used as bound while iterating.
323 QUIC_LAST_ERROR, 373 QUIC_LAST_ERROR,
324 }; 374 };
325 375
326 // Version and Crypto tags are written to the wire with a big-endian
327 // representation of the name of the tag. For example
328 // the client hello tag (CHLO) will be written as the
329 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is
330 // stored in memory as a little endian uint32, we need
331 // to reverse the order of the bytes.
332 //
333 // The TAG macro is used in header files to ensure that we don't create static
334 // initialisers. In normal code, the MakeQuicTag function should be used.
335 #define TAG(a, b, c, d) ((d << 24) + (c << 16) + (b << 8) + a)
336 const QuicTag kUnsupportedVersion = -1;
337 // Each time the wire format changes, this need needs to be incremented.
338 // At some point, we will actually freeze the wire format and make an official
339 // version number, but this works for now.
340 const QuicTag kQuicVersion1 = TAG('Q', '0', '0', '6');
341 #undef TAG
342
343 // MakeQuicTag returns a value given the four bytes. For example:
344 // MakeQuicTag('C', 'H', 'L', 'O');
345 uint32 NET_EXPORT_PRIVATE MakeQuicTag(char a, char b, char c, char d);
346
347 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { 376 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader {
348 QuicPacketPublicHeader(); 377 QuicPacketPublicHeader();
349 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); 378 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other);
350 ~QuicPacketPublicHeader(); 379 ~QuicPacketPublicHeader();
351 380
352 QuicPacketPublicHeader& operator=(const QuicPacketPublicHeader& other); 381 QuicPacketPublicHeader& operator=(const QuicPacketPublicHeader& other);
353 382
354 // Universal header. All QuicPacket headers will have a guid and public flags. 383 // Universal header. All QuicPacket headers will have a guid and public flags.
355 QuicGuid guid; 384 QuicGuid guid;
356 QuicGuidLength guid_length; 385 QuicGuidLength guid_length;
357 bool reset_flag; 386 bool reset_flag;
358 bool version_flag; 387 bool version_flag;
359 QuicSequenceNumberLength sequence_number_length; 388 QuicSequenceNumberLength sequence_number_length;
360 QuicTagVector versions; 389 QuicVersionVector versions;
361 }; 390 };
362 391
363 // Header for Data or FEC packets. 392 // Header for Data or FEC packets.
364 struct NET_EXPORT_PRIVATE QuicPacketHeader { 393 struct NET_EXPORT_PRIVATE QuicPacketHeader {
365 QuicPacketHeader(); 394 QuicPacketHeader();
366 explicit QuicPacketHeader(const QuicPacketPublicHeader& header); 395 explicit QuicPacketHeader(const QuicPacketPublicHeader& header);
367 396
368 NET_EXPORT_PRIVATE friend std::ostream& operator<<( 397 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
369 std::ostream& os, const QuicPacketHeader& s); 398 std::ostream& os, const QuicPacketHeader& s);
370 399
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 NET_EXPORT_PRIVATE friend std::ostream& operator<<( 825 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
797 std::ostream& os, const QuicConsumedData& s); 826 std::ostream& os, const QuicConsumedData& s);
798 827
799 size_t bytes_consumed; 828 size_t bytes_consumed;
800 bool fin_consumed; 829 bool fin_consumed;
801 }; 830 };
802 831
803 } // namespace net 832 } // namespace net
804 833
805 #endif // NET_QUIC_QUIC_PROTOCOL_H_ 834 #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