1 /* 2 * Copyright (c) 2015, 2021, Oracle and/or its affiliates. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License, version 2.0, 6 * as published by the Free Software Foundation. 7 * 8 * This program is also distributed with certain software (including 9 * but not limited to OpenSSL) that is licensed under separate terms, 10 * as designated in a particular file or component or in included license 11 * documentation. The authors of MySQL hereby grant you an additional 12 * permission to link the program and your derivative works with the 13 * separately licensed software that they have included with MySQL. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License, version 2.0, for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 23 * 02110-1301 USA 24 */ 25 26 #ifndef _XPL_CLIENT_H_ 27 #define _XPL_CLIENT_H_ 28 29 30 #include "ngs/client.h" 31 #include "ngs/protocol_monitor.h" 32 33 struct st_mysql_show_var; 34 35 namespace xpl 36 { 37 class Session; 38 39 class Client; 40 41 class Protocol_monitor : public ngs::Protocol_monitor_interface 42 { 43 public: Protocol_monitor()44 Protocol_monitor() : m_client(0) {} 45 void init(Client *client); 46 47 virtual void on_notice_warning_send(); 48 virtual void on_notice_other_send(); 49 virtual void on_error_send(); 50 virtual void on_fatal_error_send(); 51 virtual void on_init_error_send(); 52 virtual void on_row_send(); 53 virtual void on_send(long bytes_transferred); 54 virtual void on_receive(long bytes_transferred); 55 virtual void on_error_unknown_msg_type(); 56 57 private: 58 Client *m_client; 59 }; 60 61 class Client : public ngs::Client 62 { 63 public: 64 Client(ngs::Connection_ptr connection, ngs::Server_interface &server, Client_id client_id, Protocol_monitor *pmon); 65 virtual ~Client(); 66 67 public: // impl ngs::Client_interface 68 virtual void on_session_close(ngs::Session_interface &s); 69 virtual void on_session_reset(ngs::Session_interface &s); 70 71 virtual void on_server_shutdown(); 72 virtual void on_auth_timeout(); 73 74 public: // impl ngs::Client 75 virtual void on_network_error(int error); 76 virtual std::string resolve_hostname(); 77 virtual ngs::Capabilities_configurator *capabilities_configurator(); 78 79 public: 80 void set_supports_expired_passwords(bool flag); 81 bool supports_expired_passwords(); 82 bool is_handler_thd(THD *thd); 83 84 void get_status_ssl_cipher_list(st_mysql_show_var *var); 85 86 void kill(); 87 ngs::shared_ptr<xpl::Session> get_session(); 88 89 private: 90 bool is_localhost(const char *hostname); 91 92 bool m_supports_expired_passwords; 93 Protocol_monitor *m_protocol_monitor; 94 }; 95 96 typedef ngs::shared_ptr<Client> Client_ptr; 97 98 } // namespace xpl 99 100 101 #endif // _XPL_CLIENT_H_ 102