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