Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Botan::TLS::detail::AsyncReadOperation< Handler, Stream, MutableBufferSequence, Allocator > Class Template Reference

`#include <asio_async_ops.h>`

Inheritance diagram for Botan::TLS::detail::AsyncReadOperation< Handler, Stream, MutableBufferSequence, Allocator >:

## Public Types
using | allocator_type = boost::asio::associated_allocator_t< Handler, Allocator >
using | executor_type = boost::asio::associated_executor_t< Handler, Stream::executor_type >

## Public Member Functions
template<class HandlerT >
| AsyncReadOperation (HandlerT &&handler, Stream &stream, const MutableBufferSequence &buffers, const boost::system::error_code &ec={})
| AsyncReadOperation (AsyncReadOperation &&)=default
allocator_type | get_allocator () const noexcept
executor_type | get_executor () const noexcept
void | operator() (boost::system::error_code ec, std::size_t bytes_transferred, bool isContinuation=true)

## Protected Member Functions
void | complete_now (Args &&...args)

## Protected Attributes
Handler | m_handler
boost::asio::executor_work_guard< Stream::executor_type > | m_work_guard_1

## Detailed Description

### template<class Handler, class Stream, class MutableBufferSequence, class Allocator = std::allocator<void>>
class Botan::TLS::detail::AsyncReadOperation< Handler, Stream, MutableBufferSequence, Allocator >

Definition at line 111 of file asio_async_ops.h.

## Member Typedef Documentation

using Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type , Allocator >::allocator_type = boost::asio::associated_allocator_t<Handler, Allocator>
| inherited

Definition at line 71 of file asio_async_ops.h.

using Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type , Allocator >::executor_type = boost::asio::associated_executor_t<Handler, Stream::executor_type >
| inherited

Definition at line 72 of file asio_async_ops.h.

## Constructor & Destructor Documentation

template<class Handler, class Stream, class MutableBufferSequence, class Allocator = std::allocator<void>>
template<class HandlerT >

Botan::TLS::detail::AsyncReadOperation< Handler, Stream, MutableBufferSequence, Allocator >::AsyncReadOperation | ( | HandlerT && | handler,
|  | Stream & | stream,
|  | const MutableBufferSequence & | buffers,
|  | const boost::system::error_code & | ec = `{}`
| ) |  |
| inline

Construct and invoke an AsyncReadOperation.

Parameters

  handler | Handler function to be called upon completion.
  stream | The stream from which the data will be read
  buffers | The buffers into which the data will be read.
  ec | Optional error code; used to report an error to the handler function.

Definition at line 123 of file asio_async_ops.h.

126 {})
127 : AsyncBase<Handler, typename Stream::executor_type, Allocator>(
128 std::forward<HandlerT>(handler),
129 stream.get_executor())
130 , m_stream(stream)
131 , m_buffers(buffers)
132 , m_decodedBytes(0)
133 {
134 this->operator()(ec, std::size_t(0), false);
135 }
Botan::TLS::detail::AsyncReadOperation::operator()
void operator()(boost::system::error_code ec, std::size_t bytes_transferred, bool isContinuation=true)
Definition: asio_async_ops.h:139
template<class Handler, class Stream, class MutableBufferSequence, class Allocator = std::allocator<void>>

Botan::TLS::detail::AsyncReadOperation< Handler, Stream, MutableBufferSequence, Allocator >::AsyncReadOperation | ( | AsyncReadOperation< Handler, Stream, MutableBufferSequence, Allocator > && |  | ) |
| default

## Member Function Documentation

void Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type , Allocator >::complete_now | ( | Args &&... | args | ) |
| inline protected inherited

Call the completion handler.

This function should only be called after an intermediate initiating function has been called.

Parameters

  args | Arguments forwarded to the completion handler function.

Definition at line 100 of file asio_async_ops.h.

References Botan::TLS::detail::AsyncBase< Handler, Executor1, Allocator >::m_handler, and Botan::TLS::detail::AsyncBase< Handler, Executor1, Allocator >::m_work_guard_1.

Referenced by Botan::TLS::detail::AsyncReadOperation< Handler, Stream, MutableBufferSequence, Allocator >::operator()(), Botan::TLS::detail::AsyncWriteOperation< Handler, Stream, Allocator >::operator()(), and Botan::TLS::detail::AsyncHandshakeOperation< Handler, Stream, Allocator >::operator()().

101 {
102 m_work_guard_1.reset();
103 m_handler(std::forward<Args>(args)...);
104 }
Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type, Allocator >::m_handler
Handler m_handler
Definition: asio_async_ops.h:106
Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type, Allocator >::m_work_guard_1
boost::asio::executor_work_guard< Stream::executor_type > m_work_guard_1
Definition: asio_async_ops.h:107

allocator_type Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type , Allocator >::get_allocator | ( |  | ) | const
| inline noexcept inherited

Definition at line 74 of file asio_async_ops.h.

References Botan::TLS::detail::AsyncBase< Handler, Executor1, Allocator >::m_handler.

