xref: /freebsd/crypto/openssl/include/openssl/bio.h (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1 /*
2  * WARNING: do not edit!
3  * Generated by Makefile from include/openssl/bio.h.in
4  *
5  * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
6  *
7  * Licensed under the Apache License 2.0 (the "License").  You may not use
8  * this file except in compliance with the License.  You can obtain a copy
9  * in the file LICENSE in the source distribution or at
10  * https://www.openssl.org/source/license.html
11  */
12 
13 
14 #ifndef OPENSSL_BIO_H
15 # define OPENSSL_BIO_H
16 # pragma once
17 
18 # include <openssl/macros.h>
19 # ifndef OPENSSL_NO_DEPRECATED_3_0
20 #  define HEADER_BIO_H
21 # endif
22 
23 # include <openssl/e_os2.h>
24 
25 # ifndef OPENSSL_NO_STDIO
26 #  include <stdio.h>
27 # endif
28 # include <stdarg.h>
29 
30 # include <openssl/crypto.h>
31 # include <openssl/bioerr.h>
32 # include <openssl/core.h>
33 
34 #ifdef  __cplusplus
35 extern "C" {
36 #endif
37 
38 /* There are the classes of BIOs */
39 # define BIO_TYPE_DESCRIPTOR     0x0100 /* socket, fd, connect or accept */
40 # define BIO_TYPE_FILTER         0x0200
41 # define BIO_TYPE_SOURCE_SINK    0x0400
42 
43 /* These are the 'types' of BIOs */
44 # define BIO_TYPE_NONE             0
45 # define BIO_TYPE_MEM            ( 1|BIO_TYPE_SOURCE_SINK)
46 # define BIO_TYPE_FILE           ( 2|BIO_TYPE_SOURCE_SINK)
47 
48 # define BIO_TYPE_FD             ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
49 # define BIO_TYPE_SOCKET         ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
50 # define BIO_TYPE_NULL           ( 6|BIO_TYPE_SOURCE_SINK)
51 # define BIO_TYPE_SSL            ( 7|BIO_TYPE_FILTER)
52 # define BIO_TYPE_MD             ( 8|BIO_TYPE_FILTER)
53 # define BIO_TYPE_BUFFER         ( 9|BIO_TYPE_FILTER)
54 # define BIO_TYPE_CIPHER         (10|BIO_TYPE_FILTER)
55 # define BIO_TYPE_BASE64         (11|BIO_TYPE_FILTER)
56 # define BIO_TYPE_CONNECT        (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
57 # define BIO_TYPE_ACCEPT         (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
58 
59 # define BIO_TYPE_NBIO_TEST      (16|BIO_TYPE_FILTER)/* server proxy BIO */
60 # define BIO_TYPE_NULL_FILTER    (17|BIO_TYPE_FILTER)
61 # define BIO_TYPE_BIO            (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */
62 # define BIO_TYPE_LINEBUFFER     (20|BIO_TYPE_FILTER)
63 # define BIO_TYPE_DGRAM          (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
64 # define BIO_TYPE_ASN1           (22|BIO_TYPE_FILTER)
65 # define BIO_TYPE_COMP           (23|BIO_TYPE_FILTER)
66 # ifndef OPENSSL_NO_SCTP
67 #  define BIO_TYPE_DGRAM_SCTP    (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
68 # endif
69 # define BIO_TYPE_CORE_TO_PROV   (25|BIO_TYPE_SOURCE_SINK)
70 
71 #define BIO_TYPE_START           128
72 
73 /*
74  * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
75  * BIO_set_fp(in,stdin,BIO_NOCLOSE);
76  */
77 # define BIO_NOCLOSE             0x00
78 # define BIO_CLOSE               0x01
79 
80 /*
81  * These are used in the following macros and are passed to BIO_ctrl()
82  */
83 # define BIO_CTRL_RESET          1/* opt - rewind/zero etc */
84 # define BIO_CTRL_EOF            2/* opt - are we at the eof */
85 # define BIO_CTRL_INFO           3/* opt - extra tit-bits */
86 # define BIO_CTRL_SET            4/* man - set the 'IO' type */
87 # define BIO_CTRL_GET            5/* man - get the 'IO' type */
88 # define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */
89 # define BIO_CTRL_POP            7/* opt - internal, used to signify change */
90 # define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */
91 # define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */
92 # define BIO_CTRL_PENDING        10/* opt - is their more data buffered */
93 # define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */
94 # define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */
95 # define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */
96 # define BIO_CTRL_SET_CALLBACK   14/* opt - set callback function */
97 # define BIO_CTRL_GET_CALLBACK   15/* opt - set callback function */
98 
99 # define BIO_CTRL_PEEK           29/* BIO_f_buffer special */
100 # define BIO_CTRL_SET_FILENAME   30/* BIO_s_file special */
101 
102 /* dgram BIO stuff */
103 # define BIO_CTRL_DGRAM_CONNECT       31/* BIO dgram special */
104 # define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected
105                                          * socket to be passed in */
106 # define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */
107 # define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */
108 # define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */
109 # define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */
110 
111 # define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */
112 # define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation timed out */
113 
114 /* #ifdef IP_MTU_DISCOVER */
115 # define BIO_CTRL_DGRAM_MTU_DISCOVER       39/* set DF bit on egress packets */
116 /* #endif */
117 
118 # define BIO_CTRL_DGRAM_QUERY_MTU          40/* as kernel for current MTU */
119 # define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47
120 # define BIO_CTRL_DGRAM_GET_MTU            41/* get cached value for MTU */
121 # define BIO_CTRL_DGRAM_SET_MTU            42/* set cached value for MTU.
122                                               * want to use this if asking
123                                               * the kernel fails */
124 
125 # define BIO_CTRL_DGRAM_MTU_EXCEEDED       43/* check whether the MTU was
126                                               * exceed in the previous write
127                                               * operation */
128 
129 # define BIO_CTRL_DGRAM_GET_PEER           46
130 # define BIO_CTRL_DGRAM_SET_PEER           44/* Destination for the data */
131 
132 # define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45/* Next DTLS handshake timeout
133                                               * to adjust socket timeouts */
134 # define BIO_CTRL_DGRAM_SET_DONT_FRAG      48
135 
136 # define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49
137 
138 /* Deliberately outside of OPENSSL_NO_SCTP - used in bss_dgram.c */
139 #  define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE    50
140 # ifndef OPENSSL_NO_SCTP
141 /* SCTP stuff */
142 #  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51
143 #  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52
144 #  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53
145 #  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60
146 #  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61
147 #  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62
148 #  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63
149 #  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64
150 #  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65
151 #  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70
152 # endif
153 
154 # define BIO_CTRL_DGRAM_SET_PEEK_MODE      71
155 
156 /*
157  * internal BIO:
158  * # define BIO_CTRL_SET_KTLS_SEND                 72
159  * # define BIO_CTRL_SET_KTLS_SEND_CTRL_MSG        74
160  * # define BIO_CTRL_CLEAR_KTLS_CTRL_MSG           75
161  */
162 
163 # define BIO_CTRL_GET_KTLS_SEND                 73
164 # define BIO_CTRL_GET_KTLS_RECV                 76
165 
166 # define BIO_CTRL_DGRAM_SCTP_WAIT_FOR_DRY       77
167 # define BIO_CTRL_DGRAM_SCTP_MSG_WAITING        78
168 
169 /* BIO_f_prefix controls */
170 # define BIO_CTRL_SET_PREFIX                    79
171 # define BIO_CTRL_SET_INDENT                    80
172 # define BIO_CTRL_GET_INDENT                    81
173 
174 # ifndef OPENSSL_NO_KTLS
175 #  define BIO_get_ktls_send(b)         \
176      (BIO_ctrl(b, BIO_CTRL_GET_KTLS_SEND, 0, NULL) > 0)
177 #  define BIO_get_ktls_recv(b)         \
178      (BIO_ctrl(b, BIO_CTRL_GET_KTLS_RECV, 0, NULL) > 0)
179 # else
180 #  define BIO_get_ktls_send(b)  (0)
181 #  define BIO_get_ktls_recv(b)  (0)
182 # endif
183 
184 /* modifiers */
185 # define BIO_FP_READ             0x02
186 # define BIO_FP_WRITE            0x04
187 # define BIO_FP_APPEND           0x08
188 # define BIO_FP_TEXT             0x10
189 
190 # define BIO_FLAGS_READ          0x01
191 # define BIO_FLAGS_WRITE         0x02
192 # define BIO_FLAGS_IO_SPECIAL    0x04
193 # define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
194 # define BIO_FLAGS_SHOULD_RETRY  0x08
195 # ifndef OPENSSL_NO_DEPRECATED_3_0
196 /* This #define was replaced by an internal constant and should not be used. */
197 #  define BIO_FLAGS_UPLINK       0
198 # endif
199 
200 # define BIO_FLAGS_BASE64_NO_NL  0x100
201 
202 /*
203  * This is used with memory BIOs:
204  * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way;
205  * BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset.
206  */
207 # define BIO_FLAGS_MEM_RDONLY    0x200
208 # define BIO_FLAGS_NONCLEAR_RST  0x400
209 # define BIO_FLAGS_IN_EOF        0x800
210 
211 /* the BIO FLAGS values 0x1000 to 0x4000 are reserved for internal KTLS flags */
212 
213 typedef union bio_addr_st BIO_ADDR;
214 typedef struct bio_addrinfo_st BIO_ADDRINFO;
215 
216 int BIO_get_new_index(void);
217 void BIO_set_flags(BIO *b, int flags);
218 int BIO_test_flags(const BIO *b, int flags);
219 void BIO_clear_flags(BIO *b, int flags);
220 
221 # define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
222 # define BIO_set_retry_special(b) \
223                 BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
224 # define BIO_set_retry_read(b) \
225                 BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
226 # define BIO_set_retry_write(b) \
227                 BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
228 
229 /* These are normally used internally in BIOs */
230 # define BIO_clear_retry_flags(b) \
231                 BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
232 # define BIO_get_retry_flags(b) \
233                 BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
234 
235 /* These should be used by the application to tell why we should retry */
236 # define BIO_should_read(a)              BIO_test_flags(a, BIO_FLAGS_READ)
237 # define BIO_should_write(a)             BIO_test_flags(a, BIO_FLAGS_WRITE)
238 # define BIO_should_io_special(a)        BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
239 # define BIO_retry_type(a)               BIO_test_flags(a, BIO_FLAGS_RWS)
240 # define BIO_should_retry(a)             BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
241 
242 /*
243  * The next three are used in conjunction with the BIO_should_io_special()
244  * condition.  After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int
245  * *reason); will walk the BIO stack and return the 'reason' for the special
246  * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return
247  * the code.
248  */
249 /*
250  * Returned from the SSL bio when the certificate retrieval code had an error
251  */
252 # define BIO_RR_SSL_X509_LOOKUP          0x01
253 /* Returned from the connect BIO when a connect would have blocked */
254 # define BIO_RR_CONNECT                  0x02
255 /* Returned from the accept BIO when an accept would have blocked */
256 # define BIO_RR_ACCEPT                   0x03
257 
258 /* These are passed by the BIO callback */
259 # define BIO_CB_FREE     0x01
260 # define BIO_CB_READ     0x02
261 # define BIO_CB_WRITE    0x03
262 # define BIO_CB_PUTS     0x04
263 # define BIO_CB_GETS     0x05
264 # define BIO_CB_CTRL     0x06
265 
266 /*
267  * The callback is called before and after the underling operation, The
268  * BIO_CB_RETURN flag indicates if it is after the call
269  */
270 # define BIO_CB_RETURN   0x80
271 # define BIO_CB_return(a) ((a)|BIO_CB_RETURN)
272 # define BIO_cb_pre(a)   (!((a)&BIO_CB_RETURN))
273 # define BIO_cb_post(a)  ((a)&BIO_CB_RETURN)
274 
275 # ifndef OPENSSL_NO_DEPRECATED_3_0
276 typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
277                                 long argl, long ret);
278 OSSL_DEPRECATEDIN_3_0 BIO_callback_fn BIO_get_callback(const BIO *b);
279 OSSL_DEPRECATEDIN_3_0 void BIO_set_callback(BIO *b, BIO_callback_fn callback);
280 OSSL_DEPRECATEDIN_3_0 long BIO_debug_callback(BIO *bio, int cmd,
281                                                const char *argp, int argi,
282                                                long argl, long ret);
283 # endif
284 
285 typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp,
286                                    size_t len, int argi,
287                                    long argl, int ret, size_t *processed);
288 BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b);
289 void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback);
290 long BIO_debug_callback_ex(BIO *bio, int oper, const char *argp, size_t len,
291                            int argi, long argl, int ret, size_t *processed);
292 
293 char *BIO_get_callback_arg(const BIO *b);
294 void BIO_set_callback_arg(BIO *b, char *arg);
295 
296 typedef struct bio_method_st BIO_METHOD;
297 
298 const char *BIO_method_name(const BIO *b);
299 int BIO_method_type(const BIO *b);
300 
301 typedef int BIO_info_cb(BIO *, int, int);
302 typedef BIO_info_cb bio_info_cb;  /* backward compatibility */
303 
304 SKM_DEFINE_STACK_OF_INTERNAL(BIO, BIO, BIO)
305 #define sk_BIO_num(sk) OPENSSL_sk_num(ossl_check_const_BIO_sk_type(sk))
306 #define sk_BIO_value(sk, idx) ((BIO *)OPENSSL_sk_value(ossl_check_const_BIO_sk_type(sk), (idx)))
307 #define sk_BIO_new(cmp) ((STACK_OF(BIO) *)OPENSSL_sk_new(ossl_check_BIO_compfunc_type(cmp)))
308 #define sk_BIO_new_null() ((STACK_OF(BIO) *)OPENSSL_sk_new_null())
309 #define sk_BIO_new_reserve(cmp, n) ((STACK_OF(BIO) *)OPENSSL_sk_new_reserve(ossl_check_BIO_compfunc_type(cmp), (n)))
310 #define sk_BIO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_BIO_sk_type(sk), (n))
311 #define sk_BIO_free(sk) OPENSSL_sk_free(ossl_check_BIO_sk_type(sk))
312 #define sk_BIO_zero(sk) OPENSSL_sk_zero(ossl_check_BIO_sk_type(sk))
313 #define sk_BIO_delete(sk, i) ((BIO *)OPENSSL_sk_delete(ossl_check_BIO_sk_type(sk), (i)))
314 #define sk_BIO_delete_ptr(sk, ptr) ((BIO *)OPENSSL_sk_delete_ptr(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)))
315 #define sk_BIO_push(sk, ptr) OPENSSL_sk_push(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
316 #define sk_BIO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
317 #define sk_BIO_pop(sk) ((BIO *)OPENSSL_sk_pop(ossl_check_BIO_sk_type(sk)))
318 #define sk_BIO_shift(sk) ((BIO *)OPENSSL_sk_shift(ossl_check_BIO_sk_type(sk)))
319 #define sk_BIO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_BIO_sk_type(sk),ossl_check_BIO_freefunc_type(freefunc))
320 #define sk_BIO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), (idx))
321 #define sk_BIO_set(sk, idx, ptr) ((BIO *)OPENSSL_sk_set(ossl_check_BIO_sk_type(sk), (idx), ossl_check_BIO_type(ptr)))
322 #define sk_BIO_find(sk, ptr) OPENSSL_sk_find(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
323 #define sk_BIO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
324 #define sk_BIO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), pnum)
325 #define sk_BIO_sort(sk) OPENSSL_sk_sort(ossl_check_BIO_sk_type(sk))
326 #define sk_BIO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_BIO_sk_type(sk))
327 #define sk_BIO_dup(sk) ((STACK_OF(BIO) *)OPENSSL_sk_dup(ossl_check_const_BIO_sk_type(sk)))
328 #define sk_BIO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(BIO) *)OPENSSL_sk_deep_copy(ossl_check_const_BIO_sk_type(sk), ossl_check_BIO_copyfunc_type(copyfunc), ossl_check_BIO_freefunc_type(freefunc)))
329 #define sk_BIO_set_cmp_func(sk, cmp) ((sk_BIO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_BIO_sk_type(sk), ossl_check_BIO_compfunc_type(cmp)))
330 
331 
332 
333 /* Prefix and suffix callback in ASN1 BIO */
334 typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,
335                           void *parg);
336 
337 typedef void (*BIO_dgram_sctp_notification_handler_fn) (BIO *b,
338                                                         void *context,
339                                                         void *buf);
340 # ifndef OPENSSL_NO_SCTP
341 /* SCTP parameter structs */
342 struct bio_dgram_sctp_sndinfo {
343     uint16_t snd_sid;
344     uint16_t snd_flags;
345     uint32_t snd_ppid;
346     uint32_t snd_context;
347 };
348 
349 struct bio_dgram_sctp_rcvinfo {
350     uint16_t rcv_sid;
351     uint16_t rcv_ssn;
352     uint16_t rcv_flags;
353     uint32_t rcv_ppid;
354     uint32_t rcv_tsn;
355     uint32_t rcv_cumtsn;
356     uint32_t rcv_context;
357 };
358 
359 struct bio_dgram_sctp_prinfo {
360     uint16_t pr_policy;
361     uint32_t pr_value;
362 };
363 # endif
364 
365 /*
366  * #define BIO_CONN_get_param_hostname BIO_ctrl
367  */
368 
369 # define BIO_C_SET_CONNECT                       100
370 # define BIO_C_DO_STATE_MACHINE                  101
371 # define BIO_C_SET_NBIO                          102
372 /* # define BIO_C_SET_PROXY_PARAM                   103 */
373 # define BIO_C_SET_FD                            104
374 # define BIO_C_GET_FD                            105
375 # define BIO_C_SET_FILE_PTR                      106
376 # define BIO_C_GET_FILE_PTR                      107
377 # define BIO_C_SET_FILENAME                      108
378 # define BIO_C_SET_SSL                           109
379 # define BIO_C_GET_SSL                           110
380 # define BIO_C_SET_MD                            111
381 # define BIO_C_GET_MD                            112
382 # define BIO_C_GET_CIPHER_STATUS                 113
383 # define BIO_C_SET_BUF_MEM                       114
384 # define BIO_C_GET_BUF_MEM_PTR                   115
385 # define BIO_C_GET_BUFF_NUM_LINES                116
386 # define BIO_C_SET_BUFF_SIZE                     117
387 # define BIO_C_SET_ACCEPT                        118
388 # define BIO_C_SSL_MODE                          119
389 # define BIO_C_GET_MD_CTX                        120
390 /* # define BIO_C_GET_PROXY_PARAM                   121 */
391 # define BIO_C_SET_BUFF_READ_DATA                122/* data to read first */
392 # define BIO_C_GET_CONNECT                       123
393 # define BIO_C_GET_ACCEPT                        124
394 # define BIO_C_SET_SSL_RENEGOTIATE_BYTES         125
395 # define BIO_C_GET_SSL_NUM_RENEGOTIATES          126
396 # define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT       127
397 # define BIO_C_FILE_SEEK                         128
398 # define BIO_C_GET_CIPHER_CTX                    129
399 # define BIO_C_SET_BUF_MEM_EOF_RETURN            130/* return end of input
400                                                      * value */
401 # define BIO_C_SET_BIND_MODE                     131
402 # define BIO_C_GET_BIND_MODE                     132
403 # define BIO_C_FILE_TELL                         133
404 # define BIO_C_GET_SOCKS                         134
405 # define BIO_C_SET_SOCKS                         135
406 
407 # define BIO_C_SET_WRITE_BUF_SIZE                136/* for BIO_s_bio */
408 # define BIO_C_GET_WRITE_BUF_SIZE                137
409 # define BIO_C_MAKE_BIO_PAIR                     138
410 # define BIO_C_DESTROY_BIO_PAIR                  139
411 # define BIO_C_GET_WRITE_GUARANTEE               140
412 # define BIO_C_GET_READ_REQUEST                  141
413 # define BIO_C_SHUTDOWN_WR                       142
414 # define BIO_C_NREAD0                            143
415 # define BIO_C_NREAD                             144
416 # define BIO_C_NWRITE0                           145
417 # define BIO_C_NWRITE                            146
418 # define BIO_C_RESET_READ_REQUEST                147
419 # define BIO_C_SET_MD_CTX                        148
420 
421 # define BIO_C_SET_PREFIX                        149
422 # define BIO_C_GET_PREFIX                        150
423 # define BIO_C_SET_SUFFIX                        151
424 # define BIO_C_GET_SUFFIX                        152
425 
426 # define BIO_C_SET_EX_ARG                        153
427 # define BIO_C_GET_EX_ARG                        154
428 
429 # define BIO_C_SET_CONNECT_MODE                  155
430 
431 # define BIO_set_app_data(s,arg)         BIO_set_ex_data(s,0,arg)
432 # define BIO_get_app_data(s)             BIO_get_ex_data(s,0)
433 
434 # define BIO_set_nbio(b,n)             BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
435 
436 # ifndef OPENSSL_NO_SOCK
437 /* IP families we support, for BIO_s_connect() and BIO_s_accept() */
438 /* Note: the underlying operating system may not support some of them */
439 #  define BIO_FAMILY_IPV4                         4
440 #  define BIO_FAMILY_IPV6                         6
441 #  define BIO_FAMILY_IPANY                        256
442 
443 /* BIO_s_connect() */
444 #  define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0, \
445                                                  (char *)(name))
446 #  define BIO_set_conn_port(b,port)     BIO_ctrl(b,BIO_C_SET_CONNECT,1, \
447                                                  (char *)(port))
448 #  define BIO_set_conn_address(b,addr)  BIO_ctrl(b,BIO_C_SET_CONNECT,2, \
449                                                  (char *)(addr))
450 #  define BIO_set_conn_ip_family(b,f)   BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f)
451 #  define BIO_get_conn_hostname(b)      ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0))
452 #  define BIO_get_conn_port(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1))
453 #  define BIO_get_conn_address(b)       ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2))
454 #  define BIO_get_conn_ip_family(b)     BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)
455 #  define BIO_set_conn_mode(b,n)        BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL)
456 
457 /* BIO_s_accept() */
458 #  define BIO_set_accept_name(b,name)   BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \
459                                                  (char *)(name))
460 #  define BIO_set_accept_port(b,port)   BIO_ctrl(b,BIO_C_SET_ACCEPT,1, \
461                                                  (char *)(port))
462 #  define BIO_get_accept_name(b)        ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0))
463 #  define BIO_get_accept_port(b)        ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1))
464 #  define BIO_get_peer_name(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2))
465 #  define BIO_get_peer_port(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3))
466 /* #define BIO_set_nbio(b,n)    BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
467 #  define BIO_set_nbio_accept(b,n)      BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)"a":NULL)
468 #  define BIO_set_accept_bios(b,bio)    BIO_ctrl(b,BIO_C_SET_ACCEPT,3, \
469                                                  (char *)(bio))
470 #  define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f)
471 #  define BIO_get_accept_ip_family(b)   BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL)
472 
473 /* Aliases kept for backward compatibility */
474 #  define BIO_BIND_NORMAL                 0
475 #  define BIO_BIND_REUSEADDR              BIO_SOCK_REUSEADDR
476 #  define BIO_BIND_REUSEADDR_IF_UNUSED    BIO_SOCK_REUSEADDR
477 #  define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
478 #  define BIO_get_bind_mode(b)    BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
479 # endif /* OPENSSL_NO_SOCK */
480 
481 # define BIO_do_connect(b)       BIO_do_handshake(b)
482 # define BIO_do_accept(b)        BIO_do_handshake(b)
483 
484 # define BIO_do_handshake(b)     BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
485 
486 /* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */
487 # define BIO_set_fd(b,fd,c)      BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
488 # define BIO_get_fd(b,c)         BIO_ctrl(b,BIO_C_GET_FD,0,(char *)(c))
489 
490 /* BIO_s_file() */
491 # define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp))
492 # define BIO_get_fp(b,fpp)       BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)(fpp))
493 
494 /* BIO_s_fd() and BIO_s_file() */
495 # define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
496 # define BIO_tell(b)     (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
497 
498 /*
499  * name is cast to lose const, but might be better to route through a
500  * function so we can do it safely
501  */
502 # ifdef CONST_STRICT
503 /*
504  * If you are wondering why this isn't defined, its because CONST_STRICT is
505  * purely a compile-time kludge to allow const to be checked.
506  */
507 int BIO_read_filename(BIO *b, const char *name);
508 # else
509 #  define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
510                 BIO_CLOSE|BIO_FP_READ,(char *)(name))
511 # endif
512 # define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
513                 BIO_CLOSE|BIO_FP_WRITE,name)
514 # define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
515                 BIO_CLOSE|BIO_FP_APPEND,name)
516 # define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
517                 BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
518 
519 /*
520  * WARNING WARNING, this ups the reference count on the read bio of the SSL
521  * structure.  This is because the ssl read BIO is now pointed to by the
522  * next_bio field in the bio.  So when you free the BIO, make sure you are
523  * doing a BIO_free_all() to catch the underlying BIO.
524  */
525 # define BIO_set_ssl(b,ssl,c)    BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)(ssl))
526 # define BIO_get_ssl(b,sslp)     BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)(sslp))
527 # define BIO_set_ssl_mode(b,client)      BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
528 # define BIO_set_ssl_renegotiate_bytes(b,num) \
529         BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)
530 # define BIO_get_num_renegotiates(b) \
531         BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)
532 # define BIO_set_ssl_renegotiate_timeout(b,seconds) \
533         BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)
534 
535 /* defined in evp.h */
536 /* #define BIO_set_md(b,md)     BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */
537 
538 # define BIO_get_mem_data(b,pp)  BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)(pp))
539 # define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)(bm))
540 # define BIO_get_mem_ptr(b,pp)   BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0, \
541                                           (char *)(pp))
542 # define BIO_set_mem_eof_return(b,v) \
543                                 BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
544 
545 /* For the BIO_f_buffer() type */
546 # define BIO_get_buffer_num_lines(b)     BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
547 # define BIO_set_buffer_size(b,size)     BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
548 # define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
549 # define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
550 # define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
551 
552 /* Don't use the next one unless you know what you are doing :-) */
553 # define BIO_dup_state(b,ret)    BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
554 
555 # define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
556 # define BIO_eof(b)              (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
557 # define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
558 # define BIO_get_close(b)        (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
559 # define BIO_pending(b)          (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
560 # define BIO_wpending(b)         (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
561 /* ...pending macros have inappropriate return type */
562 size_t BIO_ctrl_pending(BIO *b);
563 size_t BIO_ctrl_wpending(BIO *b);
564 # define BIO_flush(b)            (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
565 # define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
566                                                    cbp)
567 # define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
568 
569 /* For the BIO_f_buffer() type */
570 # define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
571 # define BIO_buffer_peek(b,s,l) BIO_ctrl(b,BIO_CTRL_PEEK,(l),(s))
572 
573 /* For BIO_s_bio() */
574 # define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
575 # define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
576 # define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
577 # define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
578 # define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
579 /* macros with inappropriate type -- but ...pending macros use int too: */
580 # define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
581 # define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
582 size_t BIO_ctrl_get_write_guarantee(BIO *b);
583 size_t BIO_ctrl_get_read_request(BIO *b);
584 int BIO_ctrl_reset_read_request(BIO *b);
585 
586 /* ctrl macros for dgram */
587 # define BIO_ctrl_dgram_connect(b,peer)  \
588                      (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)(peer))
589 # define BIO_ctrl_set_connected(b,peer) \
590          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer))
591 # define BIO_dgram_recv_timedout(b) \
592          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
593 # define BIO_dgram_send_timedout(b) \
594          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
595 # define BIO_dgram_get_peer(b,peer) \
596          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer))
597 # define BIO_dgram_set_peer(b,peer) \
598          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer))
599 # define BIO_dgram_get_mtu_overhead(b) \
600          (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
601 
602 /* ctrl macros for BIO_f_prefix */
603 # define BIO_set_prefix(b,p) BIO_ctrl((b), BIO_CTRL_SET_PREFIX, 0, (void *)(p))
604 # define BIO_set_indent(b,i) BIO_ctrl((b), BIO_CTRL_SET_INDENT, (i), NULL)
605 # define BIO_get_indent(b) BIO_ctrl((b), BIO_CTRL_GET_INDENT, 0, NULL)
606 
607 #define BIO_get_ex_new_index(l, p, newf, dupf, freef) \
608     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef)
609 int BIO_set_ex_data(BIO *bio, int idx, void *data);
610 void *BIO_get_ex_data(const BIO *bio, int idx);
611 uint64_t BIO_number_read(BIO *bio);
612 uint64_t BIO_number_written(BIO *bio);
613 
614 /* For BIO_f_asn1() */
615 int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
616                         asn1_ps_func *prefix_free);
617 int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
618                         asn1_ps_func **pprefix_free);
619 int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
620                         asn1_ps_func *suffix_free);
621 int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
622                         asn1_ps_func **psuffix_free);
623 
624 const BIO_METHOD *BIO_s_file(void);
625 BIO *BIO_new_file(const char *filename, const char *mode);
626 BIO *BIO_new_from_core_bio(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio);
627 # ifndef OPENSSL_NO_STDIO
628 BIO *BIO_new_fp(FILE *stream, int close_flag);
629 # endif
630 BIO *BIO_new_ex(OSSL_LIB_CTX *libctx, const BIO_METHOD *method);
631 BIO *BIO_new(const BIO_METHOD *type);
632 int BIO_free(BIO *a);
633 void BIO_set_data(BIO *a, void *ptr);
634 void *BIO_get_data(BIO *a);
635 void BIO_set_init(BIO *a, int init);
636 int BIO_get_init(BIO *a);
637 void BIO_set_shutdown(BIO *a, int shut);
638 int BIO_get_shutdown(BIO *a);
639 void BIO_vfree(BIO *a);
640 int BIO_up_ref(BIO *a);
641 int BIO_read(BIO *b, void *data, int dlen);
642 int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);
643 int BIO_gets(BIO *bp, char *buf, int size);
644 int BIO_get_line(BIO *bio, char *buf, int size);
645 int BIO_write(BIO *b, const void *data, int dlen);
646 int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
647 int BIO_puts(BIO *bp, const char *buf);
648 int BIO_indent(BIO *b, int indent, int max);
649 long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
650 long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);
651 void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
652 long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
653 BIO *BIO_push(BIO *b, BIO *append);
654 BIO *BIO_pop(BIO *b);
655 void BIO_free_all(BIO *a);
656 BIO *BIO_find_type(BIO *b, int bio_type);
657 BIO *BIO_next(BIO *b);
658 void BIO_set_next(BIO *b, BIO *next);
659 BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
660 int BIO_get_retry_reason(BIO *bio);
661 void BIO_set_retry_reason(BIO *bio, int reason);
662 BIO *BIO_dup_chain(BIO *in);
663 
664 int BIO_nread0(BIO *bio, char **buf);
665 int BIO_nread(BIO *bio, char **buf, int num);
666 int BIO_nwrite0(BIO *bio, char **buf);
667 int BIO_nwrite(BIO *bio, char **buf, int num);
668 
669 const BIO_METHOD *BIO_s_mem(void);
670 const BIO_METHOD *BIO_s_secmem(void);
671 BIO *BIO_new_mem_buf(const void *buf, int len);
672 # ifndef OPENSSL_NO_SOCK
673 const BIO_METHOD *BIO_s_socket(void);
674 const BIO_METHOD *BIO_s_connect(void);
675 const BIO_METHOD *BIO_s_accept(void);
676 # endif
677 const BIO_METHOD *BIO_s_fd(void);
678 const BIO_METHOD *BIO_s_log(void);
679 const BIO_METHOD *BIO_s_bio(void);
680 const BIO_METHOD *BIO_s_null(void);
681 const BIO_METHOD *BIO_f_null(void);
682 const BIO_METHOD *BIO_f_buffer(void);
683 const BIO_METHOD *BIO_f_readbuffer(void);
684 const BIO_METHOD *BIO_f_linebuffer(void);
685 const BIO_METHOD *BIO_f_nbio_test(void);
686 const BIO_METHOD *BIO_f_prefix(void);
687 const BIO_METHOD *BIO_s_core(void);
688 # ifndef OPENSSL_NO_DGRAM
689 const BIO_METHOD *BIO_s_datagram(void);
690 int BIO_dgram_non_fatal_error(int error);
691 BIO *BIO_new_dgram(int fd, int close_flag);
692 #  ifndef OPENSSL_NO_SCTP
693 const BIO_METHOD *BIO_s_datagram_sctp(void);
694 BIO *BIO_new_dgram_sctp(int fd, int close_flag);
695 int BIO_dgram_is_sctp(BIO *bio);
696 int BIO_dgram_sctp_notification_cb(BIO *b,
697                 BIO_dgram_sctp_notification_handler_fn handle_notifications,
698                 void *context);
699 int BIO_dgram_sctp_wait_for_dry(BIO *b);
700 int BIO_dgram_sctp_msg_waiting(BIO *b);
701 #  endif
702 # endif
703 
704 # ifndef OPENSSL_NO_SOCK
705 int BIO_sock_should_retry(int i);
706 int BIO_sock_non_fatal_error(int error);
707 int BIO_socket_wait(int fd, int for_read, time_t max_time);
708 # endif
709 int BIO_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds);
710 int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds);
711 
712 int BIO_fd_should_retry(int i);
713 int BIO_fd_non_fatal_error(int error);
714 int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),
715                 void *u, const void *s, int len);
716 int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
717                        void *u, const void *s, int len, int indent);
718 int BIO_dump(BIO *b, const void *bytes, int len);
719 int BIO_dump_indent(BIO *b, const void *bytes, int len, int indent);
720 # ifndef OPENSSL_NO_STDIO
721 int BIO_dump_fp(FILE *fp, const void *s, int len);
722 int BIO_dump_indent_fp(FILE *fp, const void *s, int len, int indent);
723 # endif
724 int BIO_hex_string(BIO *out, int indent, int width, const void *data,
725                    int datalen);
726 
727 # ifndef OPENSSL_NO_SOCK
728 BIO_ADDR *BIO_ADDR_new(void);
729 int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
730                      const void *where, size_t wherelen, unsigned short port);
731 void BIO_ADDR_free(BIO_ADDR *);
732 void BIO_ADDR_clear(BIO_ADDR *ap);
733 int BIO_ADDR_family(const BIO_ADDR *ap);
734 int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
735 unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
736 char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
737 char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
738 char *BIO_ADDR_path_string(const BIO_ADDR *ap);
739 
740 const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);
741 int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);
742 int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);
743 int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);
744 const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);
745 void BIO_ADDRINFO_free(BIO_ADDRINFO *bai);
746 
747 enum BIO_hostserv_priorities {
748     BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
749 };
750 int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
751                        enum BIO_hostserv_priorities hostserv_prio);
752 enum BIO_lookup_type {
753     BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER
754 };
755 int BIO_lookup(const char *host, const char *service,
756                enum BIO_lookup_type lookup_type,
757                int family, int socktype, BIO_ADDRINFO **res);
758 int BIO_lookup_ex(const char *host, const char *service,
759                   int lookup_type, int family, int socktype, int protocol,
760                   BIO_ADDRINFO **res);
761 int BIO_sock_error(int sock);
762 int BIO_socket_ioctl(int fd, long type, void *arg);
763 int BIO_socket_nbio(int fd, int mode);
764 int BIO_sock_init(void);
765 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
766 #  define BIO_sock_cleanup() while(0) continue
767 # endif
768 int BIO_set_tcp_ndelay(int sock, int turn_on);
769 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
770 OSSL_DEPRECATEDIN_1_1_0 struct hostent *BIO_gethostbyname(const char *name);
771 OSSL_DEPRECATEDIN_1_1_0 int BIO_get_port(const char *str, unsigned short *port_ptr);
772 OSSL_DEPRECATEDIN_1_1_0 int BIO_get_host_ip(const char *str, unsigned char *ip);
773 OSSL_DEPRECATEDIN_1_1_0 int BIO_get_accept_socket(char *host_port, int mode);
774 OSSL_DEPRECATEDIN_1_1_0 int BIO_accept(int sock, char **ip_port);
775 # endif
776 
777 union BIO_sock_info_u {
778     BIO_ADDR *addr;
779 };
780 enum BIO_sock_info_type {
781     BIO_SOCK_INFO_ADDRESS
782 };
783 int BIO_sock_info(int sock,
784                   enum BIO_sock_info_type type, union BIO_sock_info_u *info);
785 
786 #  define BIO_SOCK_REUSEADDR    0x01
787 #  define BIO_SOCK_V6_ONLY      0x02
788 #  define BIO_SOCK_KEEPALIVE    0x04
789 #  define BIO_SOCK_NONBLOCK     0x08
790 #  define BIO_SOCK_NODELAY      0x10
791 
792 int BIO_socket(int domain, int socktype, int protocol, int options);
793 int BIO_connect(int sock, const BIO_ADDR *addr, int options);
794 int BIO_bind(int sock, const BIO_ADDR *addr, int options);
795 int BIO_listen(int sock, const BIO_ADDR *addr, int options);
796 int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options);
797 int BIO_closesocket(int sock);
798 
799 BIO *BIO_new_socket(int sock, int close_flag);
800 BIO *BIO_new_connect(const char *host_port);
801 BIO *BIO_new_accept(const char *host_port);
802 # endif /* OPENSSL_NO_SOCK*/
803 
804 BIO *BIO_new_fd(int fd, int close_flag);
805 
806 int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
807                      BIO **bio2, size_t writebuf2);
808 /*
809  * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
810  * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default
811  * value.
812  */
813 
814 void BIO_copy_next_retry(BIO *b);
815 
816 /*
817  * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
818  */
819 
820 # define ossl_bio__attr__(x)
821 # if defined(__GNUC__) && defined(__STDC_VERSION__) \
822     && !defined(__MINGW32__) && !defined(__MINGW64__) \
823     && !defined(__APPLE__)
824     /*
825      * Because we support the 'z' modifier, which made its appearance in C99,
826      * we can't use __attribute__ with pre C99 dialects.
827      */
828 #  if __STDC_VERSION__ >= 199901L
829 #   undef ossl_bio__attr__
830 #   define ossl_bio__attr__ __attribute__
831 #   if __GNUC__*10 + __GNUC_MINOR__ >= 44
832 #    define ossl_bio__printf__ __gnu_printf__
833 #   else
834 #    define ossl_bio__printf__ __printf__
835 #   endif
836 #  endif
837 # endif
838 int BIO_printf(BIO *bio, const char *format, ...)
839 ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3)));
840 int BIO_vprintf(BIO *bio, const char *format, va_list args)
841 ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0)));
842 int BIO_snprintf(char *buf, size_t n, const char *format, ...)
843 ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4)));
844 int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
845 ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0)));
846 # undef ossl_bio__attr__
847 # undef ossl_bio__printf__
848 
849 
850 BIO_METHOD *BIO_meth_new(int type, const char *name);
851 void BIO_meth_free(BIO_METHOD *biom);
852 int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int);
853 int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t,
854                                                 size_t *);
855 int BIO_meth_set_write(BIO_METHOD *biom,
856                        int (*write) (BIO *, const char *, int));
857 int BIO_meth_set_write_ex(BIO_METHOD *biom,
858                        int (*bwrite) (BIO *, const char *, size_t, size_t *));
859 int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);
860 int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *);
861 int BIO_meth_set_read(BIO_METHOD *biom,
862                       int (*read) (BIO *, char *, int));
863 int BIO_meth_set_read_ex(BIO_METHOD *biom,
864                          int (*bread) (BIO *, char *, size_t, size_t *));
865 int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);
866 int BIO_meth_set_puts(BIO_METHOD *biom,
867                       int (*puts) (BIO *, const char *));
868 int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);
869 int BIO_meth_set_gets(BIO_METHOD *biom,
870                       int (*gets) (BIO *, char *, int));
871 long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);
872 int BIO_meth_set_ctrl(BIO_METHOD *biom,
873                       long (*ctrl) (BIO *, int, long, void *));
874 int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);
875 int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));
876 int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);
877 int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));
878 long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))
879                                  (BIO *, int, BIO_info_cb *);
880 int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
881                                long (*callback_ctrl) (BIO *, int,
882                                                       BIO_info_cb *));
883 
884 # ifdef  __cplusplus
885 }
886 # endif
887 #endif
888