26#ifndef ROUTER_SRC_OPENSSL_INCLUDE_TLS_TRACE_STREAM_H_
27#define ROUTER_SRC_OPENSSL_INCLUDE_TLS_TRACE_STREAM_H_
38#ifndef USE_CUSTOM_HOLDER
47template <
typename NameType,
typename LowerLevelStream>
67 template <
typename... Args>
78 template <
class MutableBufferSequence>
80 const MutableBufferSequence &buffers) {
84 template <
class ConstBufferSequence>
86 const ConstBufferSequence &buffers) {
90 template <
typename Buffer,
typename Handler>
98 template <
class HandshakeType,
class CompletionToken>
105 template <
typename Buffer,
typename Handler>
126 print(
"handle_read error:", ec,
", size:",
size);
132 print(
"handle_write error:", ec,
", size:",
size);
138 print(
"handle_handshake error:", ec,
", size:",
size);
141 template <
typename SettableSocketOption>
143 const SettableSocketOption &option) {
147 template <
typename... Args>
149 std::unique_lock<std::mutex> l{
mutex_};
151 <<
", " << NameType::get_name() <<
": ";
181 template <
typename Vector>
182 void dump(Vector &data,
size_t s) {
183 std::unique_lock<std::mutex> l{
mutex_};
184 auto it = data.begin();
187 while (it != data.end() && s) {
188 auto data_on_page = std::min(s, it->size());
189 const char *data_ptr = (
const char *)it->data();
190 auto to_print = data_on_page;
193 auto line = std::min(to_print, 16UL);
194 *
out_ <<
"this:" <<
parent_ <<
" " << std::hex << std::setfill(
'0')
195 << std::setw(8) << offset <<
" | ";
196 for (
size_t i = 0; i < line; ++i) {
197 *
out_ <<
" 0x" << std::setw(2) << (int)((
const uint8_t *)data_ptr)[i];
200 *
out_ << std::string((16 - line) * 5,
' ');
203 for (
size_t i = 0; i < line; ++i) {
204 *
out_ << (iscntrl(data_ptr[i]) ?
'?' : data_ptr[i]);
219 template <
typename Vector,
typename SrcBuffers>
220 void copy(Vector &dst,
const SrcBuffers &src) {
225 dst.emplace_back(it->data(), it->size());
232 template <
typename Arg,
typename... Args>
238 template <
typename WriteToken,
typename StandardToken>
241 using Write_token_result = std::decay_t<WriteToken>;
242 using Write_token_handler =
243 std::conditional_t<std::is_same<WriteToken, Write_token_result>::value,
244 Write_token_result &, Write_token_result>;
246 using Standard_token_result = std::decay_t<StandardToken>;
247 using Standard_token_handler = std::conditional_t<
248 std::is_same<StandardToken, Standard_token_result>::value,
249 Standard_token_result &, Standard_token_result>;
252 std::forward<Write_token_handler>(write_token),
253 std::forward<Standard_token_handler>(std_token));
256 template <
typename ReadToken,
typename StandardToken>
259 using Read_token_result = std::decay_t<ReadToken>;
260 using Read_token_handler =
261 std::conditional_t<std::is_same<ReadToken, Read_token_result>::value,
262 Read_token_result &, Read_token_result>;
264 using Standard_token_result = std::decay_t<StandardToken>;
265 using Standard_token_handler = std::conditional_t<
266 std::is_same<StandardToken, Standard_token_result>::value,
267 Standard_token_result &, Standard_token_result>;
270 std::forward<Standard_token_handler>(std_token));
273 template <
typename HandshakeToken,
typename StandardToken>
276 StandardToken &std_token) {
277 using Handshake_token_result = std::decay_t<HandshakeToken>;
278 using Handshake_token_handler = std::conditional_t<
279 std::is_same<HandshakeToken, Handshake_token_result>::value,
280 Handshake_token_result &, Handshake_token_result>;
282 using Standard_token_result = std::decay_t<StandardToken>;
283 using Standard_token_handler = std::conditional_t<
284 std::is_same<StandardToken, Standard_token_result>::value,
285 Standard_token_result &, Standard_token_result>;
288 std::forward<Handshake_token_handler>(handshake_token),
289 std::forward<Standard_token_handler>(std_token));
299template <
typename NameType,
typename LowerLevelStream>
Definition: trace_stream.h:300
const LowerLayerType & lower_layer() const
Definition: trace_stream.h:307
typename LowerLevelStream::LowerLayerType LowerLayerType
Definition: trace_stream.h:304
LowerLayerType & lower_layer()
Definition: trace_stream.h:306
Definition: trace_stream.h:158
void handle_write(std::error_code ec, size_t size)
Definition: trace_stream.h:169
WrappedTraceStream(TraceStream *parent=nullptr)
Definition: trace_stream.h:160
WrappedTraceStream(const WrappedTraceStream &other)
Definition: trace_stream.h:161
void handle_handshake(std::error_code ec, size_t size)
Definition: trace_stream.h:173
WrappedTraceStream(WrappedTraceStream &&other)
Definition: trace_stream.h:163
void handle_read(std::error_code ec, size_t size)
Definition: trace_stream.h:165
TraceStream * parent_
Definition: trace_stream.h:178
Definition: trace_stream.h:48
auto cancel()
Definition: trace_stream.h:115
typename LowerLevelStream::endpoint_type endpoint_type
Definition: trace_stream.h:55
VectorOfConstBuffers send_buffer_
Definition: trace_stream.h:293
auto async_handshake(HandshakeType type, CompletionToken &&token)
Definition: trace_stream.h:99
const LowerLevelStream & lower_layer() const
Definition: trace_stream.h:76
void handle_read(std::error_code ec, size_t size)
Definition: trace_stream.h:125
net::tls::LowerLayerWriteCompletionToken< WriteToken, StandardToken > get_write_handler(WriteToken &write_token, StandardToken &std_token)
Definition: trace_stream.h:240
void async_receive(const Buffer &buffer, Handler &&handler)
Definition: trace_stream.h:106
void handle_write(std::error_code ec, size_t size)
Definition: trace_stream.h:131
void copy(Vector &dst, const SrcBuffers &src)
Definition: trace_stream.h:220
std::vector< net::const_buffer > VectorOfConstBuffers
Definition: trace_stream.h:57
net::tls::LowerLayerHandshakeCompletionToken< HandshakeToken, StandardToken > get_handshake_handler(HandshakeToken &handshake_token, StandardToken &std_token)
Definition: trace_stream.h:275
std::nullptr_t protocol_type
Definition: trace_stream.h:54
net::tls::LowerLayerReadCompletionToken< ReadToken, StandardToken > get_read_handler(ReadToken &read_token, StandardToken &std_token)
Definition: trace_stream.h:258
void print_single()
Definition: trace_stream.h:230
stdx::expected< void, std::error_code > set_option(const SettableSocketOption &option)
Definition: trace_stream.h:142
TraceStream(TraceStream &&other)
Definition: trace_stream.h:59
TraceStream(Args &&...args)
Definition: trace_stream.h:68
std::ostream * out_
Definition: trace_stream.h:295
stdx::expected< size_t, std::error_code > write_some(const ConstBufferSequence &buffers)
Definition: trace_stream.h:85
std::vector< net::mutable_buffer > VectorOfBuffers
Definition: trace_stream.h:56
void set_parent(const char *parent)
Definition: trace_stream.h:113
void print(const Args &...args)
Definition: trace_stream.h:148
VectorOfBuffers recv_buffer_
Definition: trace_stream.h:292
auto get_executor()
Definition: trace_stream.h:73
std::nullptr_t native_handle_type
Definition: trace_stream.h:53
LowerLevelStream & lower_layer()
Definition: trace_stream.h:75
void handle_handshake(std::error_code ec, size_t size)
Definition: trace_stream.h:137
void async_send(const Buffer &buffer, Handler &&handler)
Definition: trace_stream.h:91
std::string parent_
Definition: trace_stream.h:296
LowerLevelStream lower_layer_
Definition: trace_stream.h:294
stdx::expected< size_t, std::error_code > read_some(const MutableBufferSequence &buffers)
Definition: trace_stream.h:79
void dump(Vector &data, size_t s)
Definition: trace_stream.h:182
void print_single(const Arg &arg, const Args... args)
Definition: trace_stream.h:233
auto close()
Definition: trace_stream.h:120
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4583
Definition: lower_layer_completion.h:115
Definition: lower_layer_completion.h:40
Definition: lower_layer_completion.h:77
static const std::string dec("DECRYPTION")
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
size_t size(const char *const c)
Definition: base64.h:46
HandshakeType
Definition: tls_stream.h:44
const const_buffer * buffer_sequence_end(const const_buffer &b) noexcept
Definition: buffer.h:185
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
const const_buffer * buffer_sequence_begin(const const_buffer &b) noexcept
Definition: buffer.h:180
size_t buffer_size(const ConstBufferSequence &buffers) noexcept
Definition: buffer.h:313
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
Definition: gcs_xcom_synode.h:64
pid_type get_id()
Definition: process.h:48
required string type
Definition: replication_group_member_actions.proto:34
uint read_token(const sql_digest_storage *digest_storage, uint index, uint *tok)
Read a single token from token array.
Definition: sql_digest.cc:56
Definition: mutex_static_holder.h:32
static std::mutex mutex_
Definition: mutex_static_holder.h:33
Definition: trace_stream.h:45