| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 const QuicHeaderId kMaxHeaderIdDelta = 200; | 96 const QuicHeaderId kMaxHeaderIdDelta = 200; |
| 97 | 97 |
| 98 // Reserved ID for the crypto stream. | 98 // Reserved ID for the crypto stream. |
| 99 const QuicStreamId kCryptoStreamId = 1; | 99 const QuicStreamId kCryptoStreamId = 1; |
| 100 | 100 |
| 101 // Reserved ID for the headers stream. | 101 // Reserved ID for the headers stream. |
| 102 const QuicStreamId kHeadersStreamId = 3; | 102 const QuicStreamId kHeadersStreamId = 3; |
| 103 | 103 |
| 104 // This is the default network timeout a for connection till the crypto | 104 // This is the default network timeout a for connection till the crypto |
| 105 // handshake succeeds and the negotiated timeout from the handshake is received. | 105 // handshake succeeds and the negotiated timeout from the handshake is received. |
| 106 const int64 kDefaultInitialTimeoutSecs = 120; // 2 mins. | 106 const int64 kDefaultInitialTimeoutSecs = 120; // 2 mins. |
| 107 const int64 kDefaultTimeoutSecs = 60 * 10; // 10 minutes. | 107 const int64 kDefaultTimeoutSecs = 60 * 10; // 10 minutes. |
| 108 const int64 kDefaultMaxTimeForCryptoHandshakeSecs = 5; // 5 secs. | 108 const int64 kDefaultMaxTimeForCryptoHandshakeSecs = 5; // 5 secs. |
| 109 | 109 |
| 110 // Default ping timeout. | 110 // Default ping timeout. |
| 111 const int64 kPingTimeoutSecs = 15; // 15 secs. | 111 const int64 kPingTimeoutSecs = 15; // 15 secs. |
| 112 | 112 |
| 113 // We define an unsigned 16-bit floating point value, inspired by IEEE floats | 113 // We define an unsigned 16-bit floating point value, inspired by IEEE floats |
| 114 // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format), | 114 // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format), |
| 115 // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden | 115 // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden |
| 116 // bit) and denormals, but without signs, transfinites or fractions. Wire format | 116 // bit) and denormals, but without signs, transfinites or fractions. Wire format |
| 117 // 16 bits (little-endian byte order) are split into exponent (high 5) and | 117 // 16 bits (little-endian byte order) are split into exponent (high 5) and |
| 118 // mantissa (low 11) and decoded as: | 118 // mantissa (low 11) and decoded as: |
| 119 // uint64 value; | 119 // uint64 value; |
| 120 // if (exponent == 0) value = mantissa; | 120 // if (exponent == 0) value = mantissa; |
| 121 // else value = (mantissa | 1 << 11) << (exponent - 1) | 121 // else value = (mantissa | 1 << 11) << (exponent - 1) |
| 122 const int kUFloat16ExponentBits = 5; | 122 const int kUFloat16ExponentBits = 5; |
| 123 const int kUFloat16MaxExponent = (1 << kUFloat16ExponentBits) - 2; // 30 | 123 const int kUFloat16MaxExponent = (1 << kUFloat16ExponentBits) - 2; // 30 |
| 124 const int kUFloat16MantissaBits = 16 - kUFloat16ExponentBits; // 11 | 124 const int kUFloat16MantissaBits = 16 - kUFloat16ExponentBits; // 11 |
| 125 const int kUFloat16MantissaEffectiveBits = kUFloat16MantissaBits + 1; // 12 | 125 const int kUFloat16MantissaEffectiveBits = kUFloat16MantissaBits + 1; // 12 |
| 126 const uint64 kUFloat16MaxValue = // 0x3FFC0000000 | 126 const uint64 kUFloat16MaxValue = // 0x3FFC0000000 |
| 127 ((GG_UINT64_C(1) << kUFloat16MantissaEffectiveBits) - 1) << | 127 ((GG_UINT64_C(1) << kUFloat16MantissaEffectiveBits) - 1) |
| 128 kUFloat16MaxExponent; | 128 << kUFloat16MaxExponent; |
| 129 | 129 |
| 130 enum TransmissionType { | 130 enum TransmissionType { |
| 131 NOT_RETRANSMISSION, | 131 NOT_RETRANSMISSION, |
| 132 FIRST_TRANSMISSION_TYPE = NOT_RETRANSMISSION, | 132 FIRST_TRANSMISSION_TYPE = NOT_RETRANSMISSION, |
| 133 HANDSHAKE_RETRANSMISSION, // Retransmits due to handshake timeouts. | 133 HANDSHAKE_RETRANSMISSION, // Retransmits due to handshake timeouts. |
| 134 ALL_UNACKED_RETRANSMISSION, // Retransmits of all unacked packets. | 134 ALL_UNACKED_RETRANSMISSION, // Retransmits of all unacked packets. |
| 135 LOSS_RETRANSMISSION, // Retransmits due to loss detection. | 135 LOSS_RETRANSMISSION, // Retransmits due to loss detection. |
| 136 RTO_RETRANSMISSION, // Retransmits due to retransmit time out. | 136 RTO_RETRANSMISSION, // Retransmits due to retransmit time out. |
| 137 TLP_RETRANSMISSION, // Tail loss probes. | 137 TLP_RETRANSMISSION, // Tail loss probes. |
| 138 LAST_TRANSMISSION_TYPE = TLP_RETRANSMISSION, | 138 LAST_TRANSMISSION_TYPE = TLP_RETRANSMISSION, |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 enum RetransmissionType { | 141 enum RetransmissionType { INITIAL_ENCRYPTION_ONLY, ALL_PACKETS }; |
| 142 INITIAL_ENCRYPTION_ONLY, | |
| 143 ALL_PACKETS | |
| 144 }; | |
| 145 | 142 |
| 146 enum HasRetransmittableData { | 143 enum HasRetransmittableData { |
| 147 NO_RETRANSMITTABLE_DATA, | 144 NO_RETRANSMITTABLE_DATA, |
| 148 HAS_RETRANSMITTABLE_DATA, | 145 HAS_RETRANSMITTABLE_DATA, |
| 149 }; | 146 }; |
| 150 | 147 |
| 151 enum IsHandshake { | 148 enum IsHandshake { NOT_HANDSHAKE, IS_HANDSHAKE }; |
| 152 NOT_HANDSHAKE, | |
| 153 IS_HANDSHAKE | |
| 154 }; | |
| 155 | 149 |
| 156 enum QuicFrameType { | 150 enum QuicFrameType { |
| 157 // Regular frame types. The values set here cannot change without the | 151 // Regular frame types. The values set here cannot change without the |
| 158 // introduction of a new QUIC version. | 152 // introduction of a new QUIC version. |
| 159 PADDING_FRAME = 0, | 153 PADDING_FRAME = 0, |
| 160 RST_STREAM_FRAME = 1, | 154 RST_STREAM_FRAME = 1, |
| 161 CONNECTION_CLOSE_FRAME = 2, | 155 CONNECTION_CLOSE_FRAME = 2, |
| 162 GOAWAY_FRAME = 3, | 156 GOAWAY_FRAME = 3, |
| 163 WINDOW_UPDATE_FRAME = 4, | 157 WINDOW_UPDATE_FRAME = 4, |
| 164 BLOCKED_FRAME = 5, | 158 BLOCKED_FRAME = 5, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 187 | 181 |
| 188 enum QuicSequenceNumberLength { | 182 enum QuicSequenceNumberLength { |
| 189 PACKET_1BYTE_SEQUENCE_NUMBER = 1, | 183 PACKET_1BYTE_SEQUENCE_NUMBER = 1, |
| 190 PACKET_2BYTE_SEQUENCE_NUMBER = 2, | 184 PACKET_2BYTE_SEQUENCE_NUMBER = 2, |
| 191 PACKET_4BYTE_SEQUENCE_NUMBER = 4, | 185 PACKET_4BYTE_SEQUENCE_NUMBER = 4, |
| 192 PACKET_6BYTE_SEQUENCE_NUMBER = 6 | 186 PACKET_6BYTE_SEQUENCE_NUMBER = 6 |
| 193 }; | 187 }; |
| 194 | 188 |
| 195 // Used to indicate a QuicSequenceNumberLength using two flag bits. | 189 // Used to indicate a QuicSequenceNumberLength using two flag bits. |
| 196 enum QuicSequenceNumberLengthFlags { | 190 enum QuicSequenceNumberLengthFlags { |
| 197 PACKET_FLAGS_1BYTE_SEQUENCE = 0, // 00 | 191 PACKET_FLAGS_1BYTE_SEQUENCE = 0, // 00 |
| 198 PACKET_FLAGS_2BYTE_SEQUENCE = 1, // 01 | 192 PACKET_FLAGS_2BYTE_SEQUENCE = 1, // 01 |
| 199 PACKET_FLAGS_4BYTE_SEQUENCE = 1 << 1, // 10 | 193 PACKET_FLAGS_4BYTE_SEQUENCE = 1 << 1, // 10 |
| 200 PACKET_FLAGS_6BYTE_SEQUENCE = 1 << 1 | 1, // 11 | 194 PACKET_FLAGS_6BYTE_SEQUENCE = 1 << 1 | 1, // 11 |
| 201 }; | 195 }; |
| 202 | 196 |
| 203 // The public flags are specified in one byte. | 197 // The public flags are specified in one byte. |
| 204 enum QuicPacketPublicFlags { | 198 enum QuicPacketPublicFlags { |
| 205 PACKET_PUBLIC_FLAGS_NONE = 0, | 199 PACKET_PUBLIC_FLAGS_NONE = 0, |
| 206 | 200 |
| 207 // Bit 0: Does the packet header contains version info? | 201 // Bit 0: Does the packet header contains version info? |
| 208 PACKET_PUBLIC_FLAGS_VERSION = 1 << 0, | 202 PACKET_PUBLIC_FLAGS_VERSION = 1 << 0, |
| 209 | 203 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 247 |
| 254 // The available versions of QUIC. Guaranteed that the integer value of the enum | 248 // The available versions of QUIC. Guaranteed that the integer value of the enum |
| 255 // will match the version number. | 249 // will match the version number. |
| 256 // When adding a new version to this enum you should add it to | 250 // When adding a new version to this enum you should add it to |
| 257 // kSupportedQuicVersions (if appropriate), and also add a new case to the | 251 // kSupportedQuicVersions (if appropriate), and also add a new case to the |
| 258 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and | 252 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
| 259 // QuicVersionToString. | 253 // QuicVersionToString. |
| 260 enum QuicVersion { | 254 enum QuicVersion { |
| 261 // Special case to indicate unknown/unsupported QUIC version. | 255 // Special case to indicate unknown/unsupported QUIC version. |
| 262 QUIC_VERSION_UNSUPPORTED = 0, | 256 QUIC_VERSION_UNSUPPORTED = 0, |
| 263 | |
| 264 QUIC_VERSION_15 = 15, | 257 QUIC_VERSION_15 = 15, |
| 265 QUIC_VERSION_16 = 16, | 258 QUIC_VERSION_16 = 16, |
| 266 QUIC_VERSION_17 = 17, | 259 QUIC_VERSION_17 = 17, |
| 267 QUIC_VERSION_18 = 18, // Current version. | 260 QUIC_VERSION_18 = 18, // Current version. |
| 268 }; | 261 }; |
| 269 | 262 |
| 270 // This vector contains QUIC versions which we currently support. | 263 // This vector contains QUIC versions which we currently support. |
| 271 // 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 |
| 272 // element, with subsequent elements in descending order (versions can be | 265 // element, with subsequent elements in descending order (versions can be |
| 273 // skipped as necessary). | 266 // skipped as necessary). |
| 274 // | 267 // |
| 275 // 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 |
| 276 // http://sites/quic/adding-and-removing-versions | 269 // http://sites/quic/adding-and-removing-versions |
| 277 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_18, | 270 static const QuicVersion kSupportedQuicVersions[] = { |
| 278 QUIC_VERSION_17, | 271 QUIC_VERSION_18, QUIC_VERSION_17, QUIC_VERSION_16, QUIC_VERSION_15}; |
| 279 QUIC_VERSION_16, | |
| 280 QUIC_VERSION_15}; | |
| 281 | 272 |
| 282 typedef std::vector<QuicVersion> QuicVersionVector; | 273 typedef std::vector<QuicVersion> QuicVersionVector; |
| 283 | 274 |
| 284 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 275 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
| 285 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); | 276 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); |
| 286 | 277 |
| 287 // QuicTag is written to and read from the wire, but we prefer to use | 278 // QuicTag is written to and read from the wire, but we prefer to use |
| 288 // the more readable QuicVersion at other levels. | 279 // the more readable QuicVersion at other levels. |
| 289 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 | 280 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 |
| 290 // if QuicVersion is unsupported. | 281 // if QuicVersion is unsupported. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 310 // stored in memory as a little endian uint32, we need | 301 // stored in memory as a little endian uint32, we need |
| 311 // to reverse the order of the bytes. | 302 // to reverse the order of the bytes. |
| 312 | 303 |
| 313 // MakeQuicTag returns a value given the four bytes. For example: | 304 // MakeQuicTag returns a value given the four bytes. For example: |
| 314 // MakeQuicTag('C', 'H', 'L', 'O'); | 305 // MakeQuicTag('C', 'H', 'L', 'O'); |
| 315 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d); | 306 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d); |
| 316 | 307 |
| 317 // Size in bytes of the data or fec packet header. | 308 // Size in bytes of the data or fec packet header. |
| 318 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header); | 309 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header); |
| 319 | 310 |
| 320 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize( | 311 NET_EXPORT_PRIVATE size_t |
| 321 QuicConnectionIdLength connection_id_length, | 312 GetPacketHeaderSize(QuicConnectionIdLength connection_id_length, |
| 322 bool include_version, | 313 bool include_version, |
| 323 QuicSequenceNumberLength sequence_number_length, | 314 QuicSequenceNumberLength sequence_number_length, |
| 324 InFecGroup is_in_fec_group); | 315 InFecGroup is_in_fec_group); |
| 325 | 316 |
| 326 // Index of the first byte in a QUIC packet of FEC protected data. | 317 // Index of the first byte in a QUIC packet of FEC protected data. |
| 327 NET_EXPORT_PRIVATE size_t GetStartOfFecProtectedData( | 318 NET_EXPORT_PRIVATE size_t |
| 328 QuicConnectionIdLength connection_id_length, | 319 GetStartOfFecProtectedData(QuicConnectionIdLength connection_id_length, |
| 329 bool include_version, | 320 bool include_version, |
| 330 QuicSequenceNumberLength sequence_number_length); | 321 QuicSequenceNumberLength sequence_number_length); |
| 331 // Index of the first byte in a QUIC packet of encrypted data. | 322 // Index of the first byte in a QUIC packet of encrypted data. |
| 332 NET_EXPORT_PRIVATE size_t GetStartOfEncryptedData( | 323 NET_EXPORT_PRIVATE size_t |
| 333 QuicConnectionIdLength connection_id_length, | 324 GetStartOfEncryptedData(QuicConnectionIdLength connection_id_length, |
| 334 bool include_version, | 325 bool include_version, |
| 335 QuicSequenceNumberLength sequence_number_length); | 326 QuicSequenceNumberLength sequence_number_length); |
| 336 | 327 |
| 337 enum QuicRstStreamErrorCode { | 328 enum QuicRstStreamErrorCode { |
| 338 QUIC_STREAM_NO_ERROR = 0, | 329 QUIC_STREAM_NO_ERROR = 0, |
| 339 | 330 |
| 340 // There was some error which halted stream processing. | 331 // There was some error which halted stream processing. |
| 341 QUIC_ERROR_PROCESSING_STREAM, | 332 QUIC_ERROR_PROCESSING_STREAM, |
| 342 // We got two fin or reset offsets which did not match. | 333 // We got two fin or reset offsets which did not match. |
| 343 QUIC_MULTIPLE_TERMINATION_OFFSETS, | 334 QUIC_MULTIPLE_TERMINATION_OFFSETS, |
| 344 // We got bad payload and can not respond to it at the protocol level. | 335 // We got bad payload and can not respond to it at the protocol level. |
| 345 QUIC_BAD_APPLICATION_PAYLOAD, | 336 QUIC_BAD_APPLICATION_PAYLOAD, |
| 346 // Stream closed due to connection error. No reset frame is sent when this | 337 // Stream closed due to connection error. No reset frame is sent when this |
| 347 // happens. | 338 // happens. |
| 348 QUIC_STREAM_CONNECTION_ERROR, | 339 QUIC_STREAM_CONNECTION_ERROR, |
| 349 // GoAway frame sent. No more stream can be created. | 340 // GoAway frame sent. No more stream can be created. |
| 350 QUIC_STREAM_PEER_GOING_AWAY, | 341 QUIC_STREAM_PEER_GOING_AWAY, |
| 351 // The stream has been cancelled. | 342 // The stream has been cancelled. |
| 352 QUIC_STREAM_CANCELLED, | 343 QUIC_STREAM_CANCELLED, |
| 353 // Sending a RST to allow for proper flow control accounting. | 344 // Sending a RST to allow for proper flow control accounting. |
| 354 QUIC_RST_FLOW_CONTROL_ACCOUNTING, | 345 QUIC_RST_FLOW_CONTROL_ACCOUNTING, |
| 355 | 346 |
| 356 // No error. Used as bound while iterating. | 347 // No error. Used as bound while iterating. |
| 357 QUIC_STREAM_LAST_ERROR, | 348 QUIC_STREAM_LAST_ERROR, |
| 358 }; | 349 }; |
| 359 | 350 |
| 360 // Because receiving an unknown QuicRstStreamErrorCode results in connection | 351 // Because receiving an unknown QuicRstStreamErrorCode results in connection |
| 361 // teardown, we use this to make sure any errors predating a given version are | 352 // teardown, we use this to make sure any errors predating a given version are |
| 362 // downgraded to the most appropriate existing error. | 353 // downgraded to the most appropriate existing error. |
| 363 NET_EXPORT_PRIVATE QuicRstStreamErrorCode AdjustErrorForVersion( | 354 NET_EXPORT_PRIVATE QuicRstStreamErrorCode |
| 364 QuicRstStreamErrorCode error_code, | 355 AdjustErrorForVersion(QuicRstStreamErrorCode error_code, |
| 365 QuicVersion version); | 356 QuicVersion version); |
| 366 | 357 |
| 367 // These values must remain stable as they are uploaded to UMA histograms. | 358 // These values must remain stable as they are uploaded to UMA histograms. |
| 368 // To add a new error code, use the current value of QUIC_LAST_ERROR and | 359 // To add a new error code, use the current value of QUIC_LAST_ERROR and |
| 369 // increment QUIC_LAST_ERROR. | 360 // increment QUIC_LAST_ERROR. |
| 370 enum QuicErrorCode { | 361 enum QuicErrorCode { |
| 371 QUIC_NO_ERROR = 0, | 362 QUIC_NO_ERROR = 0, |
| 372 | 363 |
| 373 // Connection has reached an invalid state. | 364 // Connection has reached an invalid state. |
| 374 QUIC_INTERNAL_ERROR = 1, | 365 QUIC_INTERNAL_ERROR = 1, |
| 375 // There were data frames after the a fin or reset. | 366 // There were data frames after the a fin or reset. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 bool version_flag; | 511 bool version_flag; |
| 521 QuicSequenceNumberLength sequence_number_length; | 512 QuicSequenceNumberLength sequence_number_length; |
| 522 QuicVersionVector versions; | 513 QuicVersionVector versions; |
| 523 }; | 514 }; |
| 524 | 515 |
| 525 // Header for Data or FEC packets. | 516 // Header for Data or FEC packets. |
| 526 struct NET_EXPORT_PRIVATE QuicPacketHeader { | 517 struct NET_EXPORT_PRIVATE QuicPacketHeader { |
| 527 QuicPacketHeader(); | 518 QuicPacketHeader(); |
| 528 explicit QuicPacketHeader(const QuicPacketPublicHeader& header); | 519 explicit QuicPacketHeader(const QuicPacketPublicHeader& header); |
| 529 | 520 |
| 530 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 521 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, |
| 531 std::ostream& os, const QuicPacketHeader& s); | 522 const QuicPacketHeader& s); |
| 532 | 523 |
| 533 QuicPacketPublicHeader public_header; | 524 QuicPacketPublicHeader public_header; |
| 534 bool fec_flag; | 525 bool fec_flag; |
| 535 bool entropy_flag; | 526 bool entropy_flag; |
| 536 QuicPacketEntropyHash entropy_hash; | 527 QuicPacketEntropyHash entropy_hash; |
| 537 QuicPacketSequenceNumber packet_sequence_number; | 528 QuicPacketSequenceNumber packet_sequence_number; |
| 538 InFecGroup is_in_fec_group; | 529 InFecGroup is_in_fec_group; |
| 539 QuicFecGroupNumber fec_group; | 530 QuicFecGroupNumber fec_group; |
| 540 }; | 531 }; |
| 541 | 532 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 559 NEGOTIATION_IN_PROGRESS, | 550 NEGOTIATION_IN_PROGRESS, |
| 560 // This indicates this endpoint has received a packet from the peer with a | 551 // This indicates this endpoint has received a packet from the peer with a |
| 561 // version this endpoint supports. Version negotiation is complete, and the | 552 // version this endpoint supports. Version negotiation is complete, and the |
| 562 // version number will no longer be sent with future packets. | 553 // version number will no longer be sent with future packets. |
| 563 NEGOTIATED_VERSION | 554 NEGOTIATED_VERSION |
| 564 }; | 555 }; |
| 565 | 556 |
| 566 typedef QuicPacketPublicHeader QuicVersionNegotiationPacket; | 557 typedef QuicPacketPublicHeader QuicVersionNegotiationPacket; |
| 567 | 558 |
| 568 // A padding frame contains no payload. | 559 // A padding frame contains no payload. |
| 569 struct NET_EXPORT_PRIVATE QuicPaddingFrame { | 560 struct NET_EXPORT_PRIVATE QuicPaddingFrame {}; |
| 570 }; | |
| 571 | 561 |
| 572 // A ping frame contains no payload, though it is retransmittable, | 562 // A ping frame contains no payload, though it is retransmittable, |
| 573 // and ACK'd just like other normal frames. | 563 // and ACK'd just like other normal frames. |
| 574 struct NET_EXPORT_PRIVATE QuicPingFrame { | 564 struct NET_EXPORT_PRIVATE QuicPingFrame {}; |
| 575 }; | |
| 576 | 565 |
| 577 struct NET_EXPORT_PRIVATE QuicStreamFrame { | 566 struct NET_EXPORT_PRIVATE QuicStreamFrame { |
| 578 QuicStreamFrame(); | 567 QuicStreamFrame(); |
| 579 QuicStreamFrame(const QuicStreamFrame& frame); | 568 QuicStreamFrame(const QuicStreamFrame& frame); |
| 580 QuicStreamFrame(QuicStreamId stream_id, | 569 QuicStreamFrame(QuicStreamId stream_id, |
| 581 bool fin, | 570 bool fin, |
| 582 QuicStreamOffset offset, | 571 QuicStreamOffset offset, |
| 583 IOVector data); | 572 IOVector data); |
| 584 | 573 |
| 585 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 574 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, |
| 586 std::ostream& os, const QuicStreamFrame& s); | 575 const QuicStreamFrame& s); |
| 587 | 576 |
| 588 // Returns a copy of the IOVector |data| as a heap-allocated string. | 577 // Returns a copy of the IOVector |data| as a heap-allocated string. |
| 589 // Caller must take ownership of the returned string. | 578 // Caller must take ownership of the returned string. |
| 590 std::string* GetDataAsString() const; | 579 std::string* GetDataAsString() const; |
| 591 | 580 |
| 592 QuicStreamId stream_id; | 581 QuicStreamId stream_id; |
| 593 bool fin; | 582 bool fin; |
| 594 QuicStreamOffset offset; // Location of this data in the stream. | 583 QuicStreamOffset offset; // Location of this data in the stream. |
| 595 IOVector data; | 584 IOVector data; |
| 596 | 585 |
| 597 // If this is set, then when this packet is ACKed the AckNotifier will be | 586 // If this is set, then when this packet is ACKed the AckNotifier will be |
| 598 // informed. | 587 // informed. |
| 599 QuicAckNotifier* notifier; | 588 QuicAckNotifier* notifier; |
| 600 }; | 589 }; |
| 601 | 590 |
| 602 // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing | 591 // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing |
| 603 // is finalized. | 592 // is finalized. |
| 604 typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet; | 593 typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet; |
| 605 // TODO(pwestin): Add a way to enforce the max size of this map. | 594 // TODO(pwestin): Add a way to enforce the max size of this map. |
| 606 typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap; | 595 typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap; |
| 607 | 596 |
| 608 struct NET_EXPORT_PRIVATE ReceivedPacketInfo { | 597 struct NET_EXPORT_PRIVATE ReceivedPacketInfo { |
| 609 ReceivedPacketInfo(); | 598 ReceivedPacketInfo(); |
| 610 ~ReceivedPacketInfo(); | 599 ~ReceivedPacketInfo(); |
| 611 | 600 |
| 612 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 601 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 613 std::ostream& os, const ReceivedPacketInfo& s); | 602 std::ostream& os, |
| 603 const ReceivedPacketInfo& s); |
| 614 | 604 |
| 615 // Entropy hash of all packets up to largest observed not including missing | 605 // Entropy hash of all packets up to largest observed not including missing |
| 616 // packets. | 606 // packets. |
| 617 QuicPacketEntropyHash entropy_hash; | 607 QuicPacketEntropyHash entropy_hash; |
| 618 | 608 |
| 619 // The highest packet sequence number we've observed from the peer. | 609 // The highest packet sequence number we've observed from the peer. |
| 620 // | 610 // |
| 621 // In general, this should be the largest packet number we've received. In | 611 // In general, this should be the largest packet number we've received. In |
| 622 // the case of truncated acks, we may have to advertise a lower "upper bound" | 612 // the case of truncated acks, we may have to advertise a lower "upper bound" |
| 623 // than largest received, to avoid implicitly acking missing packets that | 613 // than largest received, to avoid implicitly acking missing packets that |
| (...skipping 15 matching lines...) Expand all Loading... |
| 639 bool is_truncated; | 629 bool is_truncated; |
| 640 | 630 |
| 641 // Packets which have been revived via FEC. | 631 // Packets which have been revived via FEC. |
| 642 // All of these must also be in missing_packets. | 632 // All of these must also be in missing_packets. |
| 643 SequenceNumberSet revived_packets; | 633 SequenceNumberSet revived_packets; |
| 644 }; | 634 }; |
| 645 | 635 |
| 646 // True if the sequence number is greater than largest_observed or is listed | 636 // True if the sequence number is greater than largest_observed or is listed |
| 647 // as missing. | 637 // as missing. |
| 648 // Always returns false for sequence numbers less than least_unacked. | 638 // Always returns false for sequence numbers less than least_unacked. |
| 649 bool NET_EXPORT_PRIVATE IsAwaitingPacket( | 639 bool NET_EXPORT_PRIVATE |
| 650 const ReceivedPacketInfo& received_info, | 640 IsAwaitingPacket(const ReceivedPacketInfo& received_info, |
| 651 QuicPacketSequenceNumber sequence_number); | 641 QuicPacketSequenceNumber sequence_number); |
| 652 | 642 |
| 653 // Inserts missing packets between [lower, higher). | 643 // Inserts missing packets between [lower, higher). |
| 654 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( | 644 void NET_EXPORT_PRIVATE |
| 655 ReceivedPacketInfo* received_info, | 645 InsertMissingPacketsBetween(ReceivedPacketInfo* received_info, |
| 656 QuicPacketSequenceNumber lower, | 646 QuicPacketSequenceNumber lower, |
| 657 QuicPacketSequenceNumber higher); | 647 QuicPacketSequenceNumber higher); |
| 658 | 648 |
| 659 struct NET_EXPORT_PRIVATE QuicStopWaitingFrame { | 649 struct NET_EXPORT_PRIVATE QuicStopWaitingFrame { |
| 660 QuicStopWaitingFrame(); | 650 QuicStopWaitingFrame(); |
| 661 ~QuicStopWaitingFrame(); | 651 ~QuicStopWaitingFrame(); |
| 662 | 652 |
| 663 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 653 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 664 std::ostream& os, const QuicStopWaitingFrame& s); | 654 std::ostream& os, |
| 655 const QuicStopWaitingFrame& s); |
| 665 | 656 |
| 666 // Entropy hash of all packets up to, but not including, the least unacked | 657 // Entropy hash of all packets up to, but not including, the least unacked |
| 667 // packet. | 658 // packet. |
| 668 QuicPacketEntropyHash entropy_hash; | 659 QuicPacketEntropyHash entropy_hash; |
| 669 // The lowest packet we've sent which is unacked, and we expect an ack for. | 660 // The lowest packet we've sent which is unacked, and we expect an ack for. |
| 670 QuicPacketSequenceNumber least_unacked; | 661 QuicPacketSequenceNumber least_unacked; |
| 671 }; | 662 }; |
| 672 | 663 |
| 673 struct NET_EXPORT_PRIVATE QuicAckFrame { | 664 struct NET_EXPORT_PRIVATE QuicAckFrame { |
| 674 QuicAckFrame(); | 665 QuicAckFrame(); |
| 675 | 666 |
| 676 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 667 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, |
| 677 std::ostream& os, const QuicAckFrame& s); | 668 const QuicAckFrame& s); |
| 678 | 669 |
| 679 QuicStopWaitingFrame sent_info; | 670 QuicStopWaitingFrame sent_info; |
| 680 ReceivedPacketInfo received_info; | 671 ReceivedPacketInfo received_info; |
| 681 }; | 672 }; |
| 682 | 673 |
| 683 // Defines for all types of congestion feedback that will be negotiated in QUIC, | 674 // Defines for all types of congestion feedback that will be negotiated in QUIC, |
| 684 // kTCP MUST be supported by all QUIC implementations to guarantee 100% | 675 // kTCP MUST be supported by all QUIC implementations to guarantee 100% |
| 685 // compatibility. | 676 // compatibility. |
| 686 enum CongestionFeedbackType { | 677 enum CongestionFeedbackType { |
| 687 kTCP, // Used to mimic TCP. | 678 kTCP, // Used to mimic TCP. |
| 688 kInterArrival, // Use additional inter arrival information. | 679 kInterArrival, // Use additional inter arrival information. |
| 689 kFixRate, // Provided for testing. | 680 kFixRate, // Provided for testing. |
| 690 }; | 681 }; |
| 691 | 682 |
| 692 enum LossDetectionType { | 683 enum LossDetectionType { |
| 693 kNack, // Used to mimic TCP's loss detection. | 684 kNack, // Used to mimic TCP's loss detection. |
| 694 kTime, // Time based loss detection. | 685 kTime, // Time based loss detection. |
| 695 }; | 686 }; |
| 696 | 687 |
| 697 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTCP { | 688 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTCP { |
| 698 CongestionFeedbackMessageTCP(); | 689 CongestionFeedbackMessageTCP(); |
| 699 | 690 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 712 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageFixRate { | 703 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageFixRate { |
| 713 CongestionFeedbackMessageFixRate(); | 704 CongestionFeedbackMessageFixRate(); |
| 714 QuicBandwidth bitrate; | 705 QuicBandwidth bitrate; |
| 715 }; | 706 }; |
| 716 | 707 |
| 717 struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame { | 708 struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame { |
| 718 QuicCongestionFeedbackFrame(); | 709 QuicCongestionFeedbackFrame(); |
| 719 ~QuicCongestionFeedbackFrame(); | 710 ~QuicCongestionFeedbackFrame(); |
| 720 | 711 |
| 721 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 712 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 722 std::ostream& os, const QuicCongestionFeedbackFrame& c); | 713 std::ostream& os, |
| 714 const QuicCongestionFeedbackFrame& c); |
| 723 | 715 |
| 724 CongestionFeedbackType type; | 716 CongestionFeedbackType type; |
| 725 // This should really be a union, but since the inter arrival struct | 717 // This should really be a union, but since the inter arrival struct |
| 726 // is non-trivial, C++ prohibits it. | 718 // is non-trivial, C++ prohibits it. |
| 727 CongestionFeedbackMessageTCP tcp; | 719 CongestionFeedbackMessageTCP tcp; |
| 728 CongestionFeedbackMessageInterArrival inter_arrival; | 720 CongestionFeedbackMessageInterArrival inter_arrival; |
| 729 CongestionFeedbackMessageFixRate fix_rate; | 721 CongestionFeedbackMessageFixRate fix_rate; |
| 730 }; | 722 }; |
| 731 | 723 |
| 732 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { | 724 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { |
| 733 QuicRstStreamFrame(); | 725 QuicRstStreamFrame(); |
| 734 QuicRstStreamFrame(QuicStreamId stream_id, | 726 QuicRstStreamFrame(QuicStreamId stream_id, |
| 735 QuicRstStreamErrorCode error_code, | 727 QuicRstStreamErrorCode error_code, |
| 736 QuicStreamOffset bytes_written); | 728 QuicStreamOffset bytes_written); |
| 737 | 729 |
| 738 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 730 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 739 std::ostream& os, const QuicRstStreamFrame& r); | 731 std::ostream& os, |
| 732 const QuicRstStreamFrame& r); |
| 740 | 733 |
| 741 QuicStreamId stream_id; | 734 QuicStreamId stream_id; |
| 742 QuicRstStreamErrorCode error_code; | 735 QuicRstStreamErrorCode error_code; |
| 743 std::string error_details; | 736 std::string error_details; |
| 744 | 737 |
| 745 // Used to update flow control windows. On termination of a stream, both | 738 // Used to update flow control windows. On termination of a stream, both |
| 746 // endpoints must inform the peer of the number of bytes they have sent on | 739 // endpoints must inform the peer of the number of bytes they have sent on |
| 747 // that stream. This can be done through normal termination (data packet with | 740 // that stream. This can be done through normal termination (data packet with |
| 748 // FIN) or through a RST. | 741 // FIN) or through a RST. |
| 749 QuicStreamOffset byte_offset; | 742 QuicStreamOffset byte_offset; |
| 750 }; | 743 }; |
| 751 | 744 |
| 752 struct NET_EXPORT_PRIVATE QuicConnectionCloseFrame { | 745 struct NET_EXPORT_PRIVATE QuicConnectionCloseFrame { |
| 753 QuicConnectionCloseFrame(); | 746 QuicConnectionCloseFrame(); |
| 754 | 747 |
| 755 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 748 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 756 std::ostream& os, const QuicConnectionCloseFrame& c); | 749 std::ostream& os, |
| 750 const QuicConnectionCloseFrame& c); |
| 757 | 751 |
| 758 QuicErrorCode error_code; | 752 QuicErrorCode error_code; |
| 759 std::string error_details; | 753 std::string error_details; |
| 760 }; | 754 }; |
| 761 | 755 |
| 762 struct NET_EXPORT_PRIVATE QuicGoAwayFrame { | 756 struct NET_EXPORT_PRIVATE QuicGoAwayFrame { |
| 763 QuicGoAwayFrame(); | 757 QuicGoAwayFrame(); |
| 764 QuicGoAwayFrame(QuicErrorCode error_code, | 758 QuicGoAwayFrame(QuicErrorCode error_code, |
| 765 QuicStreamId last_good_stream_id, | 759 QuicStreamId last_good_stream_id, |
| 766 const std::string& reason); | 760 const std::string& reason); |
| 767 | 761 |
| 768 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 762 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, |
| 769 std::ostream& os, const QuicGoAwayFrame& g); | 763 const QuicGoAwayFrame& g); |
| 770 | 764 |
| 771 QuicErrorCode error_code; | 765 QuicErrorCode error_code; |
| 772 QuicStreamId last_good_stream_id; | 766 QuicStreamId last_good_stream_id; |
| 773 std::string reason_phrase; | 767 std::string reason_phrase; |
| 774 }; | 768 }; |
| 775 | 769 |
| 776 // Flow control updates per-stream and at the connection levoel. | 770 // Flow control updates per-stream and at the connection levoel. |
| 777 // Based on SPDY's WINDOW_UPDATE frame, but uses an absolute byte offset rather | 771 // Based on SPDY's WINDOW_UPDATE frame, but uses an absolute byte offset rather |
| 778 // than a window delta. | 772 // than a window delta. |
| 779 // TODO(rjshade): A possible future optimization is to make stream_id and | 773 // TODO(rjshade): A possible future optimization is to make stream_id and |
| 780 // byte_offset variable length, similar to stream frames. | 774 // byte_offset variable length, similar to stream frames. |
| 781 struct NET_EXPORT_PRIVATE QuicWindowUpdateFrame { | 775 struct NET_EXPORT_PRIVATE QuicWindowUpdateFrame { |
| 782 QuicWindowUpdateFrame() {} | 776 QuicWindowUpdateFrame() {} |
| 783 QuicWindowUpdateFrame(QuicStreamId stream_id, QuicStreamOffset byte_offset); | 777 QuicWindowUpdateFrame(QuicStreamId stream_id, QuicStreamOffset byte_offset); |
| 784 | 778 |
| 785 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 779 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 786 std::ostream& os, const QuicWindowUpdateFrame& w); | 780 std::ostream& os, |
| 781 const QuicWindowUpdateFrame& w); |
| 787 | 782 |
| 788 // The stream this frame applies to. 0 is a special case meaning the overall | 783 // The stream this frame applies to. 0 is a special case meaning the overall |
| 789 // connection rather than a specific stream. | 784 // connection rather than a specific stream. |
| 790 QuicStreamId stream_id; | 785 QuicStreamId stream_id; |
| 791 | 786 |
| 792 // Byte offset in the stream or connection. The receiver of this frame must | 787 // Byte offset in the stream or connection. The receiver of this frame must |
| 793 // not send data which would result in this offset being exceeded. | 788 // not send data which would result in this offset being exceeded. |
| 794 QuicStreamOffset byte_offset; | 789 QuicStreamOffset byte_offset; |
| 795 }; | 790 }; |
| 796 | 791 |
| 797 // The BLOCKED frame is used to indicate to the remote endpoint that this | 792 // The BLOCKED frame is used to indicate to the remote endpoint that this |
| 798 // endpoint believes itself to be flow-control blocked but otherwise ready to | 793 // endpoint believes itself to be flow-control blocked but otherwise ready to |
| 799 // send data. The BLOCKED frame is purely advisory and optional. | 794 // send data. The BLOCKED frame is purely advisory and optional. |
| 800 // Based on SPDY's BLOCKED frame (undocumented as of 2014-01-28). | 795 // Based on SPDY's BLOCKED frame (undocumented as of 2014-01-28). |
| 801 struct NET_EXPORT_PRIVATE QuicBlockedFrame { | 796 struct NET_EXPORT_PRIVATE QuicBlockedFrame { |
| 802 QuicBlockedFrame() {} | 797 QuicBlockedFrame() {} |
| 803 explicit QuicBlockedFrame(QuicStreamId stream_id); | 798 explicit QuicBlockedFrame(QuicStreamId stream_id); |
| 804 | 799 |
| 805 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 800 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, |
| 806 std::ostream& os, const QuicBlockedFrame& b); | 801 const QuicBlockedFrame& b); |
| 807 | 802 |
| 808 // The stream this frame applies to. 0 is a special case meaning the overall | 803 // The stream this frame applies to. 0 is a special case meaning the overall |
| 809 // connection rather than a specific stream. | 804 // connection rather than a specific stream. |
| 810 QuicStreamId stream_id; | 805 QuicStreamId stream_id; |
| 811 }; | 806 }; |
| 812 | 807 |
| 813 // EncryptionLevel enumerates the stages of encryption that a QUIC connection | 808 // EncryptionLevel enumerates the stages of encryption that a QUIC connection |
| 814 // progresses through. When retransmitting a packet, the encryption level needs | 809 // progresses through. When retransmitting a packet, the encryption level needs |
| 815 // to be specified so that it is retransmitted at a level which the peer can | 810 // to be specified so that it is retransmitted at a level which the peer can |
| 816 // understand. | 811 // understand. |
| 817 enum EncryptionLevel { | 812 enum EncryptionLevel { |
| 818 ENCRYPTION_NONE = 0, | 813 ENCRYPTION_NONE = 0, |
| 819 ENCRYPTION_INITIAL = 1, | 814 ENCRYPTION_INITIAL = 1, |
| 820 ENCRYPTION_FORWARD_SECURE = 2, | 815 ENCRYPTION_FORWARD_SECURE = 2, |
| 821 | |
| 822 NUM_ENCRYPTION_LEVELS, | 816 NUM_ENCRYPTION_LEVELS, |
| 823 }; | 817 }; |
| 824 | 818 |
| 825 struct NET_EXPORT_PRIVATE QuicFrame { | 819 struct NET_EXPORT_PRIVATE QuicFrame { |
| 826 QuicFrame(); | 820 QuicFrame(); |
| 827 explicit QuicFrame(QuicPaddingFrame* padding_frame); | 821 explicit QuicFrame(QuicPaddingFrame* padding_frame); |
| 828 explicit QuicFrame(QuicStreamFrame* stream_frame); | 822 explicit QuicFrame(QuicStreamFrame* stream_frame); |
| 829 explicit QuicFrame(QuicAckFrame* frame); | 823 explicit QuicFrame(QuicAckFrame* frame); |
| 830 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); | 824 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); |
| 831 explicit QuicFrame(QuicRstStreamFrame* frame); | 825 explicit QuicFrame(QuicRstStreamFrame* frame); |
| 832 explicit QuicFrame(QuicConnectionCloseFrame* frame); | 826 explicit QuicFrame(QuicConnectionCloseFrame* frame); |
| 833 explicit QuicFrame(QuicStopWaitingFrame* frame); | 827 explicit QuicFrame(QuicStopWaitingFrame* frame); |
| 834 explicit QuicFrame(QuicPingFrame* frame); | 828 explicit QuicFrame(QuicPingFrame* frame); |
| 835 explicit QuicFrame(QuicGoAwayFrame* frame); | 829 explicit QuicFrame(QuicGoAwayFrame* frame); |
| 836 explicit QuicFrame(QuicWindowUpdateFrame* frame); | 830 explicit QuicFrame(QuicWindowUpdateFrame* frame); |
| 837 explicit QuicFrame(QuicBlockedFrame* frame); | 831 explicit QuicFrame(QuicBlockedFrame* frame); |
| 838 | 832 |
| 839 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 833 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, |
| 840 std::ostream& os, const QuicFrame& frame); | 834 const QuicFrame& frame); |
| 841 | 835 |
| 842 QuicFrameType type; | 836 QuicFrameType type; |
| 843 union { | 837 union { |
| 844 QuicPaddingFrame* padding_frame; | 838 QuicPaddingFrame* padding_frame; |
| 845 QuicStreamFrame* stream_frame; | 839 QuicStreamFrame* stream_frame; |
| 846 QuicAckFrame* ack_frame; | 840 QuicAckFrame* ack_frame; |
| 847 QuicCongestionFeedbackFrame* congestion_feedback_frame; | 841 QuicCongestionFeedbackFrame* congestion_feedback_frame; |
| 848 QuicStopWaitingFrame* stop_waiting_frame; | 842 QuicStopWaitingFrame* stop_waiting_frame; |
| 849 QuicPingFrame* ping_frame; | 843 QuicPingFrame* ping_frame; |
| 850 QuicRstStreamFrame* rst_stream_frame; | 844 QuicRstStreamFrame* rst_stream_frame; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 884 |
| 891 class NET_EXPORT_PRIVATE QuicPacket : public QuicData { | 885 class NET_EXPORT_PRIVATE QuicPacket : public QuicData { |
| 892 public: | 886 public: |
| 893 static QuicPacket* NewDataPacket( | 887 static QuicPacket* NewDataPacket( |
| 894 char* buffer, | 888 char* buffer, |
| 895 size_t length, | 889 size_t length, |
| 896 bool owns_buffer, | 890 bool owns_buffer, |
| 897 QuicConnectionIdLength connection_id_length, | 891 QuicConnectionIdLength connection_id_length, |
| 898 bool includes_version, | 892 bool includes_version, |
| 899 QuicSequenceNumberLength sequence_number_length) { | 893 QuicSequenceNumberLength sequence_number_length) { |
| 900 return new QuicPacket(buffer, length, owns_buffer, connection_id_length, | 894 return new QuicPacket(buffer, |
| 901 includes_version, sequence_number_length, false); | 895 length, |
| 896 owns_buffer, |
| 897 connection_id_length, |
| 898 includes_version, |
| 899 sequence_number_length, |
| 900 false); |
| 902 } | 901 } |
| 903 | 902 |
| 904 static QuicPacket* NewFecPacket( | 903 static QuicPacket* NewFecPacket( |
| 905 char* buffer, | 904 char* buffer, |
| 906 size_t length, | 905 size_t length, |
| 907 bool owns_buffer, | 906 bool owns_buffer, |
| 908 QuicConnectionIdLength connection_id_length, | 907 QuicConnectionIdLength connection_id_length, |
| 909 bool includes_version, | 908 bool includes_version, |
| 910 QuicSequenceNumberLength sequence_number_length) { | 909 QuicSequenceNumberLength sequence_number_length) { |
| 911 return new QuicPacket(buffer, length, owns_buffer, connection_id_length, | 910 return new QuicPacket(buffer, |
| 912 includes_version, sequence_number_length, true); | 911 length, |
| 912 owns_buffer, |
| 913 connection_id_length, |
| 914 includes_version, |
| 915 sequence_number_length, |
| 916 true); |
| 913 } | 917 } |
| 914 | 918 |
| 915 base::StringPiece FecProtectedData() const; | 919 base::StringPiece FecProtectedData() const; |
| 916 base::StringPiece AssociatedData() const; | 920 base::StringPiece AssociatedData() const; |
| 917 base::StringPiece BeforePlaintext() const; | 921 base::StringPiece BeforePlaintext() const; |
| 918 base::StringPiece Plaintext() const; | 922 base::StringPiece Plaintext() const; |
| 919 | 923 |
| 920 bool is_fec_packet() const { return is_fec_packet_; } | 924 bool is_fec_packet() const { return is_fec_packet_; } |
| 921 | 925 |
| 922 char* mutable_data() { return buffer_; } | 926 char* mutable_data() { return buffer_; } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 945 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer); | 949 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer); |
| 946 | 950 |
| 947 // Clones the packet into a new packet which owns the buffer. | 951 // Clones the packet into a new packet which owns the buffer. |
| 948 QuicEncryptedPacket* Clone() const; | 952 QuicEncryptedPacket* Clone() const; |
| 949 | 953 |
| 950 // By default, gtest prints the raw bytes of an object. The bool data | 954 // By default, gtest prints the raw bytes of an object. The bool data |
| 951 // member (in the base class QuicData) causes this object to have padding | 955 // member (in the base class QuicData) causes this object to have padding |
| 952 // bytes, which causes the default gtest object printer to read | 956 // bytes, which causes the default gtest object printer to read |
| 953 // uninitialize memory. So we need to teach gtest how to print this object. | 957 // uninitialize memory. So we need to teach gtest how to print this object. |
| 954 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 958 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 955 std::ostream& os, const QuicEncryptedPacket& s); | 959 std::ostream& os, |
| 960 const QuicEncryptedPacket& s); |
| 956 | 961 |
| 957 private: | 962 private: |
| 958 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); | 963 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); |
| 959 }; | 964 }; |
| 960 | 965 |
| 961 class NET_EXPORT_PRIVATE RetransmittableFrames { | 966 class NET_EXPORT_PRIVATE RetransmittableFrames { |
| 962 public: | 967 public: |
| 963 RetransmittableFrames(); | 968 RetransmittableFrames(); |
| 964 ~RetransmittableFrames(); | 969 ~RetransmittableFrames(); |
| 965 | 970 |
| 966 // Allocates a local copy of the referenced StringPiece has QuicStreamFrame | 971 // Allocates a local copy of the referenced StringPiece has QuicStreamFrame |
| 967 // use it. | 972 // use it. |
| 968 // Takes ownership of |stream_frame|. | 973 // Takes ownership of |stream_frame|. |
| 969 const QuicFrame& AddStreamFrame(QuicStreamFrame* stream_frame); | 974 const QuicFrame& AddStreamFrame(QuicStreamFrame* stream_frame); |
| 970 // Takes ownership of the frame inside |frame|. | 975 // Takes ownership of the frame inside |frame|. |
| 971 const QuicFrame& AddNonStreamFrame(const QuicFrame& frame); | 976 const QuicFrame& AddNonStreamFrame(const QuicFrame& frame); |
| 972 const QuicFrames& frames() const { return frames_; } | 977 const QuicFrames& frames() const { return frames_; } |
| 973 | 978 |
| 974 IsHandshake HasCryptoHandshake() const; | 979 IsHandshake HasCryptoHandshake() const; |
| 975 | 980 |
| 976 void set_encryption_level(EncryptionLevel level); | 981 void set_encryption_level(EncryptionLevel level); |
| 977 EncryptionLevel encryption_level() const { | 982 EncryptionLevel encryption_level() const { return encryption_level_; } |
| 978 return encryption_level_; | |
| 979 } | |
| 980 | 983 |
| 981 private: | 984 private: |
| 982 QuicFrames frames_; | 985 QuicFrames frames_; |
| 983 EncryptionLevel encryption_level_; | 986 EncryptionLevel encryption_level_; |
| 984 // Data referenced by the StringPiece of a QuicStreamFrame. | 987 // Data referenced by the StringPiece of a QuicStreamFrame. |
| 985 std::vector<std::string*> stream_data_; | 988 std::vector<std::string*> stream_data_; |
| 986 | 989 |
| 987 DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames); | 990 DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames); |
| 988 }; | 991 }; |
| 989 | 992 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1006 }; | 1009 }; |
| 1007 | 1010 |
| 1008 // A struct for functions which consume data payloads and fins. | 1011 // A struct for functions which consume data payloads and fins. |
| 1009 struct NET_EXPORT_PRIVATE QuicConsumedData { | 1012 struct NET_EXPORT_PRIVATE QuicConsumedData { |
| 1010 QuicConsumedData(size_t bytes_consumed, bool fin_consumed); | 1013 QuicConsumedData(size_t bytes_consumed, bool fin_consumed); |
| 1011 | 1014 |
| 1012 // By default, gtest prints the raw bytes of an object. The bool data | 1015 // By default, gtest prints the raw bytes of an object. The bool data |
| 1013 // member causes this object to have padding bytes, which causes the | 1016 // member causes this object to have padding bytes, which causes the |
| 1014 // default gtest object printer to read uninitialize memory. So we need | 1017 // default gtest object printer to read uninitialize memory. So we need |
| 1015 // to teach gtest how to print this object. | 1018 // to teach gtest how to print this object. |
| 1016 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 1019 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, |
| 1017 std::ostream& os, const QuicConsumedData& s); | 1020 const QuicConsumedData& s); |
| 1018 | 1021 |
| 1019 // How many bytes were consumed. | 1022 // How many bytes were consumed. |
| 1020 size_t bytes_consumed; | 1023 size_t bytes_consumed; |
| 1021 | 1024 |
| 1022 // True if an incoming fin was consumed. | 1025 // True if an incoming fin was consumed. |
| 1023 bool fin_consumed; | 1026 bool fin_consumed; |
| 1024 }; | 1027 }; |
| 1025 | 1028 |
| 1026 enum WriteStatus { | 1029 enum WriteStatus { |
| 1027 WRITE_STATUS_OK, | 1030 WRITE_STATUS_OK, |
| 1028 WRITE_STATUS_BLOCKED, | 1031 WRITE_STATUS_BLOCKED, |
| 1029 WRITE_STATUS_ERROR, | 1032 WRITE_STATUS_ERROR, |
| 1030 }; | 1033 }; |
| 1031 | 1034 |
| 1032 // A struct used to return the result of write calls including either the number | 1035 // A struct used to return the result of write calls including either the number |
| 1033 // of bytes written or the error code, depending upon the status. | 1036 // of bytes written or the error code, depending upon the status. |
| 1034 struct NET_EXPORT_PRIVATE WriteResult { | 1037 struct NET_EXPORT_PRIVATE WriteResult { |
| 1035 WriteResult(WriteStatus status, int bytes_written_or_error_code); | 1038 WriteResult(WriteStatus status, int bytes_written_or_error_code); |
| 1036 WriteResult(); | 1039 WriteResult(); |
| 1037 | 1040 |
| 1038 WriteStatus status; | 1041 WriteStatus status; |
| 1039 union { | 1042 union { |
| 1040 int bytes_written; // only valid when status is OK | 1043 int bytes_written; // only valid when status is OK |
| 1041 int error_code; // only valid when status is ERROR | 1044 int error_code; // only valid when status is ERROR |
| 1042 }; | 1045 }; |
| 1043 }; | 1046 }; |
| 1044 | 1047 |
| 1045 } // namespace net | 1048 } // namespace net |
| 1046 | 1049 |
| 1047 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1050 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
| OLD | NEW |