1/* Copyright (C) 2013 by MontyProgram AB
2
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public
14 License along with this library; if not, write to the Free
15 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 MA 02111-1301, USA */
17
18/* defines for the libmariadb library */
19
20#ifndef _ma_common_h
21#define _ma_common_h
22
23#include <mysql.h>
24#include <ma_hash.h>
25
26enum enum_multi_status {
27 COM_MULTI_OFF= 0,
28 COM_MULTI_CANCEL,
29 COM_MULTI_ENABLED,
30 COM_MULTI_DISABLED,
31 COM_MULTI_END
32};
33
34typedef struct st_mariadb_db_driver
35{
36 struct st_mariadb_client_plugin_DB *plugin;
37 char *name;
38 void *buffer;
39} MARIADB_DB_DRIVER;
40
41struct mysql_async_context;
42
43struct st_mysql_options_extension {
44 char *plugin_dir;
45 char *default_auth;
46 char *ssl_crl;
47 char *ssl_crlpath;
48 char *server_public_key_path;
49 struct mysql_async_context *async_context;
50 HASH connect_attrs;
51 size_t connect_attrs_len;
52 void (*report_progress)(const MYSQL *mysql,
53 unsigned int stage,
54 unsigned int max_stage,
55 double progress,
56 const char *proc_info,
57 unsigned int proc_info_length);
58 MARIADB_DB_DRIVER *db_driver;
59 char *tls_fp; /* finger print of server certificate */
60 char *tls_fp_list; /* white list of finger prints */
61 char *tls_pw; /* password for encrypted certificates */
62 my_bool multi_command; /* indicates if client wants to send multiple
63 commands in one packet */
64 char *url; /* for connection handler we need to save URL for reconnect */
65 unsigned int tls_cipher_strength;
66 char *tls_version;
67 my_bool read_only;
68 char *connection_handler;
69 my_bool (*set_option)(MYSQL *mysql, const char *config_option, const char *config_value);
70 HASH userdata;
71 char *server_public_key;
72 char *proxy_header;
73 size_t proxy_header_len;
74};
75
76typedef struct st_connection_handler
77{
78 struct st_ma_connection_plugin *plugin;
79 void *data;
80 my_bool active;
81 my_bool free_data;
82} MA_CONNECTION_HANDLER;
83
84struct st_mariadb_net_extension {
85 enum enum_multi_status multi_status;
86};
87
88struct st_mariadb_session_state
89{
90 LIST *list,
91 *current;
92};
93
94struct st_mariadb_extension {
95 MA_CONNECTION_HANDLER *conn_hdlr;
96 struct st_mariadb_session_state session_state[SESSION_TRACK_TYPES];
97 unsigned long mariadb_client_flag; /* MariaDB specific client flags */
98 unsigned long mariadb_server_capabilities; /* MariaDB specific server capabilities */
99};
100
101#define OPT_EXT_VAL(a,key) \
102 ((a)->options.extension && (a)->options.extension->key) ?\
103 (a)->options.extension->key : 0
104
105#endif
106