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)
35 # define bio_addrinfo_st addrinfo
36 # define bai_family ai_family
37 # define bai_socktype ai_socktype
38 # define bai_protocol ai_protocol
39 # define bai_addrlen ai_addrlen
40 # define bai_addr ai_addr
41 # define bai_next ai_next
43 struct bio_addrinfo_st {
48 struct sockaddr *bai_addr;
49 struct bio_addrinfo_st *bai_next;
56 struct sockaddr_in6 s_in6;
58 struct sockaddr_in s_in;
60 struct sockaddr_un s_un;
65 /* END BIO_ADDRINFO/BIO_ADDR stuff. */
67 #include "internal/cryptlib.h"
68 #include <internal/bio.h>
70 typedef struct bio_f_buffer_ctx_struct {
72 * Buffers are setup like this:
74 * <---------------------- size ----------------------->
75 * +---------------------------------------------------+
76 * | consumed | remaining | free space |
77 * +---------------------------------------------------+
78 * <-- off --><------- len ------->
81 * this is now in the BIO struct
83 int ibuf_size; /* how big is the input buffer */
84 int obuf_size; /* how big is the output buffer */
85 char *ibuf; /* the char array */
86 int ibuf_len; /* how many bytes are in it */
87 int ibuf_off; /* write/read offset */
88 char *obuf; /* the char array */
89 int obuf_len; /* how many bytes are in it */
90 int obuf_off; /* write/read offset */
94 const BIO_METHOD *method;
95 /* bio, mode, argp, argi, argl, ret */
96 long (*callback) (struct bio_st *, int, const char *, int, long, long);
97 char *cb_arg; /* first argument for the callback */
100 int flags; /* extra storage */
104 struct bio_st *next_bio; /* used by filter BIOs */
105 struct bio_st *prev_bio; /* used by filter BIOs */
109 CRYPTO_EX_DATA ex_data;
113 #ifndef OPENSSL_NO_SOCK
114 # ifdef OPENSSL_SYS_VMS
115 typedef unsigned int socklen_t;
118 int BIO_ADDR_make(BIO_ADDR *ap, const struct sockaddr *sa);
119 const struct sockaddr *BIO_ADDR_sockaddr(const BIO_ADDR *ap);
120 struct sockaddr *BIO_ADDR_sockaddr_noconst(BIO_ADDR *ap);
121 socklen_t BIO_ADDR_sockaddr_size(const BIO_ADDR *ap);
122 socklen_t BIO_ADDRINFO_sockaddr_size(const BIO_ADDRINFO *bai);
123 const struct sockaddr *BIO_ADDRINFO_sockaddr(const BIO_ADDRINFO *bai);
126 #if BIO_FLAGS_UPLINK==0
127 /* Shortcut UPLINK calls on most platforms... */
128 # define UP_stdin stdin
129 # define UP_stdout stdout
130 # define UP_stderr stderr
131 # define UP_fprintf fprintf
132 # define UP_fgets fgets
133 # define UP_fread fread
134 # define UP_fwrite fwrite
136 # define UP_feof feof
137 # define UP_fclose fclose
139 # define UP_fopen fopen
140 # define UP_fseek fseek
141 # define UP_ftell ftell
142 # define UP_fflush fflush
143 # define UP_ferror ferror
145 # define UP_fileno _fileno
146 # define UP_open _open
147 # define UP_read _read
148 # define UP_write _write
149 # define UP_lseek _lseek
150 # define UP_close _close
152 # define UP_fileno fileno
153 # define UP_open open
154 # define UP_read read
155 # define UP_write write
156 # define UP_lseek lseek
157 # define UP_close close