MySQL 8.4.3
Source Code Documentation
|
Vio Lite. More...
#include "my_config.h"
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <string>
#include "my_inttypes.h"
#include "my_psi_config.h"
#include "mysql/components/services/bits/my_io_bits.h"
#include "mysql/components/services/bits/my_thread_bits.h"
#include "mysql/components/services/bits/mysql_socket_bits.h"
#include "mysql/psi/mysql_socket.h"
#include <signal.h>
#include <atomic>
#include <optional>
#include <openssl/opensslv.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
Go to the source code of this file.
Classes | |
struct | st_VioSSLFd |
struct | Vio |
Macros | |
#define | USE_PPOLL_IN_VIO |
#define | MYSQL_VIO Vio * |
#define | VIO_SOCKET_ERROR ((size_t)-1) |
#define | VIO_SOCKET_WANT_READ ((size_t)-2) |
#define | VIO_SOCKET_WANT_WRITE ((size_t)-3) |
#define | VIO_LOCALHOST 1 /* a localhost connection */ |
#define | VIO_BUFFERED_READ 2 /* use buffered read */ |
#define | VIO_READ_BUFFER_SIZE 16384 /* size of read buffer */ |
#define | HANDLE void * |
#define | VIO_DESCRIPTION_SIZE 30 /* size of description */ |
#define | DES_cblock des_cblock |
#define | DES_key_schedule des_key_schedule |
#define | DES_set_key_unchecked(k, ks) des_set_key_unchecked((k), *(ks)) |
#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)) |
#define | HEADER_DES_LOCL_H dummy_something |
#define | vio_delete(vio) (vio)->viodelete(vio) |
#define | vio_errno(vio) (vio)->vioerrno(vio) |
#define | vio_read(vio, buf, size) ((vio)->read)(vio, buf, size) |
#define | vio_write(vio, buf, size) ((vio)->write)(vio, buf, size) |
#define | vio_fastsend(vio) (vio)->fastsend(vio) |
#define | vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive) |
#define | vio_should_retry(vio) (vio)->should_retry(vio) |
#define | vio_was_timeout(vio) (vio)->was_timeout(vio) |
#define | vio_shutdown(vio) ((vio)->vioshutdown)(vio) |
#define | vio_peer_addr(vio, buf, prt, buflen) (vio)->peer_addr(vio, buf, prt, buflen) |
#define | vio_io_wait(vio, event, timeout) (vio)->io_wait(vio, event, timeout) |
#define | vio_is_connected(vio) (vio)->is_connected(vio) |
#define | vio_is_blocking(vio) (vio)->is_blocking(vio) |
#define | vio_set_blocking(vio, val) (vio)->set_blocking(vio, val) |
#define | vio_set_blocking_flag(vio, val) (vio)->set_blocking_flag(vio, val) |
#define | SSL_handle SSL * |
Typedefs | |
typedef Vio | Vio |
Enumerations | |
enum | enum_vio_type : int { NO_VIO_TYPE = 0 , VIO_TYPE_TCPIP = 1 , VIO_TYPE_SOCKET = 2 , VIO_TYPE_NAMEDPIPE = 3 , VIO_TYPE_SSL = 4 , VIO_TYPE_SHARED_MEMORY = 5 , VIO_TYPE_LOCAL = 6 , VIO_TYPE_PLUGIN = 7 , FIRST_VIO_TYPE = VIO_TYPE_TCPIP , LAST_VIO_TYPE = VIO_TYPE_PLUGIN } |
enum | enum_vio_io_event { VIO_IO_EVENT_READ , VIO_IO_EVENT_WRITE , VIO_IO_EVENT_CONNECT } |
VIO I/O events. More... | |
enum | enum_ssl_init_error { SSL_INITERR_NOERROR = 0 , SSL_INITERR_CERT , SSL_INITERR_KEY , SSL_INITERR_NOMATCH , SSL_INITERR_BAD_PATHS , SSL_INITERR_CIPHERS , SSL_INITERR_MEMFAIL , SSL_INITERR_NO_USABLE_CTX , SSL_INITERR_DHFAIL , SSL_TLS_VERSION_INVALID , SSL_FIPS_MODE_INVALID , SSL_FIPS_MODE_FAILED , SSL_INITERR_ECDHFAIL , SSL_INITERR_X509_VERIFY_PARAM , SSL_INITERR_INVALID_CERTIFICATES , SSL_INITERR_LASTERR } |
enum | SSL_type { SSL_TYPE_NOT_SPECIFIED = -1 , SSL_TYPE_NONE , SSL_TYPE_ANY , SSL_TYPE_X509 , SSL_TYPE_SPECIFIED } |
Functions | |
void | init_vio_psi_keys () |
void | get_vio_type_name (enum enum_vio_type vio_type, const char **str, int *len) |
Convert a vio type to a printable string. More... | |
MYSQL_VIO | vio_new (my_socket sd, enum enum_vio_type type, uint flags) |
MYSQL_VIO | mysql_socket_vio_new (MYSQL_SOCKET mysql_socket, enum enum_vio_type type, uint flags) |
void | vio_delete (MYSQL_VIO vio) |
int | vio_shutdown (MYSQL_VIO vio) |
bool | vio_reset (MYSQL_VIO vio, enum enum_vio_type type, my_socket sd, void *ssl, uint flags) |
bool | vio_is_blocking (Vio *vio) |
int | vio_set_blocking (Vio *vio, bool set_blocking_mode) |
int | vio_set_blocking_flag (Vio *vio, bool set_blocking_flag) |
size_t | vio_read (MYSQL_VIO vio, uchar *buf, size_t size) |
size_t | vio_read_buff (MYSQL_VIO vio, uchar *buf, size_t size) |
size_t | vio_write (MYSQL_VIO vio, const uchar *buf, size_t size) |
int | vio_fastsend (MYSQL_VIO vio) |
int | vio_keepalive (MYSQL_VIO vio, bool onoff) |
bool | vio_should_retry (MYSQL_VIO vio) |
bool | vio_was_timeout (MYSQL_VIO vio) |
void | vio_description (MYSQL_VIO vio, char *buf) |
enum enum_vio_type | vio_type (const MYSQL_VIO vio) |
int | vio_errno (MYSQL_VIO vio) |
my_socket | vio_fd (MYSQL_VIO vio) |
bool | vio_peer_addr (MYSQL_VIO vio, char *buf, uint16 *port, size_t buflen) |
int | vio_io_wait (MYSQL_VIO vio, enum enum_vio_io_event event, int timeout) |
bool | vio_is_connected (MYSQL_VIO vio) |
ssize_t | vio_pending (MYSQL_VIO vio) |
int | vio_timeout (MYSQL_VIO vio, uint which, int timeout_sec) |
bool | vio_socket_connect (MYSQL_VIO vio, struct sockaddr *addr, socklen_t len, bool nonblocking, int timeout, bool *connect_done=nullptr) |
bool | vio_get_normalized_ip_string (const struct sockaddr *addr, size_t addr_length, char *ip_string, size_t ip_string_size) |
Return the normalized IP address string for a sock-address. More... | |
bool | vio_is_no_name_error (int err_code) |
Checks if the error code, returned by vio_getnameinfo(), means it was the "No-name" error. More... | |
int | vio_getnameinfo (const struct sockaddr *sa, char *hostname, size_t hostname_size, char *port, size_t port_size, int flags) |
This is a wrapper for the system getnameinfo(), because different OS differ in the getnameinfo() implementation: More... | |
const char * | sslGetErrString (enum enum_ssl_init_error err) |
int | sslaccept (struct st_VioSSLFd *, MYSQL_VIO, long timeout, unsigned long *errptr) |
int | sslconnect (struct st_VioSSLFd *, MYSQL_VIO, long timeout, SSL_SESSION *session, unsigned long *errptr, SSL **ssl, const char *sni_servername) |
struct st_VioSSLFd * | new_VioSSLConnectorFd (const char *key_file, const char *cert_file, const char *ca_file, const char *ca_path, const char *cipher, const char *ciphersuites, enum enum_ssl_init_error *error, const char *crl_file, const char *crl_path, const long ssl_ctx_flags, const char *server_host) |
long | process_tls_version (const char *tls_version) |
struct st_VioSSLFd * | new_VioSSLAcceptorFd (const char *key_file, const char *cert_file, const char *ca_file, const char *ca_path, const char *cipher, const char *ciphersuites, enum enum_ssl_init_error *error, const char *crl_file, const char *crl_path, const long ssl_ctx_flags) |
void | free_vio_ssl_acceptor_fd (struct st_VioSSLFd *fd) |
void | vio_ssl_end () |
void | ssl_start (void) |
void | vio_end (void) |
Vio Lite.
Purpose: include file for Vio that will work with C and C++.
#define DES_cblock des_cblock |
#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)) |
#define DES_key_schedule des_key_schedule |
#define DES_set_key_unchecked | ( | k, | |
ks | |||
) | des_set_key_unchecked((k), *(ks)) |
#define HANDLE void * |
#define HEADER_DES_LOCL_H dummy_something |
#define MYSQL_VIO Vio * |
#define SSL_handle SSL * |
#define USE_PPOLL_IN_VIO |
#define VIO_BUFFERED_READ 2 /* use buffered read */ |
#define vio_delete | ( | vio | ) | (vio)->viodelete(vio) |
#define VIO_DESCRIPTION_SIZE 30 /* size of description */ |
#define vio_errno | ( | vio | ) | (vio)->vioerrno(vio) |
#define vio_fastsend | ( | vio | ) | (vio)->fastsend(vio) |
#define vio_is_blocking | ( | vio | ) | (vio)->is_blocking(vio) |
#define vio_is_connected | ( | vio | ) | (vio)->is_connected(vio) |
#define vio_keepalive | ( | vio, | |
set_keep_alive | |||
) | (vio)->viokeepalive(vio, set_keep_alive) |
#define VIO_LOCALHOST 1 /* a localhost connection */ |
#define VIO_READ_BUFFER_SIZE 16384 /* size of read buffer */ |
#define vio_set_blocking | ( | vio, | |
val | |||
) | (vio)->set_blocking(vio, val) |
#define vio_set_blocking_flag | ( | vio, | |
val | |||
) | (vio)->set_blocking_flag(vio, val) |
#define vio_should_retry | ( | vio | ) | (vio)->should_retry(vio) |
#define vio_shutdown | ( | vio | ) | ((vio)->vioshutdown)(vio) |
#define VIO_SOCKET_ERROR ((size_t)-1) |
#define VIO_SOCKET_WANT_READ ((size_t)-2) |
#define VIO_SOCKET_WANT_WRITE ((size_t)-3) |
#define vio_was_timeout | ( | vio | ) | (vio)->was_timeout(vio) |
enum enum_ssl_init_error |
enum enum_vio_io_event |
enum enum_vio_type : int |
enum SSL_type |
void free_vio_ssl_acceptor_fd | ( | struct st_VioSSLFd * | fd | ) |
void get_vio_type_name | ( | enum enum_vio_type | vio_type, |
const char ** | str, | ||
int * | len | ||
) |
Convert a vio type to a printable string.
vio_type | the type | |
[out] | str | the string |
[out] | len | the string length |
void init_vio_psi_keys | ( | ) |
MYSQL_VIO mysql_socket_vio_new | ( | MYSQL_SOCKET | mysql_socket, |
enum enum_vio_type | type, | ||
uint | flags | ||
) |
struct st_VioSSLFd * new_VioSSLAcceptorFd | ( | const char * | key_file, |
const char * | cert_file, | ||
const char * | ca_file, | ||
const char * | ca_path, | ||
const char * | cipher, | ||
const char * | ciphersuites, | ||
enum enum_ssl_init_error * | error, | ||
const char * | crl_file, | ||
const char * | crl_path, | ||
const long | ssl_ctx_flags | ||
) |
struct st_VioSSLFd * new_VioSSLConnectorFd | ( | const char * | key_file, |
const char * | cert_file, | ||
const char * | ca_file, | ||
const char * | ca_path, | ||
const char * | cipher, | ||
const char * | ciphersuites, | ||
enum enum_ssl_init_error * | error, | ||
const char * | crl_file, | ||
const char * | crl_path, | ||
const long | ssl_ctx_flags, | ||
const char * | server_host | ||
) |
long process_tls_version | ( | const char * | tls_version | ) |
void ssl_start | ( | void | ) |
int sslaccept | ( | struct st_VioSSLFd * | , |
MYSQL_VIO | , | ||
long | timeout, | ||
unsigned long * | errptr | ||
) |
int sslconnect | ( | struct st_VioSSLFd * | , |
MYSQL_VIO | , | ||
long | timeout, | ||
SSL_SESSION * | session, | ||
unsigned long * | errptr, | ||
SSL ** | ssl, | ||
const char * | sni_servername | ||
) |
const char * sslGetErrString | ( | enum enum_ssl_init_error | err | ) |
void vio_delete | ( | MYSQL_VIO | vio | ) |
void vio_description | ( | MYSQL_VIO | vio, |
char * | buf | ||
) |
void vio_end | ( | void | ) |
int vio_errno | ( | MYSQL_VIO | vio | ) |
int vio_fastsend | ( | MYSQL_VIO | vio | ) |
bool vio_get_normalized_ip_string | ( | const struct sockaddr * | addr, |
size_t | addr_length, | ||
char * | ip_string, | ||
size_t | ip_string_size | ||
) |
Return the normalized IP address string for a sock-address.
The idea is to return an IPv4-address for an IPv4-mapped and IPv4-compatible IPv6 address.
The function writes the normalized IP address to the given buffer. The buffer should have enough space, otherwise error flag is returned. The system constant INET6_ADDRSTRLEN can be used to reserve buffers of the right size.
[in] | addr | sockaddr object (AF_INET or AF_INET6). |
[in] | addr_length | length of the addr. |
[out] | ip_string | buffer to write normalized IP address. |
[in] | ip_string_size | size of the ip_string. |
true | in case of error (the ip_string buffer is not enough). |
false | on success. |
int vio_getnameinfo | ( | const struct sockaddr * | sa, |
char * | hostname, | ||
size_t | hostname_size, | ||
char * | port, | ||
size_t | port_size, | ||
int | flags | ||
) |
This is a wrapper for the system getnameinfo(), because different OS differ in the getnameinfo() implementation:
int vio_io_wait | ( | MYSQL_VIO | vio, |
enum enum_vio_io_event | event, | ||
int | timeout | ||
) |
bool vio_is_blocking | ( | Vio * | vio | ) |
bool vio_is_connected | ( | MYSQL_VIO | vio | ) |
bool vio_is_no_name_error | ( | int | err_code | ) |
Checks if the error code, returned by vio_getnameinfo(), means it was the "No-name" error.
Windows-specific note: getnameinfo() returns WSANO_DATA instead of EAI_NODATA or EAI_NONAME when no reverse mapping is available at the host (i.e. Windows can't get hostname by IP-address). This error should be treated as EAI_NONAME.
true | if the error code is EAI_NONAME. |
false | otherwise. |
int vio_keepalive | ( | MYSQL_VIO | vio, |
bool | onoff | ||
) |
MYSQL_VIO vio_new | ( | my_socket | sd, |
enum enum_vio_type | type, | ||
uint | flags | ||
) |
ssize_t vio_pending | ( | MYSQL_VIO | vio | ) |
bool vio_reset | ( | MYSQL_VIO | vio, |
enum enum_vio_type | type, | ||
my_socket | sd, | ||
void * | ssl, | ||
uint | flags | ||
) |
int vio_set_blocking | ( | Vio * | vio, |
bool | set_blocking_mode | ||
) |
int vio_set_blocking_flag | ( | Vio * | vio, |
bool | set_blocking_flag | ||
) |
bool vio_should_retry | ( | MYSQL_VIO | vio | ) |
int vio_shutdown | ( | MYSQL_VIO | vio | ) |
bool vio_socket_connect | ( | MYSQL_VIO | vio, |
struct sockaddr * | addr, | ||
socklen_t | len, | ||
bool | nonblocking, | ||
int | timeout, | ||
bool * | connect_done = nullptr |
||
) |
void vio_ssl_end | ( | ) |
int vio_timeout | ( | MYSQL_VIO | vio, |
uint | which, | ||
int | timeout_sec | ||
) |
enum enum_vio_type vio_type | ( | const MYSQL_VIO | vio | ) |
bool vio_was_timeout | ( | MYSQL_VIO | vio | ) |