FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
error.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <quic/quic.h>
17 
18 #include <quicly.h>
19 
20 u8 *
21 quic_format_err (u8 * s, va_list * args)
22 {
23  u64 code = va_arg (*args, u64);
24  switch (code)
25  {
26  case 0:
27  s = format (s, "no error");
28  break;
29  /* app errors */
31  s = format (s, "full fifo");
32  break;
34  s = format (s, "QUIC_APP_ERROR_CLOSE_NOTIFY");
35  break;
37  s = format (s, "QUIC_APP_ALLOCATION_ERROR");
38  break;
40  s = format (s, "QUIC_APP_ACCEPT_NOTIFY_ERROR");
41  break;
43  s = format (s, "QUIC_APP_CONNECT_NOTIFY_ERROR");
44  break;
45  /* quicly errors */
46  case QUICLY_ERROR_PACKET_IGNORED:
47  s = format (s, "QUICLY_ERROR_PACKET_IGNORED");
48  break;
49  case QUICLY_ERROR_SENDBUF_FULL:
50  s = format (s, "QUICLY_ERROR_SENDBUF_FULL");
51  break;
52  case QUICLY_ERROR_FREE_CONNECTION:
53  s = format (s, "QUICLY_ERROR_FREE_CONNECTION");
54  break;
55  case QUICLY_ERROR_RECEIVED_STATELESS_RESET:
56  s = format (s, "QUICLY_ERROR_RECEIVED_STATELESS_RESET");
57  break;
58  case QUICLY_TRANSPORT_ERROR_NONE:
59  s = format (s, "QUICLY_TRANSPORT_ERROR_NONE");
60  break;
61  case QUICLY_TRANSPORT_ERROR_INTERNAL:
62  s = format (s, "QUICLY_TRANSPORT_ERROR_INTERNAL");
63  break;
64  case QUICLY_TRANSPORT_ERROR_SERVER_BUSY:
65  s = format (s, "QUICLY_TRANSPORT_ERROR_SERVER_BUSY");
66  break;
67  case QUICLY_TRANSPORT_ERROR_FLOW_CONTROL:
68  s = format (s, "QUICLY_TRANSPORT_ERROR_FLOW_CONTROL");
69  break;
70  case QUICLY_TRANSPORT_ERROR_STREAM_LIMIT:
71  s = format (s, "QUICLY_TRANSPORT_ERROR_STREAM_LIMIT");
72  break;
73  case QUICLY_TRANSPORT_ERROR_STREAM_STATE:
74  s = format (s, "QUICLY_TRANSPORT_ERROR_STREAM_STATE");
75  break;
76  case QUICLY_TRANSPORT_ERROR_FINAL_OFFSET:
77  s = format (s, "QUICLY_TRANSPORT_ERROR_FINAL_OFFSET");
78  break;
79  case QUICLY_TRANSPORT_ERROR_FRAME_ENCODING:
80  s = format (s, "QUICLY_TRANSPORT_ERROR_FRAME_ENCODING");
81  break;
82  case QUICLY_TRANSPORT_ERROR_TRANSPORT_PARAMETER:
83  s = format (s, "QUICLY_TRANSPORT_ERROR_TRANSPORT_PARAMETER");
84  break;
85  case QUICLY_TRANSPORT_ERROR_VERSION_NEGOTIATION:
86  s = format (s, "QUICLY_TRANSPORT_ERROR_VERSION_NEGOTIATION");
87  break;
88  case QUICLY_TRANSPORT_ERROR_PROTOCOL_VIOLATION:
89  s = format (s, "QUICLY_TRANSPORT_ERROR_PROTOCOL_VIOLATION");
90  break;
91  case QUICLY_TRANSPORT_ERROR_INVALID_MIGRATION:
92  s = format (s, "QUICLY_TRANSPORT_ERROR_INVALID_MIGRATION");
93  break;
94  /* picotls errors */
95  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CLOSE_NOTIFY):
96  s =
97  format (s, "PTLS_ALERT_CLOSE_NOTIFY");
98  break;
99  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_UNEXPECTED_MESSAGE):
100  s =
101  format (s, "PTLS_ALERT_UNEXPECTED_MESSAGE");
102  break;
103  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_BAD_RECORD_MAC):
104  s =
105  format (s, "PTLS_ALERT_BAD_RECORD_MAC");
106  break;
107  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_HANDSHAKE_FAILURE):
108  s =
109  format (s, "PTLS_ALERT_HANDSHAKE_FAILURE");
110  break;
111  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_BAD_CERTIFICATE):
112  s =
113  format (s, "PTLS_ALERT_BAD_CERTIFICATE");
114  break;
115  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CERTIFICATE_REVOKED):
116  s =
117  format (s, "PTLS_ALERT_CERTIFICATE_REVOKED");
118  break;
119  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CERTIFICATE_EXPIRED):
120  s =
121  format (s, "PTLS_ALERT_CERTIFICATE_EXPIRED");
122  break;
123  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CERTIFICATE_UNKNOWN):
124  s =
125  format (s, "PTLS_ALERT_CERTIFICATE_UNKNOWN");
126  break;
127  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_ILLEGAL_PARAMETER):
128  s =
129  format (s, "PTLS_ALERT_ILLEGAL_PARAMETER");
130  break;
131  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_UNKNOWN_CA):
132  s =
133  format (s, "PTLS_ALERT_UNKNOWN_CA");
134  break;
135  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_DECODE_ERROR):
136  s =
137  format (s, "PTLS_ALERT_DECODE_ERROR");
138  break;
139  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_DECRYPT_ERROR):
140  s =
141  format (s, "PTLS_ALERT_DECRYPT_ERROR");
142  break;
143  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_PROTOCOL_VERSION):
144  s =
145  format (s, "PTLS_ALERT_PROTOCOL_VERSION");
146  break;
147  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_INTERNAL_ERROR):
148  s =
149  format (s, "PTLS_ALERT_INTERNAL_ERROR");
150  break;
151  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_USER_CANCELED):
152  s =
153  format (s, "PTLS_ALERT_USER_CANCELED");
154  break;
155  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_MISSING_EXTENSION):
156  s =
157  format (s, "PTLS_ALERT_MISSING_EXTENSION");
158  break;
159  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_UNRECOGNIZED_NAME):
160  s =
161  format (s, "PTLS_ALERT_UNRECOGNIZED_NAME");
162  break;
163  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CERTIFICATE_REQUIRED):
164  s =
165  format (s, "PTLS_ALERT_CERTIFICATE_REQUIRED");
166  break;
167  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_NO_APPLICATION_PROTOCOL):
168  s =
169  format (s, "PTLS_ALERT_NO_APPLICATION_PROTOCOL");
170  break;
171  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_NO_MEMORY):
172  s =
173  format (s, "PTLS_ERROR_NO_MEMORY");
174  break;
175  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_IN_PROGRESS):
176  s =
177  format (s, "PTLS_ERROR_IN_PROGRESS");
178  break;
179  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_LIBRARY):
180  s =
181  format (s, "PTLS_ERROR_LIBRARY");
182  break;
183  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCOMPATIBLE_KEY):
184  s =
185  format (s, "PTLS_ERROR_INCOMPATIBLE_KEY");
186  break;
187  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_SESSION_NOT_FOUND):
188  s =
189  format (s, "PTLS_ERROR_SESSION_NOT_FOUND");
190  break;
191  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_STATELESS_RETRY):
192  s =
193  format (s, "PTLS_ERROR_STATELESS_RETRY");
194  break;
195  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_NOT_AVAILABLE):
196  s =
197  format (s, "PTLS_ERROR_NOT_AVAILABLE");
198  break;
199  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_COMPRESSION_FAILURE):
200  s =
201  format (s, "PTLS_ERROR_COMPRESSION_FAILURE");
202  break;
203  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_INCORRECT_ENCODING):
204  s =
205  format (s, "PTLS_ERROR_BER_INCORRECT_ENCODING");
206  break;
207  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_MALFORMED_TYPE):
208  s =
209  format (s, "PTLS_ERROR_BER_MALFORMED_TYPE");
210  break;
211  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_MALFORMED_LENGTH):
212  s =
213  format (s, "PTLS_ERROR_BER_MALFORMED_LENGTH");
214  break;
215  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_EXCESSIVE_LENGTH):
216  s =
217  format (s, "PTLS_ERROR_BER_EXCESSIVE_LENGTH");
218  break;
219  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_ELEMENT_TOO_SHORT):
220  s =
221  format (s, "PTLS_ERROR_BER_ELEMENT_TOO_SHORT");
222  break;
223  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_UNEXPECTED_EOC):
224  s =
225  format (s, "PTLS_ERROR_BER_UNEXPECTED_EOC");
226  break;
227  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_DER_INDEFINITE_LENGTH):
228  s =
229  format (s, "PTLS_ERROR_DER_INDEFINITE_LENGTH");
230  break;
231  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_ASN1_SYNTAX):
232  s =
233  format (s, "PTLS_ERROR_INCORRECT_ASN1_SYNTAX");
234  break;
235  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_PEM_KEY_VERSION):
236  s =
237  format (s, "PTLS_ERROR_INCORRECT_PEM_KEY_VERSION");
238  break;
239  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_PEM_ECDSA_KEY_VERSION):
240  s =
241  format (s, "PTLS_ERROR_INCORRECT_PEM_ECDSA_KEY_VERSION");
242  break;
243  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_PEM_ECDSA_CURVE):
244  s =
245  format (s, "PTLS_ERROR_INCORRECT_PEM_ECDSA_CURVE");
246  break;
247  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_PEM_ECDSA_KEYSIZE):
248  s =
249  format (s, "PTLS_ERROR_INCORRECT_PEM_ECDSA_KEYSIZE");
250  break;
251  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_ASN1_ECDSA_KEY_SYNTAX):
252  s =
253  format (s, "PTLS_ERROR_INCORRECT_ASN1_ECDSA_KEY_SYNTAX");
254  break;
255  default:
256  s = format (s, "unknown error 0x%lx", code);
257  break;
258  }
259  return s;
260 }
unsigned long u64
Definition: types.h:89
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define QUIC_ERROR_FULL_FIFO
Definition: quic.h:54
unsigned char u8
Definition: types.h:56
#define QUIC_APP_ACCEPT_NOTIFY_ERROR
Definition: quic.h:57
#define QUIC_APP_CONNECT_NOTIFY_ERROR
Definition: quic.h:58
#define QUIC_APP_ALLOCATION_ERROR
Definition: quic.h:56
u8 * quic_format_err(u8 *s, va_list *args)
Definition: error.c:21
#define QUIC_APP_ERROR_CLOSE_NOTIFY
Definition: quic.h:55