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
71238405Sjkim#ifndef OPENSSL_NO_SCTP
72238405Sjkim# ifndef OPENSSL_SYS_VMS
73238405Sjkim# include <stdint.h>
74238405Sjkim# else
75238405Sjkim# include <inttypes.h>
76238405Sjkim# endif
77238405Sjkim#endif
78238405Sjkim
7955714Skris#ifdef  __cplusplus
8055714Skrisextern "C" {
8155714Skris#endif
8255714Skris
8355714Skris/* These are the 'types' of BIOs */
8455714Skris#define BIO_TYPE_NONE		0
8555714Skris#define BIO_TYPE_MEM		(1|0x0400)
8655714Skris#define BIO_TYPE_FILE		(2|0x0400)
8755714Skris
8855714Skris#define BIO_TYPE_FD		(4|0x0400|0x0100)
8955714Skris#define BIO_TYPE_SOCKET		(5|0x0400|0x0100)
9055714Skris#define BIO_TYPE_NULL		(6|0x0400)
9155714Skris#define BIO_TYPE_SSL		(7|0x0200)
9259191Skris#define BIO_TYPE_MD		(8|0x0200)		/* passive filter */
9355714Skris#define BIO_TYPE_BUFFER		(9|0x0200)		/* filter */
9455714Skris#define BIO_TYPE_CIPHER		(10|0x0200)		/* filter */
9555714Skris#define BIO_TYPE_BASE64		(11|0x0200)		/* filter */
9655714Skris#define BIO_TYPE_CONNECT	(12|0x0400|0x0100)	/* socket - connect */
9755714Skris#define BIO_TYPE_ACCEPT		(13|0x0400|0x0100)	/* socket for accept */
9855714Skris#define BIO_TYPE_PROXY_CLIENT	(14|0x0200)		/* client proxy BIO */
9955714Skris#define BIO_TYPE_PROXY_SERVER	(15|0x0200)		/* server proxy BIO */
10055714Skris#define BIO_TYPE_NBIO_TEST	(16|0x0200)		/* server proxy BIO */
10155714Skris#define BIO_TYPE_NULL_FILTER	(17|0x0200)
10255714Skris#define BIO_TYPE_BER		(18|0x0200)		/* BER -> bin filter */
10355714Skris#define BIO_TYPE_BIO		(19|0x0400)		/* (half a) BIO pair */
10468651Skris#define BIO_TYPE_LINEBUFFER	(20|0x0200)		/* filter */
105160814Ssimon#define BIO_TYPE_DGRAM		(21|0x0400|0x0100)
106238405Sjkim#ifndef OPENSSL_NO_SCTP
107238405Sjkim#define BIO_TYPE_DGRAM_SCTP	(24|0x0400|0x0100)
108238405Sjkim#endif
109238405Sjkim#define BIO_TYPE_ASN1 		(22|0x0200)		/* filter */
110194206Ssimon#define BIO_TYPE_COMP 		(23|0x0200)		/* filter */
11155714Skris
11255714Skris#define BIO_TYPE_DESCRIPTOR	0x0100	/* socket, fd, connect or accept */
11355714Skris#define BIO_TYPE_FILTER		0x0200
11455714Skris#define BIO_TYPE_SOURCE_SINK	0x0400
11555714Skris
11655714Skris/* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
11755714Skris * BIO_set_fp(in,stdin,BIO_NOCLOSE); */
11855714Skris#define BIO_NOCLOSE		0x00
11955714Skris#define BIO_CLOSE		0x01
12055714Skris
12155714Skris/* These are used in the following macros and are passed to
12255714Skris * BIO_ctrl() */
12355714Skris#define BIO_CTRL_RESET		1  /* opt - rewind/zero etc */
12455714Skris#define BIO_CTRL_EOF		2  /* opt - are we at the eof */
12555714Skris#define BIO_CTRL_INFO		3  /* opt - extra tit-bits */
12655714Skris#define BIO_CTRL_SET		4  /* man - set the 'IO' type */
12755714Skris#define BIO_CTRL_GET		5  /* man - get the 'IO' type */
12855714Skris#define BIO_CTRL_PUSH		6  /* opt - internal, used to signify change */
12955714Skris#define BIO_CTRL_POP		7  /* opt - internal, used to signify change */
13055714Skris#define BIO_CTRL_GET_CLOSE	8  /* man - set the 'close' on free */
13155714Skris#define BIO_CTRL_SET_CLOSE	9  /* man - set the 'close' on free */
13255714Skris#define BIO_CTRL_PENDING	10  /* opt - is their more data buffered */
13355714Skris#define BIO_CTRL_FLUSH		11  /* opt - 'flush' buffered output */
13455714Skris#define BIO_CTRL_DUP		12  /* man - extra stuff for 'duped' BIO */
13555714Skris#define BIO_CTRL_WPENDING	13  /* opt - number of bytes still to write */
13655714Skris/* callback is int cb(BIO *bio,state,ret); */
13755714Skris#define BIO_CTRL_SET_CALLBACK	14  /* opt - set callback function */
13855714Skris#define BIO_CTRL_GET_CALLBACK	15  /* opt - set callback function */
13955714Skris
14055714Skris#define BIO_CTRL_SET_FILENAME	30	/* BIO_s_file special */
14155714Skris
142160814Ssimon/* dgram BIO stuff */
143160814Ssimon#define BIO_CTRL_DGRAM_CONNECT       31  /* BIO dgram special */
144160814Ssimon#define BIO_CTRL_DGRAM_SET_CONNECTED 32  /* allow for an externally
145194206Ssimon					  * connected socket to be
146194206Ssimon					  * passed in */
147160814Ssimon#define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */
148160814Ssimon#define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */
149160814Ssimon#define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */
150160814Ssimon#define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */
151160814Ssimon
152160814Ssimon#define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */
153160814Ssimon#define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */
154160814Ssimon
155160814Ssimon/* #ifdef IP_MTU_DISCOVER */
156160814Ssimon#define BIO_CTRL_DGRAM_MTU_DISCOVER       39 /* set DF bit on egress packets */
157160814Ssimon/* #endif */
158160814Ssimon
159160814Ssimon#define BIO_CTRL_DGRAM_QUERY_MTU          40 /* as kernel for current MTU */
160237657Sjkim#define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47
161160814Ssimon#define BIO_CTRL_DGRAM_GET_MTU            41 /* get cached value for MTU */
162160814Ssimon#define BIO_CTRL_DGRAM_SET_MTU            42 /* set cached value for
163194206Ssimon					      * MTU. want to use this
164194206Ssimon					      * if asking the kernel
165194206Ssimon					      * fails */
166160814Ssimon
167160814Ssimon#define BIO_CTRL_DGRAM_MTU_EXCEEDED       43 /* check whether the MTU
168194206Ssimon					      * was exceed in the
169194206Ssimon					      * previous write
170194206Ssimon					      * operation */
171160814Ssimon
172205128Ssimon#define BIO_CTRL_DGRAM_GET_PEER           46
173160814Ssimon#define BIO_CTRL_DGRAM_SET_PEER           44 /* Destination for the data */
174160814Ssimon
175205128Ssimon#define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45 /* Next DTLS handshake timeout to
176238405Sjkim                                              * adjust socket timeouts */
177160814Ssimon
178279264Sdelphij#define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49
179279264Sdelphij
180238405Sjkim#ifndef OPENSSL_NO_SCTP
181238405Sjkim/* SCTP stuff */
182238405Sjkim#define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE	50
183238405Sjkim#define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY		51
184238405Sjkim#define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY		52
185238405Sjkim#define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD		53
186238405Sjkim#define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO		60
187238405Sjkim#define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO		61
188238405Sjkim#define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO		62
189238405Sjkim#define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO		63
190238405Sjkim#define BIO_CTRL_DGRAM_SCTP_GET_PRINFO			64
191238405Sjkim#define BIO_CTRL_DGRAM_SCTP_SET_PRINFO			65
192238405Sjkim#define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN		70
193238405Sjkim#endif
194238405Sjkim
19555714Skris/* modifiers */
19655714Skris#define BIO_FP_READ		0x02
19755714Skris#define BIO_FP_WRITE		0x04
19855714Skris#define BIO_FP_APPEND		0x08
19955714Skris#define BIO_FP_TEXT		0x10
20055714Skris
20155714Skris#define BIO_FLAGS_READ		0x01
20255714Skris#define BIO_FLAGS_WRITE		0x02
20355714Skris#define BIO_FLAGS_IO_SPECIAL	0x04
20455714Skris#define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
20555714Skris#define BIO_FLAGS_SHOULD_RETRY	0x08
206160814Ssimon#ifndef	BIO_FLAGS_UPLINK
207160814Ssimon/* "UPLINK" flag denotes file descriptors provided by application.
208160814Ssimon   It defaults to 0, as most platforms don't require UPLINK interface. */
209160814Ssimon#define	BIO_FLAGS_UPLINK	0
210160814Ssimon#endif
21155714Skris
21255714Skris/* Used in BIO_gethostbyname() */
21355714Skris#define BIO_GHBN_CTRL_HITS		1
21455714Skris#define BIO_GHBN_CTRL_MISSES		2
21555714Skris#define BIO_GHBN_CTRL_CACHE_SIZE	3
21655714Skris#define BIO_GHBN_CTRL_GET_ENTRY		4
21755714Skris#define BIO_GHBN_CTRL_FLUSH		5
21855714Skris
21955714Skris/* Mostly used in the SSL BIO */
22055714Skris/* Not used anymore
22155714Skris * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10
22255714Skris * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20
22355714Skris * #define BIO_FLAGS_PROTOCOL_STARTUP	0x40
22455714Skris */
22555714Skris
22655714Skris#define BIO_FLAGS_BASE64_NO_NL	0x100
22755714Skris
22859191Skris/* This is used with memory BIOs: it means we shouldn't free up or change the
22959191Skris * data in any way.
23059191Skris */
23159191Skris#define BIO_FLAGS_MEM_RDONLY	0x200
23259191Skris
233167612Ssimontypedef struct bio_st BIO;
234167612Ssimon
235167612Ssimonvoid BIO_set_flags(BIO *b, int flags);
236167612Ssimonint  BIO_test_flags(const BIO *b, int flags);
237167612Ssimonvoid BIO_clear_flags(BIO *b, int flags);
238167612Ssimon
239167612Ssimon#define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))
24055714Skris#define BIO_set_retry_special(b) \
241167612Ssimon		BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
24255714Skris#define BIO_set_retry_read(b) \
243167612Ssimon		BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
24455714Skris#define BIO_set_retry_write(b) \
245167612Ssimon		BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
24655714Skris
24755714Skris/* These are normally used internally in BIOs */
24855714Skris#define BIO_clear_retry_flags(b) \
249167612Ssimon		BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
25055714Skris#define BIO_get_retry_flags(b) \
251167612Ssimon		BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
25255714Skris
25359191Skris/* These should be used by the application to tell why we should retry */
254167612Ssimon#define BIO_should_read(a)		BIO_test_flags(a, BIO_FLAGS_READ)
255167612Ssimon#define BIO_should_write(a)		BIO_test_flags(a, BIO_FLAGS_WRITE)
256167612Ssimon#define BIO_should_io_special(a)	BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)
257167612Ssimon#define BIO_retry_type(a)		BIO_test_flags(a, BIO_FLAGS_RWS)
258167612Ssimon#define BIO_should_retry(a)		BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)
25955714Skris
260109998Smarkm/* The next three are used in conjunction with the
26155714Skris * BIO_should_io_special() condition.  After this returns true,
26255714Skris * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
26355714Skris * stack and return the 'reason' for the special and the offending BIO.
26455714Skris * Given a BIO, BIO_get_retry_reason(bio) will return the code. */
26555714Skris/* Returned from the SSL bio when the certificate retrieval code had an error */
26655714Skris#define BIO_RR_SSL_X509_LOOKUP		0x01
26755714Skris/* Returned from the connect BIO when a connect would have blocked */
26855714Skris#define BIO_RR_CONNECT			0x02
269109998Smarkm/* Returned from the accept BIO when an accept would have blocked */
270109998Smarkm#define BIO_RR_ACCEPT			0x03
27155714Skris
27255714Skris/* These are passed by the BIO callback */
27355714Skris#define BIO_CB_FREE	0x01
27455714Skris#define BIO_CB_READ	0x02
27555714Skris#define BIO_CB_WRITE	0x03
27655714Skris#define BIO_CB_PUTS	0x04
27755714Skris#define BIO_CB_GETS	0x05
27855714Skris#define BIO_CB_CTRL	0x06
27955714Skris
28055714Skris/* The callback is called before and after the underling operation,
28155714Skris * The BIO_CB_RETURN flag indicates if it is after the call */
28255714Skris#define BIO_CB_RETURN	0x80
28355714Skris#define BIO_CB_return(a) ((a)|BIO_CB_RETURN))
28455714Skris#define BIO_cb_pre(a)	(!((a)&BIO_CB_RETURN))
28555714Skris#define BIO_cb_post(a)	((a)&BIO_CB_RETURN)
28655714Skris
287167612Ssimonlong (*BIO_get_callback(const BIO *b)) (struct bio_st *,int,const char *,int, long,long);
288167612Ssimonvoid BIO_set_callback(BIO *b,
289167612Ssimon	long (*callback)(struct bio_st *,int,const char *,int, long,long));
290167612Ssimonchar *BIO_get_callback_arg(const BIO *b);
291167612Ssimonvoid BIO_set_callback_arg(BIO *b, char *arg);
29255714Skris
293167612Ssimonconst char * BIO_method_name(const BIO *b);
294167612Ssimonint BIO_method_type(const BIO *b);
29568651Skris
29668651Skristypedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
29768651Skris
29855714Skristypedef struct bio_method_st
29955714Skris	{
30055714Skris	int type;
30155714Skris	const char *name;
30268651Skris	int (*bwrite)(BIO *, const char *, int);
30368651Skris	int (*bread)(BIO *, char *, int);
30468651Skris	int (*bputs)(BIO *, const char *);
30568651Skris	int (*bgets)(BIO *, char *, int);
30668651Skris	long (*ctrl)(BIO *, int, long, void *);
30768651Skris	int (*create)(BIO *);
30868651Skris	int (*destroy)(BIO *);
30968651Skris        long (*callback_ctrl)(BIO *, int, bio_info_cb *);
31055714Skris	} BIO_METHOD;
31155714Skris
31268651Skrisstruct bio_st
31355714Skris	{
31455714Skris	BIO_METHOD *method;
31555714Skris	/* bio, mode, argp, argi, argl, ret */
31655714Skris	long (*callback)(struct bio_st *,int,const char *,int, long,long);
31755714Skris	char *cb_arg; /* first argument for the callback */
31855714Skris
31955714Skris	int init;
32055714Skris	int shutdown;
32155714Skris	int flags;	/* extra storage */
32255714Skris	int retry_reason;
32355714Skris	int num;
32455714Skris	void *ptr;
32555714Skris	struct bio_st *next_bio;	/* used by filter BIOs */
32655714Skris	struct bio_st *prev_bio;	/* used by filter BIOs */
32755714Skris	int references;
32855714Skris	unsigned long num_read;
32955714Skris	unsigned long num_write;
33055714Skris
33155714Skris	CRYPTO_EX_DATA ex_data;
33268651Skris	};
33355714Skris
33468651SkrisDECLARE_STACK_OF(BIO)
33568651Skris
33655714Skristypedef struct bio_f_buffer_ctx_struct
33755714Skris	{
338237657Sjkim	/* Buffers are setup like this:
339237657Sjkim	 *
340237657Sjkim	 * <---------------------- size ----------------------->
341237657Sjkim	 * +---------------------------------------------------+
342237657Sjkim	 * | consumed | remaining          | free space        |
343237657Sjkim	 * +---------------------------------------------------+
344237657Sjkim	 * <-- off --><------- len ------->
345237657Sjkim	 */
346237657Sjkim
34755714Skris	/* BIO *bio; */ /* this is now in the BIO struct */
34855714Skris	int ibuf_size;	/* how big is the input buffer */
34955714Skris	int obuf_size;	/* how big is the output buffer */
35055714Skris
35155714Skris	char *ibuf;		/* the char array */
35255714Skris	int ibuf_len;		/* how many bytes are in it */
35355714Skris	int ibuf_off;		/* write/read offset */
35455714Skris
35555714Skris	char *obuf;		/* the char array */
35655714Skris	int obuf_len;		/* how many bytes are in it */
35755714Skris	int obuf_off;		/* write/read offset */
35855714Skris	} BIO_F_BUFFER_CTX;
35955714Skris
360238405Sjkim/* Prefix and suffix callback in ASN1 BIO */
361238405Sjkimtypedef int asn1_ps_func(BIO *b, unsigned char **pbuf, int *plen, void *parg);
362238405Sjkim
363238405Sjkim#ifndef OPENSSL_NO_SCTP
364238405Sjkim/* SCTP parameter structs */
365238405Sjkimstruct bio_dgram_sctp_sndinfo
366238405Sjkim	{
367238405Sjkim	uint16_t snd_sid;
368238405Sjkim	uint16_t snd_flags;
369238405Sjkim	uint32_t snd_ppid;
370238405Sjkim	uint32_t snd_context;
371238405Sjkim	};
372238405Sjkim
373238405Sjkimstruct bio_dgram_sctp_rcvinfo
374238405Sjkim	{
375238405Sjkim	uint16_t rcv_sid;
376238405Sjkim	uint16_t rcv_ssn;
377238405Sjkim	uint16_t rcv_flags;
378238405Sjkim	uint32_t rcv_ppid;
379238405Sjkim	uint32_t rcv_tsn;
380238405Sjkim	uint32_t rcv_cumtsn;
381238405Sjkim	uint32_t rcv_context;
382238405Sjkim	};
383238405Sjkim
384238405Sjkimstruct bio_dgram_sctp_prinfo
385238405Sjkim	{
386238405Sjkim	uint16_t pr_policy;
387238405Sjkim	uint32_t pr_value;
388238405Sjkim	};
389238405Sjkim#endif
390238405Sjkim
39155714Skris/* connect BIO stuff */
39255714Skris#define BIO_CONN_S_BEFORE		1
39355714Skris#define BIO_CONN_S_GET_IP		2
39455714Skris#define BIO_CONN_S_GET_PORT		3
39555714Skris#define BIO_CONN_S_CREATE_SOCKET	4
39655714Skris#define BIO_CONN_S_CONNECT		5
39755714Skris#define BIO_CONN_S_OK			6
39855714Skris#define BIO_CONN_S_BLOCKED_CONNECT	7
39955714Skris#define BIO_CONN_S_NBIO			8
40055714Skris/*#define BIO_CONN_get_param_hostname	BIO_ctrl */
40155714Skris
40255714Skris#define BIO_C_SET_CONNECT			100
40355714Skris#define BIO_C_DO_STATE_MACHINE			101
40455714Skris#define BIO_C_SET_NBIO				102
40555714Skris#define BIO_C_SET_PROXY_PARAM			103
40655714Skris#define BIO_C_SET_FD				104
40755714Skris#define BIO_C_GET_FD				105
40855714Skris#define BIO_C_SET_FILE_PTR			106
40955714Skris#define BIO_C_GET_FILE_PTR			107
41055714Skris#define BIO_C_SET_FILENAME			108
41155714Skris#define BIO_C_SET_SSL				109
41255714Skris#define BIO_C_GET_SSL				110
41355714Skris#define BIO_C_SET_MD				111
41455714Skris#define BIO_C_GET_MD				112
41555714Skris#define BIO_C_GET_CIPHER_STATUS			113
41655714Skris#define BIO_C_SET_BUF_MEM			114
41755714Skris#define BIO_C_GET_BUF_MEM_PTR			115
41855714Skris#define BIO_C_GET_BUFF_NUM_LINES		116
41955714Skris#define BIO_C_SET_BUFF_SIZE			117
42055714Skris#define BIO_C_SET_ACCEPT			118
42155714Skris#define BIO_C_SSL_MODE				119
42255714Skris#define BIO_C_GET_MD_CTX			120
42355714Skris#define BIO_C_GET_PROXY_PARAM			121
42455714Skris#define BIO_C_SET_BUFF_READ_DATA		122 /* data to read first */
42555714Skris#define BIO_C_GET_CONNECT			123
42655714Skris#define BIO_C_GET_ACCEPT			124
42755714Skris#define BIO_C_SET_SSL_RENEGOTIATE_BYTES		125
42855714Skris#define BIO_C_GET_SSL_NUM_RENEGOTIATES		126
42955714Skris#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT	127
43055714Skris#define BIO_C_FILE_SEEK				128
43155714Skris#define BIO_C_GET_CIPHER_CTX			129
43255714Skris#define BIO_C_SET_BUF_MEM_EOF_RETURN		130/*return end of input value*/
43355714Skris#define BIO_C_SET_BIND_MODE			131
43455714Skris#define BIO_C_GET_BIND_MODE			132
43555714Skris#define BIO_C_FILE_TELL				133
43655714Skris#define BIO_C_GET_SOCKS				134
43755714Skris#define BIO_C_SET_SOCKS				135
43855714Skris
43955714Skris#define BIO_C_SET_WRITE_BUF_SIZE		136/* for BIO_s_bio */
44055714Skris#define BIO_C_GET_WRITE_BUF_SIZE		137
44155714Skris#define BIO_C_MAKE_BIO_PAIR			138
44255714Skris#define BIO_C_DESTROY_BIO_PAIR			139
44355714Skris#define BIO_C_GET_WRITE_GUARANTEE		140
44455714Skris#define BIO_C_GET_READ_REQUEST			141
44555714Skris#define BIO_C_SHUTDOWN_WR			142
44659191Skris#define BIO_C_NREAD0				143
44759191Skris#define BIO_C_NREAD				144
44859191Skris#define BIO_C_NWRITE0				145
44959191Skris#define BIO_C_NWRITE				146
45059191Skris#define BIO_C_RESET_READ_REQUEST		147
451167612Ssimon#define BIO_C_SET_MD_CTX			148
45255714Skris
453238405Sjkim#define BIO_C_SET_PREFIX			149
454238405Sjkim#define BIO_C_GET_PREFIX			150
455238405Sjkim#define BIO_C_SET_SUFFIX			151
456238405Sjkim#define BIO_C_GET_SUFFIX			152
45755714Skris
458238405Sjkim#define BIO_C_SET_EX_ARG			153
459238405Sjkim#define BIO_C_GET_EX_ARG			154
460238405Sjkim
46159191Skris#define BIO_set_app_data(s,arg)		BIO_set_ex_data(s,0,arg)
46255714Skris#define BIO_get_app_data(s)		BIO_get_ex_data(s,0)
46355714Skris
46455714Skris/* BIO_s_connect() and BIO_s_socks4a_connect() */
46555714Skris#define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
46655714Skris#define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
46755714Skris#define BIO_set_conn_ip(b,ip)	  BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
46855714Skris#define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
46955714Skris#define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
47055714Skris#define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
471100928Snectar#define BIO_get_conn_ip(b) 		 BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
472205128Ssimon#define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0)
47355714Skris
47455714Skris
47555714Skris#define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
47655714Skris
47755714Skris/* BIO_s_accept_socket() */
47855714Skris#define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
47955714Skris#define BIO_get_accept_port(b)	BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
48055714Skris/* #define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
481205128Ssimon#define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL)
48255714Skris#define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
48355714Skris
48455714Skris#define BIO_BIND_NORMAL			0
48555714Skris#define BIO_BIND_REUSEADDR_IF_UNUSED	1
48655714Skris#define BIO_BIND_REUSEADDR		2
48755714Skris#define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
48855714Skris#define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
48955714Skris
49055714Skris#define BIO_do_connect(b)	BIO_do_handshake(b)
49155714Skris#define BIO_do_accept(b)	BIO_do_handshake(b)
49255714Skris#define BIO_do_handshake(b)	BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
49355714Skris
49455714Skris/* BIO_s_proxy_client() */
49555714Skris#define BIO_set_url(b,url)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))
49655714Skris#define BIO_set_proxies(b,p)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))
49755714Skris/* BIO_set_nbio(b,n) */
49855714Skris#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
49955714Skris/* BIO *BIO_get_filter_bio(BIO *bio); */
50059191Skris#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
50155714Skris#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
50255714Skris#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
50355714Skris
50455714Skris#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)
50555714Skris#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))
50655714Skris#define BIO_get_url(b,url)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
50755714Skris#define BIO_get_no_connect_return(b)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)
50855714Skris
50955714Skris#define BIO_set_fd(b,fd,c)	BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
51055714Skris#define BIO_get_fd(b,c)		BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
51155714Skris
51255714Skris#define BIO_set_fp(b,fp,c)	BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
51355714Skris#define BIO_get_fp(b,fpp)	BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
51455714Skris
51555714Skris#define BIO_seek(b,ofs)	(int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
51655714Skris#define BIO_tell(b)	(int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
51755714Skris
51855714Skris/* name is cast to lose const, but might be better to route through a function
51955714Skris   so we can do it safely */
52055714Skris#ifdef CONST_STRICT
52155714Skris/* If you are wondering why this isn't defined, its because CONST_STRICT is
52255714Skris * purely a compile-time kludge to allow const to be checked.
52355714Skris */
52455714Skrisint BIO_read_filename(BIO *b,const char *name);
52555714Skris#else
52655714Skris#define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
52755714Skris		BIO_CLOSE|BIO_FP_READ,(char *)name)
52855714Skris#endif
52955714Skris#define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
53055714Skris		BIO_CLOSE|BIO_FP_WRITE,name)
53155714Skris#define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
53255714Skris		BIO_CLOSE|BIO_FP_APPEND,name)
53355714Skris#define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
53455714Skris		BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
53555714Skris
53655714Skris/* WARNING WARNING, this ups the reference count on the read bio of the
53755714Skris * SSL structure.  This is because the ssl read BIO is now pointed to by
53855714Skris * the next_bio field in the bio.  So when you free the BIO, make sure
53955714Skris * you are doing a BIO_free_all() to catch the underlying BIO. */
54055714Skris#define BIO_set_ssl(b,ssl,c)	BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
54155714Skris#define BIO_get_ssl(b,sslp)	BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
54255714Skris#define BIO_set_ssl_mode(b,client)	BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
54355714Skris#define BIO_set_ssl_renegotiate_bytes(b,num) \
54455714Skris	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
54555714Skris#define BIO_get_num_renegotiates(b) \
54689837Skris	BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
54755714Skris#define BIO_set_ssl_renegotiate_timeout(b,seconds) \
54855714Skris	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
54955714Skris
55055714Skris/* defined in evp.h */
55155714Skris/* #define BIO_set_md(b,md)	BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
55255714Skris
55355714Skris#define BIO_get_mem_data(b,pp)	BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
55455714Skris#define BIO_set_mem_buf(b,bm,c)	BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
55555714Skris#define BIO_get_mem_ptr(b,pp)	BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
55655714Skris#define BIO_set_mem_eof_return(b,v) \
55755714Skris				BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
55855714Skris
55955714Skris/* For the BIO_f_buffer() type */
56055714Skris#define BIO_get_buffer_num_lines(b)	BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
56155714Skris#define BIO_set_buffer_size(b,size)	BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
56255714Skris#define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
56355714Skris#define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
56455714Skris#define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
56555714Skris
56655714Skris/* Don't use the next one unless you know what you are doing :-) */
56755714Skris#define BIO_dup_state(b,ret)	BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
56855714Skris
56955714Skris#define BIO_reset(b)		(int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
57055714Skris#define BIO_eof(b)		(int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
57155714Skris#define BIO_set_close(b,c)	(int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
57255714Skris#define BIO_get_close(b)	(int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
57355714Skris#define BIO_pending(b)		(int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
57455714Skris#define BIO_wpending(b)		(int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
57555714Skris/* ...pending macros have inappropriate return type */
57655714Skrissize_t BIO_ctrl_pending(BIO *b);
57755714Skrissize_t BIO_ctrl_wpending(BIO *b);
57855714Skris#define BIO_flush(b)		(int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
579109998Smarkm#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
580109998Smarkm						   cbp)
581109998Smarkm#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
58255714Skris
58355714Skris/* For the BIO_f_buffer() type */
58455714Skris#define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
58555714Skris
58655714Skris/* For BIO_s_bio() */
58755714Skris#define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
58855714Skris#define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
58955714Skris#define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
59055714Skris#define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
59168651Skris#define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
59255714Skris/* macros with inappropriate type -- but ...pending macros use int too: */
59355714Skris#define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
59455714Skris#define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
59555714Skrissize_t BIO_ctrl_get_write_guarantee(BIO *b);
59655714Skrissize_t BIO_ctrl_get_read_request(BIO *b);
59759191Skrisint BIO_ctrl_reset_read_request(BIO *b);
59855714Skris
599160814Ssimon/* ctrl macros for dgram */
600160814Ssimon#define BIO_ctrl_dgram_connect(b,peer)  \
601160814Ssimon                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)
602160814Ssimon#define BIO_ctrl_set_connected(b, state, peer) \
603160814Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)
604160814Ssimon#define BIO_dgram_recv_timedout(b) \
605160814Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
606160814Ssimon#define BIO_dgram_send_timedout(b) \
607160814Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
608205128Ssimon#define BIO_dgram_get_peer(b,peer) \
609205128Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
610160814Ssimon#define BIO_dgram_set_peer(b,peer) \
611160814Ssimon         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
612279264Sdelphij#define BIO_dgram_get_mtu_overhead(b) \
613279264Sdelphij         (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
614160814Ssimon
61555714Skris/* These two aren't currently implemented */
61655714Skris/* int BIO_get_ex_num(BIO *bio); */
61755714Skris/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
61859191Skrisint BIO_set_ex_data(BIO *bio,int idx,void *data);
61959191Skrisvoid *BIO_get_ex_data(BIO *bio,int idx);
62059191Skrisint BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
62159191Skris	CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
62259191Skrisunsigned long BIO_number_read(BIO *bio);
62359191Skrisunsigned long BIO_number_written(BIO *bio);
62455714Skris
625238405Sjkim/* For BIO_f_asn1() */
626238405Sjkimint BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,
627238405Sjkim					asn1_ps_func *prefix_free);
628238405Sjkimint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,
629238405Sjkim					asn1_ps_func **pprefix_free);
630238405Sjkimint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,
631238405Sjkim					asn1_ps_func *suffix_free);
632238405Sjkimint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
633238405Sjkim					asn1_ps_func **psuffix_free);
634238405Sjkim
635109998Smarkm# ifndef OPENSSL_NO_FP_API
63655714SkrisBIO_METHOD *BIO_s_file(void );
63755714SkrisBIO *BIO_new_file(const char *filename, const char *mode);
63855714SkrisBIO *BIO_new_fp(FILE *stream, int close_flag);
639238405Sjkim# define BIO_s_file_internal	BIO_s_file
64068651Skris# endif
64155714SkrisBIO *	BIO_new(BIO_METHOD *type);
64255714Skrisint	BIO_set(BIO *a,BIO_METHOD *type);
64355714Skrisint	BIO_free(BIO *a);
64468651Skrisvoid	BIO_vfree(BIO *a);
64555714Skrisint	BIO_read(BIO *b, void *data, int len);
64655714Skrisint	BIO_gets(BIO *bp,char *buf, int size);
64759191Skrisint	BIO_write(BIO *b, const void *data, int len);
64855714Skrisint	BIO_puts(BIO *bp,const char *buf);
649109998Smarkmint	BIO_indent(BIO *b,int indent,int max);
65055714Skrislong	BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
65168651Skrislong BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
65255714Skrischar *	BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
65355714Skrislong	BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
65455714SkrisBIO *	BIO_push(BIO *b,BIO *append);
65555714SkrisBIO *	BIO_pop(BIO *b);
65655714Skrisvoid	BIO_free_all(BIO *a);
65755714SkrisBIO *	BIO_find_type(BIO *b,int bio_type);
65868651SkrisBIO *	BIO_next(BIO *b);
65955714SkrisBIO *	BIO_get_retry_BIO(BIO *bio, int *reason);
66055714Skrisint	BIO_get_retry_reason(BIO *bio);
66155714SkrisBIO *	BIO_dup_chain(BIO *in);
66255714Skris
66359191Skrisint BIO_nread0(BIO *bio, char **buf);
66459191Skrisint BIO_nread(BIO *bio, char **buf, int num);
66559191Skrisint BIO_nwrite0(BIO *bio, char **buf);
66659191Skrisint BIO_nwrite(BIO *bio, char **buf, int num);
66759191Skris
66855714Skrislong BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
66955714Skris	long argl,long ret);
67055714Skris
67155714SkrisBIO_METHOD *BIO_s_mem(void);
67259191SkrisBIO *BIO_new_mem_buf(void *buf, int len);
67355714SkrisBIO_METHOD *BIO_s_socket(void);
67455714SkrisBIO_METHOD *BIO_s_connect(void);
67555714SkrisBIO_METHOD *BIO_s_accept(void);
67655714SkrisBIO_METHOD *BIO_s_fd(void);
677109998Smarkm#ifndef OPENSSL_SYS_OS2
67855714SkrisBIO_METHOD *BIO_s_log(void);
679109998Smarkm#endif
68055714SkrisBIO_METHOD *BIO_s_bio(void);
68155714SkrisBIO_METHOD *BIO_s_null(void);
68255714SkrisBIO_METHOD *BIO_f_null(void);
68355714SkrisBIO_METHOD *BIO_f_buffer(void);
684109998Smarkm#ifdef OPENSSL_SYS_VMS
68568651SkrisBIO_METHOD *BIO_f_linebuffer(void);
68668651Skris#endif
68755714SkrisBIO_METHOD *BIO_f_nbio_test(void);
688160814Ssimon#ifndef OPENSSL_NO_DGRAM
689160814SsimonBIO_METHOD *BIO_s_datagram(void);
690238405Sjkim#ifndef OPENSSL_NO_SCTP
691238405SjkimBIO_METHOD *BIO_s_datagram_sctp(void);
692160814Ssimon#endif
693238405Sjkim#endif
694160814Ssimon
69555714Skris/* BIO_METHOD *BIO_f_ber(void); */
69655714Skris
69755714Skrisint BIO_sock_should_retry(int i);
69855714Skrisint BIO_sock_non_fatal_error(int error);
699160814Ssimonint BIO_dgram_non_fatal_error(int error);
700160814Ssimon
70155714Skrisint BIO_fd_should_retry(int i);
70255714Skrisint BIO_fd_non_fatal_error(int error);
703160814Ssimonint BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u),
704160814Ssimon		void *u, const char *s, int len);
705160814Ssimonint BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
706160814Ssimon		       void *u, const char *s, int len, int indent);
70755714Skrisint BIO_dump(BIO *b,const char *bytes,int len);
70868651Skrisint BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
709160814Ssimon#ifndef OPENSSL_NO_FP_API
710160814Ssimonint BIO_dump_fp(FILE *fp, const char *s, int len);
711160814Ssimonint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
712160814Ssimon#endif
71355714Skrisstruct hostent *BIO_gethostbyname(const char *name);
71455714Skris/* We might want a thread-safe interface too:
71555714Skris * struct hostent *BIO_gethostbyname_r(const char *name,
71655714Skris *     struct hostent *result, void *buffer, size_t buflen);
71755714Skris * or something similar (caller allocates a struct hostent,
71855714Skris * pointed to by "result", and additional buffer space for the various
71955714Skris * substructures; if the buffer does not suffice, NULL is returned
72055714Skris * and an appropriate error code is set).
72155714Skris */
72255714Skrisint BIO_sock_error(int sock);
723111147Snectarint BIO_socket_ioctl(int fd, long type, void *arg);
72455714Skrisint BIO_socket_nbio(int fd,int mode);
72555714Skrisint BIO_get_port(const char *str, unsigned short *port_ptr);
72655714Skrisint BIO_get_host_ip(const char *str, unsigned char *ip);
72755714Skrisint BIO_get_accept_socket(char *host_port,int mode);
72855714Skrisint BIO_accept(int sock,char **ip_port);
72955714Skrisint BIO_sock_init(void );
73055714Skrisvoid BIO_sock_cleanup(void);
73155714Skrisint BIO_set_tcp_ndelay(int sock,int turn_on);
73255714Skris
73355714SkrisBIO *BIO_new_socket(int sock, int close_flag);
734160814SsimonBIO *BIO_new_dgram(int fd, int close_flag);
735238405Sjkim#ifndef OPENSSL_NO_SCTP
736238405SjkimBIO *BIO_new_dgram_sctp(int fd, int close_flag);
737238405Sjkimint BIO_dgram_is_sctp(BIO *bio);
738238405Sjkimint BIO_dgram_sctp_notification_cb(BIO *b,
739238405Sjkim                                   void (*handle_notifications)(BIO *bio, void *context, void *buf),
740238405Sjkim                                   void *context);
741238405Sjkimint BIO_dgram_sctp_wait_for_dry(BIO *b);
742238405Sjkimint BIO_dgram_sctp_msg_waiting(BIO *b);
743238405Sjkim#endif
74455714SkrisBIO *BIO_new_fd(int fd, int close_flag);
74555714SkrisBIO *BIO_new_connect(char *host_port);
74655714SkrisBIO *BIO_new_accept(char *host_port);
74755714Skris
74855714Skrisint BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
74955714Skris	BIO **bio2, size_t writebuf2);
75055714Skris/* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
75155714Skris * Otherwise returns 0 and sets *bio1 and *bio2 to NULL.
75255714Skris * Size 0 uses default value.
75355714Skris */
75455714Skris
75555714Skrisvoid BIO_copy_next_retry(BIO *b);
75655714Skris
757109998Smarkm/*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
75855714Skris
759160814Ssimon#ifdef __GNUC__
760160814Ssimon#  define __bio_h__attr__ __attribute__
761160814Ssimon#else
762160814Ssimon#  define __bio_h__attr__(x)
763160814Ssimon#endif
764160814Ssimonint BIO_printf(BIO *bio, const char *format, ...)
765160814Ssimon	__bio_h__attr__((__format__(__printf__,2,3)));
766160814Ssimonint BIO_vprintf(BIO *bio, const char *format, va_list args)
767160814Ssimon	__bio_h__attr__((__format__(__printf__,2,0)));
768160814Ssimonint BIO_snprintf(char *buf, size_t n, const char *format, ...)
769160814Ssimon	__bio_h__attr__((__format__(__printf__,3,4)));
770160814Ssimonint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
771160814Ssimon	__bio_h__attr__((__format__(__printf__,3,0)));
772160814Ssimon#undef __bio_h__attr__
77355714Skris
77455714Skris/* BEGIN ERROR CODES */
77555714Skris/* The following lines are auto generated by the script mkerr.pl. Any changes
77655714Skris * made after this point may be overwritten when the script is next run.
77755714Skris */
77889837Skrisvoid ERR_load_BIO_strings(void);
77955714Skris
78055714Skris/* Error codes for the BIO functions. */
78155714Skris
78255714Skris/* Function codes. */
78355714Skris#define BIO_F_ACPT_STATE				 100
78455714Skris#define BIO_F_BIO_ACCEPT				 101
78555714Skris#define BIO_F_BIO_BER_GET_HEADER			 102
786160814Ssimon#define BIO_F_BIO_CALLBACK_CTRL				 131
78755714Skris#define BIO_F_BIO_CTRL					 103
78855714Skris#define BIO_F_BIO_GETHOSTBYNAME				 120
78955714Skris#define BIO_F_BIO_GETS					 104
79055714Skris#define BIO_F_BIO_GET_ACCEPT_SOCKET			 105
79155714Skris#define BIO_F_BIO_GET_HOST_IP				 106
79255714Skris#define BIO_F_BIO_GET_PORT				 107
79355714Skris#define BIO_F_BIO_MAKE_PAIR				 121
79455714Skris#define BIO_F_BIO_NEW					 108
79555714Skris#define BIO_F_BIO_NEW_FILE				 109
79659191Skris#define BIO_F_BIO_NEW_MEM_BUF				 126
79759191Skris#define BIO_F_BIO_NREAD					 123
79859191Skris#define BIO_F_BIO_NREAD0				 124
79959191Skris#define BIO_F_BIO_NWRITE				 125
80059191Skris#define BIO_F_BIO_NWRITE0				 122
80155714Skris#define BIO_F_BIO_PUTS					 110
80255714Skris#define BIO_F_BIO_READ					 111
80355714Skris#define BIO_F_BIO_SOCK_INIT				 112
80455714Skris#define BIO_F_BIO_WRITE					 113
80555714Skris#define BIO_F_BUFFER_CTRL				 114
80659191Skris#define BIO_F_CONN_CTRL					 127
80755714Skris#define BIO_F_CONN_STATE				 115
808238405Sjkim#define BIO_F_DGRAM_SCTP_READ				 132
80955714Skris#define BIO_F_FILE_CTRL					 116
810109998Smarkm#define BIO_F_FILE_READ					 130
81168651Skris#define BIO_F_LINEBUFFER_CTRL				 129
81268651Skris#define BIO_F_MEM_READ					 128
81355714Skris#define BIO_F_MEM_WRITE					 117
81455714Skris#define BIO_F_SSL_NEW					 118
81555714Skris#define BIO_F_WSASTARTUP				 119
81655714Skris
81755714Skris/* Reason codes. */
81855714Skris#define BIO_R_ACCEPT_ERROR				 100
81955714Skris#define BIO_R_BAD_FOPEN_MODE				 101
82055714Skris#define BIO_R_BAD_HOSTNAME_LOOKUP			 102
82155714Skris#define BIO_R_BROKEN_PIPE				 124
82255714Skris#define BIO_R_CONNECT_ERROR				 103
82368651Skris#define BIO_R_EOF_ON_MEMORY_BIO				 127
82455714Skris#define BIO_R_ERROR_SETTING_NBIO			 104
82555714Skris#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET	 105
82655714Skris#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET	 106
82755714Skris#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET		 107
82855714Skris#define BIO_R_INVALID_ARGUMENT				 125
82955714Skris#define BIO_R_INVALID_IP_ADDRESS			 108
83055714Skris#define BIO_R_IN_USE					 123
83155714Skris#define BIO_R_KEEPALIVE					 109
83255714Skris#define BIO_R_NBIO_CONNECT_ERROR			 110
83355714Skris#define BIO_R_NO_ACCEPT_PORT_SPECIFIED			 111
83455714Skris#define BIO_R_NO_HOSTNAME_SPECIFIED			 112
83555714Skris#define BIO_R_NO_PORT_DEFINED				 113
83655714Skris#define BIO_R_NO_PORT_SPECIFIED				 114
837109998Smarkm#define BIO_R_NO_SUCH_FILE				 128
83855714Skris#define BIO_R_NULL_PARAMETER				 115
83955714Skris#define BIO_R_TAG_MISMATCH				 116
84055714Skris#define BIO_R_UNABLE_TO_BIND_SOCKET			 117
84155714Skris#define BIO_R_UNABLE_TO_CREATE_SOCKET			 118
84255714Skris#define BIO_R_UNABLE_TO_LISTEN_SOCKET			 119
84355714Skris#define BIO_R_UNINITIALIZED				 120
84455714Skris#define BIO_R_UNSUPPORTED_METHOD			 121
84559191Skris#define BIO_R_WRITE_TO_READ_ONLY_BIO			 126
84655714Skris#define BIO_R_WSASTARTUP				 122
84755714Skris
84855714Skris#ifdef  __cplusplus
84955714Skris}
85055714Skris#endif
85155714Skris#endif
852