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. */
79 #include "internal/cryptlib.h"
80 #include <internal/bio.h>
82 typedef struct bio_f_buffer_ctx_struct {
84 * Buffers are setup like this:
86 * <---------------------- size ----------------------->
87 * +---------------------------------------------------+
88 * | consumed | remaining | free space |
89 * +---------------------------------------------------+
90 * <-- off --><------- len ------->
93 * this is now in the BIO struct
95 int ibuf_size; /* how big is the input buffer */
96 int obuf_size; /* how big is the output buffer */
97 char *ibuf; /* the char array */
98 int ibuf_len; /* how many bytes are in it */
99 int ibuf_off; /* write/read offset */
100 char *obuf; /* the char array */
101 int obuf_len; /* how many bytes are in it */
102 int obuf_off; /* write/read offset */
106 const BIO_METHOD *method;
107 /* bio, mode, argp, argi, argl, ret */
108 long (*callback) (struct bio_st *, int, const char *, int, long, long);
109 char *cb_arg; /* first argument for the callback */
112 int flags; /* extra storage */
116 struct bio_st *next_bio; /* used by filter BIOs */
117 struct bio_st *prev_bio; /* used by filter BIOs */
121 CRYPTO_EX_DATA ex_data;
125 #ifndef OPENSSL_NO_SOCK
126 # ifdef OPENSSL_SYS_VMS
127 typedef unsigned int socklen_t;
130 int BIO_ADDR_make(BIO_ADDR *ap, const struct sockaddr *sa);
131 const struct sockaddr *BIO_ADDR_sockaddr(const BIO_ADDR *ap);
132 struct sockaddr *BIO_ADDR_sockaddr_noconst(BIO_ADDR *ap);
133 socklen_t BIO_ADDR_sockaddr_size(const BIO_ADDR *ap);
134 socklen_t BIO_ADDRINFO_sockaddr_size(const BIO_ADDRINFO *bai);
135 const struct sockaddr *BIO_ADDRINFO_sockaddr(const BIO_ADDRINFO *bai);
138 #if BIO_FLAGS_UPLINK==0
139 /* Shortcut UPLINK calls on most platforms... */
140 # define UP_stdin stdin
141 # define UP_stdout stdout
142 # define UP_stderr stderr
143 # define UP_fprintf fprintf
144 # define UP_fgets fgets
145 # define UP_fread fread
146 # define UP_fwrite fwrite
148 # define UP_feof feof
149 # define UP_fclose fclose
151 # define UP_fopen fopen
152 # define UP_fseek fseek
153 # define UP_ftell ftell
154 # define UP_fflush fflush
155 # define UP_ferror ferror
157 # define UP_fileno _fileno
158 # define UP_open _open
159 # define UP_read _read
160 # define UP_write _write
161 # define UP_lseek _lseek
162 # define UP_close _close
164 # define UP_fileno fileno
165 # define UP_open open
166 # define UP_read read
167 # define UP_write write
168 # define UP_lseek lseek
169 # define UP_close close