blob: 534d0b5e4c3fd08f749f4720e9688e86bbe529f3 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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
3// found in the LICENSE file.
4
5#ifndef QUICHE_QUIC_CORE_QUIC_ERROR_CODES_H_
6#define QUICHE_QUIC_CORE_QUIC_ERROR_CODES_H_
7
8#include <cstdint>
9#include <limits>
wub2b5942f2019-04-11 13:22:50 -070010#include <string>
QUICHE teama6ef0a62019-03-07 20:34:33 -050011
12#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
13
14namespace quic {
15
16enum QuicRstStreamErrorCode {
17 // Complete response has been sent, sending a RST to ask the other endpoint
18 // to stop sending request data without discarding the response.
19 QUIC_STREAM_NO_ERROR = 0,
20
21 // There was some error which halted stream processing.
22 QUIC_ERROR_PROCESSING_STREAM,
23 // We got two fin or reset offsets which did not match.
24 QUIC_MULTIPLE_TERMINATION_OFFSETS,
25 // We got bad payload and can not respond to it at the protocol level.
26 QUIC_BAD_APPLICATION_PAYLOAD,
27 // Stream closed due to connection error. No reset frame is sent when this
28 // happens.
29 QUIC_STREAM_CONNECTION_ERROR,
30 // GoAway frame sent. No more stream can be created.
31 QUIC_STREAM_PEER_GOING_AWAY,
32 // The stream has been cancelled.
33 QUIC_STREAM_CANCELLED,
34 // Closing stream locally, sending a RST to allow for proper flow control
35 // accounting. Sent in response to a RST from the peer.
36 QUIC_RST_ACKNOWLEDGEMENT,
37 // Receiver refused to create the stream (because its limit on open streams
38 // has been reached). The sender should retry the request later (using
39 // another stream).
40 QUIC_REFUSED_STREAM,
41 // Invalid URL in PUSH_PROMISE request header.
42 QUIC_INVALID_PROMISE_URL,
43 // Server is not authoritative for this URL.
44 QUIC_UNAUTHORIZED_PROMISE_URL,
45 // Can't have more than one active PUSH_PROMISE per URL.
46 QUIC_DUPLICATE_PROMISE_URL,
47 // Vary check failed.
48 QUIC_PROMISE_VARY_MISMATCH,
49 // Only GET and HEAD methods allowed.
50 QUIC_INVALID_PROMISE_METHOD,
51 // The push stream is unclaimed and timed out.
52 QUIC_PUSH_STREAM_TIMED_OUT,
53 // Received headers were too large.
54 QUIC_HEADERS_TOO_LARGE,
55 // The data is not likely arrive in time.
56 QUIC_STREAM_TTL_EXPIRED,
57 // No error. Used as bound while iterating.
58 QUIC_STREAM_LAST_ERROR,
59};
60// QuicRstStreamErrorCode is encoded as a single octet on-the-wire.
61static_assert(static_cast<int>(QUIC_STREAM_LAST_ERROR) <=
62 std::numeric_limits<uint8_t>::max(),
63 "QuicRstStreamErrorCode exceeds single octet");
64
65// These values must remain stable as they are uploaded to UMA histograms.
66// To add a new error code, use the current value of QUIC_LAST_ERROR and
67// increment QUIC_LAST_ERROR.
68enum QuicErrorCode {
69 QUIC_NO_ERROR = 0,
70
71 // Connection has reached an invalid state.
72 QUIC_INTERNAL_ERROR = 1,
73 // There were data frames after the a fin or reset.
74 QUIC_STREAM_DATA_AFTER_TERMINATION = 2,
75 // Control frame is malformed.
76 QUIC_INVALID_PACKET_HEADER = 3,
77 // Frame data is malformed.
78 QUIC_INVALID_FRAME_DATA = 4,
79 // The packet contained no payload.
80 QUIC_MISSING_PAYLOAD = 48,
81 // FEC data is malformed.
82 QUIC_INVALID_FEC_DATA = 5,
83 // STREAM frame data is malformed.
84 QUIC_INVALID_STREAM_DATA = 46,
85 // STREAM frame data overlaps with buffered data.
86 QUIC_OVERLAPPING_STREAM_DATA = 87,
87 // Received STREAM frame data is not encrypted.
88 QUIC_UNENCRYPTED_STREAM_DATA = 61,
89 // Attempt to send unencrypted STREAM frame.
90 QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA = 88,
91 // Received a frame which is likely the result of memory corruption.
92 QUIC_MAYBE_CORRUPTED_MEMORY = 89,
93 // FEC frame data is not encrypted.
94 QUIC_UNENCRYPTED_FEC_DATA = 77,
95 // RST_STREAM frame data is malformed.
96 QUIC_INVALID_RST_STREAM_DATA = 6,
97 // CONNECTION_CLOSE frame data is malformed.
98 QUIC_INVALID_CONNECTION_CLOSE_DATA = 7,
99 // GOAWAY frame data is malformed.
100 QUIC_INVALID_GOAWAY_DATA = 8,
101 // WINDOW_UPDATE frame data is malformed.
102 QUIC_INVALID_WINDOW_UPDATE_DATA = 57,
103 // BLOCKED frame data is malformed.
104 QUIC_INVALID_BLOCKED_DATA = 58,
105 // STOP_WAITING frame data is malformed.
106 QUIC_INVALID_STOP_WAITING_DATA = 60,
107 // PATH_CLOSE frame data is malformed.
108 QUIC_INVALID_PATH_CLOSE_DATA = 78,
109 // ACK frame data is malformed.
110 QUIC_INVALID_ACK_DATA = 9,
111 // Message frame data is malformed.
112 QUIC_INVALID_MESSAGE_DATA = 112,
113
114 // Version negotiation packet is malformed.
115 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10,
116 // Public RST packet is malformed.
117 QUIC_INVALID_PUBLIC_RST_PACKET = 11,
118 // There was an error decrypting.
119 QUIC_DECRYPTION_FAILURE = 12,
120 // There was an error encrypting.
121 QUIC_ENCRYPTION_FAILURE = 13,
dschinazi66dea072019-04-09 11:41:06 -0700122 // The packet exceeded kMaxOutgoingPacketSize.
QUICHE teama6ef0a62019-03-07 20:34:33 -0500123 QUIC_PACKET_TOO_LARGE = 14,
124 // The peer is going away. May be a client or server.
125 QUIC_PEER_GOING_AWAY = 16,
126 // A stream ID was invalid.
127 QUIC_INVALID_STREAM_ID = 17,
128 // A priority was invalid.
129 QUIC_INVALID_PRIORITY = 49,
130 // Too many streams already open.
131 QUIC_TOO_MANY_OPEN_STREAMS = 18,
132 // The peer created too many available streams.
133 QUIC_TOO_MANY_AVAILABLE_STREAMS = 76,
134 // Received public reset for this connection.
135 QUIC_PUBLIC_RESET = 19,
136 // Invalid protocol version.
137 QUIC_INVALID_VERSION = 20,
138
139 // The Header ID for a stream was too far from the previous.
140 QUIC_INVALID_HEADER_ID = 22,
141 // Negotiable parameter received during handshake had invalid value.
142 QUIC_INVALID_NEGOTIATED_VALUE = 23,
143 // There was an error decompressing data.
144 QUIC_DECOMPRESSION_FAILURE = 24,
145 // The connection timed out due to no network activity.
146 QUIC_NETWORK_IDLE_TIMEOUT = 25,
147 // The connection timed out waiting for the handshake to complete.
148 QUIC_HANDSHAKE_TIMEOUT = 67,
149 // There was an error encountered migrating addresses.
150 QUIC_ERROR_MIGRATING_ADDRESS = 26,
151 // There was an error encountered migrating port only.
152 QUIC_ERROR_MIGRATING_PORT = 86,
153 // There was an error while writing to the socket.
154 QUIC_PACKET_WRITE_ERROR = 27,
155 // There was an error while reading from the socket.
156 QUIC_PACKET_READ_ERROR = 51,
157 // We received a STREAM_FRAME with no data and no fin flag set.
158 QUIC_EMPTY_STREAM_FRAME_NO_FIN = 50,
159 // We received invalid data on the headers stream.
160 QUIC_INVALID_HEADERS_STREAM_DATA = 56,
161 // Invalid data on the headers stream received because of decompression
162 // failure.
163 QUIC_HEADERS_STREAM_DATA_DECOMPRESS_FAILURE = 97,
164 // The peer received too much data, violating flow control.
165 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA = 59,
166 // The peer sent too much data, violating flow control.
167 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA = 63,
168 // The peer received an invalid flow control window.
169 QUIC_FLOW_CONTROL_INVALID_WINDOW = 64,
170 // The connection has been IP pooled into an existing connection.
171 QUIC_CONNECTION_IP_POOLED = 62,
172 // The connection has too many outstanding sent packets.
173 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS = 68,
174 // The connection has too many outstanding received packets.
175 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS = 69,
176 // The quic connection has been cancelled.
177 QUIC_CONNECTION_CANCELLED = 70,
178 // Disabled QUIC because of high packet loss rate.
179 QUIC_BAD_PACKET_LOSS_RATE = 71,
180 // Disabled QUIC because of too many PUBLIC_RESETs post handshake.
181 QUIC_PUBLIC_RESETS_POST_HANDSHAKE = 73,
182 // Closed because we failed to serialize a packet.
183 QUIC_FAILED_TO_SERIALIZE_PACKET = 75,
184 // QUIC timed out after too many RTOs.
185 QUIC_TOO_MANY_RTOS = 85,
186
187 // Crypto errors.
188
189 // Handshake failed.
190 QUIC_HANDSHAKE_FAILED = 28,
191 // Handshake message contained out of order tags.
192 QUIC_CRYPTO_TAGS_OUT_OF_ORDER = 29,
193 // Handshake message contained too many entries.
194 QUIC_CRYPTO_TOO_MANY_ENTRIES = 30,
195 // Handshake message contained an invalid value length.
196 QUIC_CRYPTO_INVALID_VALUE_LENGTH = 31,
197 // A crypto message was received after the handshake was complete.
198 QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE = 32,
199 // A crypto message was received with an illegal message tag.
200 QUIC_INVALID_CRYPTO_MESSAGE_TYPE = 33,
201 // A crypto message was received with an illegal parameter.
202 QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER = 34,
203 // An invalid channel id signature was supplied.
204 QUIC_INVALID_CHANNEL_ID_SIGNATURE = 52,
205 // A crypto message was received with a mandatory parameter missing.
206 QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND = 35,
207 // A crypto message was received with a parameter that has no overlap
208 // with the local parameter.
209 QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP = 36,
210 // A crypto message was received that contained a parameter with too few
211 // values.
212 QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND = 37,
213 // A demand for an unsupport proof type was received.
214 QUIC_UNSUPPORTED_PROOF_DEMAND = 94,
215 // An internal error occurred in crypto processing.
216 QUIC_CRYPTO_INTERNAL_ERROR = 38,
217 // A crypto handshake message specified an unsupported version.
218 QUIC_CRYPTO_VERSION_NOT_SUPPORTED = 39,
wub5f64ec42019-06-06 07:31:19 -0700219 // (Deprecated) A crypto handshake message resulted in a stateless reject.
220 // QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT = 72,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500221 // There was no intersection between the crypto primitives supported by the
222 // peer and ourselves.
223 QUIC_CRYPTO_NO_SUPPORT = 40,
224 // The server rejected our client hello messages too many times.
225 QUIC_CRYPTO_TOO_MANY_REJECTS = 41,
226 // The client rejected the server's certificate chain or signature.
227 QUIC_PROOF_INVALID = 42,
228 // A crypto message was received with a duplicate tag.
229 QUIC_CRYPTO_DUPLICATE_TAG = 43,
230 // A crypto message was received with the wrong encryption level (i.e. it
231 // should have been encrypted but was not.)
232 QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT = 44,
233 // The server config for a server has expired.
234 QUIC_CRYPTO_SERVER_CONFIG_EXPIRED = 45,
235 // We failed to setup the symmetric keys for a connection.
236 QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED = 53,
237 // A handshake message arrived, but we are still validating the
238 // previous handshake message.
239 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54,
240 // A server config update arrived before the handshake is complete.
241 QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE = 65,
242 // CHLO cannot fit in one packet.
243 QUIC_CRYPTO_CHLO_TOO_LARGE = 90,
244 // This connection involved a version negotiation which appears to have been
245 // tampered with.
246 QUIC_VERSION_NEGOTIATION_MISMATCH = 55,
247
248 // Multipath errors.
249 // Multipath is not enabled, but a packet with multipath flag on is received.
250 QUIC_BAD_MULTIPATH_FLAG = 79,
251 // A path is supposed to exist but does not.
252 QUIC_MULTIPATH_PATH_DOES_NOT_EXIST = 91,
253 // A path is supposed to be active but is not.
254 QUIC_MULTIPATH_PATH_NOT_ACTIVE = 92,
255
256 // IP address changed causing connection close.
257 QUIC_IP_ADDRESS_CHANGED = 80,
258
259 // Connection migration errors.
260 // Network changed, but connection had no migratable streams.
261 QUIC_CONNECTION_MIGRATION_NO_MIGRATABLE_STREAMS = 81,
262 // Connection changed networks too many times.
263 QUIC_CONNECTION_MIGRATION_TOO_MANY_CHANGES = 82,
264 // Connection migration was attempted, but there was no new network to
265 // migrate to.
266 QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK = 83,
267 // Network changed, but connection had one or more non-migratable streams.
268 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM = 84,
269 // Network changed, but connection migration was disabled by config.
270 QUIC_CONNECTION_MIGRATION_DISABLED_BY_CONFIG = 99,
271 // Network changed, but error was encountered on the alternative network.
272 QUIC_CONNECTION_MIGRATION_INTERNAL_ERROR = 100,
273 // Network changed, but handshake is not confirmed yet.
274 QUIC_CONNECTION_MIGRATION_HANDSHAKE_UNCONFIRMED = 111,
275
276 // Stream frames arrived too discontiguously so that stream sequencer buffer
277 // maintains too many intervals.
278 QUIC_TOO_MANY_STREAM_DATA_INTERVALS = 93,
279
280 // Sequencer buffer get into weird state where continuing read/write will lead
281 // to crash.
282 QUIC_STREAM_SEQUENCER_INVALID_STATE = 95,
283
284 // Connection closed because of server hits max number of sessions allowed.
285 QUIC_TOO_MANY_SESSIONS_ON_SERVER = 96,
286
287 // Receive a RST_STREAM with offset larger than kMaxStreamLength.
288 QUIC_STREAM_LENGTH_OVERFLOW = 98,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500289 // Received a MAX DATA frame with errors.
290 QUIC_INVALID_MAX_DATA_FRAME_DATA = 102,
291 // Received a MAX STREAM DATA frame with errors.
292 QUIC_INVALID_MAX_STREAM_DATA_FRAME_DATA = 103,
fkastenholz3c4eabf2019-04-22 07:49:59 -0700293 // Received a MAX_STREAMS frame with bad data
294 QUIC_MAX_STREAMS_DATA = 104,
295 // Received a STREAMS_BLOCKED frame with bad data
296 QUIC_STREAMS_BLOCKED_DATA = 105,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500297 // Error deframing a STREAM BLOCKED frame.
298 QUIC_INVALID_STREAM_BLOCKED_DATA = 106,
299 // NEW CONNECTION ID frame data is malformed.
300 QUIC_INVALID_NEW_CONNECTION_ID_DATA = 107,
301 // Received a MAX STREAM DATA frame with errors.
302 QUIC_INVALID_STOP_SENDING_FRAME_DATA = 108,
303 // Error deframing PATH CHALLENGE or PATH RESPONSE frames.
304 QUIC_INVALID_PATH_CHALLENGE_DATA = 109,
305 QUIC_INVALID_PATH_RESPONSE_DATA = 110,
306 // This is used to indicate an IETF QUIC PROTOCOL VIOLATION
307 // transport error within Google (pre-v99) QUIC.
308 IETF_QUIC_PROTOCOL_VIOLATION = 113,
309 QUIC_INVALID_NEW_TOKEN = 114,
310
311 // Received stream data on a WRITE_UNIDIRECTIONAL stream.
312 QUIC_DATA_RECEIVED_ON_WRITE_UNIDIRECTIONAL_STREAM = 115,
313 // Try to send stream data on a READ_UNIDIRECTIONAL stream.
314 QUIC_TRY_TO_WRITE_DATA_ON_READ_UNIDIRECTIONAL_STREAM = 116,
315
316 // RETIRE CONNECTION ID frame data is malformed.
317 QUIC_INVALID_RETIRE_CONNECTION_ID_DATA = 117,
fkastenholz3c4eabf2019-04-22 07:49:59 -0700318
319 // Error in a received STREAMS BLOCKED frame.
320 QUIC_STREAMS_BLOCKED_ERROR = 118,
321 // Error in a received MAX STREAMS frame
322 QUIC_MAX_STREAMS_ERROR = 119,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500323 // Error in Http decoder
324 QUIC_HTTP_DECODER_ERROR = 120,
325 // Connection from stale host needs to be cancelled.
326 QUIC_STALE_CONNECTION_CANCELLED = 121,
327
fkastenholze9d71a82019-04-09 05:12:13 -0700328 // A pseudo error, used as an extended error reason code in the error_details
329 // of IETF-QUIC CONNECTION_CLOSE frames. It is used in
330 // OnConnectionClosed upcalls to indicate that extended error information was
331 // not available in a received CONNECTION_CLOSE frame.
332 QUIC_IETF_GQUIC_ERROR_MISSING = 122,
333
renjietang28c04b72019-07-01 15:08:09 -0700334 // Received WindowUpdate on a READ_UNIDIRECTIONAL stream.
335 QUIC_WINDOW_UPDATE_RECEIVED_ON_READ_UNIDIRECTIONAL_STREAM = 123,
336
fayang83d7e3e2019-07-31 14:45:19 -0700337 // There are too many buffered control frames in control frame manager.
338 QUIC_TOO_MANY_BUFFERED_CONTROL_FRAMES = 124,
339
QUICHE teama6ef0a62019-03-07 20:34:33 -0500340 // No error. Used as bound while iterating.
fayang83d7e3e2019-07-31 14:45:19 -0700341 QUIC_LAST_ERROR = 125,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500342};
343// QuicErrorCodes is encoded as a single octet on-the-wire.
344static_assert(static_cast<int>(QUIC_LAST_ERROR) <=
345 std::numeric_limits<uint8_t>::max(),
346 "QuicErrorCode exceeds single octet");
347
348// Returns the name of the QuicRstStreamErrorCode as a char*
349QUIC_EXPORT_PRIVATE const char* QuicRstStreamErrorCodeToString(
350 QuicRstStreamErrorCode error);
351
352// Returns the name of the QuicErrorCode as a char*
353QUIC_EXPORT const char* QuicErrorCodeToString(QuicErrorCode error);
354
wub2b5942f2019-04-11 13:22:50 -0700355QUIC_EXPORT_PRIVATE inline std::string HistogramEnumString(
356 QuicErrorCode enum_value) {
357 return QuicErrorCodeToString(enum_value);
358}
359
360QUIC_EXPORT_PRIVATE inline std::string HistogramEnumDescription(
dschinazi17d42422019-06-18 16:35:07 -0700361 QuicErrorCode /*dummy*/) {
wub2b5942f2019-04-11 13:22:50 -0700362 return "cause";
363}
364
QUICHE teama6ef0a62019-03-07 20:34:33 -0500365} // namespace quic
366
367#endif // QUICHE_QUIC_CORE_QUIC_ERROR_CODES_H_