26#ifndef MYSQL_ROUTER_CHANNEL_INCLUDED
27#define MYSQL_ROUTER_CHANNEL_INCLUDED
32#include <system_error>
43#include <openssl/ssl.h>
70 std::vector<uint8_t, default_init_allocator<uint8_t>>;
81 recv_plain_buffer_.clear();
83 send_plain_buffer_.clear();
85 payload_buffer_.clear();
95 ssl_.reset(SSL_new(ssl_ctx));
97 SSL_set_bio(ssl_.get(), BIO_new(BIO_s_mem()), BIO_new(BIO_s_mem()));
113 bool tls_init_is_finished();
127 template <
class DynamicBuffer>
129 requires(net::is_dynamic_buffer_v<DynamicBuffer>)
131 auto orig_size = dyn_buf.size();
132 size_t transferred{};
134 auto write_res = write_plain(dyn_buf.data(0, orig_size));
139 transferred += write_res.value();
140 dyn_buf.consume(write_res.value());
152 return write_plain(b);
161 template <
class DynamicBuffer>
164 auto orig_size = dyn_buf.size();
166 size_t transferred{};
168 dyn_buf.grow(grow_size);
170 const auto res_res = read_plain(dyn_buf.data(orig_size, grow_size));
172 dyn_buf.shrink(grow_size);
176 transferred += res_res.value();
177 dyn_buf.shrink(grow_size - res_res.value());
252 recv_buffer_type &send_plain_buffer();
263 const recv_view_type &recv_view()
const;
280 const recv_view_type &recv_plain_view()
const;
283 void consume_raw(
size_t count);
286 void consume_plain(
size_t count);
289 void view_discard_raw();
292 void view_discard_plain();
295 void view_sync_raw();
298 void view_sync_plain();
324 SSL *
ssl()
const {
return ssl_.get(); }
SSL aware socket buffers.
Definition: channel.h:65
stdx::expected< size_t, std::error_code > write(const net::const_buffer &b)
write unencrypted net::const_buffer to the channel.
Definition: channel.h:151
recv_buffer_type send_buffer_
Definition: channel.h:342
recv_buffer_type send_plain_buffer_
Definition: channel.h:341
const recv_buffer_type & recv_buffer() const
buffer of data that was received from the socket.
Definition: channel.h:258
void clear()
clears all buffers.
Definition: channel.h:79
size_t want_recv() const
bytes wanted.
Definition: channel.h:235
stdx::expected< size_t, std::error_code > read(DynamicBuffer &dyn_buf, size_t sz)
read unencrypted data from channel to a net::dynamic_buffer.
Definition: channel.h:162
const recv_buffer_type & send_buffer() const
buffer of data to be sent to the socket.
Definition: channel.h:268
void init_ssl(SSL_CTX *ssl_ctx)
initialize the SSL session.
Definition: channel.h:94
void is_tls(bool v)
mark channel as containing TLS data in the recv_buffer().
Definition: channel.h:307
stdx::expected< size_t, std::error_code > write(DynamicBuffer &dyn_buf)
write unencrypted net::dynamic_buffer to the channel.
Definition: channel.h:128
void want_recv(size_t wanted)
bytes wanted.
Definition: channel.h:228
recv_buffer_type & payload_buffer()
Definition: channel.h:275
SSL * ssl() const
get access to the raw SSL handle.
Definition: channel.h:324
const recv_buffer_type & payload_buffer() const
payload buffer for
Definition: channel.h:273
Channel(Ssl ssl)
Definition: channel.h:74
recv_view_type recv_view_
Definition: channel.h:335
recv_buffer_type recv_buffer_
Definition: channel.h:334
std::span< typename recv_buffer_type::value_type > recv_view_type
Definition: channel.h:71
recv_view_type recv_plain_view_
Definition: channel.h:337
mysql_harness::Ssl Ssl
Definition: channel.h:72
recv_buffer_type & send_buffer()
buffer of data to be sent to the socket.
Definition: channel.h:247
std::vector< uint8_t, default_init_allocator< uint8_t > > recv_buffer_type
Definition: channel.h:70
bool is_tls() const
check if connection switched to TLS.
Definition: channel.h:312
recv_buffer_type & recv_buffer()
buffer of data that was received from the socket.
Definition: channel.h:240
recv_buffer_type payload_buffer_
Definition: channel.h:339
recv_buffer_type recv_plain_buffer_
Definition: channel.h:336
Definition: expected.h:286
static int count
Definition: myisam_ftdump.cc:45
constexpr value_type ssl
Definition: classic_protocol_constants.h:49
std::unique_ptr< SSL, mysql_harness::impl::Deleter_SSL > Ssl
Definition: tls_types.h:48
Definition: gcs_xcom_synode.h:64
unexpected(E) -> unexpected< E >
#define ROUTING_CONNECTIONS_EXPORT
Definition: routing_connections_export.h:15