1 /* bio.h
2  *
3  * Copyright (C) 2006-2021 wolfSSL Inc.
4  *
5  * This file is part of wolfSSL.
6  *
7  * wolfSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * wolfSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20  */
21 
22 /* bio.h for openssl */
23 
24 
25 #ifndef WOLFSSL_BIO_H_
26 #define WOLFSSL_BIO_H_
27 
28 
29 #ifdef __cplusplus
30     extern "C" {
31 #endif
32 
33 
34 #define BIO_FLAGS_BASE64_NO_NL WOLFSSL_BIO_FLAG_BASE64_NO_NL
35 #define BIO_FLAGS_READ         WOLFSSL_BIO_FLAG_READ
36 #define BIO_FLAGS_WRITE        WOLFSSL_BIO_FLAG_WRITE
37 #define BIO_FLAGS_IO_SPECIAL   WOLFSSL_BIO_FLAG_IO_SPECIAL
38 #define BIO_FLAGS_SHOULD_RETRY WOLFSSL_BIO_FLAG_RETRY
39 
40 #define BIO_new_fp                      wolfSSL_BIO_new_fp
41 #if defined(OPENSSL_ALL) \
42     || defined(HAVE_STUNNEL) \
43     || defined(HAVE_LIGHTY) \
44     || defined(WOLFSSL_MYSQL_COMPATIBLE) \
45     || defined(WOLFSSL_HAPROXY) \
46     || defined(OPENSSL_EXTRA)
47 #define BIO_new_file                    wolfSSL_BIO_new_file
48 #endif
49 #define BIO_new_fp                      wolfSSL_BIO_new_fp
50 #define BIO_ctrl                        wolfSSL_BIO_ctrl
51 #define BIO_ctrl_pending                wolfSSL_BIO_ctrl_pending
52 #define BIO_wpending                    wolfSSL_BIO_wpending
53 #define BIO_get_mem_ptr                 wolfSSL_BIO_get_mem_ptr
54 #define BIO_int_ctrl                    wolfSSL_BIO_int_ctrl
55 #define BIO_reset                       wolfSSL_BIO_reset
56 #define BIO_s_file                      wolfSSL_BIO_s_file
57 #define BIO_s_bio                       wolfSSL_BIO_s_bio
58 #define BIO_s_socket                    wolfSSL_BIO_s_socket
59 #define BIO_set_fd                      wolfSSL_BIO_set_fd
60 #define BIO_set_close                   wolfSSL_BIO_set_close
61 #define BIO_ctrl_reset_read_request     wolfSSL_BIO_ctrl_reset_read_request
62 #define BIO_set_write_buf_size          wolfSSL_BIO_set_write_buf_size
63 #define BIO_make_bio_pair               wolfSSL_BIO_make_bio_pair
64 #define BIO_up_ref                      wolfSSL_BIO_up_ref
65 
66 #define BIO_new_fd                      wolfSSL_BIO_new_fd
67 #define BIO_set_fp                      wolfSSL_BIO_set_fp
68 #define BIO_get_fp                      wolfSSL_BIO_get_fp
69 #define BIO_seek                        wolfSSL_BIO_seek
70 #define BIO_tell                        wolfSSL_BIO_tell
71 #define BIO_write_filename              wolfSSL_BIO_write_filename
72 #define BIO_set_mem_eof_return          wolfSSL_BIO_set_mem_eof_return
73 
74 #define BIO_find_type wolfSSL_BIO_find_type
75 #define BIO_next      wolfSSL_BIO_next
76 #define BIO_gets      wolfSSL_BIO_gets
77 #define BIO_puts      wolfSSL_BIO_puts
78 
79 #define BIO_should_retry                wolfSSL_BIO_should_retry
80 
81 #define BIO_TYPE_FILE WOLFSSL_BIO_FILE
82 #define BIO_TYPE_BIO  WOLFSSL_BIO_BIO
83 #define BIO_TYPE_MEM  WOLFSSL_BIO_MEMORY
84 #define BIO_TYPE_BASE64 WOLFSSL_BIO_BASE64
85 
86 #define BIO_vprintf wolfSSL_BIO_vprintf
87 #define BIO_printf  wolfSSL_BIO_printf
88 #define BIO_dump    wolfSSL_BIO_dump
89 
90 /* BIO info callback */
91 #define BIO_CB_FREE   WOLFSSL_BIO_CB_FREE
92 #define BIO_CB_READ   WOLFSSL_BIO_CB_READ
93 #define BIO_CB_WRITE  WOLFSSL_BIO_CB_WRITE
94 #define BIO_CB_PUTS   WOLFSSL_BIO_CB_PUTS
95 #define BIO_CB_GETS   WOLFSSL_BIO_CB_GETS
96 #define BIO_CB_CTRL   WOLFSSL_BIO_CB_CTRL
97 #define BIO_CB_RETURN WOLFSSL_BIO_CB_RETURN
98 
99 #define BIO_set_callback         wolfSSL_BIO_set_callback
100 #define BIO_get_callback         wolfSSL_BIO_get_callback
101 #define BIO_set_callback_arg     wolfSSL_BIO_set_callback_arg
102 #define BIO_get_callback_arg     wolfSSL_BIO_get_callback_arg
103 
104 /* BIO for 1.1.0 or later */
105 #define BIO_set_init               wolfSSL_BIO_set_init
106 #define BIO_get_data               wolfSSL_BIO_get_data
107 #define BIO_set_data               wolfSSL_BIO_set_data
108 #define BIO_get_shutdown           wolfSSL_BIO_get_shutdown
109 #define BIO_set_shutdown           wolfSSL_BIO_set_shutdown
110 
111 #define BIO_get_fd                 wolfSSL_BIO_get_fd
112 
113 #define BIO_clear_flags            wolfSSL_BIO_clear_flags
114 #define BIO_set_ex_data            wolfSSL_BIO_set_ex_data
115 #define BIO_get_ex_data            wolfSSL_BIO_get_ex_data
116 
117 /* helper to set specific retry/read flags */
118 #define BIO_set_retry_read(bio)\
119     wolfSSL_BIO_set_flags((bio), WOLFSSL_BIO_FLAG_RETRY | WOLFSSL_BIO_FLAG_READ)
120 #define BIO_set_retry_write(bio)\
121     wolfSSL_BIO_set_flags((bio), WOLFSSL_BIO_FLAG_RETRY | WOLFSSL_BIO_FLAG_WRITE)
122 
123 #define BIO_clear_retry_flags      wolfSSL_BIO_clear_retry_flags
124 
125 #define BIO_meth_new               wolfSSL_BIO_meth_new
126 #define BIO_meth_set_write         wolfSSL_BIO_meth_set_write
127 #define BIO_meth_free              wolfSSL_BIO_meth_free
128 #define BIO_meth_set_write         wolfSSL_BIO_meth_set_write
129 #define BIO_meth_set_read          wolfSSL_BIO_meth_set_read
130 #define BIO_meth_set_puts          wolfSSL_BIO_meth_set_puts
131 #define BIO_meth_set_gets          wolfSSL_BIO_meth_set_gets
132 #define BIO_meth_set_ctrl          wolfSSL_BIO_meth_set_ctrl
133 #define BIO_meth_set_create        wolfSSL_BIO_meth_set_create
134 #define BIO_meth_set_destroy       wolfSSL_BIO_meth_set_destroy
135 
136 #define BIO_snprintf               XSNPRINTF
137 
138 /* BIO CTRL */
139 #define BIO_CTRL_RESET             1
140 #define BIO_CTRL_EOF               2
141 #define BIO_CTRL_INFO              3
142 #define BIO_CTRL_PUSH              6
143 #define BIO_CTRL_POP               7
144 #define BIO_CTRL_GET_CLOSE         8
145 #define BIO_CTRL_SET_CLOSE         9
146 #define BIO_CTRL_PENDING           10
147 #define BIO_CTRL_FLUSH             11
148 #define BIO_CTRL_DUP               12
149 #define BIO_CTRL_WPENDING          13
150 
151 #define BIO_C_SET_FILE_PTR              106
152 #define BIO_C_GET_FILE_PTR              107
153 #define BIO_C_SET_FILENAME              108
154 #define BIO_C_SET_BUF_MEM               114
155 #define BIO_C_GET_BUF_MEM_PTR           115
156 #define BIO_C_FILE_SEEK                 128
157 #define BIO_C_SET_BUF_MEM_EOF_RETURN    130
158 #define BIO_C_SET_WRITE_BUF_SIZE        136
159 #define BIO_C_MAKE_BIO_PAIR             138
160 
161 #define BIO_CTRL_DGRAM_QUERY_MTU   40
162 
163 #define BIO_FP_TEXT                0x00
164 #define BIO_NOCLOSE                0x00
165 #define BIO_CLOSE                  0x01
166 
167 #define BIO_FP_WRITE               0x04
168 
169 
170 #ifdef __cplusplus
171     }  /* extern "C" */
172 #endif
173 
174 
175 #endif /* WOLFSSL_BIO_H_ */
176 
177