123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- #ifndef BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP
- #define BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
- # include <boost/asio/deadline_timer.hpp>
- #else
- # include <boost/asio/steady_timer.hpp>
- #endif
- #include <boost/asio/ssl/detail/engine.hpp>
- #include <boost/asio/buffer.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace ssl {
- namespace detail {
- struct stream_core
- {
-
-
- enum { max_tls_record_size = 17 * 1024 };
- template <typename Executor>
- stream_core(SSL_CTX* context, const Executor& ex)
- : engine_(context),
- pending_read_(ex),
- pending_write_(ex),
- output_buffer_space_(max_tls_record_size),
- output_buffer_(boost::asio::buffer(output_buffer_space_)),
- input_buffer_space_(max_tls_record_size),
- input_buffer_(boost::asio::buffer(input_buffer_space_))
- {
- pending_read_.expires_at(neg_infin());
- pending_write_.expires_at(neg_infin());
- }
- template <typename Executor>
- stream_core(SSL* ssl_impl, const Executor& ex)
- : engine_(ssl_impl),
- pending_read_(ex),
- pending_write_(ex),
- output_buffer_space_(max_tls_record_size),
- output_buffer_(boost::asio::buffer(output_buffer_space_)),
- input_buffer_space_(max_tls_record_size),
- input_buffer_(boost::asio::buffer(input_buffer_space_))
- {
- pending_read_.expires_at(neg_infin());
- pending_write_.expires_at(neg_infin());
- }
- stream_core(stream_core&& other)
- : engine_(static_cast<engine&&>(other.engine_)),
- #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
- pending_read_(
- static_cast<boost::asio::deadline_timer&&>(
- other.pending_read_)),
- pending_write_(
- static_cast<boost::asio::deadline_timer&&>(
- other.pending_write_)),
- #else
- pending_read_(
- static_cast<boost::asio::steady_timer&&>(
- other.pending_read_)),
- pending_write_(
- static_cast<boost::asio::steady_timer&&>(
- other.pending_write_)),
- #endif
- output_buffer_space_(
- static_cast<std::vector<unsigned char>&&>(
- other.output_buffer_space_)),
- output_buffer_(other.output_buffer_),
- input_buffer_space_(
- static_cast<std::vector<unsigned char>&&>(
- other.input_buffer_space_)),
- input_buffer_(other.input_buffer_),
- input_(other.input_)
- {
- other.output_buffer_ = boost::asio::mutable_buffer(0, 0);
- other.input_buffer_ = boost::asio::mutable_buffer(0, 0);
- other.input_ = boost::asio::const_buffer(0, 0);
- }
- ~stream_core()
- {
- }
- stream_core& operator=(stream_core&& other)
- {
- if (this != &other)
- {
- engine_ = static_cast<engine&&>(other.engine_);
- #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
- pending_read_ =
- static_cast<boost::asio::deadline_timer&&>(
- other.pending_read_);
- pending_write_ =
- static_cast<boost::asio::deadline_timer&&>(
- other.pending_write_);
- #else
- pending_read_ =
- static_cast<boost::asio::steady_timer&&>(
- other.pending_read_);
- pending_write_ =
- static_cast<boost::asio::steady_timer&&>(
- other.pending_write_);
- #endif
- output_buffer_space_ =
- static_cast<std::vector<unsigned char>&&>(
- other.output_buffer_space_);
- output_buffer_ = other.output_buffer_;
- input_buffer_space_ =
- static_cast<std::vector<unsigned char>&&>(
- other.input_buffer_space_);
- input_buffer_ = other.input_buffer_;
- input_ = other.input_;
- other.output_buffer_ = boost::asio::mutable_buffer(0, 0);
- other.input_buffer_ = boost::asio::mutable_buffer(0, 0);
- other.input_ = boost::asio::const_buffer(0, 0);
- }
- return *this;
- }
-
- engine engine_;
- #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
-
- boost::asio::deadline_timer pending_read_;
-
- boost::asio::deadline_timer pending_write_;
-
- static boost::asio::deadline_timer::time_type neg_infin()
- {
- return boost::posix_time::neg_infin;
- }
-
- static boost::asio::deadline_timer::time_type pos_infin()
- {
- return boost::posix_time::pos_infin;
- }
-
- static boost::asio::deadline_timer::time_type expiry(
- const boost::asio::deadline_timer& timer)
- {
- return timer.expires_at();
- }
- #else
-
- boost::asio::steady_timer pending_read_;
-
- boost::asio::steady_timer pending_write_;
-
- static boost::asio::steady_timer::time_point neg_infin()
- {
- return (boost::asio::steady_timer::time_point::min)();
- }
-
- static boost::asio::steady_timer::time_point pos_infin()
- {
- return (boost::asio::steady_timer::time_point::max)();
- }
-
- static boost::asio::steady_timer::time_point expiry(
- const boost::asio::steady_timer& timer)
- {
- return timer.expiry();
- }
- #endif
-
- std::vector<unsigned char> output_buffer_space_;
-
- boost::asio::mutable_buffer output_buffer_;
-
- std::vector<unsigned char> input_buffer_space_;
-
- boost::asio::mutable_buffer input_buffer_;
-
- boost::asio::const_buffer input_;
- };
- }
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|