bio.h revision 285329
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. 8280297Sjkim * 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). 15280297Sjkim * 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. 22280297Sjkim * 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 :-). 37280297Sjkim * 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)" 40280297Sjkim * 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. 52280297Sjkim * 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 60280297Sjkim# define HEADER_BIO_H 6155714Skris 62280297Sjkim# include <openssl/e_os2.h> 63160814Ssimon 64280297Sjkim# ifndef OPENSSL_NO_FP_API 65280297Sjkim# include <stdio.h> 66280297Sjkim# endif 67280297Sjkim# include <stdarg.h> 6868651Skris 69280297Sjkim# include <openssl/crypto.h> 7068651Skris 71280297Sjkim# ifndef OPENSSL_NO_SCTP 72280297Sjkim# ifndef OPENSSL_SYS_VMS 73280297Sjkim# include <stdint.h> 74280297Sjkim# else 75280297Sjkim# include <inttypes.h> 76280297Sjkim# endif 77238405Sjkim# endif 78238405Sjkim 7955714Skris#ifdef __cplusplus 8055714Skrisextern "C" { 8155714Skris#endif 8255714Skris 8355714Skris/* These are the 'types' of BIOs */ 84280297Sjkim# define BIO_TYPE_NONE 0 85280297Sjkim# define BIO_TYPE_MEM (1|0x0400) 86280297Sjkim# define BIO_TYPE_FILE (2|0x0400) 8755714Skris 88280297Sjkim# define BIO_TYPE_FD (4|0x0400|0x0100) 89280297Sjkim# define BIO_TYPE_SOCKET (5|0x0400|0x0100) 90280297Sjkim# define BIO_TYPE_NULL (6|0x0400) 91280297Sjkim# define BIO_TYPE_SSL (7|0x0200) 92280297Sjkim# define BIO_TYPE_MD (8|0x0200)/* passive filter */ 93280297Sjkim# define BIO_TYPE_BUFFER (9|0x0200)/* filter */ 94280297Sjkim# define BIO_TYPE_CIPHER (10|0x0200)/* filter */ 95280297Sjkim# define BIO_TYPE_BASE64 (11|0x0200)/* filter */ 96280297Sjkim# define BIO_TYPE_CONNECT (12|0x0400|0x0100)/* socket - connect */ 97280297Sjkim# define BIO_TYPE_ACCEPT (13|0x0400|0x0100)/* socket for accept */ 98280297Sjkim# define BIO_TYPE_PROXY_CLIENT (14|0x0200)/* client proxy BIO */ 99280297Sjkim# define BIO_TYPE_PROXY_SERVER (15|0x0200)/* server proxy BIO */ 100280297Sjkim# define BIO_TYPE_NBIO_TEST (16|0x0200)/* server proxy BIO */ 101280297Sjkim# define BIO_TYPE_NULL_FILTER (17|0x0200) 102280297Sjkim# define BIO_TYPE_BER (18|0x0200)/* BER -> bin filter */ 103280297Sjkim# define BIO_TYPE_BIO (19|0x0400)/* (half a) BIO pair */ 104280297Sjkim# define BIO_TYPE_LINEBUFFER (20|0x0200)/* filter */ 105280297Sjkim# define BIO_TYPE_DGRAM (21|0x0400|0x0100) 106280297Sjkim# ifndef OPENSSL_NO_SCTP 107280297Sjkim# define BIO_TYPE_DGRAM_SCTP (24|0x0400|0x0100) 108280297Sjkim# endif 109280297Sjkim# define BIO_TYPE_ASN1 (22|0x0200)/* filter */ 110280297Sjkim# define BIO_TYPE_COMP (23|0x0200)/* filter */ 11155714Skris 112280297Sjkim# define BIO_TYPE_DESCRIPTOR 0x0100/* socket, fd, connect or accept */ 113280297Sjkim# define BIO_TYPE_FILTER 0x0200 114280297Sjkim# define BIO_TYPE_SOURCE_SINK 0x0400 11555714Skris 116280297Sjkim/* 117280297Sjkim * BIO_FILENAME_READ|BIO_CLOSE to open or close on free. 118280297Sjkim * BIO_set_fp(in,stdin,BIO_NOCLOSE); 119280297Sjkim */ 120280297Sjkim# define BIO_NOCLOSE 0x00 121280297Sjkim# define BIO_CLOSE 0x01 12255714Skris 123280297Sjkim/* 124280297Sjkim * These are used in the following macros and are passed to BIO_ctrl() 125280297Sjkim */ 126280297Sjkim# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */ 127280297Sjkim# define BIO_CTRL_EOF 2/* opt - are we at the eof */ 128280297Sjkim# define BIO_CTRL_INFO 3/* opt - extra tit-bits */ 129280297Sjkim# define BIO_CTRL_SET 4/* man - set the 'IO' type */ 130280297Sjkim# define BIO_CTRL_GET 5/* man - get the 'IO' type */ 131280297Sjkim# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */ 132280297Sjkim# define BIO_CTRL_POP 7/* opt - internal, used to signify change */ 133280297Sjkim# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */ 134280297Sjkim# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */ 135280297Sjkim# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */ 136280297Sjkim# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */ 137280297Sjkim# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */ 138280297Sjkim# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */ 13955714Skris/* callback is int cb(BIO *bio,state,ret); */ 140280297Sjkim# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */ 141280297Sjkim# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */ 14255714Skris 143280297Sjkim# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */ 14455714Skris 145160814Ssimon/* dgram BIO stuff */ 146280297Sjkim# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */ 147280297Sjkim# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected 148280297Sjkim * socket to be passed in */ 149280297Sjkim# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */ 150280297Sjkim# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */ 151280297Sjkim# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */ 152280297Sjkim# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */ 153160814Ssimon 154280297Sjkim# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */ 155280297Sjkim# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */ 156280297Sjkim 157160814Ssimon/* #ifdef IP_MTU_DISCOVER */ 158280297Sjkim# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */ 159160814Ssimon/* #endif */ 160160814Ssimon 161280297Sjkim# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */ 162280297Sjkim# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 163280297Sjkim# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */ 164280297Sjkim# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU. 165280297Sjkim * want to use this if asking 166280297Sjkim * the kernel fails */ 167160814Ssimon 168280297Sjkim# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was 169280297Sjkim * exceed in the previous write 170280297Sjkim * operation */ 171160814Ssimon 172280297Sjkim# define BIO_CTRL_DGRAM_GET_PEER 46 173280297Sjkim# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */ 174160814Ssimon 175280297Sjkim# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout 176280297Sjkim * to adjust socket timeouts */ 177160814Ssimon 178280297Sjkim# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49 179276861Sjkim 180280297Sjkim# ifndef OPENSSL_NO_SCTP 181238405Sjkim/* SCTP stuff */ 182280297Sjkim# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50 183280297Sjkim# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51 184280297Sjkim# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52 185280297Sjkim# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53 186280297Sjkim# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60 187280297Sjkim# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61 188280297Sjkim# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62 189280297Sjkim# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63 190280297Sjkim# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64 191280297Sjkim# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65 192280297Sjkim# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70 193280297Sjkim# endif 194238405Sjkim 19555714Skris/* modifiers */ 196280297Sjkim# define BIO_FP_READ 0x02 197280297Sjkim# define BIO_FP_WRITE 0x04 198280297Sjkim# define BIO_FP_APPEND 0x08 199280297Sjkim# define BIO_FP_TEXT 0x10 20055714Skris 201280297Sjkim# define BIO_FLAGS_READ 0x01 202280297Sjkim# define BIO_FLAGS_WRITE 0x02 203280297Sjkim# define BIO_FLAGS_IO_SPECIAL 0x04 204280297Sjkim# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) 205280297Sjkim# define BIO_FLAGS_SHOULD_RETRY 0x08 206280297Sjkim# ifndef BIO_FLAGS_UPLINK 207280297Sjkim/* 208280297Sjkim * "UPLINK" flag denotes file descriptors provided by application. It 209280297Sjkim * defaults to 0, as most platforms don't require UPLINK interface. 210280297Sjkim */ 211280297Sjkim# define BIO_FLAGS_UPLINK 0 212280297Sjkim# endif 21355714Skris 21455714Skris/* Used in BIO_gethostbyname() */ 215280297Sjkim# define BIO_GHBN_CTRL_HITS 1 216280297Sjkim# define BIO_GHBN_CTRL_MISSES 2 217280297Sjkim# define BIO_GHBN_CTRL_CACHE_SIZE 3 218280297Sjkim# define BIO_GHBN_CTRL_GET_ENTRY 4 219280297Sjkim# define BIO_GHBN_CTRL_FLUSH 5 22055714Skris 22155714Skris/* Mostly used in the SSL BIO */ 222280297Sjkim/*- 223280297Sjkim * Not used anymore 22455714Skris * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10 22555714Skris * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20 226280297Sjkim * #define BIO_FLAGS_PROTOCOL_STARTUP 0x40 22755714Skris */ 22855714Skris 229280297Sjkim# define BIO_FLAGS_BASE64_NO_NL 0x100 23055714Skris 231280297Sjkim/* 232280297Sjkim * This is used with memory BIOs: it means we shouldn't free up or change the 23359191Skris * data in any way. 23459191Skris */ 235280297Sjkim# define BIO_FLAGS_MEM_RDONLY 0x200 23659191Skris 237167612Ssimontypedef struct bio_st BIO; 238167612Ssimon 239167612Ssimonvoid BIO_set_flags(BIO *b, int flags); 240280297Sjkimint BIO_test_flags(const BIO *b, int flags); 241167612Ssimonvoid BIO_clear_flags(BIO *b, int flags); 242167612Ssimon 243280297Sjkim# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) 244280297Sjkim# define BIO_set_retry_special(b) \ 245280297Sjkim BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) 246280297Sjkim# define BIO_set_retry_read(b) \ 247280297Sjkim BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) 248280297Sjkim# define BIO_set_retry_write(b) \ 249280297Sjkim BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) 25055714Skris 25155714Skris/* These are normally used internally in BIOs */ 252280297Sjkim# define BIO_clear_retry_flags(b) \ 253280297Sjkim BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) 254280297Sjkim# define BIO_get_retry_flags(b) \ 255280297Sjkim 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 */ 258280297Sjkim# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) 259280297Sjkim# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) 260280297Sjkim# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) 261280297Sjkim# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) 262280297Sjkim# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) 26355714Skris 264280297Sjkim/* 265280297Sjkim * The next three are used in conjunction with the BIO_should_io_special() 266280297Sjkim * condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int 267280297Sjkim * *reason); will walk the BIO stack and return the 'reason' for the special 268280297Sjkim * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return 269280297Sjkim * the code. 270280297Sjkim */ 271280297Sjkim/* 272280297Sjkim * Returned from the SSL bio when the certificate retrieval code had an error 273280297Sjkim */ 274280297Sjkim# define BIO_RR_SSL_X509_LOOKUP 0x01 27555714Skris/* Returned from the connect BIO when a connect would have blocked */ 276280297Sjkim# define BIO_RR_CONNECT 0x02 277109998Smarkm/* Returned from the accept BIO when an accept would have blocked */ 278280297Sjkim# define BIO_RR_ACCEPT 0x03 27955714Skris 28055714Skris/* These are passed by the BIO callback */ 281280297Sjkim# define BIO_CB_FREE 0x01 282280297Sjkim# define BIO_CB_READ 0x02 283280297Sjkim# define BIO_CB_WRITE 0x03 284280297Sjkim# define BIO_CB_PUTS 0x04 285280297Sjkim# define BIO_CB_GETS 0x05 286280297Sjkim# define BIO_CB_CTRL 0x06 28755714Skris 288280297Sjkim/* 289280297Sjkim * The callback is called before and after the underling operation, The 290280297Sjkim * BIO_CB_RETURN flag indicates if it is after the call 291280297Sjkim */ 292280297Sjkim# define BIO_CB_RETURN 0x80 293285329Sjkim# define BIO_CB_return(a) ((a)|BIO_CB_RETURN) 294280297Sjkim# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) 295280297Sjkim# define BIO_cb_post(a) ((a)&BIO_CB_RETURN) 29655714Skris 297280297Sjkimlong (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *, 298280297Sjkim int, long, long); 299280297Sjkimvoid BIO_set_callback(BIO *b, 300280297Sjkim long (*callback) (struct bio_st *, int, const char *, 301280297Sjkim int, long, long)); 302167612Ssimonchar *BIO_get_callback_arg(const BIO *b); 303167612Ssimonvoid BIO_set_callback_arg(BIO *b, char *arg); 30455714Skris 305280297Sjkimconst char *BIO_method_name(const BIO *b); 306167612Ssimonint BIO_method_type(const BIO *b); 30768651Skris 308280297Sjkimtypedef void bio_info_cb (struct bio_st *, int, const char *, int, long, 309280297Sjkim long); 31068651Skris 311280297Sjkimtypedef struct bio_method_st { 312280297Sjkim int type; 313280297Sjkim const char *name; 314280297Sjkim int (*bwrite) (BIO *, const char *, int); 315280297Sjkim int (*bread) (BIO *, char *, int); 316280297Sjkim int (*bputs) (BIO *, const char *); 317280297Sjkim int (*bgets) (BIO *, char *, int); 318280297Sjkim long (*ctrl) (BIO *, int, long, void *); 319280297Sjkim int (*create) (BIO *); 320280297Sjkim int (*destroy) (BIO *); 321280297Sjkim long (*callback_ctrl) (BIO *, int, bio_info_cb *); 322280297Sjkim} BIO_METHOD; 32355714Skris 324280297Sjkimstruct bio_st { 325280297Sjkim BIO_METHOD *method; 326280297Sjkim /* bio, mode, argp, argi, argl, ret */ 327280297Sjkim long (*callback) (struct bio_st *, int, const char *, int, long, long); 328280297Sjkim char *cb_arg; /* first argument for the callback */ 329280297Sjkim int init; 330280297Sjkim int shutdown; 331280297Sjkim int flags; /* extra storage */ 332280297Sjkim int retry_reason; 333280297Sjkim int num; 334280297Sjkim void *ptr; 335280297Sjkim struct bio_st *next_bio; /* used by filter BIOs */ 336280297Sjkim struct bio_st *prev_bio; /* used by filter BIOs */ 337280297Sjkim int references; 338280297Sjkim unsigned long num_read; 339280297Sjkim unsigned long num_write; 340280297Sjkim CRYPTO_EX_DATA ex_data; 341280297Sjkim}; 34255714Skris 34368651SkrisDECLARE_STACK_OF(BIO) 34468651Skris 345280297Sjkimtypedef struct bio_f_buffer_ctx_struct { 346280297Sjkim /*- 347280297Sjkim * Buffers are setup like this: 348280297Sjkim * 349280297Sjkim * <---------------------- size -----------------------> 350280297Sjkim * +---------------------------------------------------+ 351280297Sjkim * | consumed | remaining | free space | 352280297Sjkim * +---------------------------------------------------+ 353280297Sjkim * <-- off --><------- len -------> 354280297Sjkim */ 355280297Sjkim /*- BIO *bio; *//* 356280297Sjkim * this is now in the BIO struct 357280297Sjkim */ 358280297Sjkim int ibuf_size; /* how big is the input buffer */ 359280297Sjkim int obuf_size; /* how big is the output buffer */ 360280297Sjkim char *ibuf; /* the char array */ 361280297Sjkim int ibuf_len; /* how many bytes are in it */ 362280297Sjkim int ibuf_off; /* write/read offset */ 363280297Sjkim char *obuf; /* the char array */ 364280297Sjkim int obuf_len; /* how many bytes are in it */ 365280297Sjkim int obuf_off; /* write/read offset */ 366280297Sjkim} BIO_F_BUFFER_CTX; 367237657Sjkim 368238405Sjkim/* Prefix and suffix callback in ASN1 BIO */ 369280297Sjkimtypedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen, 370280297Sjkim void *parg); 371238405Sjkim 372280297Sjkim# ifndef OPENSSL_NO_SCTP 373238405Sjkim/* SCTP parameter structs */ 374280297Sjkimstruct bio_dgram_sctp_sndinfo { 375280297Sjkim uint16_t snd_sid; 376280297Sjkim uint16_t snd_flags; 377280297Sjkim uint32_t snd_ppid; 378280297Sjkim uint32_t snd_context; 379280297Sjkim}; 380238405Sjkim 381280297Sjkimstruct bio_dgram_sctp_rcvinfo { 382280297Sjkim uint16_t rcv_sid; 383280297Sjkim uint16_t rcv_ssn; 384280297Sjkim uint16_t rcv_flags; 385280297Sjkim uint32_t rcv_ppid; 386280297Sjkim uint32_t rcv_tsn; 387280297Sjkim uint32_t rcv_cumtsn; 388280297Sjkim uint32_t rcv_context; 389280297Sjkim}; 390238405Sjkim 391280297Sjkimstruct bio_dgram_sctp_prinfo { 392280297Sjkim uint16_t pr_policy; 393280297Sjkim uint32_t pr_value; 394280297Sjkim}; 395280297Sjkim# endif 396238405Sjkim 39755714Skris/* connect BIO stuff */ 398280297Sjkim# define BIO_CONN_S_BEFORE 1 399280297Sjkim# define BIO_CONN_S_GET_IP 2 400280297Sjkim# define BIO_CONN_S_GET_PORT 3 401280297Sjkim# define BIO_CONN_S_CREATE_SOCKET 4 402280297Sjkim# define BIO_CONN_S_CONNECT 5 403280297Sjkim# define BIO_CONN_S_OK 6 404280297Sjkim# define BIO_CONN_S_BLOCKED_CONNECT 7 405280297Sjkim# define BIO_CONN_S_NBIO 8 406280297Sjkim/* 407280297Sjkim * #define BIO_CONN_get_param_hostname BIO_ctrl 408280297Sjkim */ 40955714Skris 410280297Sjkim# define BIO_C_SET_CONNECT 100 411280297Sjkim# define BIO_C_DO_STATE_MACHINE 101 412280297Sjkim# define BIO_C_SET_NBIO 102 413280297Sjkim# define BIO_C_SET_PROXY_PARAM 103 414280297Sjkim# define BIO_C_SET_FD 104 415280297Sjkim# define BIO_C_GET_FD 105 416280297Sjkim# define BIO_C_SET_FILE_PTR 106 417280297Sjkim# define BIO_C_GET_FILE_PTR 107 418280297Sjkim# define BIO_C_SET_FILENAME 108 419280297Sjkim# define BIO_C_SET_SSL 109 420280297Sjkim# define BIO_C_GET_SSL 110 421280297Sjkim# define BIO_C_SET_MD 111 422280297Sjkim# define BIO_C_GET_MD 112 423280297Sjkim# define BIO_C_GET_CIPHER_STATUS 113 424280297Sjkim# define BIO_C_SET_BUF_MEM 114 425280297Sjkim# define BIO_C_GET_BUF_MEM_PTR 115 426280297Sjkim# define BIO_C_GET_BUFF_NUM_LINES 116 427280297Sjkim# define BIO_C_SET_BUFF_SIZE 117 428280297Sjkim# define BIO_C_SET_ACCEPT 118 429280297Sjkim# define BIO_C_SSL_MODE 119 430280297Sjkim# define BIO_C_GET_MD_CTX 120 431280297Sjkim# define BIO_C_GET_PROXY_PARAM 121 432280297Sjkim# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */ 433280297Sjkim# define BIO_C_GET_CONNECT 123 434280297Sjkim# define BIO_C_GET_ACCEPT 124 435280297Sjkim# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 436280297Sjkim# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 437280297Sjkim# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 438280297Sjkim# define BIO_C_FILE_SEEK 128 439280297Sjkim# define BIO_C_GET_CIPHER_CTX 129 440280297Sjkim# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input 441280297Sjkim * value */ 442280297Sjkim# define BIO_C_SET_BIND_MODE 131 443280297Sjkim# define BIO_C_GET_BIND_MODE 132 444280297Sjkim# define BIO_C_FILE_TELL 133 445280297Sjkim# define BIO_C_GET_SOCKS 134 446280297Sjkim# define BIO_C_SET_SOCKS 135 44755714Skris 448280297Sjkim# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ 449280297Sjkim# define BIO_C_GET_WRITE_BUF_SIZE 137 450280297Sjkim# define BIO_C_MAKE_BIO_PAIR 138 451280297Sjkim# define BIO_C_DESTROY_BIO_PAIR 139 452280297Sjkim# define BIO_C_GET_WRITE_GUARANTEE 140 453280297Sjkim# define BIO_C_GET_READ_REQUEST 141 454280297Sjkim# define BIO_C_SHUTDOWN_WR 142 455280297Sjkim# define BIO_C_NREAD0 143 456280297Sjkim# define BIO_C_NREAD 144 457280297Sjkim# define BIO_C_NWRITE0 145 458280297Sjkim# define BIO_C_NWRITE 146 459280297Sjkim# define BIO_C_RESET_READ_REQUEST 147 460280297Sjkim# define BIO_C_SET_MD_CTX 148 46155714Skris 462280297Sjkim# define BIO_C_SET_PREFIX 149 463280297Sjkim# define BIO_C_GET_PREFIX 150 464280297Sjkim# define BIO_C_SET_SUFFIX 151 465280297Sjkim# define BIO_C_GET_SUFFIX 152 46655714Skris 467280297Sjkim# define BIO_C_SET_EX_ARG 153 468280297Sjkim# define BIO_C_GET_EX_ARG 154 469238405Sjkim 470280297Sjkim# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) 471280297Sjkim# define BIO_get_app_data(s) BIO_get_ex_data(s,0) 47255714Skris 47355714Skris/* BIO_s_connect() and BIO_s_socks4a_connect() */ 474280297Sjkim# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) 475280297Sjkim# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) 476280297Sjkim# define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) 477280297Sjkim# define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port) 478280297Sjkim# define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) 479280297Sjkim# define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) 480280297Sjkim# define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) 481280297Sjkim# define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0) 48255714Skris 483280297Sjkim# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) 48455714Skris 48555714Skris/* BIO_s_accept_socket() */ 486280297Sjkim# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) 487280297Sjkim# define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0) 488280297Sjkim/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ 489280297Sjkim# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)"a":NULL) 490280297Sjkim# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) 49155714Skris 492280297Sjkim# define BIO_BIND_NORMAL 0 493280297Sjkim# define BIO_BIND_REUSEADDR_IF_UNUSED 1 494280297Sjkim# define BIO_BIND_REUSEADDR 2 495280297Sjkim# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) 496280297Sjkim# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) 49755714Skris 498280297Sjkim# define BIO_do_connect(b) BIO_do_handshake(b) 499280297Sjkim# define BIO_do_accept(b) BIO_do_handshake(b) 500280297Sjkim# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) 50155714Skris 50255714Skris/* BIO_s_proxy_client() */ 503280297Sjkim# define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) 504280297Sjkim# define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) 50555714Skris/* BIO_set_nbio(b,n) */ 506280297Sjkim# 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); */ 508280297Sjkim# define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) 509280297Sjkim# define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) 510280297Sjkim# define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) 51155714Skris 512280297Sjkim# define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) 513280297Sjkim# define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) 514280297Sjkim# define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) 515280297Sjkim# define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) 51655714Skris 517280297Sjkim# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) 518280297Sjkim# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) 51955714Skris 520280297Sjkim# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) 521280297Sjkim# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) 52255714Skris 523280297Sjkim# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) 524280297Sjkim# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) 52555714Skris 526280297Sjkim/* 527280297Sjkim * name is cast to lose const, but might be better to route through a 528280297Sjkim * function so we can do it safely 529280297Sjkim */ 530280297Sjkim# ifdef CONST_STRICT 531280297Sjkim/* 532280297Sjkim * 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 */ 535280297Sjkimint BIO_read_filename(BIO *b, const char *name); 536280297Sjkim# else 537280297Sjkim# define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ 538280297Sjkim BIO_CLOSE|BIO_FP_READ,(char *)name) 539280297Sjkim# endif 540280297Sjkim# define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ 541280297Sjkim BIO_CLOSE|BIO_FP_WRITE,name) 542280297Sjkim# define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ 543280297Sjkim BIO_CLOSE|BIO_FP_APPEND,name) 544280297Sjkim# define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ 545280297Sjkim BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) 54655714Skris 547280297Sjkim/* 548280297Sjkim * WARNING WARNING, this ups the reference count on the read bio of the SSL 549280297Sjkim * structure. This is because the ssl read BIO is now pointed to by the 550280297Sjkim * next_bio field in the bio. So when you free the BIO, make sure you are 551280297Sjkim * doing a BIO_free_all() to catch the underlying BIO. 552280297Sjkim */ 553280297Sjkim# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) 554280297Sjkim# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) 555280297Sjkim# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) 556280297Sjkim# define BIO_set_ssl_renegotiate_bytes(b,num) \ 557280297Sjkim BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL); 558280297Sjkim# define BIO_get_num_renegotiates(b) \ 559280297Sjkim BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL); 560280297Sjkim# define BIO_set_ssl_renegotiate_timeout(b,seconds) \ 561280297Sjkim BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL); 56255714Skris 56355714Skris/* defined in evp.h */ 564280297Sjkim/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ 56555714Skris 566280297Sjkim# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) 567280297Sjkim# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) 568280297Sjkim# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) 569280297Sjkim# define BIO_set_mem_eof_return(b,v) \ 570280297Sjkim BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) 57155714Skris 57255714Skris/* For the BIO_f_buffer() type */ 573280297Sjkim# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) 574280297Sjkim# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) 575280297Sjkim# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) 576280297Sjkim# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) 577280297Sjkim# 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 :-) */ 580280297Sjkim# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) 58155714Skris 582280297Sjkim# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) 583280297Sjkim# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) 584280297Sjkim# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) 585280297Sjkim# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) 586280297Sjkim# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) 587280297Sjkim# 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); 591280297Sjkim# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) 592280297Sjkim# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ 593280297Sjkim cbp) 594280297Sjkim# 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 */ 597280297Sjkim# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) 59855714Skris 59955714Skris/* For BIO_s_bio() */ 600280297Sjkim# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) 601280297Sjkim# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) 602280297Sjkim# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) 603280297Sjkim# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) 604280297Sjkim# 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: */ 606280297Sjkim# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) 607280297Sjkim# 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 */ 613280297Sjkim# define BIO_ctrl_dgram_connect(b,peer) \ 614160814Ssimon (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) 615280297Sjkim# define BIO_ctrl_set_connected(b, state, peer) \ 616160814Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer) 617280297Sjkim# define BIO_dgram_recv_timedout(b) \ 618160814Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) 619280297Sjkim# define BIO_dgram_send_timedout(b) \ 620160814Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) 621280297Sjkim# define BIO_dgram_get_peer(b,peer) \ 622205128Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer) 623280297Sjkim# define BIO_dgram_set_peer(b,peer) \ 624160814Ssimon (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) 625280297Sjkim# define BIO_dgram_get_mtu_overhead(b) \ 626276861Sjkim (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)()); */ 631280297Sjkimint BIO_set_ex_data(BIO *bio, int idx, void *data); 632280297Sjkimvoid *BIO_get_ex_data(BIO *bio, int idx); 63359191Skrisint BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, 634280297Sjkim 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, 640280297Sjkim asn1_ps_func *prefix_free); 641238405Sjkimint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, 642280297Sjkim asn1_ps_func **pprefix_free); 643238405Sjkimint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, 644280297Sjkim asn1_ps_func *suffix_free); 645238405Sjkimint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, 646280297Sjkim asn1_ps_func **psuffix_free); 647238405Sjkim 648109998Smarkm# ifndef OPENSSL_NO_FP_API 649280297SjkimBIO_METHOD *BIO_s_file(void); 65055714SkrisBIO *BIO_new_file(const char *filename, const char *mode); 65155714SkrisBIO *BIO_new_fp(FILE *stream, int close_flag); 652280297Sjkim# define BIO_s_file_internal BIO_s_file 65368651Skris# endif 654280297SjkimBIO *BIO_new(BIO_METHOD *type); 655280297Sjkimint BIO_set(BIO *a, BIO_METHOD *type); 656280297Sjkimint BIO_free(BIO *a); 657280297Sjkimvoid BIO_vfree(BIO *a); 658280297Sjkimint BIO_read(BIO *b, void *data, int len); 659280297Sjkimint BIO_gets(BIO *bp, char *buf, int size); 660280297Sjkimint BIO_write(BIO *b, const void *data, int len); 661280297Sjkimint BIO_puts(BIO *bp, const char *buf); 662280297Sjkimint BIO_indent(BIO *b, int indent, int max); 663280297Sjkimlong BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); 664280297Sjkimlong BIO_callback_ctrl(BIO *b, int cmd, 665280297Sjkim void (*fp) (struct bio_st *, int, const char *, int, 666280297Sjkim long, long)); 667280297Sjkimchar *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); 668280297Sjkimlong BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); 669280297SjkimBIO *BIO_push(BIO *b, BIO *append); 670280297SjkimBIO *BIO_pop(BIO *b); 671280297Sjkimvoid BIO_free_all(BIO *a); 672280297SjkimBIO *BIO_find_type(BIO *b, int bio_type); 673280297SjkimBIO *BIO_next(BIO *b); 674280297SjkimBIO *BIO_get_retry_BIO(BIO *bio, int *reason); 675280297Sjkimint BIO_get_retry_reason(BIO *bio); 676280297SjkimBIO *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 683280297Sjkimlong BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, 684280297Sjkim 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); 692280297Sjkim# ifndef OPENSSL_SYS_OS2 69355714SkrisBIO_METHOD *BIO_s_log(void); 694280297Sjkim# 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); 699280297Sjkim# ifdef OPENSSL_SYS_VMS 70068651SkrisBIO_METHOD *BIO_f_linebuffer(void); 701280297Sjkim# endif 70255714SkrisBIO_METHOD *BIO_f_nbio_test(void); 703280297Sjkim# ifndef OPENSSL_NO_DGRAM 704160814SsimonBIO_METHOD *BIO_s_datagram(void); 705280297Sjkim# ifndef OPENSSL_NO_SCTP 706238405SjkimBIO_METHOD *BIO_s_datagram_sctp(void); 707280297Sjkim# endif 708280297Sjkim# 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); 718280297Sjkimint BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u), 719280297Sjkim void *u, const char *s, int len); 720280297Sjkimint BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), 721280297Sjkim void *u, const char *s, int len, int indent); 722280297Sjkimint BIO_dump(BIO *b, const char *bytes, int len); 723280297Sjkimint BIO_dump_indent(BIO *b, const char *bytes, int len, int indent); 724280297Sjkim# 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); 727280297Sjkim# endif 72855714Skrisstruct hostent *BIO_gethostbyname(const char *name); 729280297Sjkim/*- 730280297Sjkim * 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); 740280297Sjkimint 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); 743280297Sjkimint BIO_get_accept_socket(char *host_port, int mode); 744280297Sjkimint BIO_accept(int sock, char **ip_port); 745280297Sjkimint BIO_sock_init(void); 74655714Skrisvoid BIO_sock_cleanup(void); 747280297Sjkimint 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); 751280297Sjkim# 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, 755280297Sjkim void (*handle_notifications) (BIO *bio, 756280297Sjkim void 757280297Sjkim *context, 758280297Sjkim void *buf), 759238405Sjkim void *context); 760238405Sjkimint BIO_dgram_sctp_wait_for_dry(BIO *b); 761238405Sjkimint BIO_dgram_sctp_msg_waiting(BIO *b); 762280297Sjkim# 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, 768280297Sjkim BIO **bio2, size_t writebuf2); 769280297Sjkim/* 770280297Sjkim * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. 771280297Sjkim * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default 772280297Sjkim * value. 77355714Skris */ 77455714Skris 77555714Skrisvoid BIO_copy_next_retry(BIO *b); 77655714Skris 777280297Sjkim/* 778280297Sjkim * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); 779280297Sjkim */ 78055714Skris 781280297Sjkim# ifdef __GNUC__ 782160814Ssimon# define __bio_h__attr__ __attribute__ 783280297Sjkim# else 784160814Ssimon# define __bio_h__attr__(x) 785280297Sjkim# endif 786160814Ssimonint BIO_printf(BIO *bio, const char *format, ...) 787280297Sjkim__bio_h__attr__((__format__(__printf__, 2, 3))); 788160814Ssimonint BIO_vprintf(BIO *bio, const char *format, va_list args) 789280297Sjkim__bio_h__attr__((__format__(__printf__, 2, 0))); 790160814Ssimonint BIO_snprintf(char *buf, size_t n, const char *format, ...) 791280297Sjkim__bio_h__attr__((__format__(__printf__, 3, 4))); 792160814Ssimonint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) 793280297Sjkim__bio_h__attr__((__format__(__printf__, 3, 0))); 794280297Sjkim# undef __bio_h__attr__ 79555714Skris 79655714Skris/* BEGIN ERROR CODES */ 797280297Sjkim/* 798280297Sjkim * 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. */ 806280297Sjkim# define BIO_F_ACPT_STATE 100 807280297Sjkim# define BIO_F_BIO_ACCEPT 101 808280297Sjkim# define BIO_F_BIO_BER_GET_HEADER 102 809280297Sjkim# define BIO_F_BIO_CALLBACK_CTRL 131 810280297Sjkim# define BIO_F_BIO_CTRL 103 811280297Sjkim# define BIO_F_BIO_GETHOSTBYNAME 120 812280297Sjkim# define BIO_F_BIO_GETS 104 813280297Sjkim# define BIO_F_BIO_GET_ACCEPT_SOCKET 105 814280297Sjkim# define BIO_F_BIO_GET_HOST_IP 106 815280297Sjkim# define BIO_F_BIO_GET_PORT 107 816280297Sjkim# define BIO_F_BIO_MAKE_PAIR 121 817280297Sjkim# define BIO_F_BIO_NEW 108 818280297Sjkim# define BIO_F_BIO_NEW_FILE 109 819280297Sjkim# define BIO_F_BIO_NEW_MEM_BUF 126 820280297Sjkim# define BIO_F_BIO_NREAD 123 821280297Sjkim# define BIO_F_BIO_NREAD0 124 822280297Sjkim# define BIO_F_BIO_NWRITE 125 823280297Sjkim# define BIO_F_BIO_NWRITE0 122 824280297Sjkim# define BIO_F_BIO_PUTS 110 825280297Sjkim# define BIO_F_BIO_READ 111 826280297Sjkim# define BIO_F_BIO_SOCK_INIT 112 827280297Sjkim# define BIO_F_BIO_WRITE 113 828280297Sjkim# define BIO_F_BUFFER_CTRL 114 829280297Sjkim# define BIO_F_CONN_CTRL 127 830280297Sjkim# define BIO_F_CONN_STATE 115 831280297Sjkim# define BIO_F_DGRAM_SCTP_READ 132 832280297Sjkim# define BIO_F_DGRAM_SCTP_WRITE 133 833280297Sjkim# define BIO_F_FILE_CTRL 116 834280297Sjkim# define BIO_F_FILE_READ 130 835280297Sjkim# define BIO_F_LINEBUFFER_CTRL 129 836280297Sjkim# define BIO_F_MEM_READ 128 837280297Sjkim# define BIO_F_MEM_WRITE 117 838280297Sjkim# define BIO_F_SSL_NEW 118 839280297Sjkim# define BIO_F_WSASTARTUP 119 84055714Skris 84155714Skris/* Reason codes. */ 842280297Sjkim# define BIO_R_ACCEPT_ERROR 100 843280297Sjkim# define BIO_R_BAD_FOPEN_MODE 101 844280297Sjkim# define BIO_R_BAD_HOSTNAME_LOOKUP 102 845280297Sjkim# define BIO_R_BROKEN_PIPE 124 846280297Sjkim# define BIO_R_CONNECT_ERROR 103 847280297Sjkim# define BIO_R_EOF_ON_MEMORY_BIO 127 848280297Sjkim# define BIO_R_ERROR_SETTING_NBIO 104 849280297Sjkim# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 850280297Sjkim# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 851280297Sjkim# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 852280297Sjkim# define BIO_R_INVALID_ARGUMENT 125 853280297Sjkim# define BIO_R_INVALID_IP_ADDRESS 108 854280297Sjkim# define BIO_R_IN_USE 123 855280297Sjkim# define BIO_R_KEEPALIVE 109 856280297Sjkim# define BIO_R_NBIO_CONNECT_ERROR 110 857280297Sjkim# define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 858280297Sjkim# define BIO_R_NO_HOSTNAME_SPECIFIED 112 859280297Sjkim# define BIO_R_NO_PORT_DEFINED 113 860280297Sjkim# define BIO_R_NO_PORT_SPECIFIED 114 861280297Sjkim# define BIO_R_NO_SUCH_FILE 128 862280297Sjkim# define BIO_R_NULL_PARAMETER 115 863280297Sjkim# define BIO_R_TAG_MISMATCH 116 864280297Sjkim# define BIO_R_UNABLE_TO_BIND_SOCKET 117 865280297Sjkim# define BIO_R_UNABLE_TO_CREATE_SOCKET 118 866280297Sjkim# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 867280297Sjkim# define BIO_R_UNINITIALIZED 120 868280297Sjkim# define BIO_R_UNSUPPORTED_METHOD 121 869280297Sjkim# define BIO_R_WRITE_TO_READ_ONLY_BIO 126 870280297Sjkim# define BIO_R_WSASTARTUP 122 87155714Skris 87255714Skris#ifdef __cplusplus 87355714Skris} 87455714Skris#endif 87555714Skris#endif 876