1 | /* adapted from violite.h from mysql 5.0.51 *( |
1 | /* adapted from violite.h from mysql 5.0.51 */ |
2 | /* all modifications public domain */ |
2 | /* all modifications public domain */ |
3 | /* Copyright (C) 2000 MySQL AB |
3 | /* Copyright (C) 2000 MySQL AB |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
… | |
… | |
26 | /* Simple vio interface in C; The functions are implemented in violite.c */ |
26 | /* Simple vio interface in C; The functions are implemented in violite.c */ |
27 | |
27 | |
28 | #ifdef __cplusplus |
28 | #ifdef __cplusplus |
29 | extern "C" { |
29 | extern "C" { |
30 | #endif /* __cplusplus */ |
30 | #endif /* __cplusplus */ |
|
|
31 | |
|
|
32 | #if MYSQL_VERSION_ID < 50100 |
|
|
33 | typedef I8 *xgptr; |
|
|
34 | typedef I8 *const cxgptr; |
|
|
35 | typedef int xlen; |
|
|
36 | #else |
|
|
37 | typedef U8 *xgptr; |
|
|
38 | typedef const U8 *cxgptr; |
|
|
39 | typedef size_t xlen; |
|
|
40 | #endif |
31 | |
41 | |
32 | enum enum_vio_type |
42 | enum enum_vio_type |
33 | { |
43 | { |
34 | VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, |
44 | VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, |
35 | VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY |
45 | VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY |
… | |
… | |
48 | HANDLE event_server_wrote, |
58 | HANDLE event_server_wrote, |
49 | HANDLE event_server_read, |
59 | HANDLE event_server_read, |
50 | HANDLE event_client_wrote, |
60 | HANDLE event_client_wrote, |
51 | HANDLE event_client_read, |
61 | HANDLE event_client_read, |
52 | HANDLE event_conn_closed); |
62 | HANDLE event_conn_closed); |
53 | int vio_read_pipe(Vio *vio, gptr buf, int size); |
63 | xlen vio_read_pipe(Vio *vio, xgptr buf, xlen size); |
54 | int vio_write_pipe(Vio *vio, const gptr buf, int size); |
64 | xlen vio_write_pipe(Vio *vio, xcgptr buf, xlen size); |
55 | int vio_close_pipe(Vio * vio); |
65 | xlen vio_close_pipe(Vio * vio); |
56 | #else |
66 | #else |
57 | #define HANDLE void * |
67 | #define HANDLE void * |
58 | #endif /* __WIN__ */ |
68 | #endif /* __WIN__ */ |
59 | |
69 | |
60 | void vio_delete(Vio* vio); |
70 | void vio_delete(Vio* vio); |
61 | int vio_close(Vio* vio); |
71 | int vio_close(Vio* vio); |
62 | void vio_reset(Vio* vio, enum enum_vio_type type, |
72 | void vio_reset(Vio* vio, enum enum_vio_type type, |
63 | my_socket sd, HANDLE hPipe, uint flags); |
73 | my_socket sd, HANDLE hPipe, uint flags); |
64 | int vio_read(Vio *vio, gptr buf, int size); |
74 | xlen vio_read(Vio *vio, xgptr buf, xlen size); |
65 | int vio_read_buff(Vio *vio, gptr buf, int size); |
75 | xlen vio_read_buff(Vio *vio, xgptr buf, xlen size); |
66 | int vio_write(Vio *vio, const gptr buf, int size); |
76 | xlen vio_write(Vio *vio, cxgptr buf, xlen size); |
67 | int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode); |
77 | int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode); |
68 | my_bool vio_is_blocking(Vio *vio); |
78 | my_bool vio_is_blocking(Vio *vio); |
69 | /* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */ |
79 | /* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */ |
70 | int vio_fastsend(Vio *vio); |
80 | int vio_fastsend(Vio *vio); |
71 | /* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */ |
81 | /* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */ |
… | |
… | |
86 | my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port); |
96 | my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port); |
87 | /* Remotes in_addr */ |
97 | /* Remotes in_addr */ |
88 | void vio_in_addr(Vio *vio, struct in_addr *in); |
98 | void vio_in_addr(Vio *vio, struct in_addr *in); |
89 | my_bool vio_poll_read(Vio *vio,uint timeout); |
99 | my_bool vio_poll_read(Vio *vio,uint timeout); |
90 | |
100 | |
91 | #ifdef HAVE_OPENSSL |
|
|
92 | #include <openssl/opensslv.h> |
|
|
93 | #if OPENSSL_VERSION_NUMBER < 0x0090700f |
|
|
94 | #define DES_cblock des_cblock |
|
|
95 | #define DES_key_schedule des_key_schedule |
|
|
96 | #define DES_set_key_unchecked(k,ks) des_set_key_unchecked((k),*(ks)) |
|
|
97 | #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)) |
|
|
98 | #endif |
|
|
99 | |
|
|
100 | #define HEADER_DES_LOCL_H dummy_something |
|
|
101 | #define YASSL_MYSQL_COMPATIBLE |
|
|
102 | #ifndef YASSL_PREFIX |
|
|
103 | #define YASSL_PREFIX |
|
|
104 | #endif |
|
|
105 | /* Set yaSSL to use same type as MySQL do for socket handles */ |
|
|
106 | typedef my_socket YASSL_SOCKET_T; |
|
|
107 | #define YASSL_SOCKET_T_DEFINED |
|
|
108 | #include <openssl/ssl.h> |
|
|
109 | #include <openssl/err.h> |
|
|
110 | |
|
|
111 | struct st_VioSSLFd |
|
|
112 | { |
|
|
113 | SSL_CTX *ssl_context; |
|
|
114 | }; |
|
|
115 | |
|
|
116 | int sslaccept(struct st_VioSSLFd*, Vio *, long timeout); |
|
|
117 | int sslconnect(struct st_VioSSLFd*, Vio *, long timeout); |
|
|
118 | |
|
|
119 | struct st_VioSSLFd |
|
|
120 | *new_VioSSLConnectorFd(const char *key_file, const char *cert_file, |
|
|
121 | const char *ca_file, const char *ca_path, |
|
|
122 | const char *cipher); |
|
|
123 | struct st_VioSSLFd |
|
|
124 | *new_VioSSLAcceptorFd(const char *key_file, const char *cert_file, |
|
|
125 | const char *ca_file,const char *ca_path, |
|
|
126 | const char *cipher); |
|
|
127 | #endif /* HAVE_OPENSSL */ |
|
|
128 | |
|
|
129 | #ifdef HAVE_SMEM |
|
|
130 | int vio_read_shared_memory(Vio *vio, gptr buf, int size); |
|
|
131 | int vio_write_shared_memory(Vio *vio, const gptr buf, int size); |
|
|
132 | int vio_close_shared_memory(Vio * vio); |
|
|
133 | #endif |
|
|
134 | |
|
|
135 | void vio_end(void); |
101 | void vio_end(void); |
136 | |
102 | |
137 | #ifdef __cplusplus |
103 | #ifdef __cplusplus |
138 | } |
104 | } |
139 | #endif |
105 | #endif |
… | |
… | |
167 | }; |
133 | }; |
168 | |
134 | |
169 | |
135 | |
170 | /* HFTODO - hide this if we don't want client in embedded server */ |
136 | /* HFTODO - hide this if we don't want client in embedded server */ |
171 | /* This structure is for every connection on both sides */ |
137 | /* This structure is for every connection on both sides */ |
|
|
138 | #if MYSQL_VERSION_ID < 50500 |
|
|
139 | |
172 | struct st_vio |
140 | struct st_vio |
173 | { |
141 | { |
174 | my_socket sd; /* my_socket - real or imaginary */ |
142 | my_socket sd; /* my_socket - real or imaginary */ |
175 | HANDLE hPipe; |
143 | HANDLE hPipe; |
176 | my_bool localhost; /* Are we from localhost? */ |
144 | my_bool localhost; /* Are we from localhost? */ |
… | |
… | |
184 | read buffer */ |
152 | read buffer */ |
185 | char *read_end; /* end of unfetched data */ |
153 | char *read_end; /* end of unfetched data */ |
186 | /* function pointers. They are similar for socket/SSL/whatever */ |
154 | /* function pointers. They are similar for socket/SSL/whatever */ |
187 | void (*viodelete)(Vio*); |
155 | void (*viodelete)(Vio*); |
188 | int (*vioerrno)(Vio*); |
156 | int (*vioerrno)(Vio*); |
189 | int (*read)(Vio*, gptr, int); |
157 | xlen (*read)(Vio*, xgptr, xlen); |
190 | int (*write)(Vio*, const gptr, int); |
158 | xlen (*write)(Vio*, cxgptr, xlen); |
191 | int (*vioblocking)(Vio*, my_bool, my_bool *); |
159 | int (*vioblocking)(Vio*, my_bool, my_bool *); |
192 | my_bool (*is_blocking)(Vio*); |
160 | my_bool (*is_blocking)(Vio*); |
193 | int (*viokeepalive)(Vio*, my_bool); |
161 | int (*viokeepalive)(Vio*, my_bool); |
194 | int (*fastsend)(Vio*); |
162 | int (*fastsend)(Vio*); |
195 | my_bool (*peer_addr)(Vio*, char *, uint16*); |
163 | my_bool (*peer_addr)(Vio*, char *, uint16*); |
196 | void (*in_addr)(Vio*, struct in_addr*); |
164 | void (*in_addr)(Vio*, struct in_addr*); |
197 | my_bool (*should_retry)(Vio*); |
165 | my_bool (*should_retry)(Vio*); |
198 | my_bool (*was_interrupted)(Vio*); |
166 | my_bool (*was_interrupted)(Vio*); |
199 | int (*vioclose)(Vio*); |
167 | int (*vioclose)(Vio*); |
200 | void (*timeout)(Vio*, unsigned int which, unsigned int timeout); |
168 | void (*timeout)(Vio*, unsigned int which, unsigned int timeout); |
201 | #ifdef HAVE_OPENSSL |
169 | }; |
202 | void *ssl_arg; |
170 | |
|
|
171 | #else |
|
|
172 | |
|
|
173 | struct st_vio |
|
|
174 | { |
|
|
175 | my_socket sd; /* my_socket - real or imaginary */ |
|
|
176 | HANDLE hPipe; |
|
|
177 | my_bool localhost; /* Are we from localhost? */ |
|
|
178 | int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */ |
|
|
179 | struct sockaddr_storage local; /* Local internet address */ |
|
|
180 | struct sockaddr_storage remote; /* Remote internet address */ |
|
|
181 | int addrLen; /* Length of remote address */ |
|
|
182 | enum enum_vio_type type; /* Type of connection */ |
|
|
183 | char desc[30]; /* String description */ |
|
|
184 | char *read_buffer; /* buffer for vio_read_buff */ |
|
|
185 | char *read_pos; /* start of unfetched data in the |
|
|
186 | read buffer */ |
|
|
187 | char *read_end; /* end of unfetched data */ |
|
|
188 | /* function pointers. They are similar for socket/SSL/whatever */ |
|
|
189 | void (*viodelete)(Vio*); |
|
|
190 | int (*vioerrno)(Vio*); |
|
|
191 | size_t (*read)(Vio*, unsigned char *, size_t); |
|
|
192 | size_t (*write)(Vio*, const unsigned char *, size_t); |
|
|
193 | int (*vioblocking)(Vio*, my_bool, my_bool *); |
|
|
194 | my_bool (*is_blocking)(Vio*); |
|
|
195 | int (*viokeepalive)(Vio*, my_bool); |
|
|
196 | int (*fastsend)(Vio*); |
|
|
197 | my_bool (*peer_addr)(Vio*, char *, uint16*, size_t); |
|
|
198 | void (*in_addr)(Vio*, struct sockaddr_storage*); |
|
|
199 | my_bool (*should_retry)(Vio*); |
|
|
200 | my_bool (*was_interrupted)(Vio*); |
|
|
201 | int (*vioclose)(Vio*); |
|
|
202 | void (*timeout)(Vio*, unsigned int which, unsigned int timeout); |
|
|
203 | my_bool (*poll_read)(Vio *vio, uint timeout); |
|
|
204 | my_bool (*is_connected)(Vio*); |
|
|
205 | my_bool (*has_data) (Vio*); |
|
|
206 | }; |
|
|
207 | |
203 | #endif |
208 | #endif |
204 | #ifdef HAVE_SMEM |
209 | |
205 | HANDLE handle_file_map; |
|
|
206 | char *handle_map; |
|
|
207 | HANDLE event_server_wrote; |
|
|
208 | HANDLE event_server_read; |
|
|
209 | HANDLE event_client_wrote; |
|
|
210 | HANDLE event_client_read; |
|
|
211 | HANDLE event_conn_closed; |
|
|
212 | long shared_memory_remain; |
|
|
213 | char *shared_memory_pos; |
|
|
214 | NET *net; |
|
|
215 | #endif /* HAVE_SMEM */ |
|
|
216 | }; |
|
|
217 | #endif /* vio_violite_h_ */ |
210 | #endif /* vio_violite_h_ */ |