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