4 /* BEGIN BIO_ADDRINFO/BIO_ADDR stuff. */
6 #ifndef OPENSSL_NO_SOCK
8 * Throughout this file and b_addr.c, the existence of the macro
9 * AI_PASSIVE is used to detect the availability of struct addrinfo,
10 * getnameinfo() and getaddrinfo(). If that macro doesn't exist,
11 * we use our own implementation instead.
15 * It's imperative that these macros get defined before openssl/bio.h gets
16 * included. Otherwise, the AI_PASSIVE hack will not work properly.
17 * For clarity, we check for internal/cryptlib.h since it's a common header
18 * that also includes bio.h.
20 # ifdef HEADER_CRYPTLIB_H
21 # error internal/cryptlib.h included before bio_lcl.h
24 # error openssl/bio.h included before bio_lcl.h
28 * Undefine AF_UNIX on systems that define it but don't support it.
30 # if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_VMS)
37 * There's a bug in VMS C header file netdb.h, where struct addrinfo
38 * always is the P32 variant, but the functions that handle that structure,
39 * such as getaddrinfo() and freeaddrinfo() adapt to the initial pointer
40 * size. The easiest workaround is to force struct addrinfo to be the
41 * 64-bit variant when compiling in P64 mode.
43 # if defined(OPENSSL_SYS_VMS) && __INITIAL_POINTER_SIZE == 64
44 # define addrinfo __addrinfo64
47 # define bio_addrinfo_st addrinfo
48 # define bai_family ai_family
49 # define bai_socktype ai_socktype
50 # define bai_protocol ai_protocol
51 # define bai_addrlen ai_addrlen
52 # define bai_addr ai_addr
53 # define bai_next ai_next
55 struct bio_addrinfo_st {
60 struct sockaddr *bai_addr;
61 struct bio_addrinfo_st *bai_next;
68 struct sockaddr_in6 s_in6;
70 struct sockaddr_in s_in;
72 struct sockaddr_un s_un;
77 /* END BIO_ADDRINFO/BIO_ADDR stuff. */
80 struct bio_buf_mem_st {
81 struct buf_mem_st *buf; /* allocated buffer */
82 struct buf_mem_st *readp; /* read pointer */
85 #include "internal/cryptlib.h"
86 #include <internal/bio.h>
88 typedef struct bio_f_buffer_ctx_struct {
90 * Buffers are setup like this:
92 * <---------------------- size ----------------------->
93 * +---------------------------------------------------+
94 * | consumed | remaining | free space |
95 * +---------------------------------------------------+
96 * <-- off --><------- len ------->
99 * this is now in the BIO struct
101 int ibuf_size; /* how big is the input buffer */
102 int obuf_size; /* how big is the output buffer */
103 char *ibuf; /* the char array */
104 int ibuf_len; /* how many bytes are in it */
105 int ibuf_off; /* write/read offset */
106 char *obuf; /* the char array */
107 int obuf_len; /* how many bytes are in it */
108 int obuf_off; /* write/read offset */
112 const BIO_METHOD *method;
113 /* bio, mode, argp, argi, argl, ret */
114 long (*callback) (struct bio_st *, int, const char *, int, long, long);
115 char *cb_arg; /* first argument for the callback */
118 int flags; /* extra storage */
122 struct bio_st *next_bio; /* used by filter BIOs */
123 struct bio_st *prev_bio; /* used by filter BIOs */
127 CRYPTO_EX_DATA ex_data;
131 #ifndef OPENSSL_NO_SOCK
132 # ifdef OPENSSL_SYS_VMS
133 typedef unsigned int socklen_t;
136 int BIO_ADDR_make(BIO_ADDR *ap, const struct sockaddr *sa);
137 const struct sockaddr *BIO_ADDR_sockaddr(const BIO_ADDR *ap);
138 struct sockaddr *BIO_ADDR_sockaddr_noconst(BIO_ADDR *ap);
139 socklen_t BIO_ADDR_sockaddr_size(const BIO_ADDR *ap);
140 socklen_t BIO_ADDRINFO_sockaddr_size(const BIO_ADDRINFO *bai);
141 const struct sockaddr *BIO_ADDRINFO_sockaddr(const BIO_ADDRINFO *bai);
144 #if BIO_FLAGS_UPLINK==0
145 /* Shortcut UPLINK calls on most platforms... */
146 # define UP_stdin stdin
147 # define UP_stdout stdout
148 # define UP_stderr stderr
149 # define UP_fprintf fprintf
150 # define UP_fgets fgets
151 # define UP_fread fread
152 # define UP_fwrite fwrite
154 # define UP_feof feof
155 # define UP_fclose fclose
157 # define UP_fopen fopen
158 # define UP_fseek fseek
159 # define UP_ftell ftell
160 # define UP_fflush fflush
161 # define UP_ferror ferror
163 # define UP_fileno _fileno
164 # define UP_open _open
165 # define UP_read _read
166 # define UP_write _write
167 # define UP_lseek _lseek
168 # define UP_close _close
170 # define UP_fileno fileno
171 # define UP_open open
172 # define UP_read read
173 # define UP_write write
174 # define UP_lseek lseek
175 # define UP_close close