26#ifndef ROUTER_SRC_OPENSSL_INCLUDE_TLS_DETAILS_SSL_OPERATION_H_
27#define ROUTER_SRC_OPENSSL_INCLUDE_TLS_DETAILS_SSL_OPERATION_H_
29#include <openssl/bio.h>
43 return std::addressof(b);
48 return std::addressof(b) + 1;
53 return std::addressof(b);
58 return std::addressof(b) + 1;
63 ->
decltype(c.begin()) {
74 template <
typename Layer,
typename Handler>
76 return layer->async_receive(input,
handler);
79 template <
typename Layer,
typename Handler>
81 return layer->async_send(output,
handler);
91 template <
typename Layer,
typename Handler>
96 template <
typename Layer,
typename Handler>
101 template <
typename Handler>
112 template <
typename Handler>
127template <
typename SslIO,
typename BufferSequence,
typename Token,
133 std::conditional_t<std::is_same<Token, Token_result>::value,
136 template <
typename UniToken>
167 return Operation::Result::fatal;
177 return Operation::Result::fatal;
194 size_t page_begin = 0;
195 size_t page_end = it->size();
198 const bool is_last = it_next == end;
201 page_begin = page_end;
202 if (it != end) page_end += it->size();
207 size_t number_of_bytes = 0;
210 cast_and_increment<uint8_t>(it->data(),
page_offset),
215 debug_print(
"do_it - ", (SslIO::is_read_operation() ?
"read" :
"write"),
219 case Operation::Result::fatal:
227 case Operation::Result::ok:
231 case Operation::Result::want_read: {
234 return Operation::Result::ok;
239 case Operation::Result::want_write:
244 return Operation::Result::ok;
247 template <
typename HandlerToken>
249 HandlerToken &&token) {
251 std::forward<HandlerToken>(token),
NOP_token());
254 template <
typename HandlerToken>
256 HandlerToken &&token) {
258 std::forward<HandlerToken>(token),
NOP_token());
261 void do_token(
const std::error_code &ec,
const size_t no_of_bytes) {
268#if OPENSSL_VERSION_NUMBER >= NET_TLS_USE_BACKWARD_COMPATIBLE_OPENSSL
282#if OPENSSL_VERSION_NUMBER >= NET_TLS_USE_BACKWARD_COMPATIBLE_OPENSSL
294 debug_print(
"do_write - ", (SslIO::is_read_operation() ?
"read" :
"write"));
305 return Operation::Result::want_write;
309 debug_print(
"do_read - ", (SslIO::is_read_operation() ?
"read" :
"write"));
313 return Operation::Result::want_read;
322 template <
typename... Parameters>
323 void debug_print([[maybe_unused]] Parameters &&...parameters)
const {
328 template <
typename Type>
330 return static_cast<const Type *
>(ptr) + value;
333 template <
typename Type>
335 return static_cast<Type *
>(ptr) + value;
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4583
Definition: ssl_io_completion.h:72
auto send(Layer *layer, FlexibleOutputBuffer &output, Handler &&handler)
Definition: ssl_io_completion.h:80
auto recv(Layer *layer, FlexibleInputBuffer &input, Handler &&handler)
Definition: ssl_io_completion.h:75
size_t size_used() const
Definition: flexible_buffer.h:59
bool pop(size_t v) noexcept
Definition: flexible_buffer.h:67
void * data_free() const
Definition: flexible_buffer.h:57
void * data_used() const noexcept
Definition: flexible_buffer.h:56
bool push(size_t v) noexcept
Definition: flexible_buffer.h:78
size_t size_free() const
Definition: flexible_buffer.h:58
Definition: flexible_buffer.h:91
Definition: lower_layer_completion.h:40
Definition: lower_layer_completion.h:77
Definition: lower_layer_completion.h:34
Result
Definition: ssl_operation.h:41
Definition: ssl_io_completion.h:129
FlexibleInputBuffer & input_
Definition: ssl_io_completion.h:341
int bio_write_ex(size_t *out_written)
Definition: ssl_io_completion.h:279
static Type * cast_and_increment(void *ptr, int value)
Definition: ssl_io_completion.h:334
LowerLayerReadCompletionToken< HandlerToken, NOP_token > get_read_handler(HandlerToken &&token)
Definition: ssl_io_completion.h:255
Operation::Result handle_read(std::error_code ec, size_t size)
Definition: ssl_io_completion.h:164
FlexibleOutputBuffer & output_
Definition: ssl_io_completion.h:340
int bio_read_ex(size_t *out_readbytes)
Definition: ssl_io_completion.h:265
Action action_
Definition: ssl_io_completion.h:344
Token token_
Definition: ssl_io_completion.h:343
Operation::Result do_write()
Definition: ssl_io_completion.h:293
SslIoCompletionToken(TlsLayer &tls_layer, const BufferSequence &buffer, UniToken &&token, Action action=Action())
Definition: ssl_io_completion.h:137
std::decay_t< Token > Token_result
Definition: ssl_io_completion.h:131
std::conditional_t< std::is_same< Token, Token_result >::value, Token_result &, Token_result > Token_handler
Definition: ssl_io_completion.h:134
Operation::Result handle_write(std::error_code ec, size_t size)
Definition: ssl_io_completion.h:174
SslIoCompletionToken(SslIoCompletionToken &&other)
Definition: ssl_io_completion.h:146
SslIoCompletionToken(const SslIoCompletionToken &other)
Definition: ssl_io_completion.h:155
Operation::Result do_it()
Definition: ssl_io_completion.h:188
TlsLayer & tls_layer_
Definition: ssl_io_completion.h:339
const BufferSequence buffer_
Definition: ssl_io_completion.h:342
LowerLayerWriteCompletionToken< HandlerToken > get_write_handler(HandlerToken &&token)
Definition: ssl_io_completion.h:248
size_t number_bytes_transfered_
Definition: ssl_io_completion.h:338
Operation::Result do_read()
Definition: ssl_io_completion.h:308
void debug_print(Parameters &&...parameters) const
Definition: ssl_io_completion.h:323
static const Type * cast_and_increment(const void *ptr, int value)
Definition: ssl_io_completion.h:329
void do_token(const std::error_code &ec, const size_t no_of_bytes)
Definition: ssl_io_completion.h:261
Definition: ssl_io_completion.h:85
Handler_result handle_write_result(Handler *handler)
Definition: ssl_io_completion.h:102
auto send(Layer *layer, FlexibleOutputBuffer &output, Handler &&)
Definition: ssl_io_completion.h:97
Handler_result handle_read_result(Handler *handler)
Definition: ssl_io_completion.h:113
Handler_arguments write_result_
Definition: ssl_io_completion.h:123
Handler_arguments read_result_
Definition: ssl_io_completion.h:124
auto recv(Layer *layer, FlexibleInputBuffer &input, Handler &&)
Definition: ssl_io_completion.h:92
Definition: expected.h:286
std::error_code make_error_code(DynamicLoaderErrc ec)
make error_code from a DynamicLoaderErrc.
Definition: dynamic_loader.cc:79
size_t size(const char *const c)
Definition: base64.h:46
stdx::expected< void, std::error_code > close(file_handle_type native_handle)
close file handle.
Definition: file.h:239
const mutable_buffer * tls_buffer_sequence_begin(const mutable_buffer &b) noexcept
Definition: ssl_io_completion.h:41
const mutable_buffer * tls_buffer_sequence_end(const mutable_buffer &b) noexcept
Definition: ssl_io_completion.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
size_t buffer_size(const ConstBufferSequence &buffers) noexcept
Definition: buffer.h:313
Type
Definition: resource_group_basic_types.h:33
Definition: gcs_xcom_synode.h:64
Definition: tls_keylog_dumper.h:32
static ulint page_offset(const void *ptr)
Gets the offset within a page.
struct result result
Definition: result.h:34
message Action
Definition: replication_group_member_actions.proto:30
repeated Action action
Definition: replication_group_member_actions.proto:43
Definition: ssl_io_completion.h:87
HARNESS_TLS_EXPORT std::error_code make_tls_error()
make a std::error_code from ERR_get_error().
Definition: tls_error.cc:100