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. 8296341Sdelphij * 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). 15296341Sdelphij * 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. 22296341Sdelphij * 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 :-). 37296341Sdelphij * 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)" 40296341Sdelphij * 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. 52296341Sdelphij * 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 60296341Sdelphij# define HEADER_BIO_H 6155714Skris 62296341Sdelphij# include <openssl/e_os2.h> 63160814Ssimon 64296341Sdelphij# ifndef OPENSSL_NO_FP_API 65296341Sdelphij# include <stdio.h> 66296341Sdelphij# endif 67296341Sdelphij# include <stdarg.h> 6868651Skris 69296341Sdelphij# include <openssl/crypto.h> 7068651Skris 71296341Sdelphij# ifndef OPENSSL_NO_SCTP 72296341Sdelphij# ifndef OPENSSL_SYS_VMS 73296341Sdelphij# include <stdint.h> 74296341Sdelphij# else 75296341Sdelphij# include <inttypes.h> 76296341Sdelphij# endif 77238405Sjkim# endif 78238405Sjkim 7955714Skris#ifdef __cplusplus 8055714Skrisextern "C" { 8155714Skris#endif 8255714Skris 8355714Skris/* These are the 'types' of BIOs */ 84296341Sdelphij# define BIO_TYPE_NONE 0 85296341Sdelphij# define BIO_TYPE_MEM (1|0x0400) 86296341Sdelphij# define BIO_TYPE_FILE (2|0x0400) 8755714Skris 88296341Sdelphij# define BIO_TYPE_FD (4|0x0400|0x0100) 89296341Sdelphij# define BIO_TYPE_SOCKET (5|0x0400|0x0100) 90296341Sdelphij# define BIO_TYPE_NULL (6|0x0400) 91296341Sdelphij# define BIO_TYPE_SSL (7|0x0200) 92296341Sdelphij# define BIO_TYPE_MD (8|0x0200)/* passive filter */ 93296341Sdelphij# define BIO_TYPE_BUFFER (9|0x0200)/* filter */ 94296341Sdelphij# define BIO_TYPE_CIPHER (10|0x0200)/* filter */ 95296341Sdelphij# define BIO_TYPE_BASE64 (11|0x0200)/* filter */ 96296341Sdelphij# define BIO_TYPE_CONNECT (12|0x0400|0x0100)/* socket - connect */ 97296341Sdelphij# define BIO_TYPE_ACCEPT (13|0x0400|0x0100)/* socket for accept */ 98296341Sdelphij# define BIO_TYPE_PROXY_CLIENT (14|0x0200)/* client proxy BIO */ 99296341Sdelphij# define BIO_TYPE_PROXY_SERVER (15|0x0200)/* server proxy BIO */ 100296341Sdelphij# define BIO_TYPE_NBIO_TEST (16|0x0200)/* server proxy BIO */ 101296341Sdelphij# define BIO_TYPE_NULL_FILTER (17|0x0200) 102296341Sdelphij# define BIO_TYPE_BER (18|0x0200)/* BER -> bin filter */ 103296341Sdelphij# define BIO_TYPE_BIO (19|0x0400)/* (half a) BIO pair */ 104296341Sdelphij# define BIO_TYPE_LINEBUFFER (20|0x0200)/* filter */ 105296341Sdelphij# define BIO_TYPE_DGRAM (21|0x0400|0x0100) 106296341Sdelphij# ifndef OPENSSL_NO_SCTP 107296341Sdelphij# define BIO_TYPE_DGRAM_SCTP (24|0x0400|0x0100) 108296341Sdelphij# endif 109296341Sdelphij# define BIO_TYPE_ASN1 (22|0x0200)/* filter */ 110296341Sdelphij# define BIO_TYPE_COMP (23|0x0200)/* filter */ 11155714Skris 112296341Sdelphij# define BIO_TYPE_DESCRIPTOR 0x0100/* socket, fd, connect or accept */ 113296341Sdelphij# define BIO_TYPE_FILTER 0x0200 114296341Sdelphij# define BIO_TYPE_SOURCE_SINK 0x0400 11555714Skris 116296341Sdelphij/* 117296341Sdelphij * BIO_FILENAME_READ|BIO_CLOSE to open or close on free. 118296341Sdelphij * BIO_set_fp(in,stdin,BIO_NOCLOSE); 119296341Sdelphij */ 120296341Sdelphij# define BIO_NOCLOSE 0x00 121296341Sdelphij# define BIO_CLOSE 0x01 12255714Skris 123296341Sdelphij/* 124296341Sdelphij * These are used in the following macros and are passed to BIO_ctrl() 125296341Sdelphij */ 126296341Sdelphij# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */ 127296341Sdelphij# define BIO_CTRL_EOF 2/* opt - are we at the eof */ 128296341Sdelphij# define BIO_CTRL_INFO 3/* opt - extra tit-bits */ 129296341Sdelphij# define BIO_CTRL_SET 4/* man - set the 'IO' type */ 130296341Sdelphij# define BIO_CTRL_GET 5/* man - get the 'IO' type */ 131296341Sdelphij# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */ 132296341Sdelphij# define BIO_CTRL_POP 7/* opt - internal, used to signify change */ 133296341Sdelphij# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */ 134296341Sdelphij# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */ 135296341Sdelphij# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */ 136296341Sdelphij# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */ 137296341Sdelphij# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */ 138296341Sdelphij# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */ 13955714Skris/* callback is int cb(BIO *bio,state,ret); */ 140296341Sdelphij# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */ 141296341Sdelphij# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */ 14255714Skris 143296341Sdelphij# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */ 14455714Skris 145160814Ssimon/* dgram BIO stuff */ 146296341Sdelphij# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */ 147296341Sdelphij# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected 148296341Sdelphij * socket to be passed in */ 149296341Sdelphij# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */ 150296341Sdelphij# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */ 151296341Sdelphij# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */ 152296341Sdelphij# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */ 153160814Ssimon 154296341Sdelphij# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */ 155296341Sdelphij# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */ 156296341Sdelphij 157160814Ssimon/* #ifdef IP_MTU_DISCOVER */ 158296341Sdelphij# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */ 159160814Ssimon/* #endif */ 160160814Ssimon 161296341Sdelphij# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */ 162296341Sdelphij# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 163296341Sdelphij# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */ 164296341Sdelphij# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU. 165296341Sdelphij * want to use this if asking 166296341Sdelphij * the kernel fails */ 167160814Ssimon 168296341Sdelphij# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was 169296341Sdelphij * exceed in the previous write 170296341Sdelphij * operation */ 171160814Ssimon 172296341Sdelphij# define BIO_CTRL_DGRAM_GET_PEER 46 173296341Sdelphij# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */ 174160814Ssimon 175296341Sdelphij# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout 176296341Sdelphij * to adjust socket timeouts */ 177160814Ssimon 178296341Sdelphij# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49 179279264Sdelphij 180296341Sdelphij# ifndef OPENSSL_NO_SCTP 181238405Sjkim/* SCTP stuff */ 182296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50 183296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51 184296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52 185296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53 186296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60 187296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61 188296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62 189296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63 190296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64 191296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65 192296341Sdelphij# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70 193296341Sdelphij# endif 194238405Sjkim 19555714Skris/* modifiers */ 196296341Sdelphij# define BIO_FP_READ 0x02 197296341Sdelphij# define BIO_FP_WRITE 0x04 198296341Sdelphij# define BIO_FP_APPEND 0x08 199296341Sdelphij# define BIO_FP_TEXT 0x10 20055714Skris 201296341Sdelphij# define BIO_FLAGS_READ 0x01 202296341Sdelphij# define BIO_FLAGS_WRITE 0x02 203296341Sdelphij# define BIO_FLAGS_IO_SPECIAL 0x04 204296341Sdelphij# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) 205296341Sdelphij# define BIO_FLAGS_SHOULD_RETRY 0x08 206296341Sdelphij# ifndef BIO_FLAGS_UPLINK 207296341Sdelphij/* 208296341Sdelphij * "UPLINK" flag denotes file descriptors provided by application. It 209296341Sdelphij * defaults to 0, as most platforms don't require UPLINK interface. 210296341Sdelphij */ 211296341Sdelphij# define BIO_FLAGS_UPLINK 0 212296341Sdelphij# endif 21355714Skris 21455714Skris/* Used in BIO_gethostbyname() */ 215296341Sdelphij# define BIO_GHBN_CTRL_HITS 1 216296341Sdelphij# define BIO_GHBN_CTRL_MISSES 2 217296341Sdelphij# define BIO_GHBN_CTRL_CACHE_SIZE 3 218296341Sdelphij# define BIO_GHBN_CTRL_GET_ENTRY 4 219296341Sdelphij# define BIO_GHBN_CTRL_FLUSH 5 22055714Skris 22155714Skris/* Mostly used in the SSL BIO */ 222296341Sdelphij/*- 223296341Sdelphij * Not used anymore 22455714Skris * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10 22555714Skris * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20 226296341Sdelphij * #define BIO_FLAGS_PROTOCOL_STARTUP 0x40 22755714Skris */ 22855714Skris 229296341Sdelphij# define BIO_FLAGS_BASE64_NO_NL 0x100 23055714Skris 231296341Sdelphij/* 232296341Sdelphij * This is used with memory BIOs: it means we shouldn't free up or change the 23359191Skris * data in any way. 23459191Skris */ 235296341Sdelphij# define BIO_FLAGS_MEM_RDONLY 0x200 23659191Skris 237167612Ssimontypedef struct bio_st BIO; 238167612Ssimon 239167612Ssimonvoid BIO_set_flags(BIO *b, int flags); 240296341Sdelphijint BIO_test_flags(const BIO *b, int flags); 241167612Ssimonvoid BIO_clear_flags(BIO *b, int flags); 242167612Ssimon 243296341Sdelphij# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) 244296341Sdelphij# define BIO_set_retry_special(b) \ 245296341Sdelphij BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) 246296341Sdelphij# define BIO_set_retry_read(b) \ 247296341Sdelphij BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) 248296341Sdelphij# define BIO_set_retry_write(b) \ 249296341Sdelphij BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) 25055714Skris 25155714Skris/* These are normally used internally in BIOs */ 252296341Sdelphij# define BIO_clear_retry_flags(b) \ 253296341Sdelphij BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) 254296341Sdelphij# define BIO_get_retry_flags(b) \ 255296341Sdelphij BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) 25655714Skris 25759191Skris/* These should be used by the application to tell why we should retry */ 258296341Sdelphij# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) 259296341Sdelphij# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) 260296341Sdelphij# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) 261296341Sdelphij# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) 262296341Sdelphij# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) 26355714Skris 264296341Sdelphij/* 265296341Sdelphij * The next three are used in conjunction with the BIO_should_io_special() 266296341Sdelphij * condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int 267296341Sdelphij * *reason); will walk the BIO stack and return the 'reason' for the special 268296341Sdelphij * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return 269296341Sdelphij * the code. 270296341Sdelphij */ 271296341Sdelphij/* 272296341Sdelphij * Returned from the SSL bio when the certificate retrieval code had an error 273296341Sdelphij */ 274296341Sdelphij# define BIO_RR_SSL_X509_LOOKUP 0x01 27555714Skris/* Returned from the connect BIO when a connect would have blocked */ 276296341Sdelphij# define BIO_RR_CONNECT 0x02 277109998Smarkm/* Returned from the accept BIO when an accept would have blocked */ 278296341Sdelphij# define BIO_RR_ACCEPT 0x03 27955714Skris 28055714Skris/* These are passed by the BIO callback */ 281296341Sdelphij# define BIO_CB_FREE 0x01 282296341Sdelphij# define BIO_CB_READ 0x02 283296341Sdelphij# define BIO_CB_WRITE 0x03 284296341Sdelphij# define BIO_CB_PUTS 0x04 285296341Sdelphij# define BIO_CB_GETS 0x05 286296341Sdelphij# define BIO_CB_CTRL 0x06 28755714Skris 288296341Sdelphij/* 289296341Sdelphij * The callback is called before and after the underling operation, The 290296341Sdelphij * BIO_CB_RETURN flag indicates if it is after the call 291296341Sdelphij */ 292296341Sdelphij# define BIO_CB_RETURN 0x80 293296341Sdelphij# define BIO_CB_return(a) ((a)|BIO_CB_RETURN) 294296341Sdelphij# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) 295296341Sdelphij# define BIO_cb_post(a) ((a)&BIO_CB_RETURN) 29655714Skris 297296341Sdelphijlong (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *, 298296341Sdelphij int, long, long); 299296341Sdelphijvoid BIO_set_callback(BIO *b, 300296341Sdelphij long (*callback) (struct bio_st *, int, const char *, 301296341Sdelphij int, long, long)); 302167612Ssimonchar *BIO_get_callback_arg(const BIO *b); 303167612Ssimonvoid BIO_set_callback_arg(BIO *b, char *arg); 30455714Skris 305296341Sdelphijconst char *BIO_method_name(const BIO *b); 306167612Ssimonint BIO_method_type(const BIO *b); 30768651Skris 308296341Sdelphijtypedef void bio_info_cb (struct bio_st *, int, const char *, int, long, 309296341Sdelphij long); 31068651Skris 311296341Sdelphijtypedef struct bio_method_st { 312296341Sdelphij int type; 313296341Sdelphij const char *name; 314296341Sdelphij int (*bwrite) (BIO *, const char *, int); 315296341Sdelphij int (*bread) (BIO *, char *, int); 316296341Sdelphij int (*bputs) (BIO *, const char *); 317296341Sdelphij int (*bgets) (BIO *, char *, int); 318296341Sdelphij long (*ctrl) (BIO *, int, long, void *); 319296341Sdelphij int (*create) (BIO *); 320296341Sdelphij int (*destroy) (BIO *); 321296341Sdelphij long (*callback_ctrl) (BIO *, int, bio_info_cb *); 322296341Sdelphij} BIO_METHOD; 32355714Skris 324296341Sdelphijstruct bio_st { 325296341Sdelphij BIO_METHOD *method; 326296341Sdelphij /* bio, mode, argp, argi, argl, ret */ 327296341Sdelphij long (*callback) (struct bio_st *, int, const char *, int, long, long); 328296341Sdelphij char *cb_arg; /* first argument for the callback */ 329296341Sdelphij int init; 330296341Sdelphij int shutdown; 331296341Sdelphij int flags; /* extra storage */ 332296341Sdelphij int retry_reason; 333296341Sdelphij int num; 334296341Sdelphij void *ptr; 335296341Sdelphij struct bio_st *next_bio; /* used by filter BIOs */ 336296341Sdelphij struct bio_st *prev_bio; /* used by filter BIOs */ 337296341Sdelphij int references; 338296341Sdelphij unsigned long num_read; 339296341Sdelphij unsigned long num_write; 340296341Sdelphij CRYPTO_EX_DATA ex_data; 341296341Sdelphij}; 34255714Skris 34368651SkrisDECLARE_STACK_OF(BIO) 34468651Skris 345296341Sdelphijtypedef struct bio_f_buffer_ctx_struct { 346296341Sdelphij /*- 347296341Sdelphij * Buffers are setup like this: 348296341Sdelphij * 349296341Sdelphij * <---------------------- size -----------------------> 350296341Sdelphij * +---------------------------------------------------+ 351296341Sdelphij * | consumed | remaining | free space | 352296341Sdelphij * +---------------------------------------------------+ 353296341Sdelphij * <-- off --><------- len -------> 354296341Sdelphij */ 355296341Sdelphij /*- BIO *bio; *//* 356296341Sdelphij * this is now in the BIO struct 357296341Sdelphij */ 358296341Sdelphij int ibuf_size; /* how big is the input buffer */ 359296341Sdelphij int obuf_size; /* how big is the output buffer */ 360296341Sdelphij char *ibuf; /* the char array */ 361296341Sdelphij int ibuf_len; /* how many bytes are in it */ 362296341Sdelphij int ibuf_off; /* write/read offset */ 363296341Sdelphij char *obuf; /* the char array */ 364296341Sdelphij int obuf_len; /* how many bytes are in it */ 365296341Sdelphij int obuf_off; /* write/read offset */ 366296341Sdelphij} BIO_F_BUFFER_CTX; 367237657Sjkim 368238405Sjkim/* Prefix and suffix callback in ASN1 BIO */ 369296341Sdelphijtypedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen, 370296341Sdelphij void *parg); 371238405Sjkim 372296341Sdelphij# ifndef OPENSSL_NO_SCTP 373238405Sjkim/* SCTP parameter structs */ 374296341Sdelphijstruct bio_dgram_sctp_sndinfo { 375296341Sdelphij uint16_t snd_sid; 376296341Sdelphij uint16_t snd_flags; 377296341Sdelphij uint32_t snd_ppid; 378296341Sdelphij uint32_t snd_context; 379296341Sdelphij}; 380238405Sjkim 381296341Sdelphijstruct bio_dgram_sctp_rcvinfo { 382296341Sdelphij uint16_t rcv_sid; 383296341Sdelphij uint16_t rcv_ssn; 384296341Sdelphij uint16_t rcv_flags; 385296341Sdelphij uint32_t rcv_ppid; 386296341Sdelphij uint32_t rcv_tsn; 387296341Sdelphij uint32_t rcv_cumtsn; 388296341Sdelphij uint32_t rcv_context; 389296341Sdelphij}; 390238405Sjkim 391296341Sdelphijstruct bio_dgram_sctp_prinfo { 392296341Sdelphij uint16_t pr_policy; 393296341Sdelphij uint32_t pr_value; 394296341Sdelphij}; 395296341Sdelphij# endif 396238405Sjkim 39755714Skris/* connect BIO stuff */ 398296341Sdelphij# define BIO_CONN_S_BEFORE 1 399296341Sdelphij# define BIO_CONN_S_GET_IP 2 400296341Sdelphij# define BIO_CONN_S_GET_PORT 3 401296341Sdelphij# define BIO_CONN_S_CREATE_SOCKET 4 402296341Sdelphij# define BIO_CONN_S_CONNECT 5 403296341Sdelphij# define BIO_CONN_S_OK 6 404296341Sdelphij# define BIO_CONN_S_BLOCKED_CONNECT 7 405296341Sdelphij# define BIO_CONN_S_NBIO 8 406296341Sdelphij/* 407296341Sdelphij * #define BIO_CONN_get_param_hostname BIO_ctrl 408296341Sdelphij */ 40955714Skris 410296341Sdelphij# define BIO_C_SET_CONNECT 100 411296341Sdelphij# define BIO_C_DO_STATE_MACHINE 101 412296341Sdelphij# define BIO_C_SET_NBIO 102 413296341Sdelphij# define BIO_C_SET_PROXY_PARAM 103 414296341Sdelphij# define BIO_C_SET_FD 104 415296341Sdelphij# define BIO_C_GET_FD 105 416296341Sdelphij# define BIO_C_SET_FILE_PTR 106 417296341Sdelphij# define BIO_C_GET_FILE_PTR 107 418296341Sdelphij# define BIO_C_SET_FILENAME 108 419296341Sdelphij# define BIO_C_SET_SSL 109 420296341Sdelphij# define BIO_C_GET_SSL 110 421296341Sdelphij# define BIO_C_SET_MD 111 422296341Sdelphij# define BIO_C_GET_MD 112 423296341Sdelphij# define BIO_C_GET_CIPHER_STATUS 113 424296341Sdelphij# define BIO_C_SET_BUF_MEM 114 425296341Sdelphij# define BIO_C_GET_BUF_MEM_PTR 115 426296341Sdelphij# define BIO_C_GET_BUFF_NUM_LINES 116 427296341Sdelphij# define BIO_C_SET_BUFF_SIZE 117 428296341Sdelphij# define BIO_C_SET_ACCEPT 118 429296341Sdelphij# define BIO_C_SSL_MODE 119 430296341Sdelphij# define BIO_C_GET_MD_CTX 120 431296341Sdelphij# define BIO_C_GET_PROXY_PARAM 121 432296341Sdelphij# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */ 433296341Sdelphij# define BIO_C_GET_CONNECT 123 434296341Sdelphij# define BIO_C_GET_ACCEPT 124 435296341Sdelphij# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 436296341Sdelphij# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 437296341Sdelphij# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 438296341Sdelphij# define BIO_C_FILE_SEEK 128 439296341Sdelphij# define BIO_C_GET_CIPHER_CTX 129 440296341Sdelphij# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input 441296341Sdelphij * value */ 442296341Sdelphij# define BIO_C_SET_BIND_MODE 131 443296341Sdelphij# define BIO_C_GET_BIND_MODE 132 444296341Sdelphij# define BIO_C_FILE_TELL 133 445296341Sdelphij# define BIO_C_GET_SOCKS 134 446296341Sdelphij# define BIO_C_SET_SOCKS 135 44755714Skris 448296341Sdelphij# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ 449296341Sdelphij# define BIO_C_GET_WRITE_BUF_SIZE 137 450296341Sdelphij# define BIO_C_MAKE_BIO_PAIR 138 451296341Sdelphij# define BIO_C_DESTROY_BIO_PAIR 139 452296341Sdelphij# define BIO_C_GET_WRITE_GUARANTEE 140 453296341Sdelphij# define BIO_C_GET_READ_REQUEST 141 454296341Sdelphij# define BIO_C_SHUTDOWN_WR 142 455296341Sdelphij# define BIO_C_NREAD0 143 456296341Sdelphij# define BIO_C_NREAD 144 457296341Sdelphij# define BIO_C_NWRITE0 145 458296341Sdelphij# define BIO_C_NWRITE 146 459296341Sdelphij# define BIO_C_RESET_READ_REQUEST 147 460296341Sdelphij# define BIO_C_SET_MD_CTX 148 46155714Skris 462296341Sdelphij# define BIO_C_SET_PREFIX 149 463296341Sdelphij# define BIO_C_GET_PREFIX 150 464296341Sdelphij# define BIO_C_SET_SUFFIX 151 465296341Sdelphij# define BIO_C_GET_SUFFIX 152 46655714Skris 467296341Sdelphij# define BIO_C_SET_EX_ARG 153 468296341Sdelphij# define BIO_C_GET_EX_ARG 154 469238405Sjkim 470296341Sdelphij# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) 471296341Sdelphij# define BIO_get_app_data(s) BIO_get_ex_data(s,0) 47255714Skris 47355714Skris/* BIO_s_connect() and BIO_s_socks4a_connect() */ 474296341Sdelphij# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) 475296341Sdelphij# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) 476296341Sdelphij# define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) 477296341Sdelphij# define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) 478296341Sdelphij# define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) 479296341Sdelphij# define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) 480296341Sdelphij# define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) 481296341Sdelphij# define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0) 48255714Skris 483296341Sdelphij# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) 48455714Skris 48555714Skris/* BIO_s_accept_socket() */ 486296341Sdelphij# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) 487296341Sdelphij# define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) 488296341Sdelphij/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ 489296341Sdelphij# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL) 490296341Sdelphij# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) 49155714Skris 492296341Sdelphij# define BIO_BIND_NORMAL 0 493296341Sdelphij# define BIO_BIND_REUSEADDR_IF_UNUSED 1 494296341Sdelphij# define BIO_BIND_REUSEADDR 2 495296341Sdelphij# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) 496296341Sdelphij# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) 49755714Skris 498296341Sdelphij# define BIO_do_connect(b) BIO_do_handshake(b) 499296341Sdelphij# define BIO_do_accept(b) BIO_do_handshake(b) 500296341Sdelphij# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) 50155714Skris 50255714Skris/* BIO_s_proxy_client() */ 503296341Sdelphij# define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) 504296341Sdelphij# define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) 50555714Skris/* BIO_set_nbio(b,n) */ 506296341Sdelphij# define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) 50755714Skris/* BIO *BIO_get_filter_bio(BIO *bio); */ 508296341Sdelphij# define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) 509296341Sdelphij# define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) 510296341Sdelphij# define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) 51155714Skris 512296341Sdelphij# define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) 513296341Sdelphij# define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) 514296341Sdelphij# define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) 515296341Sdelphij# define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) 51655714Skris 517296341Sdelphij# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) 518296341Sdelphij# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) 51955714Skris 520296341Sdelphij# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) 521296341Sdelphij# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) 52255714Skris 523296341Sdelphij# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) 524296341Sdelphij# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) 52555714Skris 526296341Sdelphij/* 527296341Sdelphij * name is cast to lose const, but might be better to route through a 528296341Sdelphij * function so we can do it safely 529296341Sdelphij */ 530296341Sdelphij# ifdef CONST_STRICT 531296341Sdelphij/* 532296341Sdelphij * If you are wondering why this isn't defined, its because CONST_STRICT is 53355714Skris * purely a compile-time kludge to allow const to be checked. 53455714Skris */ 535296341Sdelphijint BIO_read_filename(BIO *b, const char *name); 536296341Sdelphij# else 537296341Sdelphij# define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ 538296341Sdelphij BIO_CLOSE|BIO_FP_READ,(char *)name) 539296341Sdelphij# endif 540296341Sdelphij# define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ 541296341Sdelphij BIO_CLOSE|BIO_FP_WRITE,name) 542296341Sdelphij# define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ 543296341Sdelphij BIO_CLOSE|BIO_FP_APPEND,name) 544296341Sdelphij# define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ 545296341Sdelphij BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) 54655714Skris 547296341Sdelphij/* 548296341Sdelphij * WARNING WARNING, this ups the reference count on the read bio of the SSL 549296341Sdelphij * structure. This is because the ssl read BIO is now pointed to by the 550296341Sdelphij * next_bio field in the bio. So when you free the BIO, make sure you are 551296341Sdelphij * doing a BIO_free_all() to catch the underlying BIO. 552296341Sdelphij */ 553296341Sdelphij# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) 554296341Sdelphij# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) 555296341Sdelphij# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) 556296341Sdelphij# define BIO_set_ssl_renegotiate_bytes(b,num) \ 557296341Sdelphij BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); 558296341Sdelphij# define BIO_get_num_renegotiates(b) \ 559296341Sdelphij BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL); 560296341Sdelphij# define BIO_set_ssl_renegotiate_timeout(b,seconds) \ 561296341Sdelphij BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); 56255714Skris 56355714Skris/* defined in evp.h */ 564296341Sdelphij/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ 56555714Skris 566296341Sdelphij# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) 567296341Sdelphij# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) 568296341Sdelphij# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) 569296341Sdelphij# define BIO_set_mem_eof_return(b,v) \ 570296341Sdelphij BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) 57155714Skris 57255714Skris/* For the BIO_f_buffer() type */ 573296341Sdelphij# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) 574296341Sdelphij# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) 575296341Sdelphij# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) 576296341Sdelphij# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) 577296341Sdelphij# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) 57855714Skris 57955714Skris/* Don't use the next one unless you know what you are doing :-) */ 580296341Sdelphij# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) 58155714Skris 582296341Sdelphij# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) 583296341Sdelphij# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) 584296341Sdelphij# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) 585296341Sdelphij# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) 586296341Sdelphij# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) 587296341Sdelphij# define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) 58855714Skris/* ...pending macros have inappropriate return type */ 58955714Skrissize_t BIO_ctrl_pending(BIO *b); 59055714Skrissize_t BIO_ctrl_wpending(BIO *b); 591296341Sdelphij# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) 592296341Sdelphij# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ 593296341Sdelphij cbp) 594296341Sdelphij# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) 59555714Skris 59655714Skris/* For the BIO_f_buffer() type */ 597296341Sdelphij# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) 59855714Skris 59955714Skris/* For BIO_s_bio() */ 600296341Sdelphij# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) 601296341Sdelphij# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) 602296341Sdelphij# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) 603296341Sdelphij# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) 604296341Sdelphij# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) 60555714Skris/* macros with inappropriate type -- but ...pending macros use int too: */ 606296341Sdelphij# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) 607296341Sdelphij# define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) 60855714Skrissize_t BIO_ctrl_get_write_guarantee(BIO *b); 60955714Skrissize_t BIO_ctrl_get_read_request(BIO *b); 61059191Skrisint BIO_ctrl_reset_read_request(BIO *b); 61155714Skris 612160814Ssimon/* ctrl macros for dgram */ 613296341Sdelphij# define BIO_ctrl_dgram_connect(b,peer) \ 614160814Ssimon (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) 615296341Sdelphij# define BIO_ctrl_set_connected(b, state, peer) \ 616160814Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) 617296341Sdelphij# define BIO_dgram_recv_timedout(b) \ 618160814Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) 619296341Sdelphij# define BIO_dgram_send_timedout(b) \ 620160814Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) 621296341Sdelphij# define BIO_dgram_get_peer(b,peer) \ 622205128Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer) 623296341Sdelphij# define BIO_dgram_set_peer(b,peer) \ 624160814Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) 625296341Sdelphij# define BIO_dgram_get_mtu_overhead(b) \ 626279264Sdelphij (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL) 627160814Ssimon 62855714Skris/* These two aren't currently implemented */ 62955714Skris/* int BIO_get_ex_num(BIO *bio); */ 63055714Skris/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ 631296341Sdelphijint BIO_set_ex_data(BIO *bio, int idx, void *data); 632296341Sdelphijvoid *BIO_get_ex_data(BIO *bio, int idx); 63359191Skrisint BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 634296341Sdelphij CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 63559191Skrisunsigned long BIO_number_read(BIO *bio); 63659191Skrisunsigned long BIO_number_written(BIO *bio); 63755714Skris 638238405Sjkim/* For BIO_f_asn1() */ 639238405Sjkimint BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, 640296341Sdelphij asn1_ps_func *prefix_free); 641238405Sjkimint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, 642296341Sdelphij asn1_ps_func **pprefix_free); 643238405Sjkimint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, 644296341Sdelphij asn1_ps_func *suffix_free); 645238405Sjkimint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, 646296341Sdelphij asn1_ps_func **psuffix_free); 647238405Sjkim 648109998Smarkm# ifndef OPENSSL_NO_FP_API 649296341SdelphijBIO_METHOD *BIO_s_file(void); 65055714SkrisBIO *BIO_new_file(const char *filename, const char *mode); 65155714SkrisBIO *BIO_new_fp(FILE *stream, int close_flag); 652296341Sdelphij# define BIO_s_file_internal BIO_s_file 65368651Skris# endif 654296341SdelphijBIO *BIO_new(BIO_METHOD *type); 655296341Sdelphijint BIO_set(BIO *a, BIO_METHOD *type); 656296341Sdelphijint BIO_free(BIO *a); 657296341Sdelphijvoid BIO_vfree(BIO *a); 658296341Sdelphijint BIO_read(BIO *b, void *data, int len); 659296341Sdelphijint BIO_gets(BIO *bp, char *buf, int size); 660296341Sdelphijint BIO_write(BIO *b, const void *data, int len); 661296341Sdelphijint BIO_puts(BIO *bp, const char *buf); 662296341Sdelphijint BIO_indent(BIO *b, int indent, int max); 663296341Sdelphijlong BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); 664296341Sdelphijlong BIO_callback_ctrl(BIO *b, int cmd, 665296341Sdelphij void (*fp) (struct bio_st *, int, const char *, int, 666296341Sdelphij long, long)); 667296341Sdelphijchar *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); 668296341Sdelphijlong BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); 669296341SdelphijBIO *BIO_push(BIO *b, BIO *append); 670296341SdelphijBIO *BIO_pop(BIO *b); 671296341Sdelphijvoid BIO_free_all(BIO *a); 672296341SdelphijBIO *BIO_find_type(BIO *b, int bio_type); 673296341SdelphijBIO *BIO_next(BIO *b); 674296341SdelphijBIO *BIO_get_retry_BIO(BIO *bio, int *reason); 675296341Sdelphijint BIO_get_retry_reason(BIO *bio); 676296341SdelphijBIO *BIO_dup_chain(BIO *in); 67755714Skris 67859191Skrisint BIO_nread0(BIO *bio, char **buf); 67959191Skrisint BIO_nread(BIO *bio, char **buf, int num); 68059191Skrisint BIO_nwrite0(BIO *bio, char **buf); 68159191Skrisint BIO_nwrite(BIO *bio, char **buf, int num); 68259191Skris 683296341Sdelphijlong BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, 684296341Sdelphij long argl, long ret); 68555714Skris 68655714SkrisBIO_METHOD *BIO_s_mem(void); 68759191SkrisBIO *BIO_new_mem_buf(void *buf, int len); 68855714SkrisBIO_METHOD *BIO_s_socket(void); 68955714SkrisBIO_METHOD *BIO_s_connect(void); 69055714SkrisBIO_METHOD *BIO_s_accept(void); 69155714SkrisBIO_METHOD *BIO_s_fd(void); 692296341Sdelphij# ifndef OPENSSL_SYS_OS2 69355714SkrisBIO_METHOD *BIO_s_log(void); 694296341Sdelphij# endif 69555714SkrisBIO_METHOD *BIO_s_bio(void); 69655714SkrisBIO_METHOD *BIO_s_null(void); 69755714SkrisBIO_METHOD *BIO_f_null(void); 69855714SkrisBIO_METHOD *BIO_f_buffer(void); 699296341Sdelphij# ifdef OPENSSL_SYS_VMS 70068651SkrisBIO_METHOD *BIO_f_linebuffer(void); 701296341Sdelphij# endif 70255714SkrisBIO_METHOD *BIO_f_nbio_test(void); 703296341Sdelphij# ifndef OPENSSL_NO_DGRAM 704160814SsimonBIO_METHOD *BIO_s_datagram(void); 705296341Sdelphij# ifndef OPENSSL_NO_SCTP 706238405SjkimBIO_METHOD *BIO_s_datagram_sctp(void); 707296341Sdelphij# endif 708296341Sdelphij# endif 709160814Ssimon 71055714Skris/* BIO_METHOD *BIO_f_ber(void); */ 71155714Skris 71255714Skrisint BIO_sock_should_retry(int i); 71355714Skrisint BIO_sock_non_fatal_error(int error); 714160814Ssimonint BIO_dgram_non_fatal_error(int error); 715160814Ssimon 71655714Skrisint BIO_fd_should_retry(int i); 71755714Skrisint BIO_fd_non_fatal_error(int error); 718296341Sdelphijint BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u), 719296341Sdelphij void *u, const char *s, int len); 720296341Sdelphijint BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), 721296341Sdelphij void *u, const char *s, int len, int indent); 722296341Sdelphijint BIO_dump(BIO *b, const char *bytes, int len); 723296341Sdelphijint BIO_dump_indent(BIO *b, const char *bytes, int len, int indent); 724296341Sdelphij# ifndef OPENSSL_NO_FP_API 725160814Ssimonint BIO_dump_fp(FILE *fp, const char *s, int len); 726160814Ssimonint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); 727296341Sdelphij# endif 72855714Skrisstruct hostent *BIO_gethostbyname(const char *name); 729296341Sdelphij/*- 730296341Sdelphij * We might want a thread-safe interface too: 73155714Skris * struct hostent *BIO_gethostbyname_r(const char *name, 73255714Skris * struct hostent *result, void *buffer, size_t buflen); 73355714Skris * or something similar (caller allocates a struct hostent, 73455714Skris * pointed to by "result", and additional buffer space for the various 73555714Skris * substructures; if the buffer does not suffice, NULL is returned 73655714Skris * and an appropriate error code is set). 73755714Skris */ 73855714Skrisint BIO_sock_error(int sock); 739111147Snectarint BIO_socket_ioctl(int fd, long type, void *arg); 740296341Sdelphijint BIO_socket_nbio(int fd, int mode); 74155714Skrisint BIO_get_port(const char *str, unsigned short *port_ptr); 74255714Skrisint BIO_get_host_ip(const char *str, unsigned char *ip); 743296341Sdelphijint BIO_get_accept_socket(char *host_port, int mode); 744296341Sdelphijint BIO_accept(int sock, char **ip_port); 745296341Sdelphijint BIO_sock_init(void); 74655714Skrisvoid BIO_sock_cleanup(void); 747296341Sdelphijint BIO_set_tcp_ndelay(int sock, int turn_on); 74855714Skris 74955714SkrisBIO *BIO_new_socket(int sock, int close_flag); 750160814SsimonBIO *BIO_new_dgram(int fd, int close_flag); 751296341Sdelphij# ifndef OPENSSL_NO_SCTP 752238405SjkimBIO *BIO_new_dgram_sctp(int fd, int close_flag); 753238405Sjkimint BIO_dgram_is_sctp(BIO *bio); 754238405Sjkimint BIO_dgram_sctp_notification_cb(BIO *b, 755296341Sdelphij void (*handle_notifications) (BIO *bio, 756296341Sdelphij void 757296341Sdelphij *context, 758296341Sdelphij void *buf), 759238405Sjkim void *context); 760238405Sjkimint BIO_dgram_sctp_wait_for_dry(BIO *b); 761238405Sjkimint BIO_dgram_sctp_msg_waiting(BIO *b); 762296341Sdelphij# endif 76355714SkrisBIO *BIO_new_fd(int fd, int close_flag); 76455714SkrisBIO *BIO_new_connect(char *host_port); 76555714SkrisBIO *BIO_new_accept(char *host_port); 76655714Skris 76755714Skrisint BIO_new_bio_pair(BIO **bio1, size_t writebuf1, 768296341Sdelphij BIO **bio2, size_t writebuf2); 769296341Sdelphij/* 770296341Sdelphij * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. 771296341Sdelphij * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default 772296341Sdelphij * value. 77355714Skris */ 77455714Skris 77555714Skrisvoid BIO_copy_next_retry(BIO *b); 77655714Skris 777296341Sdelphij/* 778296341Sdelphij * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); 779296341Sdelphij */ 78055714Skris 781296341Sdelphij# ifdef __GNUC__ 782160814Ssimon# define __bio_h__attr__ __attribute__ 783296341Sdelphij# else 784160814Ssimon# define __bio_h__attr__(x) 785296341Sdelphij# endif 786160814Ssimonint BIO_printf(BIO *bio, const char *format, ...) 787296341Sdelphij__bio_h__attr__((__format__(__printf__, 2, 3))); 788160814Ssimonint BIO_vprintf(BIO *bio, const char *format, va_list args) 789296341Sdelphij__bio_h__attr__((__format__(__printf__, 2, 0))); 790160814Ssimonint BIO_snprintf(char *buf, size_t n, const char *format, ...) 791296341Sdelphij__bio_h__attr__((__format__(__printf__, 3, 4))); 792160814Ssimonint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) 793296341Sdelphij__bio_h__attr__((__format__(__printf__, 3, 0))); 794296341Sdelphij# undef __bio_h__attr__ 79555714Skris 79655714Skris/* BEGIN ERROR CODES */ 797296341Sdelphij/* 798296341Sdelphij * The following lines are auto generated by the script mkerr.pl. Any changes 79955714Skris * made after this point may be overwritten when the script is next run. 80055714Skris */ 80189837Skrisvoid ERR_load_BIO_strings(void); 80255714Skris 80355714Skris/* Error codes for the BIO functions. */ 80455714Skris 80555714Skris/* Function codes. */ 806296341Sdelphij# define BIO_F_ACPT_STATE 100 807296341Sdelphij# define BIO_F_BIO_ACCEPT 101 808296341Sdelphij# define BIO_F_BIO_BER_GET_HEADER 102 809296341Sdelphij# define BIO_F_BIO_CALLBACK_CTRL 131 810296341Sdelphij# define BIO_F_BIO_CTRL 103 811296341Sdelphij# define BIO_F_BIO_GETHOSTBYNAME 120 812296341Sdelphij# define BIO_F_BIO_GETS 104 813296341Sdelphij# define BIO_F_BIO_GET_ACCEPT_SOCKET 105 814296341Sdelphij# define BIO_F_BIO_GET_HOST_IP 106 815296341Sdelphij# define BIO_F_BIO_GET_PORT 107 816296341Sdelphij# define BIO_F_BIO_MAKE_PAIR 121 817296341Sdelphij# define BIO_F_BIO_NEW 108 818296341Sdelphij# define BIO_F_BIO_NEW_FILE 109 819296341Sdelphij# define BIO_F_BIO_NEW_MEM_BUF 126 820296341Sdelphij# define BIO_F_BIO_NREAD 123 821296341Sdelphij# define BIO_F_BIO_NREAD0 124 822296341Sdelphij# define BIO_F_BIO_NWRITE 125 823296341Sdelphij# define BIO_F_BIO_NWRITE0 122 824296341Sdelphij# define BIO_F_BIO_PUTS 110 825296341Sdelphij# define BIO_F_BIO_READ 111 826296341Sdelphij# define BIO_F_BIO_SOCK_INIT 112 827296341Sdelphij# define BIO_F_BIO_WRITE 113 828296341Sdelphij# define BIO_F_BUFFER_CTRL 114 829296341Sdelphij# define BIO_F_CONN_CTRL 127 830296341Sdelphij# define BIO_F_CONN_STATE 115 831296341Sdelphij# define BIO_F_DGRAM_SCTP_READ 132 832296341Sdelphij# define BIO_F_DGRAM_SCTP_WRITE 133 833296341Sdelphij# define BIO_F_FILE_CTRL 116 834296341Sdelphij# define BIO_F_FILE_READ 130 835296341Sdelphij# define BIO_F_LINEBUFFER_CTRL 129 836296341Sdelphij# define BIO_F_MEM_READ 128 837296341Sdelphij# define BIO_F_MEM_WRITE 117 838296341Sdelphij# define BIO_F_SSL_NEW 118 839296341Sdelphij# define BIO_F_WSASTARTUP 119 84055714Skris 84155714Skris/* Reason codes. */ 842296341Sdelphij# define BIO_R_ACCEPT_ERROR 100 843296341Sdelphij# define BIO_R_BAD_FOPEN_MODE 101 844296341Sdelphij# define BIO_R_BAD_HOSTNAME_LOOKUP 102 845296341Sdelphij# define BIO_R_BROKEN_PIPE 124 846296341Sdelphij# define BIO_R_CONNECT_ERROR 103 847296341Sdelphij# define BIO_R_EOF_ON_MEMORY_BIO 127 848296341Sdelphij# define BIO_R_ERROR_SETTING_NBIO 104 849296341Sdelphij# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 850296341Sdelphij# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 851296341Sdelphij# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 852296341Sdelphij# define BIO_R_INVALID_ARGUMENT 125 853296341Sdelphij# define BIO_R_INVALID_IP_ADDRESS 108 854296341Sdelphij# define BIO_R_IN_USE 123 855296341Sdelphij# define BIO_R_KEEPALIVE 109 856296341Sdelphij# define BIO_R_NBIO_CONNECT_ERROR 110 857296341Sdelphij# define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 858296341Sdelphij# define BIO_R_NO_HOSTNAME_SPECIFIED 112 859296341Sdelphij# define BIO_R_NO_PORT_DEFINED 113 860296341Sdelphij# define BIO_R_NO_PORT_SPECIFIED 114 861296341Sdelphij# define BIO_R_NO_SUCH_FILE 128 862296341Sdelphij# define BIO_R_NULL_PARAMETER 115 863296341Sdelphij# define BIO_R_TAG_MISMATCH 116 864296341Sdelphij# define BIO_R_UNABLE_TO_BIND_SOCKET 117 865296341Sdelphij# define BIO_R_UNABLE_TO_CREATE_SOCKET 118 866296341Sdelphij# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 867296341Sdelphij# define BIO_R_UNINITIALIZED 120 868296341Sdelphij# define BIO_R_UNSUPPORTED_METHOD 121 869296341Sdelphij# define BIO_R_WRITE_TO_READ_ONLY_BIO 126 870296341Sdelphij# define BIO_R_WSASTARTUP 122 87155714Skris 87255714Skris#ifdef __cplusplus 87355714Skris} 87455714Skris#endif 87555714Skris#endif 876