xref: /openbsd/lib/libcrypto/bio/bio.h (revision 5158016f)
1*5158016fSjsg /* $OpenBSD: bio.h,v 1.64 2024/05/19 07:12:50 jsg Exp $ */
25b37fcf3Sryker /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
35b37fcf3Sryker  * All rights reserved.
45b37fcf3Sryker  *
55b37fcf3Sryker  * This package is an SSL implementation written
65b37fcf3Sryker  * by Eric Young (eay@cryptsoft.com).
75b37fcf3Sryker  * The implementation was written so as to conform with Netscapes SSL.
85b37fcf3Sryker  *
95b37fcf3Sryker  * This library is free for commercial and non-commercial use as long as
105b37fcf3Sryker  * the following conditions are aheared to.  The following conditions
115b37fcf3Sryker  * apply to all code found in this distribution, be it the RC4, RSA,
125b37fcf3Sryker  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
135b37fcf3Sryker  * included with this distribution is covered by the same copyright terms
145b37fcf3Sryker  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
155b37fcf3Sryker  *
165b37fcf3Sryker  * Copyright remains Eric Young's, and as such any Copyright notices in
175b37fcf3Sryker  * the code are not to be removed.
185b37fcf3Sryker  * If this package is used in a product, Eric Young should be given attribution
195b37fcf3Sryker  * as the author of the parts of the library used.
205b37fcf3Sryker  * This can be in the form of a textual message at program startup or
215b37fcf3Sryker  * in documentation (online or textual) provided with the package.
225b37fcf3Sryker  *
235b37fcf3Sryker  * Redistribution and use in source and binary forms, with or without
245b37fcf3Sryker  * modification, are permitted provided that the following conditions
255b37fcf3Sryker  * are met:
265b37fcf3Sryker  * 1. Redistributions of source code must retain the copyright
275b37fcf3Sryker  *    notice, this list of conditions and the following disclaimer.
285b37fcf3Sryker  * 2. Redistributions in binary form must reproduce the above copyright
295b37fcf3Sryker  *    notice, this list of conditions and the following disclaimer in the
305b37fcf3Sryker  *    documentation and/or other materials provided with the distribution.
315b37fcf3Sryker  * 3. All advertising materials mentioning features or use of this software
325b37fcf3Sryker  *    must display the following acknowledgement:
335b37fcf3Sryker  *    "This product includes cryptographic software written by
345b37fcf3Sryker  *     Eric Young (eay@cryptsoft.com)"
355b37fcf3Sryker  *    The word 'cryptographic' can be left out if the rouines from the library
365b37fcf3Sryker  *    being used are not cryptographic related :-).
375b37fcf3Sryker  * 4. If you include any Windows specific code (or a derivative thereof) from
385b37fcf3Sryker  *    the apps directory (application code) you must include an acknowledgement:
395b37fcf3Sryker  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
405b37fcf3Sryker  *
415b37fcf3Sryker  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
425b37fcf3Sryker  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
435b37fcf3Sryker  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
445b37fcf3Sryker  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
455b37fcf3Sryker  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
465b37fcf3Sryker  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
475b37fcf3Sryker  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
485b37fcf3Sryker  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
495b37fcf3Sryker  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
505b37fcf3Sryker  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
515b37fcf3Sryker  * SUCH DAMAGE.
525b37fcf3Sryker  *
535b37fcf3Sryker  * The licence and distribution terms for any publically available version or
545b37fcf3Sryker  * derivative of this code cannot be changed.  i.e. this code cannot simply be
555b37fcf3Sryker  * copied and put under another distribution licence
565b37fcf3Sryker  * [including the GNU Public Licence.]
575b37fcf3Sryker  */
585b37fcf3Sryker 
595b37fcf3Sryker #ifndef HEADER_BIO_H
605b37fcf3Sryker #define HEADER_BIO_H
6140c1866aSbeck #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__OpenBSD__)
62361740acSbeck #define __bounded__(x, y, z)
63361740acSbeck #endif
6420175b85Sjsing #include <openssl/opensslconf.h>
654fcf65c5Sdjm 
66c109e398Sbeck # include <stdio.h>
67c109e398Sbeck #include <stdarg.h>
68c109e398Sbeck 
69c109e398Sbeck #include <openssl/crypto.h>
70c109e398Sbeck 
715cdd308eSdjm 
725b37fcf3Sryker #ifdef  __cplusplus
735b37fcf3Sryker extern "C" {
745b37fcf3Sryker #endif
755b37fcf3Sryker 
765b37fcf3Sryker /* These are the 'types' of BIOs */
775b37fcf3Sryker #define BIO_TYPE_NONE		0
785b37fcf3Sryker #define BIO_TYPE_MEM		(1|0x0400)
795b37fcf3Sryker #define BIO_TYPE_FILE		(2|0x0400)
805b37fcf3Sryker 
815b37fcf3Sryker #define BIO_TYPE_FD		(4|0x0400|0x0100)
825b37fcf3Sryker #define BIO_TYPE_SOCKET		(5|0x0400|0x0100)
835b37fcf3Sryker #define BIO_TYPE_NULL		(6|0x0400)
845b37fcf3Sryker #define BIO_TYPE_SSL		(7|0x0200)
85ba5406e9Sbeck #define BIO_TYPE_MD		(8|0x0200)		/* passive filter */
865b37fcf3Sryker #define BIO_TYPE_BUFFER		(9|0x0200)		/* filter */
875b37fcf3Sryker #define BIO_TYPE_CIPHER		(10|0x0200)		/* filter */
885b37fcf3Sryker #define BIO_TYPE_BASE64		(11|0x0200)		/* filter */
895b37fcf3Sryker #define BIO_TYPE_CONNECT	(12|0x0400|0x0100)	/* socket - connect */
905b37fcf3Sryker #define BIO_TYPE_ACCEPT		(13|0x0400|0x0100)	/* socket for accept */
915b37fcf3Sryker #define BIO_TYPE_PROXY_CLIENT	(14|0x0200)		/* client proxy BIO */
925b37fcf3Sryker #define BIO_TYPE_PROXY_SERVER	(15|0x0200)		/* server proxy BIO */
935b37fcf3Sryker #define BIO_TYPE_NBIO_TEST	(16|0x0200)		/* server proxy BIO */
945b37fcf3Sryker #define BIO_TYPE_NULL_FILTER	(17|0x0200)
95913ec974Sbeck #define BIO_TYPE_BER		(18|0x0200)		/* BER -> bin filter */
96913ec974Sbeck #define BIO_TYPE_BIO		(19|0x0400)		/* (half a) BIO pair */
97c109e398Sbeck #define BIO_TYPE_LINEBUFFER	(20|0x0200)		/* filter */
984fcf65c5Sdjm #define BIO_TYPE_DGRAM		(21|0x0400|0x0100)
990a5d6edeSdjm #define BIO_TYPE_ASN1 		(22|0x0200)		/* filter */
1004fcf65c5Sdjm #define BIO_TYPE_COMP 		(23|0x0200)		/* filter */
1015b37fcf3Sryker 
1025b37fcf3Sryker #define BIO_TYPE_DESCRIPTOR	0x0100	/* socket, fd, connect or accept */
1035b37fcf3Sryker #define BIO_TYPE_FILTER		0x0200
1045b37fcf3Sryker #define BIO_TYPE_SOURCE_SINK	0x0400
1055b37fcf3Sryker 
1061a692109Sjsing /*
1071a692109Sjsing  * BIO_TYPE_START is the first user-allocated BIO type. No pre-defined type,
1081a692109Sjsing  * flag bits aside, may exceed this value.
1091a692109Sjsing  */
1101a692109Sjsing #define BIO_TYPE_START 128
1111a692109Sjsing 
1125b37fcf3Sryker /* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
1135b37fcf3Sryker  * BIO_set_fp(in,stdin,BIO_NOCLOSE); */
1145b37fcf3Sryker #define BIO_NOCLOSE		0x00
1155b37fcf3Sryker #define BIO_CLOSE		0x01
1165b37fcf3Sryker 
1175b37fcf3Sryker /* These are used in the following macros and are passed to
1185b37fcf3Sryker  * BIO_ctrl() */
1195b37fcf3Sryker #define BIO_CTRL_RESET		1  /* opt - rewind/zero etc */
1205b37fcf3Sryker #define BIO_CTRL_EOF		2  /* opt - are we at the eof */
1215b37fcf3Sryker #define BIO_CTRL_INFO		3  /* opt - extra tit-bits */
1225b37fcf3Sryker #define BIO_CTRL_SET		4  /* man - set the 'IO' type */
1235b37fcf3Sryker #define BIO_CTRL_GET		5  /* man - get the 'IO' type */
1245b37fcf3Sryker #define BIO_CTRL_PUSH		6  /* opt - internal, used to signify change */
1255b37fcf3Sryker #define BIO_CTRL_POP		7  /* opt - internal, used to signify change */
1265b37fcf3Sryker #define BIO_CTRL_GET_CLOSE	8  /* man - set the 'close' on free */
1275b37fcf3Sryker #define BIO_CTRL_SET_CLOSE	9  /* man - set the 'close' on free */
1285b37fcf3Sryker #define BIO_CTRL_PENDING	10  /* opt - is their more data buffered */
1295b37fcf3Sryker #define BIO_CTRL_FLUSH		11  /* opt - 'flush' buffered output */
1305b37fcf3Sryker #define BIO_CTRL_DUP		12  /* man - extra stuff for 'duped' BIO */
1315b37fcf3Sryker #define BIO_CTRL_WPENDING	13  /* opt - number of bytes still to write */
1325b37fcf3Sryker /* callback is int cb(BIO *bio,state,ret); */
1335b37fcf3Sryker #define BIO_CTRL_SET_CALLBACK	14  /* opt - set callback function */
1345b37fcf3Sryker #define BIO_CTRL_GET_CALLBACK	15  /* opt - set callback function */
1355b37fcf3Sryker 
1365b37fcf3Sryker #define BIO_CTRL_SET_FILENAME	30	/* BIO_s_file special */
1375b37fcf3Sryker 
1384fcf65c5Sdjm /* dgram BIO stuff */
1394fcf65c5Sdjm #define BIO_CTRL_DGRAM_CONNECT       31  /* BIO dgram special */
1404fcf65c5Sdjm #define BIO_CTRL_DGRAM_SET_CONNECTED 32  /* allow for an externally
1414fcf65c5Sdjm 					  * connected socket to be
1424fcf65c5Sdjm 					  * passed in */
1434fcf65c5Sdjm #define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */
1444fcf65c5Sdjm #define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */
1454fcf65c5Sdjm #define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */
1464fcf65c5Sdjm #define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */
1474fcf65c5Sdjm 
1484fcf65c5Sdjm #define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */
1494fcf65c5Sdjm #define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */
1504fcf65c5Sdjm 
1514fcf65c5Sdjm /* #ifdef IP_MTU_DISCOVER */
1524fcf65c5Sdjm #define BIO_CTRL_DGRAM_MTU_DISCOVER       39 /* set DF bit on egress packets */
1534fcf65c5Sdjm /* #endif */
1544fcf65c5Sdjm 
1554fcf65c5Sdjm #define BIO_CTRL_DGRAM_QUERY_MTU          40 /* as kernel for current MTU */
1565cdd308eSdjm #define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47
1574fcf65c5Sdjm #define BIO_CTRL_DGRAM_GET_MTU            41 /* get cached value for MTU */
1584fcf65c5Sdjm #define BIO_CTRL_DGRAM_SET_MTU            42 /* set cached value for
1594fcf65c5Sdjm 					      * MTU. want to use this
1604fcf65c5Sdjm 					      * if asking the kernel
1614fcf65c5Sdjm 					      * fails */
1624fcf65c5Sdjm 
1634fcf65c5Sdjm #define BIO_CTRL_DGRAM_MTU_EXCEEDED       43 /* check whether the MTU
1644fcf65c5Sdjm 					      * was exceed in the
1654fcf65c5Sdjm 					      * previous write
1664fcf65c5Sdjm 					      * operation */
1674fcf65c5Sdjm 
1680a5d6edeSdjm #define BIO_CTRL_DGRAM_GET_PEER           46
1694fcf65c5Sdjm #define BIO_CTRL_DGRAM_SET_PEER           44 /* Destination for the data */
1704fcf65c5Sdjm 
1710a5d6edeSdjm #define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45 /* Next DTLS handshake timeout to
1720a5d6edeSdjm                                               * adjust socket timeouts */
1734fcf65c5Sdjm 
1745cdd308eSdjm 
1755b37fcf3Sryker /* modifiers */
1765b37fcf3Sryker #define BIO_FP_READ		0x02
1775b37fcf3Sryker #define BIO_FP_WRITE		0x04
1785b37fcf3Sryker #define BIO_FP_APPEND		0x08
1795b37fcf3Sryker #define BIO_FP_TEXT		0x10
1805b37fcf3Sryker 
1815b37fcf3Sryker #define BIO_FLAGS_READ		0x01
1825b37fcf3Sryker #define BIO_FLAGS_WRITE		0x02
1835b37fcf3Sryker #define BIO_FLAGS_IO_SPECIAL	0x04
1845b37fcf3Sryker #define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
1855b37fcf3Sryker #define BIO_FLAGS_SHOULD_RETRY	0x08
1865b37fcf3Sryker 
1875b37fcf3Sryker /* Used in BIO_gethostbyname() */
1885b37fcf3Sryker #define BIO_GHBN_CTRL_HITS		1
1895b37fcf3Sryker #define BIO_GHBN_CTRL_MISSES		2
1905b37fcf3Sryker #define BIO_GHBN_CTRL_CACHE_SIZE	3
1915b37fcf3Sryker #define BIO_GHBN_CTRL_GET_ENTRY		4
1925b37fcf3Sryker #define BIO_GHBN_CTRL_FLUSH		5
1935b37fcf3Sryker 
1945b37fcf3Sryker /* Mostly used in the SSL BIO */
1955b37fcf3Sryker /* Not used anymore
1965b37fcf3Sryker  * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10
1975b37fcf3Sryker  * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20
1985b37fcf3Sryker  * #define BIO_FLAGS_PROTOCOL_STARTUP	0x40
1995b37fcf3Sryker  */
2005b37fcf3Sryker 
2015b37fcf3Sryker #define BIO_FLAGS_BASE64_NO_NL	0x100
2025b37fcf3Sryker 
203ba5406e9Sbeck /* This is used with memory BIOs: it means we shouldn't free up or change the
204ba5406e9Sbeck  * data in any way.
205ba5406e9Sbeck  */
206ba5406e9Sbeck #define BIO_FLAGS_MEM_RDONLY	0x200
207ba5406e9Sbeck 
2084fcf65c5Sdjm void BIO_set_flags(BIO *b, int flags);
2094fcf65c5Sdjm int  BIO_test_flags(const BIO *b, int flags);
2104fcf65c5Sdjm void BIO_clear_flags(BIO *b, int flags);
2114fcf65c5Sdjm 
2124fcf65c5Sdjm #define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
2135b37fcf3Sryker #define BIO_set_retry_special(b) \
2144fcf65c5Sdjm 		BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
2155b37fcf3Sryker #define BIO_set_retry_read(b) \
2164fcf65c5Sdjm 		BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
2175b37fcf3Sryker #define BIO_set_retry_write(b) \
2184fcf65c5Sdjm 		BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
2195b37fcf3Sryker 
2205b37fcf3Sryker /* These are normally used internally in BIOs */
2215b37fcf3Sryker #define BIO_clear_retry_flags(b) \
2224fcf65c5Sdjm 		BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
2235b37fcf3Sryker #define BIO_get_retry_flags(b) \
2244fcf65c5Sdjm 		BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
2255b37fcf3Sryker 
2265b37fcf3Sryker /* These should be used by the application to tell why we should retry */
2274fcf65c5Sdjm #define BIO_should_read(a)		BIO_test_flags(a, BIO_FLAGS_READ)
2284fcf65c5Sdjm #define BIO_should_write(a)		BIO_test_flags(a, BIO_FLAGS_WRITE)
2294fcf65c5Sdjm #define BIO_should_io_special(a)	BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
2304fcf65c5Sdjm #define BIO_retry_type(a)		BIO_test_flags(a, BIO_FLAGS_RWS)
2314fcf65c5Sdjm #define BIO_should_retry(a)		BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
2325b37fcf3Sryker 
233da347917Sbeck /* The next three are used in conjunction with the
2345b37fcf3Sryker  * BIO_should_io_special() condition.  After this returns true,
2355b37fcf3Sryker  * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
2365b37fcf3Sryker  * stack and return the 'reason' for the special and the offending BIO.
2375b37fcf3Sryker  * Given a BIO, BIO_get_retry_reason(bio) will return the code. */
2385b37fcf3Sryker /* Returned from the SSL bio when the certificate retrieval code had an error */
2395b37fcf3Sryker #define BIO_RR_SSL_X509_LOOKUP		0x01
2405b37fcf3Sryker /* Returned from the connect BIO when a connect would have blocked */
2415b37fcf3Sryker #define BIO_RR_CONNECT			0x02
242da347917Sbeck /* Returned from the accept BIO when an accept would have blocked */
243da347917Sbeck #define BIO_RR_ACCEPT			0x03
2445b37fcf3Sryker 
2455b37fcf3Sryker /* These are passed by the BIO callback */
2465b37fcf3Sryker #define BIO_CB_FREE	0x01
2475b37fcf3Sryker #define BIO_CB_READ	0x02
2485b37fcf3Sryker #define BIO_CB_WRITE	0x03
2495b37fcf3Sryker #define BIO_CB_PUTS	0x04
2505b37fcf3Sryker #define BIO_CB_GETS	0x05
2515b37fcf3Sryker #define BIO_CB_CTRL	0x06
2525b37fcf3Sryker 
253818427c5Stb /*
254818427c5Stb  * The callback is called before and after the underling operation,
255818427c5Stb  * the BIO_CB_RETURN flag indicates if it is after the call.
256818427c5Stb  */
2575b37fcf3Sryker #define BIO_CB_RETURN	0x80
2585b37fcf3Sryker #define BIO_CB_return(a) ((a)|BIO_CB_RETURN))
2595b37fcf3Sryker #define BIO_cb_pre(a)	(!((a)&BIO_CB_RETURN))
2605b37fcf3Sryker #define BIO_cb_post(a)	((a)&BIO_CB_RETURN)
2615b37fcf3Sryker 
262818427c5Stb typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
263818427c5Stb     long argl, long ret);
264818427c5Stb typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp,
265818427c5Stb     size_t len, int argi, long argl, int ret, size_t *processed);
266818427c5Stb 
267818427c5Stb BIO_callback_fn BIO_get_callback(const BIO *b);
268818427c5Stb void BIO_set_callback(BIO *b, BIO_callback_fn callback);
269818427c5Stb 
270818427c5Stb BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b);
271818427c5Stb void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback);
272818427c5Stb 
2734fcf65c5Sdjm char *BIO_get_callback_arg(const BIO *b);
2744fcf65c5Sdjm void BIO_set_callback_arg(BIO *b, char *arg);
2755b37fcf3Sryker 
2764fcf65c5Sdjm const char *BIO_method_name(const BIO *b);
2774fcf65c5Sdjm int BIO_method_type(const BIO *b);
278c109e398Sbeck 
2795fd87cb9Stb typedef int BIO_info_cb(BIO *, int, int);
280f78b0aadStb /* Compatibility with OpenSSL's backward compatibility. */
281f78b0aadStb typedef BIO_info_cb bio_info_cb;
282c109e398Sbeck 
28300451bf8Stb typedef struct bio_method_st BIO_METHOD;
284c109e398Sbeck 
285c109e398Sbeck DECLARE_STACK_OF(BIO)
2865b37fcf3Sryker 
2870a5d6edeSdjm /* Prefix and suffix callback in ASN1 BIO */
2880a5d6edeSdjm typedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg);
2890a5d6edeSdjm 
29097c7ad8eStb /* BIO_METHOD accessors */
29197c7ad8eStb BIO_METHOD *BIO_meth_new(int type, const char *name);
29297c7ad8eStb void BIO_meth_free(BIO_METHOD *biom);
2938625b501Stb int (*BIO_meth_get_write(const BIO_METHOD *biom))(BIO *, const char *, int);
29497c7ad8eStb int BIO_meth_set_write(BIO_METHOD *biom,
29597c7ad8eStb     int (*write)(BIO *, const char *, int));
2968625b501Stb int (*BIO_meth_get_read(const BIO_METHOD *biom))(BIO *, char *, int);
29797c7ad8eStb int BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int));
2988625b501Stb int (*BIO_meth_get_puts(const BIO_METHOD *biom))(BIO *, const char *);
29997c7ad8eStb int BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *));
3008625b501Stb int (*BIO_meth_get_gets(const BIO_METHOD *biom))(BIO *, char *, int);
301f02021ddStb int BIO_meth_set_gets(BIO_METHOD *biom, int (*gets)(BIO *, char *, int));
3028625b501Stb long (*BIO_meth_get_ctrl(const BIO_METHOD *biom))(BIO *, int, long, void *);
30329b74c60Stb int BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl)(BIO *, int, long, void *));
3048625b501Stb int (*BIO_meth_get_create(const BIO_METHOD *biom))(BIO *);
30597c7ad8eStb int BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *));
3068625b501Stb int (*BIO_meth_get_destroy(const BIO_METHOD *biom))(BIO *);
30797c7ad8eStb int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *));
3088625b501Stb long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))(BIO *, int, BIO_info_cb *);
3095fd87cb9Stb int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
3105fd87cb9Stb     long (*callback_ctrl)(BIO *, int, BIO_info_cb *));
3115cdd308eSdjm 
3125b37fcf3Sryker /* connect BIO stuff */
3135b37fcf3Sryker #define BIO_CONN_S_BEFORE		1
3145b37fcf3Sryker #define BIO_CONN_S_GET_IP		2
3155b37fcf3Sryker #define BIO_CONN_S_GET_PORT		3
3165b37fcf3Sryker #define BIO_CONN_S_CREATE_SOCKET	4
3175b37fcf3Sryker #define BIO_CONN_S_CONNECT		5
3185b37fcf3Sryker #define BIO_CONN_S_OK			6
3195b37fcf3Sryker #define BIO_CONN_S_BLOCKED_CONNECT	7
3205b37fcf3Sryker #define BIO_CONN_S_NBIO			8
321913ec974Sbeck /*#define BIO_CONN_get_param_hostname	BIO_ctrl */
3225b37fcf3Sryker 
3235b37fcf3Sryker #define BIO_C_SET_CONNECT			100
3245b37fcf3Sryker #define BIO_C_DO_STATE_MACHINE			101
3255b37fcf3Sryker #define BIO_C_SET_NBIO				102
3265b37fcf3Sryker #define BIO_C_SET_PROXY_PARAM			103
3275b37fcf3Sryker #define BIO_C_SET_FD				104
3285b37fcf3Sryker #define BIO_C_GET_FD				105
3295b37fcf3Sryker #define BIO_C_SET_FILE_PTR			106
3305b37fcf3Sryker #define BIO_C_GET_FILE_PTR			107
3315b37fcf3Sryker #define BIO_C_SET_FILENAME			108
3325b37fcf3Sryker #define BIO_C_SET_SSL				109
3335b37fcf3Sryker #define BIO_C_GET_SSL				110
3345b37fcf3Sryker #define BIO_C_SET_MD				111
3355b37fcf3Sryker #define BIO_C_GET_MD				112
3365b37fcf3Sryker #define BIO_C_GET_CIPHER_STATUS			113
3375b37fcf3Sryker #define BIO_C_SET_BUF_MEM			114
3385b37fcf3Sryker #define BIO_C_GET_BUF_MEM_PTR			115
3395b37fcf3Sryker #define BIO_C_GET_BUFF_NUM_LINES		116
3405b37fcf3Sryker #define BIO_C_SET_BUFF_SIZE			117
3415b37fcf3Sryker #define BIO_C_SET_ACCEPT			118
3425b37fcf3Sryker #define BIO_C_SSL_MODE				119
3435b37fcf3Sryker #define BIO_C_GET_MD_CTX			120
3445b37fcf3Sryker #define BIO_C_GET_PROXY_PARAM			121
3455b37fcf3Sryker #define BIO_C_SET_BUFF_READ_DATA		122 /* data to read first */
3465b37fcf3Sryker #define BIO_C_GET_CONNECT			123
3475b37fcf3Sryker #define BIO_C_GET_ACCEPT			124
3485b37fcf3Sryker #define BIO_C_SET_SSL_RENEGOTIATE_BYTES		125
3495b37fcf3Sryker #define BIO_C_GET_SSL_NUM_RENEGOTIATES		126
3505b37fcf3Sryker #define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT	127
351913ec974Sbeck #define BIO_C_FILE_SEEK				128
352913ec974Sbeck #define BIO_C_GET_CIPHER_CTX			129
353913ec974Sbeck #define BIO_C_SET_BUF_MEM_EOF_RETURN		130/*return end of input value*/
354913ec974Sbeck #define BIO_C_SET_BIND_MODE			131
355913ec974Sbeck #define BIO_C_GET_BIND_MODE			132
356913ec974Sbeck #define BIO_C_FILE_TELL				133
357913ec974Sbeck #define BIO_C_GET_SOCKS				134
358913ec974Sbeck #define BIO_C_SET_SOCKS				135
359913ec974Sbeck 
360913ec974Sbeck #define BIO_C_SET_WRITE_BUF_SIZE		136/* for BIO_s_bio */
361913ec974Sbeck #define BIO_C_GET_WRITE_BUF_SIZE		137
362913ec974Sbeck #define BIO_C_MAKE_BIO_PAIR			138
363913ec974Sbeck #define BIO_C_DESTROY_BIO_PAIR			139
364913ec974Sbeck #define BIO_C_GET_WRITE_GUARANTEE		140
365913ec974Sbeck #define BIO_C_GET_READ_REQUEST			141
366913ec974Sbeck #define BIO_C_SHUTDOWN_WR			142
367ba5406e9Sbeck #define BIO_C_RESET_READ_REQUEST		147
36840d8aef3Sdjm #define BIO_C_SET_MD_CTX			148
369913ec974Sbeck 
3700a5d6edeSdjm #define BIO_C_SET_EX_ARG			153
3710a5d6edeSdjm #define BIO_C_GET_EX_ARG			154
3725b37fcf3Sryker 
373ba5406e9Sbeck #define BIO_set_app_data(s,arg)		BIO_set_ex_data(s,0,arg)
3745b37fcf3Sryker #define BIO_get_app_data(s)		BIO_get_ex_data(s,0)
3755b37fcf3Sryker 
376913ec974Sbeck /* BIO_s_connect() and BIO_s_socks4a_connect() */
3775b37fcf3Sryker #define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
3785b37fcf3Sryker #define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
3795b37fcf3Sryker #define BIO_set_conn_ip(b,ip)	  BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
3805b37fcf3Sryker #define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
3815b37fcf3Sryker #define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
3825b37fcf3Sryker #define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
383da347917Sbeck #define BIO_get_conn_ip(b) 		 BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
3840a5d6edeSdjm #define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0)
385913ec974Sbeck 
3865b37fcf3Sryker 
3875b37fcf3Sryker #define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
3885b37fcf3Sryker 
3895b37fcf3Sryker /* BIO_s_accept_socket() */
3905b37fcf3Sryker #define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
3915b37fcf3Sryker #define BIO_get_accept_port(b)	BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
3925b37fcf3Sryker /* #define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
3930a5d6edeSdjm #define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL)
3945b37fcf3Sryker #define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
3955b37fcf3Sryker 
396913ec974Sbeck #define BIO_BIND_NORMAL			0
397913ec974Sbeck #define BIO_BIND_REUSEADDR_IF_UNUSED	1
398913ec974Sbeck #define BIO_BIND_REUSEADDR		2
399913ec974Sbeck #define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
400913ec974Sbeck #define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
401913ec974Sbeck 
4025b37fcf3Sryker #define BIO_do_connect(b)	BIO_do_handshake(b)
4035b37fcf3Sryker #define BIO_do_accept(b)	BIO_do_handshake(b)
4045b37fcf3Sryker #define BIO_do_handshake(b)	BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
4055b37fcf3Sryker 
4065b37fcf3Sryker /* BIO_s_proxy_client() */
4075b37fcf3Sryker #define BIO_set_url(b,url)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))
4085b37fcf3Sryker #define BIO_set_proxies(b,p)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))
4095b37fcf3Sryker /* BIO_set_nbio(b,n) */
4105b37fcf3Sryker #define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
4115b37fcf3Sryker /* BIO *BIO_get_filter_bio(BIO *bio); */
412ba5406e9Sbeck #define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
4135b37fcf3Sryker #define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
4145b37fcf3Sryker #define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
4155b37fcf3Sryker 
4165b37fcf3Sryker #define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)
4175b37fcf3Sryker #define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))
4185b37fcf3Sryker #define BIO_get_url(b,url)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
4195b37fcf3Sryker #define BIO_get_no_connect_return(b)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)
4205b37fcf3Sryker 
4215b37fcf3Sryker #define BIO_set_fd(b,fd,c)	BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
4225b37fcf3Sryker #define BIO_get_fd(b,c)		BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
4235b37fcf3Sryker 
4245b37fcf3Sryker #define BIO_set_fp(b,fp,c)	BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
4255b37fcf3Sryker #define BIO_get_fp(b,fpp)	BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
4265b37fcf3Sryker 
427913ec974Sbeck #define BIO_seek(b,ofs)	(int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
428913ec974Sbeck #define BIO_tell(b)	(int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
429913ec974Sbeck 
430913ec974Sbeck /* name is cast to lose const, but might be better to route through a function
431913ec974Sbeck    so we can do it safely */
4325b37fcf3Sryker #define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
433913ec974Sbeck 		BIO_CLOSE|BIO_FP_READ,(char *)name)
4345b37fcf3Sryker #define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
4355b37fcf3Sryker 		BIO_CLOSE|BIO_FP_WRITE,name)
4365b37fcf3Sryker #define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
4375b37fcf3Sryker 		BIO_CLOSE|BIO_FP_APPEND,name)
438913ec974Sbeck #define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
439913ec974Sbeck 		BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
4405b37fcf3Sryker 
4415b37fcf3Sryker /* WARNING WARNING, this ups the reference count on the read bio of the
4425b37fcf3Sryker  * SSL structure.  This is because the ssl read BIO is now pointed to by
4435b37fcf3Sryker  * the next_bio field in the bio.  So when you free the BIO, make sure
4445b37fcf3Sryker  * you are doing a BIO_free_all() to catch the underlying BIO. */
4455b37fcf3Sryker #define BIO_set_ssl(b,ssl,c)	BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
4465b37fcf3Sryker #define BIO_get_ssl(b,sslp)	BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
4475b37fcf3Sryker #define BIO_set_ssl_mode(b,client)	BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
4485b37fcf3Sryker #define BIO_set_ssl_renegotiate_bytes(b,num) \
449d94c81a7Sderaadt 	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)
4505b37fcf3Sryker #define BIO_get_num_renegotiates(b) \
451d94c81a7Sderaadt 	BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)
4525b37fcf3Sryker #define BIO_set_ssl_renegotiate_timeout(b,seconds) \
453d94c81a7Sderaadt 	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)
4545b37fcf3Sryker 
4555b37fcf3Sryker /* defined in evp.h */
4565b37fcf3Sryker /* #define BIO_set_md(b,md)	BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
4575b37fcf3Sryker 
458913ec974Sbeck #define BIO_get_mem_data(b,pp)	BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
4595b37fcf3Sryker #define BIO_set_mem_buf(b,bm,c)	BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
4605b37fcf3Sryker #define BIO_get_mem_ptr(b,pp)	BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
461913ec974Sbeck #define BIO_set_mem_eof_return(b,v) \
462913ec974Sbeck 				BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
4635b37fcf3Sryker 
4645b37fcf3Sryker /* For the BIO_f_buffer() type */
4655b37fcf3Sryker #define BIO_get_buffer_num_lines(b)	BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
4665b37fcf3Sryker #define BIO_set_buffer_size(b,size)	BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
4675b37fcf3Sryker #define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
4685b37fcf3Sryker #define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
4695b37fcf3Sryker #define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
4705b37fcf3Sryker 
4715b37fcf3Sryker /* Don't use the next one unless you know what you are doing :-) */
4725b37fcf3Sryker #define BIO_dup_state(b,ret)	BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
4735b37fcf3Sryker 
4745b37fcf3Sryker #define BIO_reset(b)		(int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
4755b37fcf3Sryker #define BIO_eof(b)		(int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
4765b37fcf3Sryker #define BIO_set_close(b,c)	(int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
4775b37fcf3Sryker #define BIO_get_close(b)	(int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
4785b37fcf3Sryker #define BIO_pending(b)		(int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
4795b37fcf3Sryker #define BIO_wpending(b)		(int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
480913ec974Sbeck /* ...pending macros have inappropriate return type */
481913ec974Sbeck size_t BIO_ctrl_pending(BIO *b);
482913ec974Sbeck size_t BIO_ctrl_wpending(BIO *b);
4835b37fcf3Sryker #define BIO_flush(b)		(int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
484da347917Sbeck #define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
485da347917Sbeck 						   cbp)
486da347917Sbeck #define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
4875b37fcf3Sryker 
4885b37fcf3Sryker /* For the BIO_f_buffer() type */
4895b37fcf3Sryker #define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
4905b37fcf3Sryker 
491913ec974Sbeck /* For BIO_s_bio() */
492913ec974Sbeck #define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
493913ec974Sbeck #define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
494913ec974Sbeck #define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
495913ec974Sbeck #define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
496c109e398Sbeck #define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
497913ec974Sbeck /* macros with inappropriate type -- but ...pending macros use int too: */
498913ec974Sbeck #define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
499913ec974Sbeck #define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
500913ec974Sbeck size_t BIO_ctrl_get_write_guarantee(BIO *b);
501913ec974Sbeck size_t BIO_ctrl_get_read_request(BIO *b);
502ba5406e9Sbeck int BIO_ctrl_reset_read_request(BIO *b);
503913ec974Sbeck 
5044fcf65c5Sdjm /* ctrl macros for dgram */
5054fcf65c5Sdjm #define BIO_ctrl_dgram_connect(b,peer)  \
5064fcf65c5Sdjm                      (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)
5074fcf65c5Sdjm #define BIO_ctrl_set_connected(b, state, peer) \
5084fcf65c5Sdjm          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)
5094fcf65c5Sdjm #define BIO_dgram_recv_timedout(b) \
5104fcf65c5Sdjm          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
5114fcf65c5Sdjm #define BIO_dgram_send_timedout(b) \
5124fcf65c5Sdjm          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
5130a5d6edeSdjm #define BIO_dgram_get_peer(b,peer) \
5140a5d6edeSdjm          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
5154fcf65c5Sdjm #define BIO_dgram_set_peer(b,peer) \
5164fcf65c5Sdjm          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
5174fcf65c5Sdjm 
518913ec974Sbeck /* These two aren't currently implemented */
519913ec974Sbeck /* int BIO_get_ex_num(BIO *bio); */
520913ec974Sbeck /* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
521ba5406e9Sbeck int BIO_set_ex_data(BIO *bio, int idx, void *data);
522ba5406e9Sbeck void *BIO_get_ex_data(BIO *bio, int idx);
52351323fa6Sschwarze int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
524ba5406e9Sbeck     CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
525ba5406e9Sbeck unsigned long BIO_number_read(BIO *bio);
526ba5406e9Sbeck unsigned long BIO_number_written(BIO *bio);
527913ec974Sbeck 
5281a692109Sjsing int BIO_get_new_index(void);
529cc83181bStb const BIO_METHOD *BIO_s_file(void);
530913ec974Sbeck BIO *BIO_new_file(const char *filename, const char *mode);
5315b37fcf3Sryker BIO *BIO_new_fp(FILE *stream, int close_flag);
5326dc76777Stb BIO	*BIO_new(const BIO_METHOD *type);
5335b37fcf3Sryker int	BIO_free(BIO *a);
534e5cfd1dcSjsing int	BIO_up_ref(BIO *bio);
535b47f35fcStb void	*BIO_get_data(BIO *a);
536b47f35fcStb void	BIO_set_data(BIO *a, void *ptr);
53766eead03Stb int	BIO_get_init(BIO *a);
538b47f35fcStb void	BIO_set_init(BIO *a, int init);
5395db89a4fStb int	BIO_get_shutdown(BIO *a);
5405db89a4fStb void	BIO_set_shutdown(BIO *a, int shut);
541c109e398Sbeck void	BIO_vfree(BIO *a);
5428a890fdfStedu int	BIO_read(BIO *b, void *data, int len)
5438a890fdfStedu 		__attribute__((__bounded__(__buffer__,2,3)));
5448a890fdfStedu int	BIO_gets(BIO *bp, char *buf, int size)
5458a890fdfStedu 		__attribute__((__bounded__ (__string__,2,3)));
5468a890fdfStedu int	BIO_write(BIO *b, const void *data, int len)
5478a890fdfStedu 		__attribute__((__bounded__(__buffer__,2,3)));
548913ec974Sbeck int	BIO_puts(BIO *bp, const char *buf);
549767fe2ffSmarkus int	BIO_indent(BIO *b, int indent, int max);
550913ec974Sbeck long	BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
551818427c5Stb long	BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);
5525b37fcf3Sryker char *	BIO_ptr_ctrl(BIO *bp, int cmd, long larg);
5535b37fcf3Sryker long	BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);
5545b37fcf3Sryker BIO *	BIO_push(BIO *b, BIO *append);
5555b37fcf3Sryker BIO *	BIO_pop(BIO *b);
5565b37fcf3Sryker void	BIO_free_all(BIO *a);
5575b37fcf3Sryker BIO *	BIO_find_type(BIO *b, int bio_type);
558c109e398Sbeck BIO *	BIO_next(BIO *b);
55905505bebStb void	BIO_set_next(BIO *b, BIO *next);
5605b37fcf3Sryker BIO *	BIO_get_retry_BIO(BIO *bio, int *reason);
5615b37fcf3Sryker int	BIO_get_retry_reason(BIO *bio);
562635cb7a5Stb void	BIO_set_retry_reason(BIO *bio, int reason);
5635b37fcf3Sryker BIO *	BIO_dup_chain(BIO *in);
5645b37fcf3Sryker 
565913ec974Sbeck long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
5665b37fcf3Sryker     long argl, long ret);
5675b37fcf3Sryker 
5688341b5ddStb const BIO_METHOD *BIO_s_mem(void);
56991427bf7Stb BIO *BIO_new_mem_buf(const void *buf, int len);
5706dc76777Stb const BIO_METHOD *BIO_s_socket(void);
5716dc76777Stb const BIO_METHOD *BIO_s_connect(void);
5726dc76777Stb const BIO_METHOD *BIO_s_accept(void);
5736dc76777Stb const BIO_METHOD *BIO_s_fd(void);
5746dc76777Stb const BIO_METHOD *BIO_s_log(void);
5756dc76777Stb const BIO_METHOD *BIO_s_bio(void);
5766dc76777Stb const BIO_METHOD *BIO_s_null(void);
5776dc76777Stb const BIO_METHOD *BIO_f_null(void);
5786dc76777Stb const BIO_METHOD *BIO_f_buffer(void);
5796dc76777Stb const BIO_METHOD *BIO_f_nbio_test(void);
5804fcf65c5Sdjm #ifndef OPENSSL_NO_DGRAM
5818341b5ddStb const BIO_METHOD *BIO_s_datagram(void);
5824fcf65c5Sdjm #endif
5834fcf65c5Sdjm 
584913ec974Sbeck /* BIO_METHOD *BIO_f_ber(void); */
5855b37fcf3Sryker 
5865b37fcf3Sryker int BIO_sock_should_retry(int i);
587385ffcfeSdoug int BIO_sock_non_fatal_error(int _error);
588385ffcfeSdoug int BIO_dgram_non_fatal_error(int _error);
5894fcf65c5Sdjm 
5905b37fcf3Sryker int BIO_fd_should_retry(int i);
591385ffcfeSdoug int BIO_fd_non_fatal_error(int _error);
5921fa3bebfStb 
593913ec974Sbeck int BIO_dump(BIO *b, const char *bytes, int len);
594c109e398Sbeck int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);
5951fa3bebfStb 
596913ec974Sbeck struct hostent *BIO_gethostbyname(const char *name);
597913ec974Sbeck /* We might want a thread-safe interface too:
598913ec974Sbeck  * struct hostent *BIO_gethostbyname_r(const char *name,
599913ec974Sbeck  *     struct hostent *result, void *buffer, size_t buflen);
600913ec974Sbeck  * or something similar (caller allocates a struct hostent,
601913ec974Sbeck  * pointed to by "result", and additional buffer space for the various
602913ec974Sbeck  * substructures; if the buffer does not suffice, NULL is returned
603913ec974Sbeck  * and an appropriate error code is set).
604913ec974Sbeck  */
6055b37fcf3Sryker int BIO_sock_error(int sock);
606767fe2ffSmarkus int BIO_socket_ioctl(int fd, long type, void *arg);
607913ec974Sbeck int BIO_socket_nbio(int fd, int mode);
608913ec974Sbeck int BIO_get_port(const char *str, unsigned short *port_ptr);
609913ec974Sbeck int BIO_get_host_ip(const char *str, unsigned char *ip);
610913ec974Sbeck int BIO_get_accept_socket(char *host_port, int mode);
6115b37fcf3Sryker int BIO_accept(int sock, char **ip_port);
6125b37fcf3Sryker int BIO_sock_init(void );
6135b37fcf3Sryker void BIO_sock_cleanup(void);
6145b37fcf3Sryker int BIO_set_tcp_ndelay(int sock, int turn_on);
6155b37fcf3Sryker 
6165b37fcf3Sryker BIO *BIO_new_socket(int sock, int close_flag);
6174fcf65c5Sdjm BIO *BIO_new_dgram(int fd, int close_flag);
6185b37fcf3Sryker BIO *BIO_new_fd(int fd, int close_flag);
61991427bf7Stb BIO *BIO_new_connect(const char *host_port);
62091427bf7Stb BIO *BIO_new_accept(const char *host_port);
6215b37fcf3Sryker 
62251323fa6Sschwarze int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
623913ec974Sbeck     BIO **bio2, size_t writebuf2);
624913ec974Sbeck /* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
625913ec974Sbeck  * Otherwise returns 0 and sets *bio1 and *bio2 to NULL.
626913ec974Sbeck  * Size 0 uses default value.
627913ec974Sbeck  */
628913ec974Sbeck 
6295b37fcf3Sryker void BIO_copy_next_retry(BIO *b);
6305b37fcf3Sryker 
631767fe2ffSmarkus /*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
6325b37fcf3Sryker 
63370bd79abStb /* Needed for libressl-portable. */
63470bd79abStb #ifndef __MINGW_PRINTF_FORMAT
635dfdadbdbSbeck int BIO_printf(BIO *bio, const char *format, ...)
636ab588a6aSguenther 	__attribute__((__format__(__printf__, 2, 3), __nonnull__(2)));
63770bd79abStb #else
63870bd79abStb int BIO_printf(BIO *bio, const char *format, ...)
63970bd79abStb 	__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 3), __nonnull__(2)));
64070bd79abStb #endif
6415b37fcf3Sryker 
642da347917Sbeck void ERR_load_BIO_strings(void);
643913ec974Sbeck 
6445b37fcf3Sryker /* Error codes for the BIO functions. */
6455b37fcf3Sryker 
6465b37fcf3Sryker /* Function codes. */
6475b37fcf3Sryker #define BIO_F_ACPT_STATE				 100
6485b37fcf3Sryker #define BIO_F_BIO_ACCEPT				 101
649913ec974Sbeck #define BIO_F_BIO_BER_GET_HEADER			 102
6504fcf65c5Sdjm #define BIO_F_BIO_CALLBACK_CTRL				 131
651913ec974Sbeck #define BIO_F_BIO_CTRL					 103
652913ec974Sbeck #define BIO_F_BIO_GETHOSTBYNAME				 120
653913ec974Sbeck #define BIO_F_BIO_GETS					 104
654913ec974Sbeck #define BIO_F_BIO_GET_ACCEPT_SOCKET			 105
655913ec974Sbeck #define BIO_F_BIO_GET_HOST_IP				 106
656913ec974Sbeck #define BIO_F_BIO_GET_PORT				 107
657913ec974Sbeck #define BIO_F_BIO_MAKE_PAIR				 121
658913ec974Sbeck #define BIO_F_BIO_NEW					 108
659913ec974Sbeck #define BIO_F_BIO_NEW_FILE				 109
660ba5406e9Sbeck #define BIO_F_BIO_NEW_MEM_BUF				 126
661ba5406e9Sbeck #define BIO_F_BIO_NREAD					 123
662ba5406e9Sbeck #define BIO_F_BIO_NREAD0				 124
663ba5406e9Sbeck #define BIO_F_BIO_NWRITE				 125
664ba5406e9Sbeck #define BIO_F_BIO_NWRITE0				 122
665913ec974Sbeck #define BIO_F_BIO_PUTS					 110
666913ec974Sbeck #define BIO_F_BIO_READ					 111
667913ec974Sbeck #define BIO_F_BIO_SOCK_INIT				 112
668913ec974Sbeck #define BIO_F_BIO_WRITE					 113
669913ec974Sbeck #define BIO_F_BUFFER_CTRL				 114
670ba5406e9Sbeck #define BIO_F_CONN_CTRL					 127
671913ec974Sbeck #define BIO_F_CONN_STATE				 115
6725cdd308eSdjm #define BIO_F_DGRAM_SCTP_READ				 132
673913ec974Sbeck #define BIO_F_FILE_CTRL					 116
6741f9308f9Smarkus #define BIO_F_FILE_READ					 130
675c109e398Sbeck #define BIO_F_LINEBUFFER_CTRL				 129
676c109e398Sbeck #define BIO_F_MEM_READ					 128
677913ec974Sbeck #define BIO_F_MEM_WRITE					 117
678913ec974Sbeck #define BIO_F_SSL_NEW					 118
679913ec974Sbeck #define BIO_F_WSASTARTUP				 119
6805b37fcf3Sryker 
6815b37fcf3Sryker /* Reason codes. */
6825b37fcf3Sryker #define BIO_R_ACCEPT_ERROR				 100
6835b37fcf3Sryker #define BIO_R_BAD_FOPEN_MODE				 101
6845b37fcf3Sryker #define BIO_R_BAD_HOSTNAME_LOOKUP			 102
685913ec974Sbeck #define BIO_R_BROKEN_PIPE				 124
6865b37fcf3Sryker #define BIO_R_CONNECT_ERROR				 103
687c109e398Sbeck #define BIO_R_EOF_ON_MEMORY_BIO				 127
6885b37fcf3Sryker #define BIO_R_ERROR_SETTING_NBIO			 104
6895b37fcf3Sryker #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET	 105
6905b37fcf3Sryker #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET	 106
6915b37fcf3Sryker #define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET		 107
692913ec974Sbeck #define BIO_R_INVALID_ARGUMENT				 125
6935b37fcf3Sryker #define BIO_R_INVALID_IP_ADDRESS			 108
694e5e87f23Sjsing #define BIO_R_INVALID_PORT_NUMBER			 129
695913ec974Sbeck #define BIO_R_IN_USE					 123
6965b37fcf3Sryker #define BIO_R_KEEPALIVE					 109
697818427c5Stb #define BIO_R_LENGTH_TOO_LONG				 130
6985b37fcf3Sryker #define BIO_R_NBIO_CONNECT_ERROR			 110
6995b37fcf3Sryker #define BIO_R_NO_ACCEPT_PORT_SPECIFIED			 111
700913ec974Sbeck #define BIO_R_NO_HOSTNAME_SPECIFIED			 112
7015b37fcf3Sryker #define BIO_R_NO_PORT_DEFINED				 113
7025b37fcf3Sryker #define BIO_R_NO_PORT_SPECIFIED				 114
703da347917Sbeck #define BIO_R_NO_SUCH_FILE				 128
7045b37fcf3Sryker #define BIO_R_NULL_PARAMETER				 115
705913ec974Sbeck #define BIO_R_TAG_MISMATCH				 116
706913ec974Sbeck #define BIO_R_UNABLE_TO_BIND_SOCKET			 117
707913ec974Sbeck #define BIO_R_UNABLE_TO_CREATE_SOCKET			 118
708913ec974Sbeck #define BIO_R_UNABLE_TO_LISTEN_SOCKET			 119
709913ec974Sbeck #define BIO_R_UNINITIALIZED				 120
710913ec974Sbeck #define BIO_R_UNSUPPORTED_METHOD			 121
711ba5406e9Sbeck #define BIO_R_WRITE_TO_READ_ONLY_BIO			 126
712913ec974Sbeck #define BIO_R_WSASTARTUP				 122
7135b37fcf3Sryker 
7145b37fcf3Sryker #ifdef  __cplusplus
7155b37fcf3Sryker }
7165b37fcf3Sryker #endif
7175b37fcf3Sryker #endif
718