Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:38

0001 /*
0002  * WARNING: do not edit!
0003  * Generated by Makefile from include/openssl/bio.h.in
0004  *
0005  * Copyright 1995-2024 The OpenSSL Project Authors. All Rights Reserved.
0006  *
0007  * Licensed under the Apache License 2.0 (the "License").  You may not use
0008  * this file except in compliance with the License.  You can obtain a copy
0009  * in the file LICENSE in the source distribution or at
0010  * https://www.openssl.org/source/license.html
0011  */
0012 
0013 
0014 #ifndef OPENSSL_BIO_H
0015 # define OPENSSL_BIO_H
0016 # pragma once
0017 
0018 # include <openssl/macros.h>
0019 # ifndef OPENSSL_NO_DEPRECATED_3_0
0020 #  define HEADER_BIO_H
0021 # endif
0022 
0023 # include <openssl/e_os2.h>
0024 
0025 # ifndef OPENSSL_NO_STDIO
0026 #  include <stdio.h>
0027 # endif
0028 # include <stdarg.h>
0029 
0030 # include <openssl/crypto.h>
0031 # include <openssl/bioerr.h>
0032 # include <openssl/core.h>
0033 
0034 #ifdef  __cplusplus
0035 extern "C" {
0036 #endif
0037 
0038 /* There are the classes of BIOs */
0039 # define BIO_TYPE_DESCRIPTOR     0x0100 /* socket, fd, connect or accept */
0040 # define BIO_TYPE_FILTER         0x0200
0041 # define BIO_TYPE_SOURCE_SINK    0x0400
0042 
0043 /* These are the 'types' of BIOs */
0044 # define BIO_TYPE_NONE             0
0045 # define BIO_TYPE_MEM            ( 1|BIO_TYPE_SOURCE_SINK)
0046 # define BIO_TYPE_FILE           ( 2|BIO_TYPE_SOURCE_SINK)
0047 
0048 # define BIO_TYPE_FD             ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
0049 # define BIO_TYPE_SOCKET         ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
0050 # define BIO_TYPE_NULL           ( 6|BIO_TYPE_SOURCE_SINK)
0051 # define BIO_TYPE_SSL            ( 7|BIO_TYPE_FILTER)
0052 # define BIO_TYPE_MD             ( 8|BIO_TYPE_FILTER)
0053 # define BIO_TYPE_BUFFER         ( 9|BIO_TYPE_FILTER)
0054 # define BIO_TYPE_CIPHER         (10|BIO_TYPE_FILTER)
0055 # define BIO_TYPE_BASE64         (11|BIO_TYPE_FILTER)
0056 # define BIO_TYPE_CONNECT        (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
0057 # define BIO_TYPE_ACCEPT         (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
0058 
0059 # define BIO_TYPE_NBIO_TEST      (16|BIO_TYPE_FILTER)/* server proxy BIO */
0060 # define BIO_TYPE_NULL_FILTER    (17|BIO_TYPE_FILTER)
0061 # define BIO_TYPE_BIO            (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */
0062 # define BIO_TYPE_LINEBUFFER     (20|BIO_TYPE_FILTER)
0063 # define BIO_TYPE_DGRAM          (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
0064 # define BIO_TYPE_ASN1           (22|BIO_TYPE_FILTER)
0065 # define BIO_TYPE_COMP           (23|BIO_TYPE_FILTER)
0066 # ifndef OPENSSL_NO_SCTP
0067 #  define BIO_TYPE_DGRAM_SCTP    (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)
0068 # endif
0069 # define BIO_TYPE_CORE_TO_PROV   (25|BIO_TYPE_SOURCE_SINK)
0070 # define BIO_TYPE_DGRAM_PAIR     (26|BIO_TYPE_SOURCE_SINK)
0071 # define BIO_TYPE_DGRAM_MEM      (27|BIO_TYPE_SOURCE_SINK)
0072 
0073 /* Custom type starting index returned by BIO_get_new_index() */
0074 #define BIO_TYPE_START           128
0075 /* Custom type maximum index that can be returned by BIO_get_new_index() */
0076 #define BIO_TYPE_MASK            0xFF
0077 
0078 /*
0079  * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
0080  * BIO_set_fp(in,stdin,BIO_NOCLOSE);
0081  */
0082 # define BIO_NOCLOSE             0x00
0083 # define BIO_CLOSE               0x01
0084 
0085 /*
0086  * These are used in the following macros and are passed to BIO_ctrl()
0087  */
0088 # define BIO_CTRL_RESET          1/* opt - rewind/zero etc */
0089 # define BIO_CTRL_EOF            2/* opt - are we at the eof */
0090 # define BIO_CTRL_INFO           3/* opt - extra tit-bits */
0091 # define BIO_CTRL_SET            4/* man - set the 'IO' type */
0092 # define BIO_CTRL_GET            5/* man - get the 'IO' type */
0093 # define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */
0094 # define BIO_CTRL_POP            7/* opt - internal, used to signify change */
0095 # define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */
0096 # define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */
0097 # define BIO_CTRL_PENDING        10/* opt - is their more data buffered */
0098 # define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */
0099 # define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */
0100 # define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */
0101 # define BIO_CTRL_SET_CALLBACK   14/* opt - set callback function */
0102 # define BIO_CTRL_GET_CALLBACK   15/* opt - set callback function */
0103 
0104 # define BIO_CTRL_PEEK           29/* BIO_f_buffer special */
0105 # define BIO_CTRL_SET_FILENAME   30/* BIO_s_file special */
0106 
0107 /* dgram BIO stuff */
0108 # define BIO_CTRL_DGRAM_CONNECT       31/* BIO dgram special */
0109 # define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected
0110                                          * socket to be passed in */
0111 # define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */
0112 # define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */
0113 # define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */
0114 # define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */
0115 
0116 # define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */
0117 # define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation timed out */
0118 
0119 /* #ifdef IP_MTU_DISCOVER */
0120 # define BIO_CTRL_DGRAM_MTU_DISCOVER       39/* set DF bit on egress packets */
0121 /* #endif */
0122 
0123 # define BIO_CTRL_DGRAM_QUERY_MTU          40/* as kernel for current MTU */
0124 # define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47
0125 # define BIO_CTRL_DGRAM_GET_MTU            41/* get cached value for MTU */
0126 # define BIO_CTRL_DGRAM_SET_MTU            42/* set cached value for MTU.
0127                                               * want to use this if asking
0128                                               * the kernel fails */
0129 
0130 # define BIO_CTRL_DGRAM_MTU_EXCEEDED       43/* check whether the MTU was
0131                                               * exceed in the previous write
0132                                               * operation */
0133 
0134 # define BIO_CTRL_DGRAM_GET_PEER           46
0135 # define BIO_CTRL_DGRAM_SET_PEER           44/* Destination for the data */
0136 
0137 # define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45/* Next DTLS handshake timeout
0138                                               * to adjust socket timeouts */
0139 # define BIO_CTRL_DGRAM_SET_DONT_FRAG      48
0140 
0141 # define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49
0142 
0143 /* Deliberately outside of OPENSSL_NO_SCTP - used in bss_dgram.c */
0144 #  define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE    50
0145 # ifndef OPENSSL_NO_SCTP
0146 /* SCTP stuff */
0147 #  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51
0148 #  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52
0149 #  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53
0150 #  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60
0151 #  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61
0152 #  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62
0153 #  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63
0154 #  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64
0155 #  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65
0156 #  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70
0157 # endif
0158 
0159 # define BIO_CTRL_DGRAM_SET_PEEK_MODE      71
0160 
0161 /*
0162  * internal BIO:
0163  * # define BIO_CTRL_SET_KTLS_SEND                 72
0164  * # define BIO_CTRL_SET_KTLS_SEND_CTRL_MSG        74
0165  * # define BIO_CTRL_CLEAR_KTLS_CTRL_MSG           75
0166  */
0167 
0168 # define BIO_CTRL_GET_KTLS_SEND                 73
0169 # define BIO_CTRL_GET_KTLS_RECV                 76
0170 
0171 # define BIO_CTRL_DGRAM_SCTP_WAIT_FOR_DRY       77
0172 # define BIO_CTRL_DGRAM_SCTP_MSG_WAITING        78
0173 
0174 /* BIO_f_prefix controls */
0175 # define BIO_CTRL_SET_PREFIX                    79
0176 # define BIO_CTRL_SET_INDENT                    80
0177 # define BIO_CTRL_GET_INDENT                    81
0178 
0179 # define BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP      82
0180 # define BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE   83
0181 # define BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE   84
0182 # define BIO_CTRL_DGRAM_GET_EFFECTIVE_CAPS      85
0183 # define BIO_CTRL_DGRAM_GET_CAPS                86
0184 # define BIO_CTRL_DGRAM_SET_CAPS                87
0185 # define BIO_CTRL_DGRAM_GET_NO_TRUNC            88
0186 # define BIO_CTRL_DGRAM_SET_NO_TRUNC            89
0187 
0188 /*
0189  * internal BIO:
0190  * # define BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE 90
0191  */
0192 
0193 # define BIO_CTRL_GET_RPOLL_DESCRIPTOR          91
0194 # define BIO_CTRL_GET_WPOLL_DESCRIPTOR          92
0195 # define BIO_CTRL_DGRAM_DETECT_PEER_ADDR        93
0196 
0197 # define BIO_DGRAM_CAP_NONE                 0U
0198 # define BIO_DGRAM_CAP_HANDLES_SRC_ADDR     (1U << 0)
0199 # define BIO_DGRAM_CAP_HANDLES_DST_ADDR     (1U << 1)
0200 # define BIO_DGRAM_CAP_PROVIDES_SRC_ADDR    (1U << 2)
0201 # define BIO_DGRAM_CAP_PROVIDES_DST_ADDR    (1U << 3)
0202 
0203 # ifndef OPENSSL_NO_KTLS
0204 #  define BIO_get_ktls_send(b)         \
0205      (BIO_ctrl(b, BIO_CTRL_GET_KTLS_SEND, 0, NULL) > 0)
0206 #  define BIO_get_ktls_recv(b)         \
0207      (BIO_ctrl(b, BIO_CTRL_GET_KTLS_RECV, 0, NULL) > 0)
0208 # else
0209 #  define BIO_get_ktls_send(b)  (0)
0210 #  define BIO_get_ktls_recv(b)  (0)
0211 # endif
0212 
0213 /* modifiers */
0214 # define BIO_FP_READ             0x02
0215 # define BIO_FP_WRITE            0x04
0216 # define BIO_FP_APPEND           0x08
0217 # define BIO_FP_TEXT             0x10
0218 
0219 # define BIO_FLAGS_READ          0x01
0220 # define BIO_FLAGS_WRITE         0x02
0221 # define BIO_FLAGS_IO_SPECIAL    0x04
0222 # define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
0223 # define BIO_FLAGS_SHOULD_RETRY  0x08
0224 # ifndef OPENSSL_NO_DEPRECATED_3_0
0225 /* This #define was replaced by an internal constant and should not be used. */
0226 #  define BIO_FLAGS_UPLINK       0
0227 # endif
0228 
0229 # define BIO_FLAGS_BASE64_NO_NL  0x100
0230 
0231 /*
0232  * This is used with memory BIOs:
0233  * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way;
0234  * BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset.
0235  */
0236 # define BIO_FLAGS_MEM_RDONLY    0x200
0237 # define BIO_FLAGS_NONCLEAR_RST  0x400
0238 # define BIO_FLAGS_IN_EOF        0x800
0239 
0240 /* the BIO FLAGS values 0x1000 to 0x8000 are reserved for internal KTLS flags */
0241 
0242 typedef union bio_addr_st BIO_ADDR;
0243 typedef struct bio_addrinfo_st BIO_ADDRINFO;
0244 
0245 int BIO_get_new_index(void);
0246 void BIO_set_flags(BIO *b, int flags);
0247 int BIO_test_flags(const BIO *b, int flags);
0248 void BIO_clear_flags(BIO *b, int flags);
0249 
0250 # define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
0251 # define BIO_set_retry_special(b) \
0252                 BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
0253 # define BIO_set_retry_read(b) \
0254                 BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
0255 # define BIO_set_retry_write(b) \
0256                 BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
0257 
0258 /* These are normally used internally in BIOs */
0259 # define BIO_clear_retry_flags(b) \
0260                 BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
0261 # define BIO_get_retry_flags(b) \
0262                 BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
0263 
0264 /* These should be used by the application to tell why we should retry */
0265 # define BIO_should_read(a)              BIO_test_flags(a, BIO_FLAGS_READ)
0266 # define BIO_should_write(a)             BIO_test_flags(a, BIO_FLAGS_WRITE)
0267 # define BIO_should_io_special(a)        BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
0268 # define BIO_retry_type(a)               BIO_test_flags(a, BIO_FLAGS_RWS)
0269 # define BIO_should_retry(a)             BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
0270 
0271 /*
0272  * The next three are used in conjunction with the BIO_should_io_special()
0273  * condition.  After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int
0274  * *reason); will walk the BIO stack and return the 'reason' for the special
0275  * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return
0276  * the code.
0277  */
0278 /*
0279  * Returned from the SSL bio when the certificate retrieval code had an error
0280  */
0281 # define BIO_RR_SSL_X509_LOOKUP          0x01
0282 /* Returned from the connect BIO when a connect would have blocked */
0283 # define BIO_RR_CONNECT                  0x02
0284 /* Returned from the accept BIO when an accept would have blocked */
0285 # define BIO_RR_ACCEPT                   0x03
0286 
0287 /* These are passed by the BIO callback */
0288 # define BIO_CB_FREE        0x01
0289 # define BIO_CB_READ        0x02
0290 # define BIO_CB_WRITE       0x03
0291 # define BIO_CB_PUTS        0x04
0292 # define BIO_CB_GETS        0x05
0293 # define BIO_CB_CTRL        0x06
0294 # define BIO_CB_RECVMMSG    0x07
0295 # define BIO_CB_SENDMMSG    0x08
0296 
0297 /*
0298  * The callback is called before and after the underling operation, The
0299  * BIO_CB_RETURN flag indicates if it is after the call
0300  */
0301 # define BIO_CB_RETURN   0x80
0302 # define BIO_CB_return(a) ((a)|BIO_CB_RETURN)
0303 # define BIO_cb_pre(a)   (!((a)&BIO_CB_RETURN))
0304 # define BIO_cb_post(a)  ((a)&BIO_CB_RETURN)
0305 
0306 # ifndef OPENSSL_NO_DEPRECATED_3_0
0307 typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
0308                                 long argl, long ret);
0309 OSSL_DEPRECATEDIN_3_0 BIO_callback_fn BIO_get_callback(const BIO *b);
0310 OSSL_DEPRECATEDIN_3_0 void BIO_set_callback(BIO *b, BIO_callback_fn callback);
0311 OSSL_DEPRECATEDIN_3_0 long BIO_debug_callback(BIO *bio, int cmd,
0312                                                const char *argp, int argi,
0313                                                long argl, long ret);
0314 # endif
0315 
0316 typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp,
0317                                    size_t len, int argi,
0318                                    long argl, int ret, size_t *processed);
0319 BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b);
0320 void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback);
0321 long BIO_debug_callback_ex(BIO *bio, int oper, const char *argp, size_t len,
0322                            int argi, long argl, int ret, size_t *processed);
0323 
0324 char *BIO_get_callback_arg(const BIO *b);
0325 void BIO_set_callback_arg(BIO *b, char *arg);
0326 
0327 typedef struct bio_method_st BIO_METHOD;
0328 
0329 const char *BIO_method_name(const BIO *b);
0330 int BIO_method_type(const BIO *b);
0331 
0332 typedef int BIO_info_cb(BIO *, int, int);
0333 typedef BIO_info_cb bio_info_cb;  /* backward compatibility */
0334 
0335 SKM_DEFINE_STACK_OF_INTERNAL(BIO, BIO, BIO)
0336 #define sk_BIO_num(sk) OPENSSL_sk_num(ossl_check_const_BIO_sk_type(sk))
0337 #define sk_BIO_value(sk, idx) ((BIO *)OPENSSL_sk_value(ossl_check_const_BIO_sk_type(sk), (idx)))
0338 #define sk_BIO_new(cmp) ((STACK_OF(BIO) *)OPENSSL_sk_new(ossl_check_BIO_compfunc_type(cmp)))
0339 #define sk_BIO_new_null() ((STACK_OF(BIO) *)OPENSSL_sk_new_null())
0340 #define sk_BIO_new_reserve(cmp, n) ((STACK_OF(BIO) *)OPENSSL_sk_new_reserve(ossl_check_BIO_compfunc_type(cmp), (n)))
0341 #define sk_BIO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_BIO_sk_type(sk), (n))
0342 #define sk_BIO_free(sk) OPENSSL_sk_free(ossl_check_BIO_sk_type(sk))
0343 #define sk_BIO_zero(sk) OPENSSL_sk_zero(ossl_check_BIO_sk_type(sk))
0344 #define sk_BIO_delete(sk, i) ((BIO *)OPENSSL_sk_delete(ossl_check_BIO_sk_type(sk), (i)))
0345 #define sk_BIO_delete_ptr(sk, ptr) ((BIO *)OPENSSL_sk_delete_ptr(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr)))
0346 #define sk_BIO_push(sk, ptr) OPENSSL_sk_push(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
0347 #define sk_BIO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
0348 #define sk_BIO_pop(sk) ((BIO *)OPENSSL_sk_pop(ossl_check_BIO_sk_type(sk)))
0349 #define sk_BIO_shift(sk) ((BIO *)OPENSSL_sk_shift(ossl_check_BIO_sk_type(sk)))
0350 #define sk_BIO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_BIO_sk_type(sk),ossl_check_BIO_freefunc_type(freefunc))
0351 #define sk_BIO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), (idx))
0352 #define sk_BIO_set(sk, idx, ptr) ((BIO *)OPENSSL_sk_set(ossl_check_BIO_sk_type(sk), (idx), ossl_check_BIO_type(ptr)))
0353 #define sk_BIO_find(sk, ptr) OPENSSL_sk_find(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
0354 #define sk_BIO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr))
0355 #define sk_BIO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_BIO_sk_type(sk), ossl_check_BIO_type(ptr), pnum)
0356 #define sk_BIO_sort(sk) OPENSSL_sk_sort(ossl_check_BIO_sk_type(sk))
0357 #define sk_BIO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_BIO_sk_type(sk))
0358 #define sk_BIO_dup(sk) ((STACK_OF(BIO) *)OPENSSL_sk_dup(ossl_check_const_BIO_sk_type(sk)))
0359 #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)))
0360 #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)))
0361 
0362 
0363 
0364 /* Prefix and suffix callback in ASN1 BIO */
0365 typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,
0366                           void *parg);
0367 
0368 typedef void (*BIO_dgram_sctp_notification_handler_fn) (BIO *b,
0369                                                         void *context,
0370                                                         void *buf);
0371 # ifndef OPENSSL_NO_SCTP
0372 /* SCTP parameter structs */
0373 struct bio_dgram_sctp_sndinfo {
0374     uint16_t snd_sid;
0375     uint16_t snd_flags;
0376     uint32_t snd_ppid;
0377     uint32_t snd_context;
0378 };
0379 
0380 struct bio_dgram_sctp_rcvinfo {
0381     uint16_t rcv_sid;
0382     uint16_t rcv_ssn;
0383     uint16_t rcv_flags;
0384     uint32_t rcv_ppid;
0385     uint32_t rcv_tsn;
0386     uint32_t rcv_cumtsn;
0387     uint32_t rcv_context;
0388 };
0389 
0390 struct bio_dgram_sctp_prinfo {
0391     uint16_t pr_policy;
0392     uint32_t pr_value;
0393 };
0394 # endif
0395 
0396 /* BIO_sendmmsg/BIO_recvmmsg-related definitions */
0397 typedef struct bio_msg_st {
0398     void *data;
0399     size_t data_len;
0400     BIO_ADDR *peer, *local;
0401     uint64_t flags;
0402 } BIO_MSG;
0403 
0404 typedef struct bio_mmsg_cb_args_st {
0405     BIO_MSG    *msg;
0406     size_t      stride, num_msg;
0407     uint64_t    flags;
0408     size_t     *msgs_processed;
0409 } BIO_MMSG_CB_ARGS;
0410 
0411 #define BIO_POLL_DESCRIPTOR_TYPE_NONE       0
0412 #define BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD    1
0413 #define BIO_POLL_DESCRIPTOR_TYPE_SSL        2
0414 #define BIO_POLL_DESCRIPTOR_CUSTOM_START    8192
0415 
0416 typedef struct bio_poll_descriptor_st {
0417     uint32_t type;
0418     union {
0419         int         fd;
0420         void        *custom;
0421         uintptr_t   custom_ui;
0422         SSL         *ssl;
0423     } value;
0424 } BIO_POLL_DESCRIPTOR;
0425 
0426 /*
0427  * #define BIO_CONN_get_param_hostname BIO_ctrl
0428  */
0429 
0430 # define BIO_C_SET_CONNECT                       100
0431 # define BIO_C_DO_STATE_MACHINE                  101
0432 # define BIO_C_SET_NBIO                          102
0433 /* # define BIO_C_SET_PROXY_PARAM                   103 */
0434 # define BIO_C_SET_FD                            104
0435 # define BIO_C_GET_FD                            105
0436 # define BIO_C_SET_FILE_PTR                      106
0437 # define BIO_C_GET_FILE_PTR                      107
0438 # define BIO_C_SET_FILENAME                      108
0439 # define BIO_C_SET_SSL                           109
0440 # define BIO_C_GET_SSL                           110
0441 # define BIO_C_SET_MD                            111
0442 # define BIO_C_GET_MD                            112
0443 # define BIO_C_GET_CIPHER_STATUS                 113
0444 # define BIO_C_SET_BUF_MEM                       114
0445 # define BIO_C_GET_BUF_MEM_PTR                   115
0446 # define BIO_C_GET_BUFF_NUM_LINES                116
0447 # define BIO_C_SET_BUFF_SIZE                     117
0448 # define BIO_C_SET_ACCEPT                        118
0449 # define BIO_C_SSL_MODE                          119
0450 # define BIO_C_GET_MD_CTX                        120
0451 /* # define BIO_C_GET_PROXY_PARAM                   121 */
0452 # define BIO_C_SET_BUFF_READ_DATA                122/* data to read first */
0453 # define BIO_C_GET_CONNECT                       123
0454 # define BIO_C_GET_ACCEPT                        124
0455 # define BIO_C_SET_SSL_RENEGOTIATE_BYTES         125
0456 # define BIO_C_GET_SSL_NUM_RENEGOTIATES          126
0457 # define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT       127
0458 # define BIO_C_FILE_SEEK                         128
0459 # define BIO_C_GET_CIPHER_CTX                    129
0460 # define BIO_C_SET_BUF_MEM_EOF_RETURN            130/* return end of input
0461                                                      * value */
0462 # define BIO_C_SET_BIND_MODE                     131
0463 # define BIO_C_GET_BIND_MODE                     132
0464 # define BIO_C_FILE_TELL                         133
0465 # define BIO_C_GET_SOCKS                         134
0466 # define BIO_C_SET_SOCKS                         135
0467 
0468 # define BIO_C_SET_WRITE_BUF_SIZE                136/* for BIO_s_bio */
0469 # define BIO_C_GET_WRITE_BUF_SIZE                137
0470 # define BIO_C_MAKE_BIO_PAIR                     138
0471 # define BIO_C_DESTROY_BIO_PAIR                  139
0472 # define BIO_C_GET_WRITE_GUARANTEE               140
0473 # define BIO_C_GET_READ_REQUEST                  141
0474 # define BIO_C_SHUTDOWN_WR                       142
0475 # define BIO_C_NREAD0                            143
0476 # define BIO_C_NREAD                             144
0477 # define BIO_C_NWRITE0                           145
0478 # define BIO_C_NWRITE                            146
0479 # define BIO_C_RESET_READ_REQUEST                147
0480 # define BIO_C_SET_MD_CTX                        148
0481 
0482 # define BIO_C_SET_PREFIX                        149
0483 # define BIO_C_GET_PREFIX                        150
0484 # define BIO_C_SET_SUFFIX                        151
0485 # define BIO_C_GET_SUFFIX                        152
0486 
0487 # define BIO_C_SET_EX_ARG                        153
0488 # define BIO_C_GET_EX_ARG                        154
0489 
0490 # define BIO_C_SET_CONNECT_MODE                  155
0491 
0492 # define BIO_C_SET_TFO                           156 /* like BIO_C_SET_NBIO */
0493 
0494 # define BIO_C_SET_SOCK_TYPE                     157
0495 # define BIO_C_GET_SOCK_TYPE                     158
0496 # define BIO_C_GET_DGRAM_BIO                     159
0497 
0498 # define BIO_set_app_data(s,arg)         BIO_set_ex_data(s,0,arg)
0499 # define BIO_get_app_data(s)             BIO_get_ex_data(s,0)
0500 
0501 # define BIO_set_nbio(b,n)               BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
0502 # define BIO_set_tfo(b,n)                BIO_ctrl(b,BIO_C_SET_TFO,(n),NULL)
0503 
0504 # ifndef OPENSSL_NO_SOCK
0505 /* IP families we support, for BIO_s_connect() and BIO_s_accept() */
0506 /* Note: the underlying operating system may not support some of them */
0507 #  define BIO_FAMILY_IPV4                         4
0508 #  define BIO_FAMILY_IPV6                         6
0509 #  define BIO_FAMILY_IPANY                        256
0510 
0511 /* BIO_s_connect() */
0512 #  define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0, \
0513                                                  (char *)(name))
0514 #  define BIO_set_conn_port(b,port)     BIO_ctrl(b,BIO_C_SET_CONNECT,1, \
0515                                                  (char *)(port))
0516 #  define BIO_set_conn_address(b,addr)  BIO_ctrl(b,BIO_C_SET_CONNECT,2, \
0517                                                  (char *)(addr))
0518 #  define BIO_set_conn_ip_family(b,f)   BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f)
0519 #  define BIO_get_conn_hostname(b)      ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0))
0520 #  define BIO_get_conn_port(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1))
0521 #  define BIO_get_conn_address(b)       ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2))
0522 #  define BIO_get_conn_ip_family(b)     BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)
0523 #  define BIO_get_conn_mode(b)          BIO_ctrl(b,BIO_C_GET_CONNECT,4,NULL)
0524 #  define BIO_set_conn_mode(b,n)        BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL)
0525 #  define BIO_set_sock_type(b,t)        BIO_ctrl(b,BIO_C_SET_SOCK_TYPE,(t),NULL)
0526 #  define BIO_get_sock_type(b)          BIO_ctrl(b,BIO_C_GET_SOCK_TYPE,0,NULL)
0527 #  define BIO_get0_dgram_bio(b, p)      BIO_ctrl(b,BIO_C_GET_DGRAM_BIO,0,(void *)(BIO **)(p))
0528 
0529 /* BIO_s_accept() */
0530 #  define BIO_set_accept_name(b,name)   BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \
0531                                                  (char *)(name))
0532 #  define BIO_set_accept_port(b,port)   BIO_ctrl(b,BIO_C_SET_ACCEPT,1, \
0533                                                  (char *)(port))
0534 #  define BIO_get_accept_name(b)        ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0))
0535 #  define BIO_get_accept_port(b)        ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1))
0536 #  define BIO_get_peer_name(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2))
0537 #  define BIO_get_peer_port(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3))
0538 /* #define BIO_set_nbio(b,n)    BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
0539 #  define BIO_set_nbio_accept(b,n)      BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)"a":NULL)
0540 #  define BIO_set_accept_bios(b,bio)    BIO_ctrl(b,BIO_C_SET_ACCEPT,3, \
0541                                                  (char *)(bio))
0542 #  define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f)
0543 #  define BIO_get_accept_ip_family(b)   BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL)
0544 #  define BIO_set_tfo_accept(b,n)       BIO_ctrl(b,BIO_C_SET_ACCEPT,5,(n)?(void *)"a":NULL)
0545 
0546 /* Aliases kept for backward compatibility */
0547 #  define BIO_BIND_NORMAL                 0
0548 #  define BIO_BIND_REUSEADDR              BIO_SOCK_REUSEADDR
0549 #  define BIO_BIND_REUSEADDR_IF_UNUSED    BIO_SOCK_REUSEADDR
0550 #  define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
0551 #  define BIO_get_bind_mode(b)    BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
0552 # endif /* OPENSSL_NO_SOCK */
0553 
0554 # define BIO_do_connect(b)       BIO_do_handshake(b)
0555 # define BIO_do_accept(b)        BIO_do_handshake(b)
0556 
0557 # define BIO_do_handshake(b)     BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
0558 
0559 /* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */
0560 # define BIO_set_fd(b,fd,c)      BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
0561 # define BIO_get_fd(b,c)         BIO_ctrl(b,BIO_C_GET_FD,0,(char *)(c))
0562 
0563 /* BIO_s_file() */
0564 # define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp))
0565 # define BIO_get_fp(b,fpp)       BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)(fpp))
0566 
0567 /* BIO_s_fd() and BIO_s_file() */
0568 # define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
0569 # define BIO_tell(b)     (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
0570 
0571 /*
0572  * name is cast to lose const, but might be better to route through a
0573  * function so we can do it safely
0574  */
0575 # ifdef CONST_STRICT
0576 /*
0577  * If you are wondering why this isn't defined, its because CONST_STRICT is
0578  * purely a compile-time kludge to allow const to be checked.
0579  */
0580 int BIO_read_filename(BIO *b, const char *name);
0581 # else
0582 #  define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
0583                 BIO_CLOSE|BIO_FP_READ,(char *)(name))
0584 # endif
0585 # define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
0586                 BIO_CLOSE|BIO_FP_WRITE,name)
0587 # define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
0588                 BIO_CLOSE|BIO_FP_APPEND,name)
0589 # define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \
0590                 BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
0591 
0592 /*
0593  * WARNING WARNING, this ups the reference count on the read bio of the SSL
0594  * structure.  This is because the ssl read BIO is now pointed to by the
0595  * next_bio field in the bio.  So when you free the BIO, make sure you are
0596  * doing a BIO_free_all() to catch the underlying BIO.
0597  */
0598 # define BIO_set_ssl(b,ssl,c)    BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)(ssl))
0599 # define BIO_get_ssl(b,sslp)     BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)(sslp))
0600 # define BIO_set_ssl_mode(b,client)      BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
0601 # define BIO_set_ssl_renegotiate_bytes(b,num) \
0602         BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)
0603 # define BIO_get_num_renegotiates(b) \
0604         BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)
0605 # define BIO_set_ssl_renegotiate_timeout(b,seconds) \
0606         BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)
0607 
0608 /* defined in evp.h */
0609 /* #define BIO_set_md(b,md)     BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */
0610 
0611 # define BIO_get_mem_data(b,pp)  BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)(pp))
0612 # define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)(bm))
0613 # define BIO_get_mem_ptr(b,pp)   BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0, \
0614                                           (char *)(pp))
0615 # define BIO_set_mem_eof_return(b,v) \
0616                                 BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
0617 
0618 /* For the BIO_f_buffer() type */
0619 # define BIO_get_buffer_num_lines(b)     BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
0620 # define BIO_set_buffer_size(b,size)     BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
0621 # define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
0622 # define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
0623 # define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
0624 
0625 /* Don't use the next one unless you know what you are doing :-) */
0626 # define BIO_dup_state(b,ret)    BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
0627 
0628 # define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
0629 # define BIO_eof(b)              (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
0630 # define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
0631 # define BIO_get_close(b)        (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
0632 # define BIO_pending(b)          (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
0633 # define BIO_wpending(b)         (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
0634 /* ...pending macros have inappropriate return type */
0635 size_t BIO_ctrl_pending(BIO *b);
0636 size_t BIO_ctrl_wpending(BIO *b);
0637 # define BIO_flush(b)            (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
0638 # define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
0639                                                    cbp)
0640 # define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
0641 
0642 /* For the BIO_f_buffer() type */
0643 # define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
0644 # define BIO_buffer_peek(b,s,l) BIO_ctrl(b,BIO_CTRL_PEEK,(l),(s))
0645 
0646 /* For BIO_s_bio() */
0647 # define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
0648 # define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
0649 # define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
0650 # define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
0651 # define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
0652 /* macros with inappropriate type -- but ...pending macros use int too: */
0653 # define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
0654 # define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
0655 size_t BIO_ctrl_get_write_guarantee(BIO *b);
0656 size_t BIO_ctrl_get_read_request(BIO *b);
0657 int BIO_ctrl_reset_read_request(BIO *b);
0658 
0659 /* ctrl macros for dgram */
0660 # define BIO_ctrl_dgram_connect(b,peer)  \
0661                      (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)(peer))
0662 # define BIO_ctrl_set_connected(b,peer) \
0663          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer))
0664 # define BIO_dgram_recv_timedout(b) \
0665          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
0666 # define BIO_dgram_send_timedout(b) \
0667          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
0668 # define BIO_dgram_get_peer(b,peer) \
0669          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer))
0670 # define BIO_dgram_set_peer(b,peer) \
0671          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer))
0672 # define BIO_dgram_detect_peer_addr(b,peer) \
0673          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_DETECT_PEER_ADDR, 0, (char *)(peer))
0674 # define BIO_dgram_get_mtu_overhead(b) \
0675          (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
0676 # define BIO_dgram_get_local_addr_cap(b) \
0677          (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_CAP, 0, NULL)
0678 # define BIO_dgram_get_local_addr_enable(b, penable) \
0679          (int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_LOCAL_ADDR_ENABLE, 0, (char *)(penable))
0680 # define BIO_dgram_set_local_addr_enable(b, enable) \
0681          (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_LOCAL_ADDR_ENABLE, (enable), NULL)
0682 # define BIO_dgram_get_effective_caps(b) \
0683          (uint32_t)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_EFFECTIVE_CAPS, 0, NULL)
0684 # define BIO_dgram_get_caps(b) \
0685          (uint32_t)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_CAPS, 0, NULL)
0686 # define BIO_dgram_set_caps(b, caps) \
0687          (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_CAPS, (long)(caps), NULL)
0688 # define BIO_dgram_get_no_trunc(b) \
0689          (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_NO_TRUNC, 0, NULL)
0690 # define BIO_dgram_set_no_trunc(b, enable) \
0691          (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_NO_TRUNC, (enable), NULL)
0692 # define BIO_dgram_get_mtu(b) \
0693          (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU, 0, NULL)
0694 # define BIO_dgram_set_mtu(b, mtu) \
0695          (int)BIO_ctrl((b), BIO_CTRL_DGRAM_SET_MTU, (mtu), NULL)
0696 
0697 /* ctrl macros for BIO_f_prefix */
0698 # define BIO_set_prefix(b,p) BIO_ctrl((b), BIO_CTRL_SET_PREFIX, 0, (void *)(p))
0699 # define BIO_set_indent(b,i) BIO_ctrl((b), BIO_CTRL_SET_INDENT, (i), NULL)
0700 # define BIO_get_indent(b) BIO_ctrl((b), BIO_CTRL_GET_INDENT, 0, NULL)
0701 
0702 #define BIO_get_ex_new_index(l, p, newf, dupf, freef) \
0703     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef)
0704 int BIO_set_ex_data(BIO *bio, int idx, void *data);
0705 void *BIO_get_ex_data(const BIO *bio, int idx);
0706 uint64_t BIO_number_read(BIO *bio);
0707 uint64_t BIO_number_written(BIO *bio);
0708 
0709 /* For BIO_f_asn1() */
0710 int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
0711                         asn1_ps_func *prefix_free);
0712 int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
0713                         asn1_ps_func **pprefix_free);
0714 int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
0715                         asn1_ps_func *suffix_free);
0716 int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
0717                         asn1_ps_func **psuffix_free);
0718 
0719 const BIO_METHOD *BIO_s_file(void);
0720 BIO *BIO_new_file(const char *filename, const char *mode);
0721 BIO *BIO_new_from_core_bio(OSSL_LIB_CTX *libctx, OSSL_CORE_BIO *corebio);
0722 # ifndef OPENSSL_NO_STDIO
0723 BIO *BIO_new_fp(FILE *stream, int close_flag);
0724 # endif
0725 BIO *BIO_new_ex(OSSL_LIB_CTX *libctx, const BIO_METHOD *method);
0726 BIO *BIO_new(const BIO_METHOD *type);
0727 int BIO_free(BIO *a);
0728 void BIO_set_data(BIO *a, void *ptr);
0729 void *BIO_get_data(BIO *a);
0730 void BIO_set_init(BIO *a, int init);
0731 int BIO_get_init(BIO *a);
0732 void BIO_set_shutdown(BIO *a, int shut);
0733 int BIO_get_shutdown(BIO *a);
0734 void BIO_vfree(BIO *a);
0735 int BIO_up_ref(BIO *a);
0736 int BIO_read(BIO *b, void *data, int dlen);
0737 int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);
0738 __owur int BIO_recvmmsg(BIO *b, BIO_MSG *msg,
0739                         size_t stride, size_t num_msg, uint64_t flags,
0740                         size_t *msgs_processed);
0741 int BIO_gets(BIO *bp, char *buf, int size);
0742 int BIO_get_line(BIO *bio, char *buf, int size);
0743 int BIO_write(BIO *b, const void *data, int dlen);
0744 int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
0745 __owur int BIO_sendmmsg(BIO *b, BIO_MSG *msg,
0746                         size_t stride, size_t num_msg, uint64_t flags,
0747                         size_t *msgs_processed);
0748 __owur int BIO_get_rpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
0749 __owur int BIO_get_wpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
0750 int BIO_puts(BIO *bp, const char *buf);
0751 int BIO_indent(BIO *b, int indent, int max);
0752 long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
0753 long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);
0754 void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
0755 long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
0756 BIO *BIO_push(BIO *b, BIO *append);
0757 BIO *BIO_pop(BIO *b);
0758 void BIO_free_all(BIO *a);
0759 BIO *BIO_find_type(BIO *b, int bio_type);
0760 BIO *BIO_next(BIO *b);
0761 void BIO_set_next(BIO *b, BIO *next);
0762 BIO *BIO_get_retry_BIO(BIO *bio, int *reason);
0763 int BIO_get_retry_reason(BIO *bio);
0764 void BIO_set_retry_reason(BIO *bio, int reason);
0765 BIO *BIO_dup_chain(BIO *in);
0766 
0767 int BIO_nread0(BIO *bio, char **buf);
0768 int BIO_nread(BIO *bio, char **buf, int num);
0769 int BIO_nwrite0(BIO *bio, char **buf);
0770 int BIO_nwrite(BIO *bio, char **buf, int num);
0771 
0772 const BIO_METHOD *BIO_s_mem(void);
0773 # ifndef OPENSSL_NO_DGRAM
0774 const BIO_METHOD *BIO_s_dgram_mem(void);
0775 # endif
0776 const BIO_METHOD *BIO_s_secmem(void);
0777 BIO *BIO_new_mem_buf(const void *buf, int len);
0778 # ifndef OPENSSL_NO_SOCK
0779 const BIO_METHOD *BIO_s_socket(void);
0780 const BIO_METHOD *BIO_s_connect(void);
0781 const BIO_METHOD *BIO_s_accept(void);
0782 # endif
0783 const BIO_METHOD *BIO_s_fd(void);
0784 const BIO_METHOD *BIO_s_log(void);
0785 const BIO_METHOD *BIO_s_bio(void);
0786 const BIO_METHOD *BIO_s_null(void);
0787 const BIO_METHOD *BIO_f_null(void);
0788 const BIO_METHOD *BIO_f_buffer(void);
0789 const BIO_METHOD *BIO_f_readbuffer(void);
0790 const BIO_METHOD *BIO_f_linebuffer(void);
0791 const BIO_METHOD *BIO_f_nbio_test(void);
0792 const BIO_METHOD *BIO_f_prefix(void);
0793 const BIO_METHOD *BIO_s_core(void);
0794 # ifndef OPENSSL_NO_DGRAM
0795 const BIO_METHOD *BIO_s_dgram_pair(void);
0796 const BIO_METHOD *BIO_s_datagram(void);
0797 int BIO_dgram_non_fatal_error(int error);
0798 BIO *BIO_new_dgram(int fd, int close_flag);
0799 #  ifndef OPENSSL_NO_SCTP
0800 const BIO_METHOD *BIO_s_datagram_sctp(void);
0801 BIO *BIO_new_dgram_sctp(int fd, int close_flag);
0802 int BIO_dgram_is_sctp(BIO *bio);
0803 int BIO_dgram_sctp_notification_cb(BIO *b,
0804                 BIO_dgram_sctp_notification_handler_fn handle_notifications,
0805                 void *context);
0806 int BIO_dgram_sctp_wait_for_dry(BIO *b);
0807 int BIO_dgram_sctp_msg_waiting(BIO *b);
0808 #  endif
0809 # endif
0810 
0811 # ifndef OPENSSL_NO_SOCK
0812 int BIO_sock_should_retry(int i);
0813 int BIO_sock_non_fatal_error(int error);
0814 int BIO_err_is_non_fatal(unsigned int errcode);
0815 int BIO_socket_wait(int fd, int for_read, time_t max_time);
0816 # endif
0817 int BIO_wait(BIO *bio, time_t max_time, unsigned int nap_milliseconds);
0818 int BIO_do_connect_retry(BIO *bio, int timeout, int nap_milliseconds);
0819 
0820 int BIO_fd_should_retry(int i);
0821 int BIO_fd_non_fatal_error(int error);
0822 int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),
0823                 void *u, const void *s, int len);
0824 int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
0825                        void *u, const void *s, int len, int indent);
0826 int BIO_dump(BIO *b, const void *bytes, int len);
0827 int BIO_dump_indent(BIO *b, const void *bytes, int len, int indent);
0828 # ifndef OPENSSL_NO_STDIO
0829 int BIO_dump_fp(FILE *fp, const void *s, int len);
0830 int BIO_dump_indent_fp(FILE *fp, const void *s, int len, int indent);
0831 # endif
0832 int BIO_hex_string(BIO *out, int indent, int width, const void *data,
0833                    int datalen);
0834 
0835 # ifndef OPENSSL_NO_SOCK
0836 BIO_ADDR *BIO_ADDR_new(void);
0837 int BIO_ADDR_copy(BIO_ADDR *dst, const BIO_ADDR *src);
0838 BIO_ADDR *BIO_ADDR_dup(const BIO_ADDR *ap);
0839 int BIO_ADDR_rawmake(BIO_ADDR *ap, int family,
0840                      const void *where, size_t wherelen, unsigned short port);
0841 void BIO_ADDR_free(BIO_ADDR *);
0842 void BIO_ADDR_clear(BIO_ADDR *ap);
0843 int BIO_ADDR_family(const BIO_ADDR *ap);
0844 int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);
0845 unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);
0846 char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);
0847 char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);
0848 char *BIO_ADDR_path_string(const BIO_ADDR *ap);
0849 
0850 const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);
0851 int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);
0852 int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);
0853 int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);
0854 const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);
0855 void BIO_ADDRINFO_free(BIO_ADDRINFO *bai);
0856 
0857 enum BIO_hostserv_priorities {
0858     BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
0859 };
0860 int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
0861                        enum BIO_hostserv_priorities hostserv_prio);
0862 enum BIO_lookup_type {
0863     BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER
0864 };
0865 int BIO_lookup(const char *host, const char *service,
0866                enum BIO_lookup_type lookup_type,
0867                int family, int socktype, BIO_ADDRINFO **res);
0868 int BIO_lookup_ex(const char *host, const char *service,
0869                   int lookup_type, int family, int socktype, int protocol,
0870                   BIO_ADDRINFO **res);
0871 int BIO_sock_error(int sock);
0872 int BIO_socket_ioctl(int fd, long type, void *arg);
0873 int BIO_socket_nbio(int fd, int mode);
0874 int BIO_sock_init(void);
0875 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0876 #  define BIO_sock_cleanup() while(0) continue
0877 # endif
0878 int BIO_set_tcp_ndelay(int sock, int turn_on);
0879 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0880 OSSL_DEPRECATEDIN_1_1_0 struct hostent *BIO_gethostbyname(const char *name);
0881 OSSL_DEPRECATEDIN_1_1_0 int BIO_get_port(const char *str, unsigned short *port_ptr);
0882 OSSL_DEPRECATEDIN_1_1_0 int BIO_get_host_ip(const char *str, unsigned char *ip);
0883 OSSL_DEPRECATEDIN_1_1_0 int BIO_get_accept_socket(char *host_port, int mode);
0884 OSSL_DEPRECATEDIN_1_1_0 int BIO_accept(int sock, char **ip_port);
0885 # endif
0886 
0887 union BIO_sock_info_u {
0888     BIO_ADDR *addr;
0889 };
0890 enum BIO_sock_info_type {
0891     BIO_SOCK_INFO_ADDRESS
0892 };
0893 int BIO_sock_info(int sock,
0894                   enum BIO_sock_info_type type, union BIO_sock_info_u *info);
0895 
0896 #  define BIO_SOCK_REUSEADDR    0x01
0897 #  define BIO_SOCK_V6_ONLY      0x02
0898 #  define BIO_SOCK_KEEPALIVE    0x04
0899 #  define BIO_SOCK_NONBLOCK     0x08
0900 #  define BIO_SOCK_NODELAY      0x10
0901 #  define BIO_SOCK_TFO          0x20
0902 
0903 int BIO_socket(int domain, int socktype, int protocol, int options);
0904 int BIO_connect(int sock, const BIO_ADDR *addr, int options);
0905 int BIO_bind(int sock, const BIO_ADDR *addr, int options);
0906 int BIO_listen(int sock, const BIO_ADDR *addr, int options);
0907 int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options);
0908 int BIO_closesocket(int sock);
0909 
0910 BIO *BIO_new_socket(int sock, int close_flag);
0911 BIO *BIO_new_connect(const char *host_port);
0912 BIO *BIO_new_accept(const char *host_port);
0913 # endif /* OPENSSL_NO_SOCK*/
0914 
0915 BIO *BIO_new_fd(int fd, int close_flag);
0916 
0917 int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
0918                      BIO **bio2, size_t writebuf2);
0919 # ifndef OPENSSL_NO_DGRAM
0920 int BIO_new_bio_dgram_pair(BIO **bio1, size_t writebuf1,
0921                            BIO **bio2, size_t writebuf2);
0922 # endif
0923 
0924 /*
0925  * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
0926  * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default
0927  * value.
0928  */
0929 
0930 void BIO_copy_next_retry(BIO *b);
0931 
0932 /*
0933  * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);
0934  */
0935 
0936 # define ossl_bio__attr__(x)
0937 # if defined(__GNUC__) && defined(__STDC_VERSION__) \
0938     && !defined(__MINGW32__) && !defined(__MINGW64__) \
0939     && !defined(__APPLE__)
0940     /*
0941      * Because we support the 'z' modifier, which made its appearance in C99,
0942      * we can't use __attribute__ with pre C99 dialects.
0943      */
0944 #  if __STDC_VERSION__ >= 199901L
0945 #   undef ossl_bio__attr__
0946 #   define ossl_bio__attr__ __attribute__
0947 #   if __GNUC__*10 + __GNUC_MINOR__ >= 44
0948 #    define ossl_bio__printf__ __gnu_printf__
0949 #   else
0950 #    define ossl_bio__printf__ __printf__
0951 #   endif
0952 #  endif
0953 # endif
0954 int BIO_printf(BIO *bio, const char *format, ...)
0955 ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3)));
0956 int BIO_vprintf(BIO *bio, const char *format, va_list args)
0957 ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0)));
0958 int BIO_snprintf(char *buf, size_t n, const char *format, ...)
0959 ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4)));
0960 int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
0961 ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0)));
0962 # undef ossl_bio__attr__
0963 # undef ossl_bio__printf__
0964 
0965 
0966 BIO_METHOD *BIO_meth_new(int type, const char *name);
0967 void BIO_meth_free(BIO_METHOD *biom);
0968 int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int);
0969 int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t,
0970                                                 size_t *);
0971 int BIO_meth_set_write(BIO_METHOD *biom,
0972                        int (*write) (BIO *, const char *, int));
0973 int BIO_meth_set_write_ex(BIO_METHOD *biom,
0974                        int (*bwrite) (BIO *, const char *, size_t, size_t *));
0975 int BIO_meth_set_sendmmsg(BIO_METHOD *biom,
0976                           int (*f) (BIO *, BIO_MSG *, size_t, size_t,
0977                                     uint64_t, size_t *));
0978 int (*BIO_meth_get_sendmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *,
0979                                                      size_t, size_t,
0980                                                      uint64_t, size_t *);
0981 int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);
0982 int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *);
0983 int BIO_meth_set_read(BIO_METHOD *biom,
0984                       int (*read) (BIO *, char *, int));
0985 int BIO_meth_set_read_ex(BIO_METHOD *biom,
0986                          int (*bread) (BIO *, char *, size_t, size_t *));
0987 int BIO_meth_set_recvmmsg(BIO_METHOD *biom,
0988                           int (*f) (BIO *, BIO_MSG *, size_t, size_t,
0989                                     uint64_t, size_t *));
0990 int (*BIO_meth_get_recvmmsg(const BIO_METHOD *biom))(BIO *, BIO_MSG *,
0991                                                      size_t, size_t,
0992                                                      uint64_t, size_t *);
0993 int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);
0994 int BIO_meth_set_puts(BIO_METHOD *biom,
0995                       int (*puts) (BIO *, const char *));
0996 int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);
0997 int BIO_meth_set_gets(BIO_METHOD *biom,
0998                       int (*ossl_gets) (BIO *, char *, int));
0999 long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);
1000 int BIO_meth_set_ctrl(BIO_METHOD *biom,
1001                       long (*ctrl) (BIO *, int, long, void *));
1002 int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);
1003 int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));
1004 int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);
1005 int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));
1006 long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))
1007                                  (BIO *, int, BIO_info_cb *);
1008 int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
1009                                long (*callback_ctrl) (BIO *, int,
1010                                                       BIO_info_cb *));
1011 
1012 # ifdef  __cplusplus
1013 }
1014 # endif
1015 #endif