xref: /onnv-gate/usr/src/common/openssl/crypto/bio/bio.h (revision 2139:6243c3338933)
10Sstevel@tonic-gate /* crypto/bio/bio.h */
20Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
30Sstevel@tonic-gate  * All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * This package is an SSL implementation written
60Sstevel@tonic-gate  * by Eric Young (eay@cryptsoft.com).
70Sstevel@tonic-gate  * The implementation was written so as to conform with Netscapes SSL.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * This library is free for commercial and non-commercial use as long as
100Sstevel@tonic-gate  * the following conditions are aheared to.  The following conditions
110Sstevel@tonic-gate  * apply to all code found in this distribution, be it the RC4, RSA,
120Sstevel@tonic-gate  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
130Sstevel@tonic-gate  * included with this distribution is covered by the same copyright terms
140Sstevel@tonic-gate  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
150Sstevel@tonic-gate  *
160Sstevel@tonic-gate  * Copyright remains Eric Young's, and as such any Copyright notices in
170Sstevel@tonic-gate  * the code are not to be removed.
180Sstevel@tonic-gate  * If this package is used in a product, Eric Young should be given attribution
190Sstevel@tonic-gate  * as the author of the parts of the library used.
200Sstevel@tonic-gate  * This can be in the form of a textual message at program startup or
210Sstevel@tonic-gate  * in documentation (online or textual) provided with the package.
220Sstevel@tonic-gate  *
230Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
240Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
250Sstevel@tonic-gate  * are met:
260Sstevel@tonic-gate  * 1. Redistributions of source code must retain the copyright
270Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
280Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
290Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
300Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
310Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
320Sstevel@tonic-gate  *    must display the following acknowledgement:
330Sstevel@tonic-gate  *    "This product includes cryptographic software written by
340Sstevel@tonic-gate  *     Eric Young (eay@cryptsoft.com)"
350Sstevel@tonic-gate  *    The word 'cryptographic' can be left out if the rouines from the library
360Sstevel@tonic-gate  *    being used are not cryptographic related :-).
370Sstevel@tonic-gate  * 4. If you include any Windows specific code (or a derivative thereof) from
380Sstevel@tonic-gate  *    the apps directory (application code) you must include an acknowledgement:
390Sstevel@tonic-gate  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
420Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
430Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
440Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
450Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
460Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
470Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
480Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
490Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
500Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
510Sstevel@tonic-gate  * SUCH DAMAGE.
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * The licence and distribution terms for any publically available version or
540Sstevel@tonic-gate  * derivative of this code cannot be changed.  i.e. this code cannot simply be
550Sstevel@tonic-gate  * copied and put under another distribution licence
560Sstevel@tonic-gate  * [including the GNU Public Licence.]
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #ifndef HEADER_BIO_H
600Sstevel@tonic-gate #define HEADER_BIO_H
610Sstevel@tonic-gate 
62*2139Sjp161948 #include <openssl/e_os2.h>
63*2139Sjp161948 
640Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
650Sstevel@tonic-gate # include <stdio.h>
660Sstevel@tonic-gate #endif
670Sstevel@tonic-gate #include <stdarg.h>
680Sstevel@tonic-gate 
690Sstevel@tonic-gate #include <openssl/crypto.h>
700Sstevel@tonic-gate 
710Sstevel@tonic-gate #ifdef  __cplusplus
720Sstevel@tonic-gate extern "C" {
730Sstevel@tonic-gate #endif
740Sstevel@tonic-gate 
750Sstevel@tonic-gate /* These are the 'types' of BIOs */
760Sstevel@tonic-gate #define BIO_TYPE_NONE		0
770Sstevel@tonic-gate #define BIO_TYPE_MEM		(1|0x0400)
780Sstevel@tonic-gate #define BIO_TYPE_FILE		(2|0x0400)
790Sstevel@tonic-gate 
800Sstevel@tonic-gate #define BIO_TYPE_FD		(4|0x0400|0x0100)
810Sstevel@tonic-gate #define BIO_TYPE_SOCKET		(5|0x0400|0x0100)
820Sstevel@tonic-gate #define BIO_TYPE_NULL		(6|0x0400)
830Sstevel@tonic-gate #define BIO_TYPE_SSL		(7|0x0200)
840Sstevel@tonic-gate #define BIO_TYPE_MD		(8|0x0200)		/* passive filter */
850Sstevel@tonic-gate #define BIO_TYPE_BUFFER		(9|0x0200)		/* filter */
860Sstevel@tonic-gate #define BIO_TYPE_CIPHER		(10|0x0200)		/* filter */
870Sstevel@tonic-gate #define BIO_TYPE_BASE64		(11|0x0200)		/* filter */
880Sstevel@tonic-gate #define BIO_TYPE_CONNECT	(12|0x0400|0x0100)	/* socket - connect */
890Sstevel@tonic-gate #define BIO_TYPE_ACCEPT		(13|0x0400|0x0100)	/* socket for accept */
900Sstevel@tonic-gate #define BIO_TYPE_PROXY_CLIENT	(14|0x0200)		/* client proxy BIO */
910Sstevel@tonic-gate #define BIO_TYPE_PROXY_SERVER	(15|0x0200)		/* server proxy BIO */
920Sstevel@tonic-gate #define BIO_TYPE_NBIO_TEST	(16|0x0200)		/* server proxy BIO */
930Sstevel@tonic-gate #define BIO_TYPE_NULL_FILTER	(17|0x0200)
940Sstevel@tonic-gate #define BIO_TYPE_BER		(18|0x0200)		/* BER -> bin filter */
950Sstevel@tonic-gate #define BIO_TYPE_BIO		(19|0x0400)		/* (half a) BIO pair */
960Sstevel@tonic-gate #define BIO_TYPE_LINEBUFFER	(20|0x0200)		/* filter */
97*2139Sjp161948 #define BIO_TYPE_DGRAM		(21|0x0400|0x0100)
980Sstevel@tonic-gate 
990Sstevel@tonic-gate #define BIO_TYPE_DESCRIPTOR	0x0100	/* socket, fd, connect or accept */
1000Sstevel@tonic-gate #define BIO_TYPE_FILTER		0x0200
1010Sstevel@tonic-gate #define BIO_TYPE_SOURCE_SINK	0x0400
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate /* BIO_FILENAME_READ|BIO_CLOSE to open or close on free.
1040Sstevel@tonic-gate  * BIO_set_fp(in,stdin,BIO_NOCLOSE); */
1050Sstevel@tonic-gate #define BIO_NOCLOSE		0x00
1060Sstevel@tonic-gate #define BIO_CLOSE		0x01
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /* These are used in the following macros and are passed to
1090Sstevel@tonic-gate  * BIO_ctrl() */
1100Sstevel@tonic-gate #define BIO_CTRL_RESET		1  /* opt - rewind/zero etc */
1110Sstevel@tonic-gate #define BIO_CTRL_EOF		2  /* opt - are we at the eof */
1120Sstevel@tonic-gate #define BIO_CTRL_INFO		3  /* opt - extra tit-bits */
1130Sstevel@tonic-gate #define BIO_CTRL_SET		4  /* man - set the 'IO' type */
1140Sstevel@tonic-gate #define BIO_CTRL_GET		5  /* man - get the 'IO' type */
1150Sstevel@tonic-gate #define BIO_CTRL_PUSH		6  /* opt - internal, used to signify change */
1160Sstevel@tonic-gate #define BIO_CTRL_POP		7  /* opt - internal, used to signify change */
1170Sstevel@tonic-gate #define BIO_CTRL_GET_CLOSE	8  /* man - set the 'close' on free */
1180Sstevel@tonic-gate #define BIO_CTRL_SET_CLOSE	9  /* man - set the 'close' on free */
1190Sstevel@tonic-gate #define BIO_CTRL_PENDING	10  /* opt - is their more data buffered */
1200Sstevel@tonic-gate #define BIO_CTRL_FLUSH		11  /* opt - 'flush' buffered output */
1210Sstevel@tonic-gate #define BIO_CTRL_DUP		12  /* man - extra stuff for 'duped' BIO */
1220Sstevel@tonic-gate #define BIO_CTRL_WPENDING	13  /* opt - number of bytes still to write */
1230Sstevel@tonic-gate /* callback is int cb(BIO *bio,state,ret); */
1240Sstevel@tonic-gate #define BIO_CTRL_SET_CALLBACK	14  /* opt - set callback function */
1250Sstevel@tonic-gate #define BIO_CTRL_GET_CALLBACK	15  /* opt - set callback function */
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate #define BIO_CTRL_SET_FILENAME	30	/* BIO_s_file special */
1280Sstevel@tonic-gate 
129*2139Sjp161948 /* dgram BIO stuff */
130*2139Sjp161948 #define BIO_CTRL_DGRAM_CONNECT       31  /* BIO dgram special */
131*2139Sjp161948 #define BIO_CTRL_DGRAM_SET_CONNECTED 32  /* allow for an externally
132*2139Sjp161948 										  * connected socket to be
133*2139Sjp161948 										  * passed in */
134*2139Sjp161948 #define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33 /* setsockopt, essentially */
135*2139Sjp161948 #define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34 /* getsockopt, essentially */
136*2139Sjp161948 #define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35 /* setsockopt, essentially */
137*2139Sjp161948 #define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36 /* getsockopt, essentially */
138*2139Sjp161948 
139*2139Sjp161948 #define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37 /* flag whether the last */
140*2139Sjp161948 #define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38 /* I/O operation tiemd out */
141*2139Sjp161948 
142*2139Sjp161948 /* #ifdef IP_MTU_DISCOVER */
143*2139Sjp161948 #define BIO_CTRL_DGRAM_MTU_DISCOVER       39 /* set DF bit on egress packets */
144*2139Sjp161948 /* #endif */
145*2139Sjp161948 
146*2139Sjp161948 #define BIO_CTRL_DGRAM_QUERY_MTU          40 /* as kernel for current MTU */
147*2139Sjp161948 #define BIO_CTRL_DGRAM_GET_MTU            41 /* get cached value for MTU */
148*2139Sjp161948 #define BIO_CTRL_DGRAM_SET_MTU            42 /* set cached value for
149*2139Sjp161948 											  * MTU. want to use this
150*2139Sjp161948                                               * if asking the kernel
151*2139Sjp161948                                               * fails */
152*2139Sjp161948 
153*2139Sjp161948 #define BIO_CTRL_DGRAM_MTU_EXCEEDED       43 /* check whether the MTU
154*2139Sjp161948 											  * was exceed in the
155*2139Sjp161948 											  * previous write
156*2139Sjp161948 											  * operation */
157*2139Sjp161948 
158*2139Sjp161948 #define BIO_CTRL_DGRAM_SET_PEER           44 /* Destination for the data */
159*2139Sjp161948 
160*2139Sjp161948 
1610Sstevel@tonic-gate /* modifiers */
1620Sstevel@tonic-gate #define BIO_FP_READ		0x02
1630Sstevel@tonic-gate #define BIO_FP_WRITE		0x04
1640Sstevel@tonic-gate #define BIO_FP_APPEND		0x08
1650Sstevel@tonic-gate #define BIO_FP_TEXT		0x10
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate #define BIO_FLAGS_READ		0x01
1680Sstevel@tonic-gate #define BIO_FLAGS_WRITE		0x02
1690Sstevel@tonic-gate #define BIO_FLAGS_IO_SPECIAL	0x04
1700Sstevel@tonic-gate #define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
1710Sstevel@tonic-gate #define BIO_FLAGS_SHOULD_RETRY	0x08
172*2139Sjp161948 #ifndef	BIO_FLAGS_UPLINK
173*2139Sjp161948 /* "UPLINK" flag denotes file descriptors provided by application.
174*2139Sjp161948    It defaults to 0, as most platforms don't require UPLINK interface. */
175*2139Sjp161948 #define	BIO_FLAGS_UPLINK	0
176*2139Sjp161948 #endif
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate /* Used in BIO_gethostbyname() */
1790Sstevel@tonic-gate #define BIO_GHBN_CTRL_HITS		1
1800Sstevel@tonic-gate #define BIO_GHBN_CTRL_MISSES		2
1810Sstevel@tonic-gate #define BIO_GHBN_CTRL_CACHE_SIZE	3
1820Sstevel@tonic-gate #define BIO_GHBN_CTRL_GET_ENTRY		4
1830Sstevel@tonic-gate #define BIO_GHBN_CTRL_FLUSH		5
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate /* Mostly used in the SSL BIO */
1860Sstevel@tonic-gate /* Not used anymore
1870Sstevel@tonic-gate  * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10
1880Sstevel@tonic-gate  * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20
1890Sstevel@tonic-gate  * #define BIO_FLAGS_PROTOCOL_STARTUP	0x40
1900Sstevel@tonic-gate  */
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate #define BIO_FLAGS_BASE64_NO_NL	0x100
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate /* This is used with memory BIOs: it means we shouldn't free up or change the
1950Sstevel@tonic-gate  * data in any way.
1960Sstevel@tonic-gate  */
1970Sstevel@tonic-gate #define BIO_FLAGS_MEM_RDONLY	0x200
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate #define BIO_set_flags(b,f) ((b)->flags|=(f))
2000Sstevel@tonic-gate #define BIO_get_flags(b) ((b)->flags)
2010Sstevel@tonic-gate #define BIO_set_retry_special(b) \
2020Sstevel@tonic-gate 		((b)->flags|=(BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))
2030Sstevel@tonic-gate #define BIO_set_retry_read(b) \
2040Sstevel@tonic-gate 		((b)->flags|=(BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))
2050Sstevel@tonic-gate #define BIO_set_retry_write(b) \
2060Sstevel@tonic-gate 		((b)->flags|=(BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))
2070Sstevel@tonic-gate 
2080Sstevel@tonic-gate /* These are normally used internally in BIOs */
2090Sstevel@tonic-gate #define BIO_clear_flags(b,f) ((b)->flags&= ~(f))
2100Sstevel@tonic-gate #define BIO_clear_retry_flags(b) \
2110Sstevel@tonic-gate 		((b)->flags&= ~(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
2120Sstevel@tonic-gate #define BIO_get_retry_flags(b) \
2130Sstevel@tonic-gate 		((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate /* These should be used by the application to tell why we should retry */
2160Sstevel@tonic-gate #define BIO_should_read(a)		((a)->flags & BIO_FLAGS_READ)
2170Sstevel@tonic-gate #define BIO_should_write(a)		((a)->flags & BIO_FLAGS_WRITE)
2180Sstevel@tonic-gate #define BIO_should_io_special(a)	((a)->flags & BIO_FLAGS_IO_SPECIAL)
2190Sstevel@tonic-gate #define BIO_retry_type(a)		((a)->flags & BIO_FLAGS_RWS)
2200Sstevel@tonic-gate #define BIO_should_retry(a)		((a)->flags & BIO_FLAGS_SHOULD_RETRY)
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate /* The next three are used in conjunction with the
2230Sstevel@tonic-gate  * BIO_should_io_special() condition.  After this returns true,
2240Sstevel@tonic-gate  * BIO *BIO_get_retry_BIO(BIO *bio, int *reason); will walk the BIO
2250Sstevel@tonic-gate  * stack and return the 'reason' for the special and the offending BIO.
2260Sstevel@tonic-gate  * Given a BIO, BIO_get_retry_reason(bio) will return the code. */
2270Sstevel@tonic-gate /* Returned from the SSL bio when the certificate retrieval code had an error */
2280Sstevel@tonic-gate #define BIO_RR_SSL_X509_LOOKUP		0x01
2290Sstevel@tonic-gate /* Returned from the connect BIO when a connect would have blocked */
2300Sstevel@tonic-gate #define BIO_RR_CONNECT			0x02
2310Sstevel@tonic-gate /* Returned from the accept BIO when an accept would have blocked */
2320Sstevel@tonic-gate #define BIO_RR_ACCEPT			0x03
2330Sstevel@tonic-gate 
2340Sstevel@tonic-gate /* These are passed by the BIO callback */
2350Sstevel@tonic-gate #define BIO_CB_FREE	0x01
2360Sstevel@tonic-gate #define BIO_CB_READ	0x02
2370Sstevel@tonic-gate #define BIO_CB_WRITE	0x03
2380Sstevel@tonic-gate #define BIO_CB_PUTS	0x04
2390Sstevel@tonic-gate #define BIO_CB_GETS	0x05
2400Sstevel@tonic-gate #define BIO_CB_CTRL	0x06
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate /* The callback is called before and after the underling operation,
2430Sstevel@tonic-gate  * The BIO_CB_RETURN flag indicates if it is after the call */
2440Sstevel@tonic-gate #define BIO_CB_RETURN	0x80
2450Sstevel@tonic-gate #define BIO_CB_return(a) ((a)|BIO_CB_RETURN))
2460Sstevel@tonic-gate #define BIO_cb_pre(a)	(!((a)&BIO_CB_RETURN))
2470Sstevel@tonic-gate #define BIO_cb_post(a)	((a)&BIO_CB_RETURN)
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate #define BIO_set_callback(b,cb)		((b)->callback=(cb))
2500Sstevel@tonic-gate #define BIO_set_callback_arg(b,arg)	((b)->cb_arg=(char *)(arg))
2510Sstevel@tonic-gate #define BIO_get_callback_arg(b)		((b)->cb_arg)
2520Sstevel@tonic-gate #define BIO_get_callback(b)		((b)->callback)
2530Sstevel@tonic-gate #define BIO_method_name(b)		((b)->method->name)
2540Sstevel@tonic-gate #define BIO_method_type(b)		((b)->method->type)
2550Sstevel@tonic-gate 
2560Sstevel@tonic-gate typedef struct bio_st BIO;
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate typedef void bio_info_cb(struct bio_st *, int, const char *, int, long, long);
2590Sstevel@tonic-gate 
2600Sstevel@tonic-gate #ifndef OPENSSL_SYS_WIN16
2610Sstevel@tonic-gate typedef struct bio_method_st
2620Sstevel@tonic-gate 	{
2630Sstevel@tonic-gate 	int type;
2640Sstevel@tonic-gate 	const char *name;
2650Sstevel@tonic-gate 	int (*bwrite)(BIO *, const char *, int);
2660Sstevel@tonic-gate 	int (*bread)(BIO *, char *, int);
2670Sstevel@tonic-gate 	int (*bputs)(BIO *, const char *);
2680Sstevel@tonic-gate 	int (*bgets)(BIO *, char *, int);
2690Sstevel@tonic-gate 	long (*ctrl)(BIO *, int, long, void *);
2700Sstevel@tonic-gate 	int (*create)(BIO *);
2710Sstevel@tonic-gate 	int (*destroy)(BIO *);
2720Sstevel@tonic-gate         long (*callback_ctrl)(BIO *, int, bio_info_cb *);
2730Sstevel@tonic-gate 	} BIO_METHOD;
2740Sstevel@tonic-gate #else
2750Sstevel@tonic-gate typedef struct bio_method_st
2760Sstevel@tonic-gate 	{
2770Sstevel@tonic-gate 	int type;
2780Sstevel@tonic-gate 	const char *name;
2790Sstevel@tonic-gate 	int (_far *bwrite)();
2800Sstevel@tonic-gate 	int (_far *bread)();
2810Sstevel@tonic-gate 	int (_far *bputs)();
2820Sstevel@tonic-gate 	int (_far *bgets)();
2830Sstevel@tonic-gate 	long (_far *ctrl)();
2840Sstevel@tonic-gate 	int (_far *create)();
2850Sstevel@tonic-gate 	int (_far *destroy)();
2860Sstevel@tonic-gate 	long (_far *callback_ctrl)();
2870Sstevel@tonic-gate 	} BIO_METHOD;
2880Sstevel@tonic-gate #endif
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate struct bio_st
2910Sstevel@tonic-gate 	{
2920Sstevel@tonic-gate 	BIO_METHOD *method;
2930Sstevel@tonic-gate 	/* bio, mode, argp, argi, argl, ret */
2940Sstevel@tonic-gate 	long (*callback)(struct bio_st *,int,const char *,int, long,long);
2950Sstevel@tonic-gate 	char *cb_arg; /* first argument for the callback */
2960Sstevel@tonic-gate 
2970Sstevel@tonic-gate 	int init;
2980Sstevel@tonic-gate 	int shutdown;
2990Sstevel@tonic-gate 	int flags;	/* extra storage */
3000Sstevel@tonic-gate 	int retry_reason;
3010Sstevel@tonic-gate 	int num;
3020Sstevel@tonic-gate 	void *ptr;
3030Sstevel@tonic-gate 	struct bio_st *next_bio;	/* used by filter BIOs */
3040Sstevel@tonic-gate 	struct bio_st *prev_bio;	/* used by filter BIOs */
3050Sstevel@tonic-gate 	int references;
3060Sstevel@tonic-gate 	unsigned long num_read;
3070Sstevel@tonic-gate 	unsigned long num_write;
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate 	CRYPTO_EX_DATA ex_data;
3100Sstevel@tonic-gate 	};
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate DECLARE_STACK_OF(BIO)
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate typedef struct bio_f_buffer_ctx_struct
3150Sstevel@tonic-gate 	{
3160Sstevel@tonic-gate 	/* BIO *bio; */ /* this is now in the BIO struct */
3170Sstevel@tonic-gate 	int ibuf_size;	/* how big is the input buffer */
3180Sstevel@tonic-gate 	int obuf_size;	/* how big is the output buffer */
3190Sstevel@tonic-gate 
3200Sstevel@tonic-gate 	char *ibuf;		/* the char array */
3210Sstevel@tonic-gate 	int ibuf_len;		/* how many bytes are in it */
3220Sstevel@tonic-gate 	int ibuf_off;		/* write/read offset */
3230Sstevel@tonic-gate 
3240Sstevel@tonic-gate 	char *obuf;		/* the char array */
3250Sstevel@tonic-gate 	int obuf_len;		/* how many bytes are in it */
3260Sstevel@tonic-gate 	int obuf_off;		/* write/read offset */
3270Sstevel@tonic-gate 	} BIO_F_BUFFER_CTX;
3280Sstevel@tonic-gate 
3290Sstevel@tonic-gate /* connect BIO stuff */
3300Sstevel@tonic-gate #define BIO_CONN_S_BEFORE		1
3310Sstevel@tonic-gate #define BIO_CONN_S_GET_IP		2
3320Sstevel@tonic-gate #define BIO_CONN_S_GET_PORT		3
3330Sstevel@tonic-gate #define BIO_CONN_S_CREATE_SOCKET	4
3340Sstevel@tonic-gate #define BIO_CONN_S_CONNECT		5
3350Sstevel@tonic-gate #define BIO_CONN_S_OK			6
3360Sstevel@tonic-gate #define BIO_CONN_S_BLOCKED_CONNECT	7
3370Sstevel@tonic-gate #define BIO_CONN_S_NBIO			8
3380Sstevel@tonic-gate /*#define BIO_CONN_get_param_hostname	BIO_ctrl */
3390Sstevel@tonic-gate 
3400Sstevel@tonic-gate #define BIO_C_SET_CONNECT			100
3410Sstevel@tonic-gate #define BIO_C_DO_STATE_MACHINE			101
3420Sstevel@tonic-gate #define BIO_C_SET_NBIO				102
3430Sstevel@tonic-gate #define BIO_C_SET_PROXY_PARAM			103
3440Sstevel@tonic-gate #define BIO_C_SET_FD				104
3450Sstevel@tonic-gate #define BIO_C_GET_FD				105
3460Sstevel@tonic-gate #define BIO_C_SET_FILE_PTR			106
3470Sstevel@tonic-gate #define BIO_C_GET_FILE_PTR			107
3480Sstevel@tonic-gate #define BIO_C_SET_FILENAME			108
3490Sstevel@tonic-gate #define BIO_C_SET_SSL				109
3500Sstevel@tonic-gate #define BIO_C_GET_SSL				110
3510Sstevel@tonic-gate #define BIO_C_SET_MD				111
3520Sstevel@tonic-gate #define BIO_C_GET_MD				112
3530Sstevel@tonic-gate #define BIO_C_GET_CIPHER_STATUS			113
3540Sstevel@tonic-gate #define BIO_C_SET_BUF_MEM			114
3550Sstevel@tonic-gate #define BIO_C_GET_BUF_MEM_PTR			115
3560Sstevel@tonic-gate #define BIO_C_GET_BUFF_NUM_LINES		116
3570Sstevel@tonic-gate #define BIO_C_SET_BUFF_SIZE			117
3580Sstevel@tonic-gate #define BIO_C_SET_ACCEPT			118
3590Sstevel@tonic-gate #define BIO_C_SSL_MODE				119
3600Sstevel@tonic-gate #define BIO_C_GET_MD_CTX			120
3610Sstevel@tonic-gate #define BIO_C_GET_PROXY_PARAM			121
3620Sstevel@tonic-gate #define BIO_C_SET_BUFF_READ_DATA		122 /* data to read first */
3630Sstevel@tonic-gate #define BIO_C_GET_CONNECT			123
3640Sstevel@tonic-gate #define BIO_C_GET_ACCEPT			124
3650Sstevel@tonic-gate #define BIO_C_SET_SSL_RENEGOTIATE_BYTES		125
3660Sstevel@tonic-gate #define BIO_C_GET_SSL_NUM_RENEGOTIATES		126
3670Sstevel@tonic-gate #define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT	127
3680Sstevel@tonic-gate #define BIO_C_FILE_SEEK				128
3690Sstevel@tonic-gate #define BIO_C_GET_CIPHER_CTX			129
3700Sstevel@tonic-gate #define BIO_C_SET_BUF_MEM_EOF_RETURN		130/*return end of input value*/
3710Sstevel@tonic-gate #define BIO_C_SET_BIND_MODE			131
3720Sstevel@tonic-gate #define BIO_C_GET_BIND_MODE			132
3730Sstevel@tonic-gate #define BIO_C_FILE_TELL				133
3740Sstevel@tonic-gate #define BIO_C_GET_SOCKS				134
3750Sstevel@tonic-gate #define BIO_C_SET_SOCKS				135
3760Sstevel@tonic-gate 
3770Sstevel@tonic-gate #define BIO_C_SET_WRITE_BUF_SIZE		136/* for BIO_s_bio */
3780Sstevel@tonic-gate #define BIO_C_GET_WRITE_BUF_SIZE		137
3790Sstevel@tonic-gate #define BIO_C_MAKE_BIO_PAIR			138
3800Sstevel@tonic-gate #define BIO_C_DESTROY_BIO_PAIR			139
3810Sstevel@tonic-gate #define BIO_C_GET_WRITE_GUARANTEE		140
3820Sstevel@tonic-gate #define BIO_C_GET_READ_REQUEST			141
3830Sstevel@tonic-gate #define BIO_C_SHUTDOWN_WR			142
3840Sstevel@tonic-gate #define BIO_C_NREAD0				143
3850Sstevel@tonic-gate #define BIO_C_NREAD				144
3860Sstevel@tonic-gate #define BIO_C_NWRITE0				145
3870Sstevel@tonic-gate #define BIO_C_NWRITE				146
3880Sstevel@tonic-gate #define BIO_C_RESET_READ_REQUEST		147
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate #define BIO_set_app_data(s,arg)		BIO_set_ex_data(s,0,arg)
3920Sstevel@tonic-gate #define BIO_get_app_data(s)		BIO_get_ex_data(s,0)
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate /* BIO_s_connect() and BIO_s_socks4a_connect() */
3950Sstevel@tonic-gate #define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)
3960Sstevel@tonic-gate #define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)
3970Sstevel@tonic-gate #define BIO_set_conn_ip(b,ip)	  BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)
3980Sstevel@tonic-gate #define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)
3990Sstevel@tonic-gate #define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
4000Sstevel@tonic-gate #define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
4010Sstevel@tonic-gate #define BIO_get_conn_ip(b) 		 BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
4020Sstevel@tonic-gate #define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3)
4030Sstevel@tonic-gate 
4040Sstevel@tonic-gate 
4050Sstevel@tonic-gate #define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
4060Sstevel@tonic-gate 
4070Sstevel@tonic-gate /* BIO_s_accept_socket() */
4080Sstevel@tonic-gate #define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
4090Sstevel@tonic-gate #define BIO_get_accept_port(b)	BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
4100Sstevel@tonic-gate /* #define BIO_set_nbio(b,n)	BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
4110Sstevel@tonic-gate #define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL)
4120Sstevel@tonic-gate #define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)
4130Sstevel@tonic-gate 
4140Sstevel@tonic-gate #define BIO_BIND_NORMAL			0
4150Sstevel@tonic-gate #define BIO_BIND_REUSEADDR_IF_UNUSED	1
4160Sstevel@tonic-gate #define BIO_BIND_REUSEADDR		2
4170Sstevel@tonic-gate #define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
4180Sstevel@tonic-gate #define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
4190Sstevel@tonic-gate 
4200Sstevel@tonic-gate #define BIO_do_connect(b)	BIO_do_handshake(b)
4210Sstevel@tonic-gate #define BIO_do_accept(b)	BIO_do_handshake(b)
4220Sstevel@tonic-gate #define BIO_do_handshake(b)	BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate /* BIO_s_proxy_client() */
4250Sstevel@tonic-gate #define BIO_set_url(b,url)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))
4260Sstevel@tonic-gate #define BIO_set_proxies(b,p)	BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))
4270Sstevel@tonic-gate /* BIO_set_nbio(b,n) */
4280Sstevel@tonic-gate #define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))
4290Sstevel@tonic-gate /* BIO *BIO_get_filter_bio(BIO *bio); */
4300Sstevel@tonic-gate #define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))
4310Sstevel@tonic-gate #define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)
4320Sstevel@tonic-gate #define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)
4330Sstevel@tonic-gate 
4340Sstevel@tonic-gate #define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)
4350Sstevel@tonic-gate #define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))
4360Sstevel@tonic-gate #define BIO_get_url(b,url)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
4370Sstevel@tonic-gate #define BIO_get_no_connect_return(b)	BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)
4380Sstevel@tonic-gate 
4390Sstevel@tonic-gate #define BIO_set_fd(b,fd,c)	BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
4400Sstevel@tonic-gate #define BIO_get_fd(b,c)		BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate #define BIO_set_fp(b,fp,c)	BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
4430Sstevel@tonic-gate #define BIO_get_fp(b,fpp)	BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
4440Sstevel@tonic-gate 
4450Sstevel@tonic-gate #define BIO_seek(b,ofs)	(int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
4460Sstevel@tonic-gate #define BIO_tell(b)	(int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
4470Sstevel@tonic-gate 
4480Sstevel@tonic-gate /* name is cast to lose const, but might be better to route through a function
4490Sstevel@tonic-gate    so we can do it safely */
4500Sstevel@tonic-gate #ifdef CONST_STRICT
4510Sstevel@tonic-gate /* If you are wondering why this isn't defined, its because CONST_STRICT is
4520Sstevel@tonic-gate  * purely a compile-time kludge to allow const to be checked.
4530Sstevel@tonic-gate  */
4540Sstevel@tonic-gate int BIO_read_filename(BIO *b,const char *name);
4550Sstevel@tonic-gate #else
4560Sstevel@tonic-gate #define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
4570Sstevel@tonic-gate 		BIO_CLOSE|BIO_FP_READ,(char *)name)
4580Sstevel@tonic-gate #endif
4590Sstevel@tonic-gate #define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
4600Sstevel@tonic-gate 		BIO_CLOSE|BIO_FP_WRITE,name)
4610Sstevel@tonic-gate #define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
4620Sstevel@tonic-gate 		BIO_CLOSE|BIO_FP_APPEND,name)
4630Sstevel@tonic-gate #define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \
4640Sstevel@tonic-gate 		BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate /* WARNING WARNING, this ups the reference count on the read bio of the
4670Sstevel@tonic-gate  * SSL structure.  This is because the ssl read BIO is now pointed to by
4680Sstevel@tonic-gate  * the next_bio field in the bio.  So when you free the BIO, make sure
4690Sstevel@tonic-gate  * you are doing a BIO_free_all() to catch the underlying BIO. */
4700Sstevel@tonic-gate #define BIO_set_ssl(b,ssl,c)	BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)
4710Sstevel@tonic-gate #define BIO_get_ssl(b,sslp)	BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)
4720Sstevel@tonic-gate #define BIO_set_ssl_mode(b,client)	BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)
4730Sstevel@tonic-gate #define BIO_set_ssl_renegotiate_bytes(b,num) \
4740Sstevel@tonic-gate 	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL);
4750Sstevel@tonic-gate #define BIO_get_num_renegotiates(b) \
4760Sstevel@tonic-gate 	BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL);
4770Sstevel@tonic-gate #define BIO_set_ssl_renegotiate_timeout(b,seconds) \
4780Sstevel@tonic-gate 	BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL);
4790Sstevel@tonic-gate 
4800Sstevel@tonic-gate /* defined in evp.h */
4810Sstevel@tonic-gate /* #define BIO_set_md(b,md)	BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
4820Sstevel@tonic-gate 
4830Sstevel@tonic-gate #define BIO_get_mem_data(b,pp)	BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
4840Sstevel@tonic-gate #define BIO_set_mem_buf(b,bm,c)	BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
4850Sstevel@tonic-gate #define BIO_get_mem_ptr(b,pp)	BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
4860Sstevel@tonic-gate #define BIO_set_mem_eof_return(b,v) \
4870Sstevel@tonic-gate 				BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
4880Sstevel@tonic-gate 
4890Sstevel@tonic-gate /* For the BIO_f_buffer() type */
4900Sstevel@tonic-gate #define BIO_get_buffer_num_lines(b)	BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)
4910Sstevel@tonic-gate #define BIO_set_buffer_size(b,size)	BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)
4920Sstevel@tonic-gate #define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)
4930Sstevel@tonic-gate #define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)
4940Sstevel@tonic-gate #define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)
4950Sstevel@tonic-gate 
4960Sstevel@tonic-gate /* Don't use the next one unless you know what you are doing :-) */
4970Sstevel@tonic-gate #define BIO_dup_state(b,ret)	BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate #define BIO_reset(b)		(int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
5000Sstevel@tonic-gate #define BIO_eof(b)		(int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)
5010Sstevel@tonic-gate #define BIO_set_close(b,c)	(int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)
5020Sstevel@tonic-gate #define BIO_get_close(b)	(int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)
5030Sstevel@tonic-gate #define BIO_pending(b)		(int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)
5040Sstevel@tonic-gate #define BIO_wpending(b)		(int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)
5050Sstevel@tonic-gate /* ...pending macros have inappropriate return type */
5060Sstevel@tonic-gate size_t BIO_ctrl_pending(BIO *b);
5070Sstevel@tonic-gate size_t BIO_ctrl_wpending(BIO *b);
5080Sstevel@tonic-gate #define BIO_flush(b)		(int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)
5090Sstevel@tonic-gate #define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \
5100Sstevel@tonic-gate 						   cbp)
5110Sstevel@tonic-gate #define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)
5120Sstevel@tonic-gate 
5130Sstevel@tonic-gate /* For the BIO_f_buffer() type */
5140Sstevel@tonic-gate #define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)
5150Sstevel@tonic-gate 
5160Sstevel@tonic-gate /* For BIO_s_bio() */
5170Sstevel@tonic-gate #define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)
5180Sstevel@tonic-gate #define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)
5190Sstevel@tonic-gate #define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)
5200Sstevel@tonic-gate #define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)
5210Sstevel@tonic-gate #define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)
5220Sstevel@tonic-gate /* macros with inappropriate type -- but ...pending macros use int too: */
5230Sstevel@tonic-gate #define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)
5240Sstevel@tonic-gate #define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)
5250Sstevel@tonic-gate size_t BIO_ctrl_get_write_guarantee(BIO *b);
5260Sstevel@tonic-gate size_t BIO_ctrl_get_read_request(BIO *b);
5270Sstevel@tonic-gate int BIO_ctrl_reset_read_request(BIO *b);
5280Sstevel@tonic-gate 
529*2139Sjp161948 /* ctrl macros for dgram */
530*2139Sjp161948 #define BIO_ctrl_dgram_connect(b,peer)  \
531*2139Sjp161948                      (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)
532*2139Sjp161948 #define BIO_ctrl_set_connected(b, state, peer) \
533*2139Sjp161948          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)
534*2139Sjp161948 #define BIO_dgram_recv_timedout(b) \
535*2139Sjp161948          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)
536*2139Sjp161948 #define BIO_dgram_send_timedout(b) \
537*2139Sjp161948          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)
538*2139Sjp161948 #define BIO_dgram_set_peer(b,peer) \
539*2139Sjp161948          (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
540*2139Sjp161948 
5410Sstevel@tonic-gate /* These two aren't currently implemented */
5420Sstevel@tonic-gate /* int BIO_get_ex_num(BIO *bio); */
5430Sstevel@tonic-gate /* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */
5440Sstevel@tonic-gate int BIO_set_ex_data(BIO *bio,int idx,void *data);
5450Sstevel@tonic-gate void *BIO_get_ex_data(BIO *bio,int idx);
5460Sstevel@tonic-gate int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
5470Sstevel@tonic-gate 	CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
5480Sstevel@tonic-gate unsigned long BIO_number_read(BIO *bio);
5490Sstevel@tonic-gate unsigned long BIO_number_written(BIO *bio);
5500Sstevel@tonic-gate 
5510Sstevel@tonic-gate # ifndef OPENSSL_NO_FP_API
5520Sstevel@tonic-gate #  if defined(OPENSSL_SYS_WIN16) && defined(_WINDLL)
5530Sstevel@tonic-gate BIO_METHOD *BIO_s_file_internal(void);
5540Sstevel@tonic-gate BIO *BIO_new_file_internal(char *filename, char *mode);
5550Sstevel@tonic-gate BIO *BIO_new_fp_internal(FILE *stream, int close_flag);
5560Sstevel@tonic-gate #    define BIO_s_file	BIO_s_file_internal
5570Sstevel@tonic-gate #    define BIO_new_file	BIO_new_file_internal
5580Sstevel@tonic-gate #    define BIO_new_fp	BIO_new_fp_internal
5590Sstevel@tonic-gate #  else /* FP_API */
5600Sstevel@tonic-gate BIO_METHOD *BIO_s_file(void );
5610Sstevel@tonic-gate BIO *BIO_new_file(const char *filename, const char *mode);
5620Sstevel@tonic-gate BIO *BIO_new_fp(FILE *stream, int close_flag);
5630Sstevel@tonic-gate #    define BIO_s_file_internal		BIO_s_file
5640Sstevel@tonic-gate #    define BIO_new_file_internal	BIO_new_file
5650Sstevel@tonic-gate #    define BIO_new_fp_internal		BIO_s_file
5660Sstevel@tonic-gate #  endif /* FP_API */
5670Sstevel@tonic-gate # endif
5680Sstevel@tonic-gate BIO *	BIO_new(BIO_METHOD *type);
5690Sstevel@tonic-gate int	BIO_set(BIO *a,BIO_METHOD *type);
5700Sstevel@tonic-gate int	BIO_free(BIO *a);
5710Sstevel@tonic-gate void	BIO_vfree(BIO *a);
5720Sstevel@tonic-gate int	BIO_read(BIO *b, void *data, int len);
5730Sstevel@tonic-gate int	BIO_gets(BIO *bp,char *buf, int size);
5740Sstevel@tonic-gate int	BIO_write(BIO *b, const void *data, int len);
5750Sstevel@tonic-gate int	BIO_puts(BIO *bp,const char *buf);
5760Sstevel@tonic-gate int	BIO_indent(BIO *b,int indent,int max);
5770Sstevel@tonic-gate long	BIO_ctrl(BIO *bp,int cmd,long larg,void *parg);
5780Sstevel@tonic-gate long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long));
5790Sstevel@tonic-gate char *	BIO_ptr_ctrl(BIO *bp,int cmd,long larg);
5800Sstevel@tonic-gate long	BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg);
5810Sstevel@tonic-gate BIO *	BIO_push(BIO *b,BIO *append);
5820Sstevel@tonic-gate BIO *	BIO_pop(BIO *b);
5830Sstevel@tonic-gate void	BIO_free_all(BIO *a);
5840Sstevel@tonic-gate BIO *	BIO_find_type(BIO *b,int bio_type);
5850Sstevel@tonic-gate BIO *	BIO_next(BIO *b);
5860Sstevel@tonic-gate BIO *	BIO_get_retry_BIO(BIO *bio, int *reason);
5870Sstevel@tonic-gate int	BIO_get_retry_reason(BIO *bio);
5880Sstevel@tonic-gate BIO *	BIO_dup_chain(BIO *in);
5890Sstevel@tonic-gate 
5900Sstevel@tonic-gate int BIO_nread0(BIO *bio, char **buf);
5910Sstevel@tonic-gate int BIO_nread(BIO *bio, char **buf, int num);
5920Sstevel@tonic-gate int BIO_nwrite0(BIO *bio, char **buf);
5930Sstevel@tonic-gate int BIO_nwrite(BIO *bio, char **buf, int num);
5940Sstevel@tonic-gate 
5950Sstevel@tonic-gate #ifndef OPENSSL_SYS_WIN16
5960Sstevel@tonic-gate long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
5970Sstevel@tonic-gate 	long argl,long ret);
5980Sstevel@tonic-gate #else
5990Sstevel@tonic-gate long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi,
6000Sstevel@tonic-gate 	long argl,long ret);
6010Sstevel@tonic-gate #endif
6020Sstevel@tonic-gate 
6030Sstevel@tonic-gate BIO_METHOD *BIO_s_mem(void);
6040Sstevel@tonic-gate BIO *BIO_new_mem_buf(void *buf, int len);
6050Sstevel@tonic-gate BIO_METHOD *BIO_s_socket(void);
6060Sstevel@tonic-gate BIO_METHOD *BIO_s_connect(void);
6070Sstevel@tonic-gate BIO_METHOD *BIO_s_accept(void);
6080Sstevel@tonic-gate BIO_METHOD *BIO_s_fd(void);
6090Sstevel@tonic-gate #ifndef OPENSSL_SYS_OS2
6100Sstevel@tonic-gate BIO_METHOD *BIO_s_log(void);
6110Sstevel@tonic-gate #endif
6120Sstevel@tonic-gate BIO_METHOD *BIO_s_bio(void);
6130Sstevel@tonic-gate BIO_METHOD *BIO_s_null(void);
6140Sstevel@tonic-gate BIO_METHOD *BIO_f_null(void);
6150Sstevel@tonic-gate BIO_METHOD *BIO_f_buffer(void);
6160Sstevel@tonic-gate #ifdef OPENSSL_SYS_VMS
6170Sstevel@tonic-gate BIO_METHOD *BIO_f_linebuffer(void);
6180Sstevel@tonic-gate #endif
6190Sstevel@tonic-gate BIO_METHOD *BIO_f_nbio_test(void);
620*2139Sjp161948 #ifndef OPENSSL_NO_DGRAM
621*2139Sjp161948 BIO_METHOD *BIO_s_datagram(void);
622*2139Sjp161948 #endif
623*2139Sjp161948 
6240Sstevel@tonic-gate /* BIO_METHOD *BIO_f_ber(void); */
6250Sstevel@tonic-gate 
6260Sstevel@tonic-gate int BIO_sock_should_retry(int i);
6270Sstevel@tonic-gate int BIO_sock_non_fatal_error(int error);
628*2139Sjp161948 int BIO_dgram_non_fatal_error(int error);
629*2139Sjp161948 
6300Sstevel@tonic-gate int BIO_fd_should_retry(int i);
6310Sstevel@tonic-gate int BIO_fd_non_fatal_error(int error);
632*2139Sjp161948 int BIO_dump_cb(int (*cb)(const void *data, size_t len, void *u),
633*2139Sjp161948 		void *u, const char *s, int len);
634*2139Sjp161948 int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
635*2139Sjp161948 		       void *u, const char *s, int len, int indent);
6360Sstevel@tonic-gate int BIO_dump(BIO *b,const char *bytes,int len);
6370Sstevel@tonic-gate int BIO_dump_indent(BIO *b,const char *bytes,int len,int indent);
638*2139Sjp161948 #ifndef OPENSSL_NO_FP_API
639*2139Sjp161948 int BIO_dump_fp(FILE *fp, const char *s, int len);
640*2139Sjp161948 int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);
641*2139Sjp161948 #endif
6420Sstevel@tonic-gate struct hostent *BIO_gethostbyname(const char *name);
6430Sstevel@tonic-gate /* We might want a thread-safe interface too:
6440Sstevel@tonic-gate  * struct hostent *BIO_gethostbyname_r(const char *name,
6450Sstevel@tonic-gate  *     struct hostent *result, void *buffer, size_t buflen);
6460Sstevel@tonic-gate  * or something similar (caller allocates a struct hostent,
6470Sstevel@tonic-gate  * pointed to by "result", and additional buffer space for the various
6480Sstevel@tonic-gate  * substructures; if the buffer does not suffice, NULL is returned
6490Sstevel@tonic-gate  * and an appropriate error code is set).
6500Sstevel@tonic-gate  */
6510Sstevel@tonic-gate int BIO_sock_error(int sock);
6520Sstevel@tonic-gate int BIO_socket_ioctl(int fd, long type, void *arg);
6530Sstevel@tonic-gate int BIO_socket_nbio(int fd,int mode);
6540Sstevel@tonic-gate int BIO_get_port(const char *str, unsigned short *port_ptr);
6550Sstevel@tonic-gate int BIO_get_host_ip(const char *str, unsigned char *ip);
6560Sstevel@tonic-gate int BIO_get_accept_socket(char *host_port,int mode);
6570Sstevel@tonic-gate int BIO_accept(int sock,char **ip_port);
6580Sstevel@tonic-gate int BIO_sock_init(void );
6590Sstevel@tonic-gate void BIO_sock_cleanup(void);
6600Sstevel@tonic-gate int BIO_set_tcp_ndelay(int sock,int turn_on);
6610Sstevel@tonic-gate 
6620Sstevel@tonic-gate BIO *BIO_new_socket(int sock, int close_flag);
663*2139Sjp161948 BIO *BIO_new_dgram(int fd, int close_flag);
6640Sstevel@tonic-gate BIO *BIO_new_fd(int fd, int close_flag);
6650Sstevel@tonic-gate BIO *BIO_new_connect(char *host_port);
6660Sstevel@tonic-gate BIO *BIO_new_accept(char *host_port);
6670Sstevel@tonic-gate 
6680Sstevel@tonic-gate int BIO_new_bio_pair(BIO **bio1, size_t writebuf1,
6690Sstevel@tonic-gate 	BIO **bio2, size_t writebuf2);
6700Sstevel@tonic-gate /* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.
6710Sstevel@tonic-gate  * Otherwise returns 0 and sets *bio1 and *bio2 to NULL.
6720Sstevel@tonic-gate  * Size 0 uses default value.
6730Sstevel@tonic-gate  */
6740Sstevel@tonic-gate 
6750Sstevel@tonic-gate void BIO_copy_next_retry(BIO *b);
6760Sstevel@tonic-gate 
6770Sstevel@tonic-gate /*long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);*/
6780Sstevel@tonic-gate 
679*2139Sjp161948 #ifndef __GNUC__
680*2139Sjp161948 #define __attribute__(x)
681*2139Sjp161948 #endif
682*2139Sjp161948 int BIO_printf(BIO *bio, const char *format, ...)
683*2139Sjp161948 	__attribute__((__format__(__printf__,2,3)));
684*2139Sjp161948 int BIO_vprintf(BIO *bio, const char *format, va_list args)
685*2139Sjp161948 	__attribute__((__format__(__printf__,2,0)));
686*2139Sjp161948 int BIO_snprintf(char *buf, size_t n, const char *format, ...)
687*2139Sjp161948 	__attribute__((__format__(__printf__,3,4)));
688*2139Sjp161948 int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
689*2139Sjp161948 	__attribute__((__format__(__printf__,3,0)));
6900Sstevel@tonic-gate 
6910Sstevel@tonic-gate /* BEGIN ERROR CODES */
6920Sstevel@tonic-gate /* The following lines are auto generated by the script mkerr.pl. Any changes
6930Sstevel@tonic-gate  * made after this point may be overwritten when the script is next run.
6940Sstevel@tonic-gate  */
6950Sstevel@tonic-gate void ERR_load_BIO_strings(void);
6960Sstevel@tonic-gate 
6970Sstevel@tonic-gate /* Error codes for the BIO functions. */
6980Sstevel@tonic-gate 
6990Sstevel@tonic-gate /* Function codes. */
7000Sstevel@tonic-gate #define BIO_F_ACPT_STATE				 100
7010Sstevel@tonic-gate #define BIO_F_BIO_ACCEPT				 101
7020Sstevel@tonic-gate #define BIO_F_BIO_BER_GET_HEADER			 102
703*2139Sjp161948 #define BIO_F_BIO_CALLBACK_CTRL				 131
7040Sstevel@tonic-gate #define BIO_F_BIO_CTRL					 103
7050Sstevel@tonic-gate #define BIO_F_BIO_GETHOSTBYNAME				 120
7060Sstevel@tonic-gate #define BIO_F_BIO_GETS					 104
7070Sstevel@tonic-gate #define BIO_F_BIO_GET_ACCEPT_SOCKET			 105
7080Sstevel@tonic-gate #define BIO_F_BIO_GET_HOST_IP				 106
7090Sstevel@tonic-gate #define BIO_F_BIO_GET_PORT				 107
7100Sstevel@tonic-gate #define BIO_F_BIO_MAKE_PAIR				 121
7110Sstevel@tonic-gate #define BIO_F_BIO_NEW					 108
7120Sstevel@tonic-gate #define BIO_F_BIO_NEW_FILE				 109
7130Sstevel@tonic-gate #define BIO_F_BIO_NEW_MEM_BUF				 126
7140Sstevel@tonic-gate #define BIO_F_BIO_NREAD					 123
7150Sstevel@tonic-gate #define BIO_F_BIO_NREAD0				 124
7160Sstevel@tonic-gate #define BIO_F_BIO_NWRITE				 125
7170Sstevel@tonic-gate #define BIO_F_BIO_NWRITE0				 122
7180Sstevel@tonic-gate #define BIO_F_BIO_PUTS					 110
7190Sstevel@tonic-gate #define BIO_F_BIO_READ					 111
7200Sstevel@tonic-gate #define BIO_F_BIO_SOCK_INIT				 112
7210Sstevel@tonic-gate #define BIO_F_BIO_WRITE					 113
7220Sstevel@tonic-gate #define BIO_F_BUFFER_CTRL				 114
7230Sstevel@tonic-gate #define BIO_F_CONN_CTRL					 127
7240Sstevel@tonic-gate #define BIO_F_CONN_STATE				 115
7250Sstevel@tonic-gate #define BIO_F_FILE_CTRL					 116
7260Sstevel@tonic-gate #define BIO_F_FILE_READ					 130
7270Sstevel@tonic-gate #define BIO_F_LINEBUFFER_CTRL				 129
7280Sstevel@tonic-gate #define BIO_F_MEM_READ					 128
7290Sstevel@tonic-gate #define BIO_F_MEM_WRITE					 117
7300Sstevel@tonic-gate #define BIO_F_SSL_NEW					 118
7310Sstevel@tonic-gate #define BIO_F_WSASTARTUP				 119
7320Sstevel@tonic-gate 
7330Sstevel@tonic-gate /* Reason codes. */
7340Sstevel@tonic-gate #define BIO_R_ACCEPT_ERROR				 100
7350Sstevel@tonic-gate #define BIO_R_BAD_FOPEN_MODE				 101
7360Sstevel@tonic-gate #define BIO_R_BAD_HOSTNAME_LOOKUP			 102
7370Sstevel@tonic-gate #define BIO_R_BROKEN_PIPE				 124
7380Sstevel@tonic-gate #define BIO_R_CONNECT_ERROR				 103
7390Sstevel@tonic-gate #define BIO_R_EOF_ON_MEMORY_BIO				 127
7400Sstevel@tonic-gate #define BIO_R_ERROR_SETTING_NBIO			 104
7410Sstevel@tonic-gate #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET	 105
7420Sstevel@tonic-gate #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET	 106
7430Sstevel@tonic-gate #define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET		 107
7440Sstevel@tonic-gate #define BIO_R_INVALID_ARGUMENT				 125
7450Sstevel@tonic-gate #define BIO_R_INVALID_IP_ADDRESS			 108
7460Sstevel@tonic-gate #define BIO_R_IN_USE					 123
7470Sstevel@tonic-gate #define BIO_R_KEEPALIVE					 109
7480Sstevel@tonic-gate #define BIO_R_NBIO_CONNECT_ERROR			 110
7490Sstevel@tonic-gate #define BIO_R_NO_ACCEPT_PORT_SPECIFIED			 111
7500Sstevel@tonic-gate #define BIO_R_NO_HOSTNAME_SPECIFIED			 112
7510Sstevel@tonic-gate #define BIO_R_NO_PORT_DEFINED				 113
7520Sstevel@tonic-gate #define BIO_R_NO_PORT_SPECIFIED				 114
7530Sstevel@tonic-gate #define BIO_R_NO_SUCH_FILE				 128
7540Sstevel@tonic-gate #define BIO_R_NULL_PARAMETER				 115
7550Sstevel@tonic-gate #define BIO_R_TAG_MISMATCH				 116
7560Sstevel@tonic-gate #define BIO_R_UNABLE_TO_BIND_SOCKET			 117
7570Sstevel@tonic-gate #define BIO_R_UNABLE_TO_CREATE_SOCKET			 118
7580Sstevel@tonic-gate #define BIO_R_UNABLE_TO_LISTEN_SOCKET			 119
7590Sstevel@tonic-gate #define BIO_R_UNINITIALIZED				 120
7600Sstevel@tonic-gate #define BIO_R_UNSUPPORTED_METHOD			 121
7610Sstevel@tonic-gate #define BIO_R_WRITE_TO_READ_ONLY_BIO			 126
7620Sstevel@tonic-gate #define BIO_R_WSASTARTUP				 122
7630Sstevel@tonic-gate 
7640Sstevel@tonic-gate #ifdef  __cplusplus
7650Sstevel@tonic-gate }
7660Sstevel@tonic-gate #endif
7670Sstevel@tonic-gate #endif
768