FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
error.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 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 #include <quicly/constants.h>
20 
21 u8 *
22 quic_format_err (u8 * s, va_list * args)
23 {
24  u64 code = va_arg (*args, u64);
25  switch (code)
26  {
27  case 0:
28  s = format (s, "no error");
29  break;
30  /* app errors */
32  s = format (s, "full fifo");
33  break;
35  s = format (s, "QUIC_APP_ERROR_CLOSE_NOTIFY");
36  break;
38  s = format (s, "QUIC_APP_ALLOCATION_ERROR");
39  break;
41  s = format (s, "QUIC_APP_ACCEPT_NOTIFY_ERROR");
42  break;
44  s = format (s, "QUIC_APP_CONNECT_NOTIFY_ERROR");
45  break;
46  /* quicly errors */
47  case QUICLY_ERROR_PACKET_IGNORED:
48  s = format (s, "QUICLY_ERROR_PACKET_IGNORED");
49  break;
50  case QUICLY_ERROR_SENDBUF_FULL:
51  s = format (s, "QUICLY_ERROR_SENDBUF_FULL");
52  break;
53  case QUICLY_ERROR_FREE_CONNECTION:
54  s = format (s, "QUICLY_ERROR_FREE_CONNECTION");
55  break;
56  case QUICLY_ERROR_RECEIVED_STATELESS_RESET:
57  s = format (s, "QUICLY_ERROR_RECEIVED_STATELESS_RESET");
58  break;
59  case QUICLY_TRANSPORT_ERROR_NONE:
60  s = format (s, "QUICLY_TRANSPORT_ERROR_NONE");
61  break;
62  case QUICLY_TRANSPORT_ERROR_INTERNAL:
63  s = format (s, "QUICLY_TRANSPORT_ERROR_INTERNAL");
64  break;
65  case QUICLY_TRANSPORT_ERROR_CONNECTION_REFUSED:
66  s = format (s, "QUICLY_TRANSPORT_ERROR_CONNECTION_REFUSED");
67  break;
68  case QUICLY_TRANSPORT_ERROR_FLOW_CONTROL:
69  s = format (s, "QUICLY_TRANSPORT_ERROR_FLOW_CONTROL");
70  break;
71  case QUICLY_TRANSPORT_ERROR_STREAM_LIMIT:
72  s = format (s, "QUICLY_TRANSPORT_ERROR_STREAM_LIMIT");
73  break;
74  case QUICLY_TRANSPORT_ERROR_STREAM_STATE:
75  s = format (s, "QUICLY_TRANSPORT_ERROR_STREAM_STATE");
76  break;
77  case QUICLY_TRANSPORT_ERROR_FINAL_SIZE:
78  s = format (s, "QUICLY_TRANSPORT_ERROR_FINAL_SIZE");
79  break;
80  case QUICLY_TRANSPORT_ERROR_FRAME_ENCODING:
81  s = format (s, "QUICLY_TRANSPORT_ERROR_FRAME_ENCODING");
82  break;
83  case QUICLY_TRANSPORT_ERROR_TRANSPORT_PARAMETER:
84  s = format (s, "QUICLY_TRANSPORT_ERROR_TRANSPORT_PARAMETER");
85  break;
86  case QUICLY_ERROR_NO_COMPATIBLE_VERSION:
87  s = format (s, "QUICLY_ERROR_NO_COMPATIBLE_VERSION");
88  break;
89  case QUICLY_TRANSPORT_ERROR_PROTOCOL_VIOLATION:
90  s = format (s, "QUICLY_TRANSPORT_ERROR_PROTOCOL_VIOLATION");
91  break;
92  case QUICLY_TRANSPORT_ERROR_CRYPTO_BUFFER_EXCEEDED:
93  s = format (s, "QUICLY_TRANSPORT_ERROR_CRYPTO_BUFFER_EXCEEDED");
94  break;
95  /* picotls errors */
96  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CLOSE_NOTIFY):
97  s =
98  format (s, "PTLS_ALERT_CLOSE_NOTIFY");
99  break;
100  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_UNEXPECTED_MESSAGE):
101  s =
102  format (s, "PTLS_ALERT_UNEXPECTED_MESSAGE");
103  break;
104  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_BAD_RECORD_MAC):
105  s =
106  format (s, "PTLS_ALERT_BAD_RECORD_MAC");
107  break;
108  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_HANDSHAKE_FAILURE):
109  s =
110  format (s, "PTLS_ALERT_HANDSHAKE_FAILURE");
111  break;
112  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_BAD_CERTIFICATE):
113  s =
114  format (s, "PTLS_ALERT_BAD_CERTIFICATE");
115  break;
116  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CERTIFICATE_REVOKED):
117  s =
118  format (s, "PTLS_ALERT_CERTIFICATE_REVOKED");
119  break;
120  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CERTIFICATE_EXPIRED):
121  s =
122  format (s, "PTLS_ALERT_CERTIFICATE_EXPIRED");
123  break;
124  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CERTIFICATE_UNKNOWN):
125  s =
126  format (s, "PTLS_ALERT_CERTIFICATE_UNKNOWN");
127  break;
128  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_ILLEGAL_PARAMETER):
129  s =
130  format (s, "PTLS_ALERT_ILLEGAL_PARAMETER");
131  break;
132  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_UNKNOWN_CA):
133  s =
134  format (s, "PTLS_ALERT_UNKNOWN_CA");
135  break;
136  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_DECODE_ERROR):
137  s =
138  format (s, "PTLS_ALERT_DECODE_ERROR");
139  break;
140  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_DECRYPT_ERROR):
141  s =
142  format (s, "PTLS_ALERT_DECRYPT_ERROR");
143  break;
144  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_PROTOCOL_VERSION):
145  s =
146  format (s, "PTLS_ALERT_PROTOCOL_VERSION");
147  break;
148  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_INTERNAL_ERROR):
149  s =
150  format (s, "PTLS_ALERT_INTERNAL_ERROR");
151  break;
152  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_USER_CANCELED):
153  s =
154  format (s, "PTLS_ALERT_USER_CANCELED");
155  break;
156  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_MISSING_EXTENSION):
157  s =
158  format (s, "PTLS_ALERT_MISSING_EXTENSION");
159  break;
160  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_UNRECOGNIZED_NAME):
161  s =
162  format (s, "PTLS_ALERT_UNRECOGNIZED_NAME");
163  break;
164  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_CERTIFICATE_REQUIRED):
165  s =
166  format (s, "PTLS_ALERT_CERTIFICATE_REQUIRED");
167  break;
168  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ALERT_NO_APPLICATION_PROTOCOL):
169  s =
170  format (s, "PTLS_ALERT_NO_APPLICATION_PROTOCOL");
171  break;
172  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_NO_MEMORY):
173  s =
174  format (s, "PTLS_ERROR_NO_MEMORY");
175  break;
176  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_IN_PROGRESS):
177  s =
178  format (s, "PTLS_ERROR_IN_PROGRESS");
179  break;
180  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_LIBRARY):
181  s =
182  format (s, "PTLS_ERROR_LIBRARY");
183  break;
184  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCOMPATIBLE_KEY):
185  s =
186  format (s, "PTLS_ERROR_INCOMPATIBLE_KEY");
187  break;
188  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_SESSION_NOT_FOUND):
189  s =
190  format (s, "PTLS_ERROR_SESSION_NOT_FOUND");
191  break;
192  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_STATELESS_RETRY):
193  s =
194  format (s, "PTLS_ERROR_STATELESS_RETRY");
195  break;
196  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_NOT_AVAILABLE):
197  s =
198  format (s, "PTLS_ERROR_NOT_AVAILABLE");
199  break;
200  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_COMPRESSION_FAILURE):
201  s =
202  format (s, "PTLS_ERROR_COMPRESSION_FAILURE");
203  break;
204  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_INCORRECT_ENCODING):
205  s =
206  format (s, "PTLS_ERROR_BER_INCORRECT_ENCODING");
207  break;
208  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_MALFORMED_TYPE):
209  s =
210  format (s, "PTLS_ERROR_BER_MALFORMED_TYPE");
211  break;
212  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_MALFORMED_LENGTH):
213  s =
214  format (s, "PTLS_ERROR_BER_MALFORMED_LENGTH");
215  break;
216  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_EXCESSIVE_LENGTH):
217  s =
218  format (s, "PTLS_ERROR_BER_EXCESSIVE_LENGTH");
219  break;
220  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_ELEMENT_TOO_SHORT):
221  s =
222  format (s, "PTLS_ERROR_BER_ELEMENT_TOO_SHORT");
223  break;
224  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_BER_UNEXPECTED_EOC):
225  s =
226  format (s, "PTLS_ERROR_BER_UNEXPECTED_EOC");
227  break;
228  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_DER_INDEFINITE_LENGTH):
229  s =
230  format (s, "PTLS_ERROR_DER_INDEFINITE_LENGTH");
231  break;
232  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_ASN1_SYNTAX):
233  s =
234  format (s, "PTLS_ERROR_INCORRECT_ASN1_SYNTAX");
235  break;
236  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_PEM_KEY_VERSION):
237  s =
238  format (s, "PTLS_ERROR_INCORRECT_PEM_KEY_VERSION");
239  break;
240  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_PEM_ECDSA_KEY_VERSION):
241  s =
242  format (s, "PTLS_ERROR_INCORRECT_PEM_ECDSA_KEY_VERSION");
243  break;
244  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_PEM_ECDSA_CURVE):
245  s =
246  format (s, "PTLS_ERROR_INCORRECT_PEM_ECDSA_CURVE");
247  break;
248  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_PEM_ECDSA_KEYSIZE):
249  s =
250  format (s, "PTLS_ERROR_INCORRECT_PEM_ECDSA_KEYSIZE");
251  break;
252  case QUICLY_TRANSPORT_ERROR_TLS_ALERT_BASE + PTLS_ERROR_TO_ALERT (PTLS_ERROR_INCORRECT_ASN1_ECDSA_KEY_SYNTAX):
253  s =
254  format (s, "PTLS_ERROR_INCORRECT_ASN1_ECDSA_KEY_SYNTAX");
255  break;
256  default:
257  s = format (s, "unknown error 0x%lx", code);
258  break;
259  }
260  return s;
261 }
QUIC_APP_ALLOCATION_ERROR
#define QUIC_APP_ALLOCATION_ERROR
Definition: quic.h:66
QUIC_APP_CONNECT_NOTIFY_ERROR
#define QUIC_APP_CONNECT_NOTIFY_ERROR
Definition: quic.h:68
QUIC_APP_ACCEPT_NOTIFY_ERROR
#define QUIC_APP_ACCEPT_NOTIFY_ERROR
Definition: quic.h:67
quic_format_err
u8 * quic_format_err(u8 *s, va_list *args)
Definition: error.c:22
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
quic.h
u8
unsigned char u8
Definition: types.h:56
QUIC_ERROR_FULL_FIFO
#define QUIC_ERROR_FULL_FIFO
Definition: quic.h:64
QUIC_APP_ERROR_CLOSE_NOTIFY
#define QUIC_APP_ERROR_CLOSE_NOTIFY
Definition: quic.h:65