75 {
76 return boost::asio::get_associated_allocator(m_handler);
77 }
Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type, Allocator >::m_handler
Handler m_handler
Definition: asio_async_ops.h:106

executor_type Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type , Allocator >::get_executor | ( |  | ) | const
| inline noexcept inherited

Definition at line 79 of file asio_async_ops.h.

References Botan::TLS::detail::AsyncBase< Handler, Executor1, Allocator >::m_handler, and Botan::TLS::detail::AsyncBase< Handler, Executor1, Allocator >::m_work_guard_1.

80 {
81 return boost::asio::get_associated_executor(m_handler, m_work_guard_1.get_executor());
82 }
Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type, Allocator >::m_handler
Handler m_handler
Definition: asio_async_ops.h:106
Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type, Allocator >::m_work_guard_1
boost::asio::executor_work_guard< Stream::executor_type > m_work_guard_1
Definition: asio_async_ops.h:107
template<class Handler, class Stream, class MutableBufferSequence, class Allocator = std::allocator<void>>

void Botan::TLS::detail::AsyncReadOperation< Handler, Stream, MutableBufferSequence, Allocator >::operator() | ( | boost::system::error_code | ec,
|  | std::size_t | bytes_transferred,
|  | bool | isContinuation = `true`
| ) |  |
| inline

Definition at line 139 of file asio_async_ops.h.

References Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type, Allocator >::complete_now(), Botan::TLS::Stream< StreamLayer, ChannelT >::copy_received_data(), Botan::Exception::error_type(), Botan::TLS::Stream< StreamLayer, ChannelT >::has_received_data(), Botan::TLS::Stream< StreamLayer, ChannelT >::input_buffer(), Botan::TLS::Stream< StreamLayer, ChannelT >::native_handle(), Botan::TLS::Stream< StreamLayer, ChannelT >::next_layer(), Botan::TLS::TLS_Exception::type(), and Botan::Unknown.

140 {
141 reenter(this)
142 {
143 if(bytes_transferred > 0 && !ec)
144 {
145 // We have received encrypted data from the network, now hand it to TLS::Channel for decryption.
146 boost::asio::const_buffer read_buffer{m_stream.input_buffer().data(), bytes_transferred};
147 try
148 {
149 m_stream.native_handle()->received_data(
150 static_cast<const uint8_t*>(read_buffer.data()), read_buffer.size()
151 );
152 }
153 catch(const TLS_Exception& e)
154 {
155 ec = e.type();
156 }
157 catch(const Botan::Exception& e)
158 {
159 ec = e.error_type();
160 }
161 catch(...)
162 {
163 ec = Botan::ErrorType::Unknown;
164 }
165 }
166
167 if(!m_stream.has_received_data() && !ec && boost::asio::buffer_size(m_buffers) > 0)
168 {
169 // The channel did not decrypt a complete record yet, we need more data from the socket.
170 m_stream.next_layer().async_read_some(m_stream.input_buffer(), std::move(*this));
171 return;
172 }
173
174 if(m_stream.has_received_data() && !ec)
175 {
176 // The channel has decrypted a TLS record, now copy it to the output buffers.
177 m_decodedBytes = m_stream.copy_received_data(m_buffers);
178 }
179
180 if(!isContinuation)
181 {
182 // Make sure the handler is not called without an intermediate initiating function.
183 // "Reading" into a zero-byte buffer will complete immediately.
184 m_ec = ec;
185 yield m_stream.next_layer().async_read_some(boost::asio::mutable_buffer(), std::move(*this));
186 ec = m_ec;
187 }
188
189 this->complete_now(ec, m_decodedBytes);
190 }
191 }
Botan::Exception
Definition: exceptn.h:85
Botan::TLS::Stream::next_layer
const next_layer_type & next_layer() const
Definition: asio_stream.h:110
Botan::Exception::error_type
virtual ErrorType error_type() const noexcept
Definition: exceptn.h:101
Botan::TLS::Stream::input_buffer
const boost::asio::mutable_buffer & input_buffer()
Definition: asio_stream.h:594
Botan::TLS::Stream::copy_received_data
std::size_t copy_received_data(MutableBufferSequence buffers)
Copy decrypted data into the user-provided buffer.
Definition: asio_stream.h:602
Botan::TLS::Stream::native_handle
native_handle_type native_handle()
Definition: asio_stream.h:116
Botan::ErrorType::Unknown
Botan::TLS::Stream::has_received_data
bool has_received_data() const
Check if decrypted data is available in the receive buffer.
Definition: asio_stream.h:598
Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type, Allocator >::complete_now
void complete_now(Args &&...args)
Definition: asio_async_ops.h:100

## Member Data Documentation

Handler Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type , Allocator >::m_handler
| protected inherited

Definition at line 106 of file asio_async_ops.h.

boost::asio::executor_work_guard<Stream::executor_type > Botan::TLS::detail::AsyncBase< Handler, Stream::executor_type , Allocator >::m_work_guard_1
| protected inherited

Definition at line 107 of file asio_async_ops.h.

The documentation for this class was generated from the following file:

- src/lib/tls/asio/asio_async_ops.h