| 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 <stdint.h> | 9 #include <stdint.h> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // QuicVersionToString. | 339 // QuicVersionToString. |
| 340 enum QuicVersion { | 340 enum QuicVersion { |
| 341 // Special case to indicate unknown/unsupported QUIC version. | 341 // Special case to indicate unknown/unsupported QUIC version. |
| 342 QUIC_VERSION_UNSUPPORTED = 0, | 342 QUIC_VERSION_UNSUPPORTED = 0, |
| 343 | 343 |
| 344 QUIC_VERSION_25 = 25, // SPDY/4 header keys, and removal of error_details | 344 QUIC_VERSION_25 = 25, // SPDY/4 header keys, and removal of error_details |
| 345 // from QuicRstStreamFrame | 345 // from QuicRstStreamFrame |
| 346 QUIC_VERSION_26 = 26, // In CHLO, send XLCT tag containing hash of leaf cert | 346 QUIC_VERSION_26 = 26, // In CHLO, send XLCT tag containing hash of leaf cert |
| 347 QUIC_VERSION_27 = 27, // Sends a nonce in the SHLO. | 347 QUIC_VERSION_27 = 27, // Sends a nonce in the SHLO. |
| 348 QUIC_VERSION_28 = 28, // Receiver can refuse to create a requested stream. | 348 QUIC_VERSION_28 = 28, // Receiver can refuse to create a requested stream. |
| 349 QUIC_VERSION_29 = 29, // Server and client honor QUIC_STREAM_NO_ERROR. |
| 350 QUIC_VERSION_30 = 30, // Add server side support of cert transparency. |
| 349 }; | 351 }; |
| 350 | 352 |
| 351 // This vector contains QUIC versions which we currently support. | 353 // This vector contains QUIC versions which we currently support. |
| 352 // This should be ordered such that the highest supported version is the first | 354 // This should be ordered such that the highest supported version is the first |
| 353 // element, with subsequent elements in descending order (versions can be | 355 // element, with subsequent elements in descending order (versions can be |
| 354 // skipped as necessary). | 356 // skipped as necessary). |
| 355 // | 357 // |
| 356 // IMPORTANT: if you are adding to this list, follow the instructions at | 358 // IMPORTANT: if you are adding to this list, follow the instructions at |
| 357 // http://sites/quic/adding-and-removing-versions | 359 // http://sites/quic/adding-and-removing-versions |
| 358 static const QuicVersion kSupportedQuicVersions[] = { | 360 static const QuicVersion kSupportedQuicVersions[] = { |
| 359 QUIC_VERSION_28, QUIC_VERSION_27, QUIC_VERSION_26, QUIC_VERSION_25}; | 361 QUIC_VERSION_30, QUIC_VERSION_29, QUIC_VERSION_28, |
| 362 QUIC_VERSION_27, QUIC_VERSION_26, QUIC_VERSION_25}; |
| 360 | 363 |
| 361 typedef std::vector<QuicVersion> QuicVersionVector; | 364 typedef std::vector<QuicVersion> QuicVersionVector; |
| 362 | 365 |
| 363 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 366 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
| 364 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); | 367 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); |
| 365 | 368 |
| 366 // QuicTag is written to and read from the wire, but we prefer to use | 369 // QuicTag is written to and read from the wire, but we prefer to use |
| 367 // the more readable QuicVersion at other levels. | 370 // the more readable QuicVersion at other levels. |
| 368 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 | 371 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 |
| 369 // if QuicVersion is unsupported. | 372 // if QuicVersion is unsupported. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 GetStartOfFecProtectedData(QuicConnectionIdLength connection_id_length, | 414 GetStartOfFecProtectedData(QuicConnectionIdLength connection_id_length, |
| 412 bool include_version, | 415 bool include_version, |
| 413 QuicPacketNumberLength packet_number_length); | 416 QuicPacketNumberLength packet_number_length); |
| 414 // Index of the first byte in a QUIC packet of encrypted data. | 417 // Index of the first byte in a QUIC packet of encrypted data. |
| 415 NET_EXPORT_PRIVATE size_t | 418 NET_EXPORT_PRIVATE size_t |
| 416 GetStartOfEncryptedData(QuicConnectionIdLength connection_id_length, | 419 GetStartOfEncryptedData(QuicConnectionIdLength connection_id_length, |
| 417 bool include_version, | 420 bool include_version, |
| 418 QuicPacketNumberLength packet_number_length); | 421 QuicPacketNumberLength packet_number_length); |
| 419 | 422 |
| 420 enum QuicRstStreamErrorCode { | 423 enum QuicRstStreamErrorCode { |
| 424 // Complete response has been sent, sending a RST to ask the other endpoint |
| 425 // to stop sending request data without discarding the response. |
| 421 QUIC_STREAM_NO_ERROR = 0, | 426 QUIC_STREAM_NO_ERROR = 0, |
| 422 | 427 |
| 423 // There was some error which halted stream processing. | 428 // There was some error which halted stream processing. |
| 424 QUIC_ERROR_PROCESSING_STREAM, | 429 QUIC_ERROR_PROCESSING_STREAM, |
| 425 // We got two fin or reset offsets which did not match. | 430 // We got two fin or reset offsets which did not match. |
| 426 QUIC_MULTIPLE_TERMINATION_OFFSETS, | 431 QUIC_MULTIPLE_TERMINATION_OFFSETS, |
| 427 // We got bad payload and can not respond to it at the protocol level. | 432 // We got bad payload and can not respond to it at the protocol level. |
| 428 QUIC_BAD_APPLICATION_PAYLOAD, | 433 QUIC_BAD_APPLICATION_PAYLOAD, |
| 429 // Stream closed due to connection error. No reset frame is sent when this | 434 // Stream closed due to connection error. No reset frame is sent when this |
| 430 // happens. | 435 // happens. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 QUIC_INVALID_GOAWAY_DATA = 8, | 488 QUIC_INVALID_GOAWAY_DATA = 8, |
| 484 // WINDOW_UPDATE frame data is malformed. | 489 // WINDOW_UPDATE frame data is malformed. |
| 485 QUIC_INVALID_WINDOW_UPDATE_DATA = 57, | 490 QUIC_INVALID_WINDOW_UPDATE_DATA = 57, |
| 486 // BLOCKED frame data is malformed. | 491 // BLOCKED frame data is malformed. |
| 487 QUIC_INVALID_BLOCKED_DATA = 58, | 492 QUIC_INVALID_BLOCKED_DATA = 58, |
| 488 // STOP_WAITING frame data is malformed. | 493 // STOP_WAITING frame data is malformed. |
| 489 QUIC_INVALID_STOP_WAITING_DATA = 60, | 494 QUIC_INVALID_STOP_WAITING_DATA = 60, |
| 490 // ACK frame data is malformed. | 495 // ACK frame data is malformed. |
| 491 QUIC_INVALID_ACK_DATA = 9, | 496 QUIC_INVALID_ACK_DATA = 9, |
| 492 | 497 |
| 493 // deprecated: QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47, | |
| 494 | |
| 495 // Version negotiation packet is malformed. | 498 // Version negotiation packet is malformed. |
| 496 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, | 499 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, |
| 497 // Public RST packet is malformed. | 500 // Public RST packet is malformed. |
| 498 QUIC_INVALID_PUBLIC_RST_PACKET = 11, | 501 QUIC_INVALID_PUBLIC_RST_PACKET = 11, |
| 499 // There was an error decrypting. | 502 // There was an error decrypting. |
| 500 QUIC_DECRYPTION_FAILURE = 12, | 503 QUIC_DECRYPTION_FAILURE = 12, |
| 501 // There was an error encrypting. | 504 // There was an error encrypting. |
| 502 QUIC_ENCRYPTION_FAILURE = 13, | 505 QUIC_ENCRYPTION_FAILURE = 13, |
| 503 // The packet exceeded kMaxPacketSize. | 506 // The packet exceeded kMaxPacketSize. |
| 504 QUIC_PACKET_TOO_LARGE = 14, | 507 QUIC_PACKET_TOO_LARGE = 14, |
| 505 // Data was sent for a stream which did not exist. | |
| 506 QUIC_PACKET_FOR_NONEXISTENT_STREAM = 15, | |
| 507 // The peer is going away. May be a client or server. | 508 // The peer is going away. May be a client or server. |
| 508 QUIC_PEER_GOING_AWAY = 16, | 509 QUIC_PEER_GOING_AWAY = 16, |
| 509 // A stream ID was invalid. | 510 // A stream ID was invalid. |
| 510 QUIC_INVALID_STREAM_ID = 17, | 511 QUIC_INVALID_STREAM_ID = 17, |
| 511 // A priority was invalid. | 512 // A priority was invalid. |
| 512 QUIC_INVALID_PRIORITY = 49, | 513 QUIC_INVALID_PRIORITY = 49, |
| 513 // Too many streams already open. | 514 // Too many streams already open. |
| 514 QUIC_TOO_MANY_OPEN_STREAMS = 18, | 515 QUIC_TOO_MANY_OPEN_STREAMS = 18, |
| 515 // The peer must send a FIN/RST for each stream, and has not been doing so. | 516 // The peer must send a FIN/RST for each stream, and has not been doing so. |
| 516 QUIC_TOO_MANY_UNFINISHED_STREAMS = 66, | 517 QUIC_TOO_MANY_UNFINISHED_STREAMS = 66, |
| 517 // The peer created too many available streams. | 518 // The peer created too many available streams. |
| 518 QUIC_TOO_MANY_AVAILABLE_STREAMS = 76, | 519 QUIC_TOO_MANY_AVAILABLE_STREAMS = 76, |
| 519 // Received public reset for this connection. | 520 // Received public reset for this connection. |
| 520 QUIC_PUBLIC_RESET = 19, | 521 QUIC_PUBLIC_RESET = 19, |
| 521 // Invalid protocol version. | 522 // Invalid protocol version. |
| 522 QUIC_INVALID_VERSION = 20, | 523 QUIC_INVALID_VERSION = 20, |
| 523 | 524 |
| 524 // deprecated: QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED = 21 | |
| 525 | |
| 526 // The Header ID for a stream was too far from the previous. | 525 // The Header ID for a stream was too far from the previous. |
| 527 QUIC_INVALID_HEADER_ID = 22, | 526 QUIC_INVALID_HEADER_ID = 22, |
| 528 // Negotiable parameter received during handshake had invalid value. | 527 // Negotiable parameter received during handshake had invalid value. |
| 529 QUIC_INVALID_NEGOTIATED_VALUE = 23, | 528 QUIC_INVALID_NEGOTIATED_VALUE = 23, |
| 530 // There was an error decompressing data. | 529 // There was an error decompressing data. |
| 531 QUIC_DECOMPRESSION_FAILURE = 24, | 530 QUIC_DECOMPRESSION_FAILURE = 24, |
| 532 // We hit our prenegotiated (or default) timeout | 531 // We hit our prenegotiated (or default) timeout |
| 533 QUIC_CONNECTION_TIMED_OUT = 25, | 532 QUIC_CONNECTION_TIMED_OUT = 25, |
| 534 // We hit our overall connection timeout | 533 // We hit our overall connection timeout |
| 535 QUIC_CONNECTION_OVERALL_TIMED_OUT = 67, | 534 QUIC_CONNECTION_OVERALL_TIMED_OUT = 67, |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 // Time elapsed since largest_observed was received until this Ack frame was | 860 // Time elapsed since largest_observed was received until this Ack frame was |
| 862 // sent. | 861 // sent. |
| 863 QuicTime::Delta delta_time_largest_observed; | 862 QuicTime::Delta delta_time_largest_observed; |
| 864 | 863 |
| 865 // Vector of <packet_number, time> for when packets arrived. | 864 // Vector of <packet_number, time> for when packets arrived. |
| 866 PacketTimeVector received_packet_times; | 865 PacketTimeVector received_packet_times; |
| 867 | 866 |
| 868 // The set of packets which we're expecting and have not received. | 867 // The set of packets which we're expecting and have not received. |
| 869 PacketNumberQueue missing_packets; | 868 PacketNumberQueue missing_packets; |
| 870 | 869 |
| 871 // Packets which have been revived via FEC. | 870 // Packet most recently revived via FEC, 0 if no packet was revived by FEC. |
| 872 // All of these must also be in missing_packets. | 871 // If non-zero, must be present in missing_packets. |
| 873 PacketNumberSet revived_packets; | 872 QuicPacketNumber latest_revived_packet; |
| 874 }; | 873 }; |
| 875 | 874 |
| 876 // True if the packet number is greater than largest_observed or is listed | 875 // True if the packet number is greater than largest_observed or is listed |
| 877 // as missing. | 876 // as missing. |
| 878 // Always returns false for packet numbers less than least_unacked. | 877 // Always returns false for packet numbers less than least_unacked. |
| 879 bool NET_EXPORT_PRIVATE IsAwaitingPacket(const QuicAckFrame& ack_frame, | 878 bool NET_EXPORT_PRIVATE IsAwaitingPacket(const QuicAckFrame& ack_frame, |
| 880 QuicPacketNumber packet_number); | 879 QuicPacketNumber packet_number); |
| 881 | 880 |
| 882 // Defines for all types of congestion control algorithms that can be used in | 881 // Defines for all types of congestion control algorithms that can be used in |
| 883 // QUIC. Note that this is separate from the congestion feedback type - | 882 // QUIC. Note that this is separate from the congestion feedback type - |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 // to be specified so that it is retransmitted at a level which the peer can | 980 // to be specified so that it is retransmitted at a level which the peer can |
| 982 // understand. | 981 // understand. |
| 983 enum EncryptionLevel { | 982 enum EncryptionLevel { |
| 984 ENCRYPTION_NONE = 0, | 983 ENCRYPTION_NONE = 0, |
| 985 ENCRYPTION_INITIAL = 1, | 984 ENCRYPTION_INITIAL = 1, |
| 986 ENCRYPTION_FORWARD_SECURE = 2, | 985 ENCRYPTION_FORWARD_SECURE = 2, |
| 987 | 986 |
| 988 NUM_ENCRYPTION_LEVELS, | 987 NUM_ENCRYPTION_LEVELS, |
| 989 }; | 988 }; |
| 990 | 989 |
| 990 enum PeerAddressChangeType { |
| 991 NO_CHANGE, |
| 992 // Peer address changes which are considered to be cause by NATs. Currently, |
| 993 // IPv4 address change with /24 does not change is considered to be cause by |
| 994 // NATs. |
| 995 NAT_PORT_REBINDING, |
| 996 IPV4_SUBNET_REBINDING, |
| 997 // IPv6 related address changes. |
| 998 IPV4_TO_IPV6, |
| 999 IPV6_TO_IPV4, |
| 1000 IPV6_TO_IPV6, |
| 1001 // This type is used when we always allow peer address changes. |
| 1002 UNKNOWN, |
| 1003 // All other peer address change types. |
| 1004 UNSPECIFIED, |
| 1005 }; |
| 1006 |
| 991 struct NET_EXPORT_PRIVATE QuicFrame { | 1007 struct NET_EXPORT_PRIVATE QuicFrame { |
| 992 QuicFrame(); | 1008 QuicFrame(); |
| 993 explicit QuicFrame(QuicPaddingFrame padding_frame); | 1009 explicit QuicFrame(QuicPaddingFrame padding_frame); |
| 994 explicit QuicFrame(QuicMtuDiscoveryFrame frame); | 1010 explicit QuicFrame(QuicMtuDiscoveryFrame frame); |
| 995 explicit QuicFrame(QuicPingFrame frame); | 1011 explicit QuicFrame(QuicPingFrame frame); |
| 996 | 1012 |
| 997 explicit QuicFrame(QuicStreamFrame* stream_frame); | 1013 explicit QuicFrame(QuicStreamFrame* stream_frame); |
| 998 explicit QuicFrame(QuicAckFrame* frame); | 1014 explicit QuicFrame(QuicAckFrame* frame); |
| 999 explicit QuicFrame(QuicRstStreamFrame* frame); | 1015 explicit QuicFrame(QuicRstStreamFrame* frame); |
| 1000 explicit QuicFrame(QuicConnectionCloseFrame* frame); | 1016 explicit QuicFrame(QuicConnectionCloseFrame* frame); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 }; | 1163 }; |
| 1148 | 1164 |
| 1149 struct NET_EXPORT_PRIVATE SerializedPacket { | 1165 struct NET_EXPORT_PRIVATE SerializedPacket { |
| 1150 SerializedPacket(QuicPacketNumber packet_number, | 1166 SerializedPacket(QuicPacketNumber packet_number, |
| 1151 QuicPacketNumberLength packet_number_length, | 1167 QuicPacketNumberLength packet_number_length, |
| 1152 QuicEncryptedPacket* packet, | 1168 QuicEncryptedPacket* packet, |
| 1153 QuicPacketEntropyHash entropy_hash, | 1169 QuicPacketEntropyHash entropy_hash, |
| 1154 RetransmittableFrames* retransmittable_frames, | 1170 RetransmittableFrames* retransmittable_frames, |
| 1155 bool has_ack, | 1171 bool has_ack, |
| 1156 bool has_stop_waiting); | 1172 bool has_stop_waiting); |
| 1173 SerializedPacket(QuicPacketNumber packet_number, |
| 1174 QuicPacketNumberLength packet_number_length, |
| 1175 char* encrypted_buffer, |
| 1176 size_t encrypted_length, |
| 1177 bool owns_buffer, |
| 1178 QuicPacketEntropyHash entropy_hash, |
| 1179 RetransmittableFrames* retransmittable_frames, |
| 1180 bool has_ack, |
| 1181 bool has_stop_waiting); |
| 1157 ~SerializedPacket(); | 1182 ~SerializedPacket(); |
| 1158 | 1183 |
| 1159 QuicEncryptedPacket* packet; | 1184 QuicEncryptedPacket* packet; |
| 1160 RetransmittableFrames* retransmittable_frames; | 1185 RetransmittableFrames* retransmittable_frames; |
| 1161 QuicPacketNumber packet_number; | 1186 QuicPacketNumber packet_number; |
| 1162 QuicPacketNumberLength packet_number_length; | 1187 QuicPacketNumberLength packet_number_length; |
| 1163 QuicPacketEntropyHash entropy_hash; | 1188 QuicPacketEntropyHash entropy_hash; |
| 1164 bool is_fec_packet; | 1189 bool is_fec_packet; |
| 1165 bool has_ack; | 1190 bool has_ack; |
| 1166 bool has_stop_waiting; | 1191 bool has_stop_waiting; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 : iov(iov), iov_count(iov_count), total_length(total_length) {} | 1238 : iov(iov), iov_count(iov_count), total_length(total_length) {} |
| 1214 | 1239 |
| 1215 const struct iovec* iov; | 1240 const struct iovec* iov; |
| 1216 const int iov_count; | 1241 const int iov_count; |
| 1217 const size_t total_length; | 1242 const size_t total_length; |
| 1218 }; | 1243 }; |
| 1219 | 1244 |
| 1220 } // namespace net | 1245 } // namespace net |
| 1221 | 1246 |
| 1222 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1247 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
| OLD | NEW |