21 #ifndef vio_violite_h_
22 #define vio_violite_h_
40 VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL,
41 VIO_TYPE_SHARED_MEMORY
47 enum enum_vio_io_event
54 #define VIO_LOCALHOST 1
55 #define VIO_BUFFERED_READ 2
56 #define VIO_READ_BUFFER_SIZE 16384
57 #define VIO_DESCRIPTION_SIZE 30
59 Vio* vio_new(my_socket sd,
enum enum_vio_type
type, uint
flags);
62 Vio* vio_new_win32pipe(HANDLE hPipe);
63 Vio* vio_new_win32shared_memory(HANDLE handle_file_map,
65 HANDLE event_server_wrote,
66 HANDLE event_server_read,
67 HANDLE event_client_wrote,
68 HANDLE event_client_read,
69 HANDLE event_conn_closed);
74 void vio_delete(
Vio* vio);
75 int vio_shutdown(
Vio* vio);
76 my_bool vio_reset(
Vio* vio,
enum enum_vio_type
type,
77 my_socket sd,
void *ssl, uint
flags);
78 size_t vio_read(
Vio *vio, uchar *
buf,
size_t size);
79 size_t vio_read_buff(
Vio *vio, uchar *
buf,
size_t size);
80 size_t vio_write(
Vio *vio,
const uchar *
buf,
size_t size);
82 int vio_fastsend(
Vio *vio);
84 int vio_keepalive(
Vio *vio, my_bool onoff);
86 my_bool vio_should_retry(
Vio *vio);
88 my_bool vio_was_timeout(
Vio *vio);
90 const char* vio_description(
Vio *vio);
92 enum enum_vio_type vio_type(
Vio* vio);
94 int vio_errno(
Vio*vio);
96 my_socket vio_fd(
Vio*vio);
98 my_bool vio_peer_addr(
Vio *vio,
char *
buf, uint16 *port,
size_t buflen);
100 int vio_io_wait(
Vio *vio,
enum enum_vio_io_event
event,
int timeout);
101 my_bool vio_is_connected(
Vio *vio);
103 ssize_t vio_pending(
Vio *vio);
106 int vio_timeout(
Vio *vio, uint which,
int timeout_sec);
108 my_bool vio_socket_connect(
Vio *vio,
struct sockaddr *addr, socklen_t len,
111 my_bool vio_get_normalized_ip_string(
const struct sockaddr *addr,
int addr_length,
112 char *ip_string,
size_t ip_string_size);
114 my_bool vio_is_no_name_error(
int err_code);
116 int vio_getnameinfo(
const struct sockaddr *sa,
117 char *hostname,
size_t hostname_size,
118 char *port,
size_t port_size,
122 #include <openssl/opensslv.h>
123 #if OPENSSL_VERSION_NUMBER < 0x0090700f
124 #define DES_cblock des_cblock
125 #define DES_key_schedule des_key_schedule
126 #define DES_set_key_unchecked(k,ks) des_set_key_unchecked((k),*(ks))
127 #define DES_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e) des_ede3_cbc_encrypt((i),(o),(l),*(k1),*(k2),*(k3),(iv),(e))
131 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
134 #define HEADER_DES_LOCL_H dummy_something
135 #define YASSL_MYSQL_COMPATIBLE
140 typedef my_socket YASSL_SOCKET_T;
141 #define YASSL_SOCKET_T_DEFINED
142 #include <openssl/ssl.h>
143 #include <openssl/err.h>
145 #ifndef EMBEDDED_LIBRARY
146 enum enum_ssl_init_error
148 SSL_INITERR_NOERROR= 0, SSL_INITERR_CERT, SSL_INITERR_KEY,
149 SSL_INITERR_NOMATCH, SSL_INITERR_BAD_PATHS, SSL_INITERR_CIPHERS,
150 SSL_INITERR_MEMFAIL, SSL_INITERR_LASTERR
152 const char* sslGetErrString(
enum enum_ssl_init_error err);
156 SSL_CTX *ssl_context;
159 int sslaccept(
struct st_VioSSLFd*,
Vio *,
long timeout,
unsigned long *errptr);
160 int sslconnect(
struct st_VioSSLFd*,
Vio *,
long timeout,
unsigned long *errptr);
163 *new_VioSSLConnectorFd(
const char *key_file,
const char *cert_file,
164 const char *ca_file,
const char *ca_path,
165 const char *cipher,
enum enum_ssl_init_error *error,
166 const char *crl_file,
const char *crl_path);
168 *new_VioSSLAcceptorFd(
const char *key_file,
const char *cert_file,
169 const char *ca_file,
const char *ca_path,
170 const char *cipher,
enum enum_ssl_init_error *error,
171 const char *crl_file,
const char *crl_path);
172 void free_vio_ssl_acceptor_fd(
struct st_VioSSLFd *fd);
176 void ssl_start(
void);
183 #if !defined(DONT_MAP_VIO)
184 #define vio_delete(vio) (vio)->viodelete(vio)
185 #define vio_errno(vio) (vio)->vioerrno(vio)
186 #define vio_read(vio, buf, size) ((vio)->read)(vio,buf,size)
187 #define vio_write(vio, buf, size) ((vio)->write)(vio, buf, size)
188 #define vio_fastsend(vio) (vio)->fastsend(vio)
189 #define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive)
190 #define vio_should_retry(vio) (vio)->should_retry(vio)
191 #define vio_was_timeout(vio) (vio)->was_timeout(vio)
192 #define vio_shutdown(vio) ((vio)->vioshutdown)(vio)
193 #define vio_peer_addr(vio, buf, prt, buflen) (vio)->peer_addr(vio, buf, prt, buflen)
194 #define vio_io_wait(vio, event, timeout) (vio)->io_wait(vio, event, timeout)
195 #define vio_is_connected(vio) (vio)->is_connected(vio)
201 SSL_TYPE_NOT_SPECIFIED= -1,
215 struct sockaddr_storage local;
216 struct sockaddr_storage remote;
218 enum enum_vio_type
type;
220 char desc[VIO_DESCRIPTION_SIZE];
241 void (*viodelete)(
Vio*);
242 int (*vioerrno)(
Vio*);
243 size_t (*read)(
Vio*, uchar *, size_t);
244 size_t (*write)(
Vio*,
const uchar *, size_t);
245 int (*timeout)(
Vio*, uint, my_bool);
246 int (*viokeepalive)(
Vio*, my_bool);
247 int (*fastsend)(
Vio*);
248 my_bool (*peer_addr)(
Vio*,
char *, uint16*, size_t);
249 void (*in_addr)(
Vio*,
struct sockaddr_storage*);
250 my_bool (*should_retry)(
Vio*);
251 my_bool (*was_timeout)(
Vio*);
257 int (*vioshutdown)(
Vio*);
258 my_bool (*is_connected)(
Vio*);
259 my_bool (*has_data) (
Vio*);
260 int (*io_wait)(
Vio*,
enum enum_vio_io_event, int);
261 my_bool (*connect)(
Vio*,
struct sockaddr *, socklen_t, int);
263 OVERLAPPED overlapped;
270 HANDLE handle_file_map;
272 HANDLE event_server_wrote;
273 HANDLE event_server_read;
274 HANDLE event_client_wrote;
275 HANDLE event_client_read;
276 HANDLE event_conn_closed;
277 size_t shared_memory_remain;
278 char *shared_memory_pos;