bio.h revision 205128
155714Skris/* crypto/bio/bio.h */
255714Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
355714Skris * All rights reserved.
455714Skris *
555714Skris * This package is an SSL implementation written
655714Skris * by Eric Young (eay@cryptsoft.com).
755714Skris * The implementation was written so as to conform with Netscapes SSL.
855714Skris *
955714Skris * This library is free for commercial and non-commercial use as long as
1055714Skris * the following conditions are aheared to.  The following conditions
1155714Skris * apply to all code found in this distribution, be it the RC4, RSA,
1255714Skris * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1355714Skris * included with this distribution is covered by the same copyright terms
1455714Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1555714Skris *
1655714Skris * Copyright remains Eric Young's, and as such any Copyright notices in
1755714Skris * the code are not to be removed.
1855714Skris * If this package is used in a product, Eric Young should be given attribution
1955714Skris * as the author of the parts of the library used.
2055714Skris * This can be in the form of a textual message at program startup or
2155714Skris * in documentation (online or textual) provided with the package.
2255714Skris *
2355714Skris * Redistribution and use in source and binary forms, with or without
2455714Skris * modification, are permitted provided that the following conditions
2555714Skris * are met:
2655714Skris * 1. Redistributions of source code must retain the copyright
2755714Skris *    notice, this list of conditions and the following disclaimer.
2855714Skris * 2. Redistributions in binary form must reproduce the above copyright
2955714Skris *    notice, this list of conditions and the following disclaimer in the
3055714Skris *    documentation and/or other materials provided with the distribution.
3155714Skris * 3. All advertising materials mentioning features or use of this software
3255714Skris *    must display the following acknowledgement:
3355714Skris *    "This product includes cryptographic software written by
3455714Skris *     Eric Young (eay@cryptsoft.com)"
3555714Skris *    The word 'cryptographic' can be left out if the rouines from the library
3655714Skris *    being used are not cryptographic related :-).
3755714Skris * 4. If you include any Windows specific code (or a derivative thereof) from
3855714Skris *    the apps directory (application code) you must include an acknowledgement:
3955714Skris *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
4055714Skris *
4155714Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4255714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4355714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4455714Skris * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4555714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4655714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4755714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4855714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4955714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5055714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5155714Skris * SUCH DAMAGE.
5255714Skris *
5355714Skris * The licence and distribution terms for any publically available version or
5455714Skris * derivative of this code cannot be changed.  i.e. this code cannot simply be
5555714Skris * copied and put under another distribution licence
5655714Skris * [including the GNU Public Licence.]
5755714Skris */
5855714Skris
5955714Skris#ifndef HEADER_BIO_H
6055714Skris#define HEADER_BIO_H
6155714Skris
62160814Ssimon#include <openssl/e_os2.h>
63160814Ssimon
64109998Smarkm#ifndef OPENSSL_NO_FP_API
6568651Skris# include <stdio.h>
6668651Skris#endif
6768651Skris#include <stdarg.h>
6868651Skris
6968651Skris#include <openssl/crypto.h>
7068651Skris
7155714Skris#ifdef  __cplusplus
7255714Skrisextern "C" {
7355714Skris#endif
7455714Skris
7555714Skris/* These are the 'types' of BIOs */
7655714Skris#define BIO_TYPE_NONE		0
7755714Skris#define BIO_TYPE_MEM		(1|0x0400)
7855714Skris#define BIO_TYPE_FILE		(2|0x0400)
7955714Skris
8055714Skris#define BIO_TYPE_FD		(4|0x0400|0x0100)
8155714Skris#define BIO_TYPE_SOCKET		(5|0x0400|0x0100)
8255714Skris#define BIO_TYPE_NULL		(6|0x0400)
8355714Skris#define BIO_TYPE_SSL		(7|0x0200)
8459191Skris#define BIO_TYPE_MD		(8|0x0200)		/* passive filter */
8555714Skris#define BIO_TYPE_BUFFER		(9|0x0200)		/* filter */
8655714Skris#define BIO_TYPE_CIPHER		(10|0x0200)		/* filter */
8755714Skris#define BIO_TYPE_BASE64		(11|0x0200)		/* filter */
8855714Skris#define BIO_TYPE_CONNECT	(12|0x0400|0x0100)	/* socket - connect */
8955714Skris#define BIO_TYPE_ACCEPT		(13|0x0400|0x0100)	/* socket for accept */
9055714Skris#define BIO_TYPE_PROXY_CLIENT	(14|0x0200)		/* client proxy BIO */
9155714Skris#define BIO_TYPE_PROXY_SERVER	(15|0x0200)		/* server proxy BIO */
9255714Skris#define BIO_TYPE_NBIO_TEST	(16|0x0200)		/* server proxy BIO */
9355714Skris#define BIO_TYPE_NULL_FILTER	(17|0x0200)
9455714Skris#define BIO_TYPE_BER		(18|0x0200)		/* BER -> bin filter */
9555714Skris#define BIO_TYPE_BIO		(19|0x0400)		/* (half a) BIO pair */
9668651Skris#define BIO_TYPE_LINEBUFFER	(20|0x0200)		/* filter */
97160814Ssimon#define BIO_TYPE_DGRAM		(21|0x0400|0x0100)
98194206Ssimon#define BIO_TYPE_COMP 		(23|0x0200)		/* filter */
9955714Skris
10055714Skris#define BIO_TYPE_DESCRIPTOR	0x0100	/* socket, fd, connect or accept */
10155714Skris#define BIO_TYPE_FILTER		0x0200
10255714Skris#define BIO_TYPE_SOURCE_SINK	0x0400
10355714Skris
10455714Skris/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
10555714Skris * BIO_set_fp(in,stdin,BIO_NOCLOSE); */
10655714Skris#define BIO_NOCLOSE		0x00
10755714Skris#define BIO_CLOSE		0x01
10855714Skris
10955714Skris/* These are used in the following macros and are passed to
11055714Skris * BIO_ctrl() */
11155714Skris#define BIO_CTRL_RESET		1  /* opt - rewind/zero etc */
11255714Skris#define BIO_CTRL_EOF		2  /* opt - are we at the eof */
11355714Skris#define BIO_CTRL_INFO		3  /* opt - extra tit-bits */
11455714Skris#define BIO_CTRL_SET		4  /* man - set the 'IO' type */
11555714Skris#define BIO_CTRL_GET		5  /* man - get the 'IO' type */
11655714Skris#define BIO_CTRL_PUSH		6  /* opt - internal, used to signify change */
11755714Skris#define BIO_CTRL_POP		7  /* opt - internal, used to signify change */
11855714Skris#define BIO_CTRL_GET_CLOSE	8  /* man - set the 'close' on free */
11955714Skris#define BIO_CTRL_SET_CLOSE	9  /* man - set the 'close' on free */
12055714Skris#define BIO_CTRL_PENDING	10  /* opt - is their more data buffered */
12155714Skris#define BIO_CTRL_FLUSH		11  /* opt - 'flush' buffered output */
12255714Skris#define BIO_CTRL_DUP		12  /* man - extra stuff for 'duped' BIO */
12355714Skris#define BIO_CTRL_WPENDING	13  /* opt - number of bytes still to write */
12455714Skris/* callback is int cb(BIO *bio,state,ret); */
12555714Skris#define BIO_CTRL_SET_CALLBACK	14  /* opt - set callback function */
12655714Skris#define BIO_CTRL_GET_CALLBACK	15  /* opt - set callback function */
12755714Skris
12855714Skris#define BIO_CTRL_SET_FILENAME	30	/* BIO_s_file special */
12955714Skris
130160814Ssimon/* dgram BIO stuff */
131160814Ssimon#define BIO_CTRL_DGRAM_CONNECT       31  /* BIO dgram special */
132160814Ssimon#define BIO_CTRL_DGRAM_SET_CONNECTED 32  /* allow for an externally
133194206Ssimon					  * connected socket to be
134194206Ssimon					  * passed in */
135160814Ssimon#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */
136160814Ssimon#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */
137160814Ssimon#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */
138160814Ssimon#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */
139160814Ssimon
140160814Ssimon#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */
141160814Ssimon#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */
142160814Ssimon
143160814Ssimon/* #ifdef IP_MTU_DISCOVER */
144160814Ssimon#define BIO_CTRL_DGRAM_MTU_DISCOVER       39 /* set DF bit on egress packets */
145160814Ssimon/* #endif */
146160814Ssimon
147160814Ssimon#define BIO_CTRL_DGRAM_QUERY_MTU          40 /* as kernel for current MTU */
148160814Ssimon#define BIO_CTRL_DGRAM_GET_MTU            41 /* get cached value for MTU */
149160814Ssimon#define BIO_CTRL_DGRAM_SET_MTU            42 /* set cached value for
150194206Ssimon					      * MTU. want to use this
151194206Ssimon					      * if asking the kernel
152194206Ssimon					      * fails */
153160814Ssimon
154160814Ssimon#define BIO_CTRL_DGRAM_MTU_EXCEEDED       43 /* check whether the MTU
155194206Ssimon					      * was exceed in the
156194206Ssimon					      * previous write
157194206Ssimon					      * operation */
158160814Ssimon
159205128Ssimon#define BIO_CTRL_DGRAM_GET_PEER           46
160160814Ssimon#define BIO_CTRL_DGRAM_SET_PEER           44 /* Destination for the data */
161160814Ssimon
162205128Ssimon#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45 /* Next DTLS handshake timeout to
163205128Ssimon											  * adjust socket timeouts */
164160814Ssimon
16555714Skris/* modifiers */
16655714Skris#define BIO_FP_READ		0x02
16755714Skris#define BIO_FP_WRITE		0x04
16855714Skris#define BIO_FP_APPEND		0x08
16955714Skris#define BIO_FP_TEXT		0x10
17055714Skris
17155714Skris#define BIO_FLAGS_READ		0x01
17255714Skris#define BIO_FLAGS_WRITE		0x02
17355714Skris#define BIO_FLAGS_IO_SPECIAL	0x04
17455714Skris#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
17555714Skris#define BIO_FLAGS_SHOULD_RETRY	0x08
176160814Ssimon#ifndef	BIO_FLAGS_UPLINK
177160814Ssimon/* "UPLINK" flag denotes file descriptors provided by application.
178160814Ssimon   It defaults to 0, as most platforms don't require UPLINK interface. */
179160814Ssimon#define	BIO_FLAGS_UPLINK	0
180160814Ssimon#endif
18155714Skris
18255714Skris/* Used in BIO_gethostbyname() */
18355714Skris#define BIO_GHBN_CTRL_HITS		1
18455714Skris#define BIO_GHBN_CTRL_MISSES		2
18555714Skris#define BIO_GHBN_CTRL_CACHE_SIZE	3
18655714Skris#define BIO_GHBN_CTRL_GET_ENTRY		4
18755714Skris#define BIO_GHBN_CTRL_FLUSH		5
18855714Skris
18955714Skris/* Mostly used in the SSL BIO */
19055714Skris/* Not used anymore
19155714Skris * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10
19255714Skris * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20
19355714Skris * #define BIO_FLAGS_PROTOCOL_STARTUP	0x40
19455714Skris */
19555714Skris
19655714Skris#define BIO_FLAGS_BASE64_NO_NL	0x100
19755714Skris
19859191Skris/* This is used with memory BIOs: it means we shouldn't free up or change the
19959191Skris * data in any way.
20059191Skris */
20159191Skris#define BIO_FLAGS_MEM_RDONLY	0x200
20259191Skris
203167612Ssimontypedef struct bio_st BIO;
204167612Ssimon
205167612Ssimonvoid BIO_set_flags(BIO *b, int flags);
206167612Ssimonint  BIO_test_flags(const BIO *b, int flags);
207167612Ssimonvoid BIO_clear_flags(BIO *b, int flags);
208167612Ssimon
209167612Ssimon#define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
21055714Skris#define BIO_set_retry_special(b) \
211167612Ssimon		BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
21255714Skris#define BIO_set_retry_read(b) \
213167612Ssimon		BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
21455714Skris#define BIO_set_retry_write(b) \
215167612Ssimon		BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
21655714Skris
21755714Skris/* These are normally used internally in BIOs */
21855714Skris#define BIO_clear_retry_flags(b) \
219167612Ssimon		BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
22055714Skris#define BIO_get_retry_flags(b) \
221167612Ssimon		BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
22255714Skris
22359191Skris/* These should be used by the application to tell why we should retry */
224167612Ssimon#define BIO_should_read(a)		BIO_test_flags(a, BIO_FLAGS_READ)
225167612Ssimon#define BIO_should_write(a)		BIO_test_flags(a, BIO_FLAGS_WRITE)
226167612Ssimon#define BIO_should_io_special(a)	BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
227167612Ssimon#define BIO_retry_type(a)		BIO_test_flags(a, BIO_FLAGS_RWS)
228167612Ssimon#define BIO_should_retry(a)		BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
22955714Skris
230109998Smarkm/* The next three are used in conjunction with the
23155714Skris * BIO_should_io_special() condition.  After this returns true,
23255714Skris * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
23355714Skris * stack and return the 'reason' for the special and the offending BIO.
23455714Skris * Given a BIO, BIO_get_retry_reason(bio) will return the code. */
23555714Skris/* Returned from the SSL bio when the certificate retrieval code had an error */
23655714Skris#define BIO_RR_SSL_X509_LOOKUP		0x01
23755714Skris/* Returned from the connect BIO when a connect would have blocked */
23855714Skris#define BIO_RR_CONNECT			0x02
239109998Smarkm/* Returned from the accept BIO when an accept would have blocked */
240109998Smarkm#define BIO_RR_ACCEPT			0x03
24155714Skris
24255714Skris/* These are passed by the BIO callback */
24355714Skris#define BIO_CB_FREE	0x01
24455714Skris#define BIO_CB_READ	0x02
24555714Skris#define BIO_CB_WRITE	0x03
24655714Skris#define BIO_CB_PUTS	0x04
24755714Skris#define BIO_CB_GETS	0x05
24855714Skris#define BIO_CB_CTRL	0x06
24955714Skris
25055714Skris/* The callback is called before and after the underling operation,
25155714Skris * The BIO_CB_RETURN flag indicates if it is after the call */
25255714Skris#define BIO_CB_RETURN	0x80
25355714Skris#define BIO_CB_return(a) ((a)|BIO_CB_RETURN))
25455714Skris#define BIO_cb_pre(a)	(!((a)&BIO_CB_RETURN))
25555714Skris#define BIO_cb_post(a)	((a)&BIO_CB_RETURN)
25655714Skris
257167612Ssimonlong (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long);
258167612Ssimonvoid BIO_set_callback(BIO *b,
259167612Ssimon	long (*callback)(struct bio_st *,int,const char *,int, long,long));
260167612Ssimonchar *BIO_get_callback_arg(const BIO *b);
261167612Ssimonvoid BIO_set_callback_arg(BIO *b, char *arg);
26255714Skris
263167612Ssimonconst char * BIO_method_name(const BIO *b);
264167612Ssimonint BIO_method_type(const BIO *b);
26568651Skris
26668651Skristypedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
26768651Skris
268109998Smarkm#ifndef OPENSSL_SYS_WIN16
26955714Skristypedef struct bio_method_st
27055714Skris	{
27155714Skris	int type;
27255714Skris	const char *name;
27368651Skris	int (*bwrite)(BIO *, const char *, int);
27468651Skris	int (*bread)(BIO *, char *, int);
27568651Skris	int (*bputs)(BIO *, const char *);
27668651Skris	int (*bgets)(BIO *, char *, int);
27768651Skris	long (*ctrl)(BIO *, int, long, void *);
27868651Skris	int (*create)(BIO *);
27968651Skris	int (*destroy)(BIO *);
28068651Skris        long (*callback_ctrl)(BIO *, int, bio_info_cb *);
28155714Skris	} BIO_METHOD;
28255714Skris#else
28355714Skristypedef struct bio_method_st
28455714Skris	{
28555714Skris	int type;
28655714Skris	const char *name;
28755714Skris	int (_far *bwrite)();
28855714Skris	int (_far *bread)();
28955714Skris	int (_far *bputs)();
29055714Skris	int (_far *bgets)();
29155714Skris	long (_far *ctrl)();
29255714Skris	int (_far *create)();
29355714Skris	int (_far *destroy)();
294111147Snectar	long (_far *callback_ctrl)();
29555714Skris	} BIO_METHOD;
29655714Skris#endif
29755714Skris
29868651Skrisstruct bio_st
29955714Skris	{
30055714Skris	BIO_METHOD *method;
30155714Skris	/* bio, mode, argp, argi, argl, ret */
30255714Skris	long (*callback)(struct bio_st *,int,const char *,int, long,long);
30355714Skris	char *cb_arg; /* first argument for the callback */
30455714Skris
30555714Skris	int init;
30655714Skris	int shutdown;
30755714Skris	int flags;	/* extra storage */
30855714Skris	int retry_reason;
30955714Skris	int num;
31055714Skris	void *ptr;
31155714Skris	struct bio_st *next_bio;	/* used by filter BIOs */
31255714Skris	struct bio_st *prev_bio;	/* used by filter BIOs */
31355714Skris	int references;
31455714Skris	unsigned long num_read;
31555714Skris	unsigned long num_write;
31655714Skris
31755714Skris	CRYPTO_EX_DATA ex_data;
31868651Skris	};
31955714Skris
32068651SkrisDECLARE_STACK_OF(BIO)
32168651Skris
32255714Skristypedef struct bio_f_buffer_ctx_struct
32355714Skris	{
32455714Skris	/* BIO *bio; */ /* this is now in the BIO struct */
32555714Skris	int ibuf_size;	/* how big is the input buffer */
32655714Skris	int obuf_size;	/* how big is the output buffer */
32755714Skris
32855714Skris	char *ibuf;		/* the char array */
32955714Skris	int ibuf_len;		/* how many bytes are in it */
33055714Skris	int ibuf_off;		/* write/read offset */
33155714Skris
33255714Skris	char *obuf;		/* the char array */
33355714Skris	int obuf_len;		/* how many bytes are in it */
33455714Skris	int obuf_off;		/* write/read offset */
33555714Skris	} BIO_F_BUFFER_CTX;
33655714Skris
33755714Skris/* connect BIO stuff */
33855714Skris#define BIO_CONN_S_BEFORE		1
33955714Skris#define BIO_CONN_S_GET_IP		2
34055714Skris#define BIO_CONN_S_GET_PORT		3
34155714Skris#define BIO_CONN_S_CREATE_SOCKET	4
34255714Skris#define BIO_CONN_S_CONNECT		5
34355714Skris#define BIO_CONN_S_OK			6
34455714Skris#define BIO_CONN_S_BLOCKED_CONNECT	7
34555714Skris#define BIO_CONN_S_NBIO			8
34655714Skris/*#define BIO_CONN_get_param_hostname	BIO_ctrl */
34755714Skris
34855714Skris#define BIO_C_SET_CONNECT			100
34955714Skris#define BIO_C_DO_STATE_MACHINE			101
35055714Skris#define BIO_C_SET_NBIO				102
35155714Skris#define BIO_C_SET_PROXY_PARAM			103
35255714Skris#define BIO_C_SET_FD				104
35355714Skris#define BIO_C_GET_FD				105
35455714Skris#define BIO_C_SET_FILE_PTR			106
35555714Skris#define BIO_C_GET_FILE_PTR			107
35655714Skris#define BIO_C_SET_FILENAME			108
35755714Skris#define BIO_C_SET_SSL				109
35855714Skris#define BIO_C_GET_SSL				110
35955714Skris#define BIO_C_SET_MD				111
36055714Skris#define BIO_C_GET_MD				112
36155714Skris#define BIO_C_GET_CIPHER_STATUS			113
36255714Skris#define BIO_C_SET_BUF_MEM			114
36355714Skris#define BIO_C_GET_BUF_MEM_PTR			115
36455714Skris#define BIO_C_GET_BUFF_NUM_LINES		116
36555714Skris#define BIO_C_SET_BUFF_SIZE			117
36655714Skris#define BIO_C_SET_ACCEPT			118
36755714Skris#define BIO_C_SSL_MODE				119
36855714Skris#define BIO_C_GET_MD_CTX			120
36955714Skris#define BIO_C_GET_PROXY_PARAM			121
37055714Skris#define BIO_C_SET_BUFF_READ_DATA		122 /* data to read first */
37155714Skris#define BIO_C_GET_CONNECT			123
37255714Skris#define BIO_C_GET_ACCEPT			124
37355714Skris#define BIO_C_SET_SSL_RENEGOTIATE_BYTES		125
37455714Skris#define BIO_C_GET_SSL_NUM_RENEGOTIATES		126
37555714Skris#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT	127
37655714Skris#define BIO_C_FILE_SEEK				128
37755714Skris#define BIO_C_GET_CIPHER_CTX			129
37855714Skris#define BIO_C_SET_BUF_MEM_EOF_RETURN		130/*return end of input value*/
37955714Skris#define BIO_C_SET_BIND_MODE			131
38055714Skris#define BIO_C_GET_BIND_MODE			132
38155714Skris#define BIO_C_FILE_TELL				133
38255714Skris#define BIO_C_GET_SOCKS				134
38355714Skris#define BIO_C_SET_SOCKS				135
38455714Skris
38555714Skris#define BIO_C_SET_WRITE_BUF_SIZE		136/* for BIO_s_bio */
38655714Skris#define BIO_C_GET_WRITE_BUF_SIZE		137
38755714Skris#define BIO_C_MAKE_BIO_PAIR			138
38855714Skris#define BIO_C_DESTROY_BIO_PAIR			139
38955714Skris#define BIO_C_GET_WRITE_GUARANTEE		140
39055714Skris#define BIO_C_GET_READ_REQUEST			141
39155714Skris#define BIO_C_SHUTDOWN_WR			142
39259191Skris#define BIO_C_NREAD0				143
39359191Skris#define BIO_C_NREAD				144
39459191Skris#define BIO_C_NWRITE0				145
39559191Skris#define BIO_C_NWRITE				146
39659191Skris#define BIO_C_RESET_READ_REQUEST		147
397167612Ssimon#define BIO_C_SET_MD_CTX			148
39855714Skris
39955714Skris
40059191Skris#define BIO_set_app_data(s,arg)		BIO_set_ex_data(s,0,arg)
40155714Skris#define BIO_get_app_data(s)		BIO_get_ex_data(s,0)
40255714Skris
40355714Skris/* BIO_s_connect() and BIO_s_socks4a_connect() */
40455714Skris#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
40555714Skris#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
40655714Skris#define BIO_set_conn_ip(b,ip)	  BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
40755714Skris#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
40855714Skris#define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
40955714Skris#define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
410100928Snectar#define BIO_get_conn_ip(b) 		 BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
411205128Ssimon#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0)
41255714Skris
41355714Skris
41455714Skris#define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
41555714Skris
41655714Skris/* BIO_s_accept_socket() */
41755714Skris#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
41855714Skris#define BIO_get_accept_port(b)	BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
41955714Skris/* #define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
420205128Ssimon#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL)
42155714Skris#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
42255714Skris
42355714Skris#define BIO_BIND_NORMAL			0
42455714Skris#define BIO_BIND_REUSEADDR_IF_UNUSED	1
42555714Skris#define BIO_BIND_REUSEADDR		2
42655714Skris#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
42755714Skris#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
42855714Skris
42955714Skris#define BIO_do_connect(b)	BIO_do_handshake(b)
43055714Skris#define BIO_do_accept(b)	BIO_do_handshake(b)
43155714Skris#define BIO_do_handshake(b)	BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
43255714Skris
43355714Skris/* BIO_s_proxy_client() */
43455714Skris#define BIO_set_url(b,url)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))
43555714Skris#define BIO_set_proxies(b,p)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))
43655714Skris/* BIO_set_nbio(b,n) */
43755714Skris#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
43855714Skris/* BIO *BIO_get_filter_bio(BIO *bio); */
43959191Skris#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
44055714Skris#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
44155714Skris#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
44255714Skris
44355714Skris#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)
44455714Skris#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))
44555714Skris#define BIO_get_url(b,url)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
44655714Skris#define BIO_get_no_connect_return(b)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)
44755714Skris
44855714Skris#define BIO_set_fd(b,fd,c)	BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
44955714Skris#define BIO_get_fd(b,c)		BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
45055714Skris
45155714Skris#define BIO_set_fp(b,fp,c)	BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
45255714Skris#define BIO_get_fp(b,fpp)	BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
45355714Skris
45455714Skris#define BIO_seek(b,ofs)	(int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
45555714Skris#define BIO_tell(b)	(int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
45655714Skris
45755714Skris/* name is cast to lose const, but might be better to route through a function
45855714Skris   so we can do it safely */
45955714Skris#ifdef CONST_STRICT
46055714Skris/* If you are wondering why this isn't defined, its because CONST_STRICT is
46155714Skris * purely a compile-time kludge to allow const to be checked.
46255714Skris */
46355714Skrisint BIO_read_filename(BIO *b,const char *name);
46455714Skris#else
46555714Skris#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
46655714Skris		BIO_CLOSE|BIO_FP_READ,(char *)name)
46755714Skris#endif
46855714Skris#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
46955714Skris		BIO_CLOSE|BIO_FP_WRITE,name)
47055714Skris#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
47155714Skris		BIO_CLOSE|BIO_FP_APPEND,name)
47255714Skris#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
47355714Skris		BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
47455714Skris
47555714Skris/* WARNING WARNING, this ups the reference count on the read bio of the
47655714Skris * SSL structure.  This is because the ssl read BIO is now pointed to by
47755714Skris * the next_bio field in the bio.  So when you free the BIO, make sure
47855714Skris * you are doing a BIO_free_all() to catch the underlying BIO. */
47955714Skris#define BIO_set_ssl(b,ssl,c)	BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
48055714Skris#define BIO_get_ssl(b,sslp)	BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
48155714Skris#define BIO_set_ssl_mode(b,client)	BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
48255714Skris#define BIO_set_ssl_renegotiate_bytes(b,num) \
48355714Skris	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
48455714Skris#define BIO_get_num_renegotiates(b) \
48589837Skris	BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
48655714Skris#define BIO_set_ssl_renegotiate_timeout(b,seconds) \
48755714Skris	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
48855714Skris
48955714Skris/* defined in evp.h */
49055714Skris/* #define BIO_set_md(b,md)	BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
49155714Skris
49255714Skris#define BIO_get_mem_data(b,pp)	BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
49355714Skris#define BIO_set_mem_buf(b,bm,c)	BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
49455714Skris#define BIO_get_mem_ptr(b,pp)	BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
49555714Skris#define BIO_set_mem_eof_return(b,v) \
49655714Skris				BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
49755714Skris
49855714Skris/* For the BIO_f_buffer() type */
49955714Skris#define BIO_get_buffer_num_lines(b)	BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
50055714Skris#define BIO_set_buffer_size(b,size)	BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
50155714Skris#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
50255714Skris#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
50355714Skris#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
50455714Skris
50555714Skris/* Don't use the next one unless you know what you are doing :-) */
50655714Skris#define BIO_dup_state(b,ret)	BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
50755714Skris
50855714Skris#define BIO_reset(b)		(int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
50955714Skris#define BIO_eof(b)		(int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
51055714Skris#define BIO_set_close(b,c)	(int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
51155714Skris#define BIO_get_close(b)	(int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
51255714Skris#define BIO_pending(b)		(int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
51355714Skris#define BIO_wpending(b)		(int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
51455714Skris/* ...pending macros have inappropriate return type */
51555714Skrissize_t BIO_ctrl_pending(BIO *b);
51655714Skrissize_t BIO_ctrl_wpending(BIO *b);
51755714Skris#define BIO_flush(b)		(int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
518109998Smarkm#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
519109998Smarkm						   cbp)
520109998Smarkm#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
52155714Skris
52255714Skris/* For the BIO_f_buffer() type */
52355714Skris#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
52455714Skris
52555714Skris/* For BIO_s_bio() */
52655714Skris#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
52755714Skris#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
52855714Skris#define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
52955714Skris#define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
53068651Skris#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
53155714Skris/* macros with inappropriate type -- but ...pending macros use int too: */
53255714Skris#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
53355714Skris#define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
53455714Skrissize_t BIO_ctrl_get_write_guarantee(BIO *b);
53555714Skrissize_t BIO_ctrl_get_read_request(BIO *b);
53659191Skrisint BIO_ctrl_reset_read_request(BIO *b);
53755714Skris
538160814Ssimon/* ctrl macros for dgram */
539160814Ssimon#define BIO_ctrl_dgram_connect(b,peer)  \
540160814Ssimon                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)
541160814Ssimon#define BIO_ctrl_set_connected(b, state, peer) \
542160814Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)
543160814Ssimon#define BIO_dgram_recv_timedout(b) \
544160814Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
545160814Ssimon#define BIO_dgram_send_timedout(b) \
546160814Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
547205128Ssimon#define BIO_dgram_get_peer(b,peer) \
548205128Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
549160814Ssimon#define BIO_dgram_set_peer(b,peer) \
550160814Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
551160814Ssimon
55255714Skris/* These two aren't currently implemented */
55355714Skris/* int BIO_get_ex_num(BIO *bio); */
55455714Skris/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
55559191Skrisint BIO_set_ex_data(BIO *bio,int idx,void *data);
55659191Skrisvoid *BIO_get_ex_data(BIO *bio,int idx);
55759191Skrisint BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
55859191Skris	CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
55959191Skrisunsigned long BIO_number_read(BIO *bio);
56059191Skrisunsigned long BIO_number_written(BIO *bio);
56155714Skris
562109998Smarkm# ifndef OPENSSL_NO_FP_API
563109998Smarkm#  if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL)
56455714SkrisBIO_METHOD *BIO_s_file_internal(void);
56555714SkrisBIO *BIO_new_file_internal(char *filename, char *mode);
56655714SkrisBIO *BIO_new_fp_internal(FILE *stream, int close_flag);
56755714Skris#    define BIO_s_file	BIO_s_file_internal
56855714Skris#    define BIO_new_file	BIO_new_file_internal
56955714Skris#    define BIO_new_fp	BIO_new_fp_internal
57055714Skris#  else /* FP_API */
57155714SkrisBIO_METHOD *BIO_s_file(void );
57255714SkrisBIO *BIO_new_file(const char *filename, const char *mode);
57355714SkrisBIO *BIO_new_fp(FILE *stream, int close_flag);
57455714Skris#    define BIO_s_file_internal		BIO_s_file
57555714Skris#    define BIO_new_file_internal	BIO_new_file
57655714Skris#    define BIO_new_fp_internal		BIO_s_file
57755714Skris#  endif /* FP_API */
57868651Skris# endif
57955714SkrisBIO *	BIO_new(BIO_METHOD *type);
58055714Skrisint	BIO_set(BIO *a,BIO_METHOD *type);
58155714Skrisint	BIO_free(BIO *a);
58268651Skrisvoid	BIO_vfree(BIO *a);
58355714Skrisint	BIO_read(BIO *b, void *data, int len);
58455714Skrisint	BIO_gets(BIO *bp,char *buf, int size);
58559191Skrisint	BIO_write(BIO *b, const void *data, int len);
58655714Skrisint	BIO_puts(BIO *bp,const char *buf);
587109998Smarkmint	BIO_indent(BIO *b,int indent,int max);
58855714Skrislong	BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
58968651Skrislong BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
59055714Skrischar *	BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
59155714Skrislong	BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
59255714SkrisBIO *	BIO_push(BIO *b,BIO *append);
59355714SkrisBIO *	BIO_pop(BIO *b);
59455714Skrisvoid	BIO_free_all(BIO *a);
59555714SkrisBIO *	BIO_find_type(BIO *b,int bio_type);
59668651SkrisBIO *	BIO_next(BIO *b);
59755714SkrisBIO *	BIO_get_retry_BIO(BIO *bio, int *reason);
59855714Skrisint	BIO_get_retry_reason(BIO *bio);
59955714SkrisBIO *	BIO_dup_chain(BIO *in);
60055714Skris
60159191Skrisint BIO_nread0(BIO *bio, char **buf);
60259191Skrisint BIO_nread(BIO *bio, char **buf, int num);
60359191Skrisint BIO_nwrite0(BIO *bio, char **buf);
60459191Skrisint BIO_nwrite(BIO *bio, char **buf, int num);
60559191Skris
606109998Smarkm#ifndef OPENSSL_SYS_WIN16
60755714Skrislong BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
60855714Skris	long argl,long ret);
60955714Skris#else
61055714Skrislong _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
61155714Skris	long argl,long ret);
61255714Skris#endif
61355714Skris
61455714SkrisBIO_METHOD *BIO_s_mem(void);
61559191SkrisBIO *BIO_new_mem_buf(void *buf, int len);
61655714SkrisBIO_METHOD *BIO_s_socket(void);
61755714SkrisBIO_METHOD *BIO_s_connect(void);
61855714SkrisBIO_METHOD *BIO_s_accept(void);
61955714SkrisBIO_METHOD *BIO_s_fd(void);
620109998Smarkm#ifndef OPENSSL_SYS_OS2
62155714SkrisBIO_METHOD *BIO_s_log(void);
622109998Smarkm#endif
62355714SkrisBIO_METHOD *BIO_s_bio(void);
62455714SkrisBIO_METHOD *BIO_s_null(void);
62555714SkrisBIO_METHOD *BIO_f_null(void);
62655714SkrisBIO_METHOD *BIO_f_buffer(void);
627109998Smarkm#ifdef OPENSSL_SYS_VMS
62868651SkrisBIO_METHOD *BIO_f_linebuffer(void);
62968651Skris#endif
63055714SkrisBIO_METHOD *BIO_f_nbio_test(void);
631160814Ssimon#ifndef OPENSSL_NO_DGRAM
632160814SsimonBIO_METHOD *BIO_s_datagram(void);
633160814Ssimon#endif
634160814Ssimon
63555714Skris/* BIO_METHOD *BIO_f_ber(void); */
63655714Skris
63755714Skrisint BIO_sock_should_retry(int i);
63855714Skrisint BIO_sock_non_fatal_error(int error);
639160814Ssimonint BIO_dgram_non_fatal_error(int error);
640160814Ssimon
64155714Skrisint BIO_fd_should_retry(int i);
64255714Skrisint BIO_fd_non_fatal_error(int error);
643160814Ssimonint BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u),
644160814Ssimon		void *u, const char *s, int len);
645160814Ssimonint BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
646160814Ssimon		       void *u, const char *s, int len, int indent);
64755714Skrisint BIO_dump(BIO *b,const char *bytes,int len);
64868651Skrisint BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
649160814Ssimon#ifndef OPENSSL_NO_FP_API
650160814Ssimonint BIO_dump_fp(FILE *fp, const char *s, int len);
651160814Ssimonint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
652160814Ssimon#endif
65355714Skrisstruct hostent *BIO_gethostbyname(const char *name);
65455714Skris/* We might want a thread-safe interface too:
65555714Skris * struct hostent *BIO_gethostbyname_r(const char *name,
65655714Skris *     struct hostent *result, void *buffer, size_t buflen);
65755714Skris * or something similar (caller allocates a struct hostent,
65855714Skris * pointed to by "result", and additional buffer space for the various
65955714Skris * substructures; if the buffer does not suffice, NULL is returned
66055714Skris * and an appropriate error code is set).
66155714Skris */
66255714Skrisint BIO_sock_error(int sock);
663111147Snectarint BIO_socket_ioctl(int fd, long type, void *arg);
66455714Skrisint BIO_socket_nbio(int fd,int mode);
66555714Skrisint BIO_get_port(const char *str, unsigned short *port_ptr);
66655714Skrisint BIO_get_host_ip(const char *str, unsigned char *ip);
66755714Skrisint BIO_get_accept_socket(char *host_port,int mode);
66855714Skrisint BIO_accept(int sock,char **ip_port);
66955714Skrisint BIO_sock_init(void );
67055714Skrisvoid BIO_sock_cleanup(void);
67155714Skrisint BIO_set_tcp_ndelay(int sock,int turn_on);
67255714Skris
67355714SkrisBIO *BIO_new_socket(int sock, int close_flag);
674160814SsimonBIO *BIO_new_dgram(int fd, int close_flag);
67555714SkrisBIO *BIO_new_fd(int fd, int close_flag);
67655714SkrisBIO *BIO_new_connect(char *host_port);
67755714SkrisBIO *BIO_new_accept(char *host_port);
67855714Skris
67955714Skrisint BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
68055714Skris	BIO **bio2, size_t writebuf2);
68155714Skris/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
68255714Skris * Otherwise returns 0 and sets *bio1 and *bio2 to NULL.
68355714Skris * Size 0 uses default value.
68455714Skris */
68555714Skris
68655714Skrisvoid BIO_copy_next_retry(BIO *b);
68755714Skris
688109998Smarkm/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
68955714Skris
690160814Ssimon#ifdef __GNUC__
691160814Ssimon#  define __bio_h__attr__ __attribute__
692160814Ssimon#else
693160814Ssimon#  define __bio_h__attr__(x)
694160814Ssimon#endif
695160814Ssimonint BIO_printf(BIO *bio, const char *format, ...)
696160814Ssimon	__bio_h__attr__((__format__(__printf__,2,3)));
697160814Ssimonint BIO_vprintf(BIO *bio, const char *format, va_list args)
698160814Ssimon	__bio_h__attr__((__format__(__printf__,2,0)));
699160814Ssimonint BIO_snprintf(char *buf, size_t n, const char *format, ...)
700160814Ssimon	__bio_h__attr__((__format__(__printf__,3,4)));
701160814Ssimonint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
702160814Ssimon	__bio_h__attr__((__format__(__printf__,3,0)));
703160814Ssimon#undef __bio_h__attr__
70455714Skris
70555714Skris/* BEGIN ERROR CODES */
70655714Skris/* The following lines are auto generated by the script mkerr.pl. Any changes
70755714Skris * made after this point may be overwritten when the script is next run.
70855714Skris */
70989837Skrisvoid ERR_load_BIO_strings(void);
71055714Skris
71155714Skris/* Error codes for the BIO functions. */
71255714Skris
71355714Skris/* Function codes. */
71455714Skris#define BIO_F_ACPT_STATE				 100
71555714Skris#define BIO_F_BIO_ACCEPT				 101
71655714Skris#define BIO_F_BIO_BER_GET_HEADER			 102
717160814Ssimon#define BIO_F_BIO_CALLBACK_CTRL				 131
71855714Skris#define BIO_F_BIO_CTRL					 103
71955714Skris#define BIO_F_BIO_GETHOSTBYNAME				 120
72055714Skris#define BIO_F_BIO_GETS					 104
72155714Skris#define BIO_F_BIO_GET_ACCEPT_SOCKET			 105
72255714Skris#define BIO_F_BIO_GET_HOST_IP				 106
72355714Skris#define BIO_F_BIO_GET_PORT				 107
72455714Skris#define BIO_F_BIO_MAKE_PAIR				 121
72555714Skris#define BIO_F_BIO_NEW					 108
72655714Skris#define BIO_F_BIO_NEW_FILE				 109
72759191Skris#define BIO_F_BIO_NEW_MEM_BUF				 126
72859191Skris#define BIO_F_BIO_NREAD					 123
72959191Skris#define BIO_F_BIO_NREAD0				 124
73059191Skris#define BIO_F_BIO_NWRITE				 125
73159191Skris#define BIO_F_BIO_NWRITE0				 122
73255714Skris#define BIO_F_BIO_PUTS					 110
73355714Skris#define BIO_F_BIO_READ					 111
73455714Skris#define BIO_F_BIO_SOCK_INIT				 112
73555714Skris#define BIO_F_BIO_WRITE					 113
73655714Skris#define BIO_F_BUFFER_CTRL				 114
73759191Skris#define BIO_F_CONN_CTRL					 127
73855714Skris#define BIO_F_CONN_STATE				 115
73955714Skris#define BIO_F_FILE_CTRL					 116
740109998Smarkm#define BIO_F_FILE_READ					 130
74168651Skris#define BIO_F_LINEBUFFER_CTRL				 129
74268651Skris#define BIO_F_MEM_READ					 128
74355714Skris#define BIO_F_MEM_WRITE					 117
74455714Skris#define BIO_F_SSL_NEW					 118
74555714Skris#define BIO_F_WSASTARTUP				 119
74655714Skris
74755714Skris/* Reason codes. */
74855714Skris#define BIO_R_ACCEPT_ERROR				 100
74955714Skris#define BIO_R_BAD_FOPEN_MODE				 101
75055714Skris#define BIO_R_BAD_HOSTNAME_LOOKUP			 102
75155714Skris#define BIO_R_BROKEN_PIPE				 124
75255714Skris#define BIO_R_CONNECT_ERROR				 103
75368651Skris#define BIO_R_EOF_ON_MEMORY_BIO				 127
75455714Skris#define BIO_R_ERROR_SETTING_NBIO			 104
75555714Skris#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET	 105
75655714Skris#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET	 106
75755714Skris#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET		 107
75855714Skris#define BIO_R_INVALID_ARGUMENT				 125
75955714Skris#define BIO_R_INVALID_IP_ADDRESS			 108
76055714Skris#define BIO_R_IN_USE					 123
76155714Skris#define BIO_R_KEEPALIVE					 109
76255714Skris#define BIO_R_NBIO_CONNECT_ERROR			 110
76355714Skris#define BIO_R_NO_ACCEPT_PORT_SPECIFIED			 111
76455714Skris#define BIO_R_NO_HOSTNAME_SPECIFIED			 112
76555714Skris#define BIO_R_NO_PORT_DEFINED				 113
76655714Skris#define BIO_R_NO_PORT_SPECIFIED				 114
767109998Smarkm#define BIO_R_NO_SUCH_FILE				 128
76855714Skris#define BIO_R_NULL_PARAMETER				 115
76955714Skris#define BIO_R_TAG_MISMATCH				 116
77055714Skris#define BIO_R_UNABLE_TO_BIND_SOCKET			 117
77155714Skris#define BIO_R_UNABLE_TO_CREATE_SOCKET			 118
77255714Skris#define BIO_R_UNABLE_TO_LISTEN_SOCKET			 119
77355714Skris#define BIO_R_UNINITIALIZED				 120
77455714Skris#define BIO_R_UNSUPPORTED_METHOD			 121
77559191Skris#define BIO_R_WRITE_TO_READ_ONLY_BIO			 126
77655714Skris#define BIO_R_WSASTARTUP				 122
77755714Skris
77855714Skris#ifdef  __cplusplus
77955714Skris}
78055714Skris#endif
78155714Skris#endif
782