xref: /openssl/crypto/bio/bio_err.c (revision b88ce46e)
1 /*
2  * Generated by util/mkerr.pl DO NOT EDIT
3  * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
4  *
5  * Licensed under the Apache License 2.0 (the "License").  You may not use
6  * this file except in compliance with the License.  You can obtain a copy
7  * in the file LICENSE in the source distribution or at
8  * https://www.openssl.org/source/license.html
9  */
10 
11 #include <openssl/err.h>
12 #include <openssl/bioerr.h>
13 #include "crypto/bioerr.h"
14 
15 #ifndef OPENSSL_NO_ERR
16 
17 static const ERR_STRING_DATA BIO_str_reasons[] = {
18     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_ACCEPT_ERROR), "accept error"},
19     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET),
20     "addrinfo addr is not af inet"},
21     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_AMBIGUOUS_HOST_OR_SERVICE),
22     "ambiguous host or service"},
23     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_BAD_FOPEN_MODE), "bad fopen mode"},
24     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_BROKEN_PIPE), "broken pipe"},
25     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_CONNECT_ERROR), "connect error"},
26     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_CONNECT_TIMEOUT), "connect timeout"},
27     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET),
28     "gethostbyname addr is not af inet"},
29     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_GETSOCKNAME_ERROR), "getsockname error"},
30     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS),
31     "getsockname truncated address"},
32     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_GETTING_SOCKTYPE), "getting socktype"},
33     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_INVALID_ARGUMENT), "invalid argument"},
34     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_INVALID_SOCKET), "invalid socket"},
35     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_IN_USE), "in use"},
36     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_LENGTH_TOO_LONG), "length too long"},
37     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_LISTEN_V6_ONLY), "listen v6 only"},
38     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_LOOKUP_RETURNED_NOTHING),
39     "lookup returned nothing"},
40     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_MALFORMED_HOST_OR_SERVICE),
41     "malformed host or service"},
42     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NBIO_CONNECT_ERROR), "nbio connect error"},
43     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED),
44     "no accept addr or service specified"},
45     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED),
46     "no hostname or service specified"},
47     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NO_PORT_DEFINED), "no port defined"},
48     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NO_SUCH_FILE), "no such file"},
49     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_PORT_MISMATCH), "port mismatch"},
50     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_TFO_DISABLED), "tfo disabled"},
51     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_TFO_NO_KERNEL_SUPPORT),
52     "tfo no kernel support"},
53     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_TRANSFER_ERROR), "transfer error"},
54     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_TRANSFER_TIMEOUT), "transfer timeout"},
55     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_BIND_SOCKET),
56     "unable to bind socket"},
57     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_CREATE_SOCKET),
58     "unable to create socket"},
59     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_KEEPALIVE),
60     "unable to keepalive"},
61     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_LISTEN_SOCKET),
62     "unable to listen socket"},
63     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_NODELAY), "unable to nodelay"},
64     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_REUSEADDR),
65     "unable to reuseaddr"},
66     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_TFO), "unable to tfo"},
67     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNAVAILABLE_IP_FAMILY),
68     "unavailable ip family"},
69     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNINITIALIZED), "uninitialized"},
70     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNKNOWN_INFO_TYPE), "unknown info type"},
71     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNSUPPORTED_IP_FAMILY),
72     "unsupported ip family"},
73     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNSUPPORTED_METHOD), "unsupported method"},
74     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNSUPPORTED_PROTOCOL_FAMILY),
75     "unsupported protocol family"},
76     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_WRITE_TO_READ_ONLY_BIO),
77     "write to read only BIO"},
78     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_WSASTARTUP), "WSAStartup"},
79     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_LOCAL_ADDR_NOT_AVAILABLE),
80      "local address not available"},
81     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_PEER_ADDR_NOT_AVAILABLE),
82      "peer address not available"},
83     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NON_FATAL),
84      "non-fatal or transient error"},
85     {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_PORT_MISMATCH),
86      "port mismatch"},
87     {0, NULL}
88 };
89 
90 #endif
91 
ossl_err_load_BIO_strings(void)92 int ossl_err_load_BIO_strings(void)
93 {
94 #ifndef OPENSSL_NO_ERR
95     if (ERR_reason_error_string(BIO_str_reasons[0].error) == NULL)
96         ERR_load_strings_const(BIO_str_reasons);
97 #endif
98     return 1;
99 }
100 
101 #ifndef OPENSSL_NO_SOCK
102 
BIO_err_is_non_fatal(unsigned int errcode)103 int BIO_err_is_non_fatal(unsigned int errcode)
104 {
105     if (ERR_SYSTEM_ERROR(errcode))
106         return BIO_sock_non_fatal_error(ERR_GET_REASON(errcode));
107     else if (ERR_GET_LIB(errcode) == ERR_LIB_BIO
108              && ERR_GET_REASON(errcode) == BIO_R_NON_FATAL)
109         return 1;
110     else
111         return 0;
112 }
113 
114 #endif
115