File indexing completed on 2025-01-18 09:29:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP
0012 #define BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
0021 # include <boost/asio/deadline_timer.hpp>
0022 #else
0023 # include <boost/asio/steady_timer.hpp>
0024 #endif
0025 #include <boost/asio/ssl/detail/engine.hpp>
0026 #include <boost/asio/buffer.hpp>
0027
0028 #include <boost/asio/detail/push_options.hpp>
0029
0030 namespace boost {
0031 namespace asio {
0032 namespace ssl {
0033 namespace detail {
0034
0035 struct stream_core
0036 {
0037
0038
0039 enum { max_tls_record_size = 17 * 1024 };
0040
0041 template <typename Executor>
0042 stream_core(SSL_CTX* context, const Executor& ex)
0043 : engine_(context),
0044 pending_read_(ex),
0045 pending_write_(ex),
0046 output_buffer_space_(max_tls_record_size),
0047 output_buffer_(boost::asio::buffer(output_buffer_space_)),
0048 input_buffer_space_(max_tls_record_size),
0049 input_buffer_(boost::asio::buffer(input_buffer_space_))
0050 {
0051 pending_read_.expires_at(neg_infin());
0052 pending_write_.expires_at(neg_infin());
0053 }
0054
0055 template <typename Executor>
0056 stream_core(SSL* ssl_impl, const Executor& ex)
0057 : engine_(ssl_impl),
0058 pending_read_(ex),
0059 pending_write_(ex),
0060 output_buffer_space_(max_tls_record_size),
0061 output_buffer_(boost::asio::buffer(output_buffer_space_)),
0062 input_buffer_space_(max_tls_record_size),
0063 input_buffer_(boost::asio::buffer(input_buffer_space_))
0064 {
0065 pending_read_.expires_at(neg_infin());
0066 pending_write_.expires_at(neg_infin());
0067 }
0068
0069 stream_core(stream_core&& other)
0070 : engine_(static_cast<engine&&>(other.engine_)),
0071 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
0072 pending_read_(
0073 static_cast<boost::asio::deadline_timer&&>(
0074 other.pending_read_)),
0075 pending_write_(
0076 static_cast<boost::asio::deadline_timer&&>(
0077 other.pending_write_)),
0078 #else
0079 pending_read_(
0080 static_cast<boost::asio::steady_timer&&>(
0081 other.pending_read_)),
0082 pending_write_(
0083 static_cast<boost::asio::steady_timer&&>(
0084 other.pending_write_)),
0085 #endif
0086 output_buffer_space_(
0087 static_cast<std::vector<unsigned char>&&>(
0088 other.output_buffer_space_)),
0089 output_buffer_(other.output_buffer_),
0090 input_buffer_space_(
0091 static_cast<std::vector<unsigned char>&&>(
0092 other.input_buffer_space_)),
0093 input_buffer_(other.input_buffer_),
0094 input_(other.input_)
0095 {
0096 other.output_buffer_ = boost::asio::mutable_buffer(0, 0);
0097 other.input_buffer_ = boost::asio::mutable_buffer(0, 0);
0098 other.input_ = boost::asio::const_buffer(0, 0);
0099 }
0100
0101 ~stream_core()
0102 {
0103 }
0104
0105 stream_core& operator=(stream_core&& other)
0106 {
0107 if (this != &other)
0108 {
0109 engine_ = static_cast<engine&&>(other.engine_);
0110 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
0111 pending_read_ =
0112 static_cast<boost::asio::deadline_timer&&>(
0113 other.pending_read_);
0114 pending_write_ =
0115 static_cast<boost::asio::deadline_timer&&>(
0116 other.pending_write_);
0117 #else
0118 pending_read_ =
0119 static_cast<boost::asio::steady_timer&&>(
0120 other.pending_read_);
0121 pending_write_ =
0122 static_cast<boost::asio::steady_timer&&>(
0123 other.pending_write_);
0124 #endif
0125 output_buffer_space_ =
0126 static_cast<std::vector<unsigned char>&&>(
0127 other.output_buffer_space_);
0128 output_buffer_ = other.output_buffer_;
0129 input_buffer_space_ =
0130 static_cast<std::vector<unsigned char>&&>(
0131 other.input_buffer_space_);
0132 input_buffer_ = other.input_buffer_;
0133 input_ = other.input_;
0134 other.output_buffer_ = boost::asio::mutable_buffer(0, 0);
0135 other.input_buffer_ = boost::asio::mutable_buffer(0, 0);
0136 other.input_ = boost::asio::const_buffer(0, 0);
0137 }
0138 return *this;
0139 }
0140
0141
0142 engine engine_;
0143
0144 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
0145
0146 boost::asio::deadline_timer pending_read_;
0147
0148
0149 boost::asio::deadline_timer pending_write_;
0150
0151
0152 static boost::asio::deadline_timer::time_type neg_infin()
0153 {
0154 return boost::posix_time::neg_infin;
0155 }
0156
0157
0158 static boost::asio::deadline_timer::time_type pos_infin()
0159 {
0160 return boost::posix_time::pos_infin;
0161 }
0162
0163
0164 static boost::asio::deadline_timer::time_type expiry(
0165 const boost::asio::deadline_timer& timer)
0166 {
0167 return timer.expires_at();
0168 }
0169 #else
0170
0171 boost::asio::steady_timer pending_read_;
0172
0173
0174 boost::asio::steady_timer pending_write_;
0175
0176
0177 static boost::asio::steady_timer::time_point neg_infin()
0178 {
0179 return (boost::asio::steady_timer::time_point::min)();
0180 }
0181
0182
0183 static boost::asio::steady_timer::time_point pos_infin()
0184 {
0185 return (boost::asio::steady_timer::time_point::max)();
0186 }
0187
0188
0189 static boost::asio::steady_timer::time_point expiry(
0190 const boost::asio::steady_timer& timer)
0191 {
0192 return timer.expiry();
0193 }
0194 #endif
0195
0196
0197 std::vector<unsigned char> output_buffer_space_;
0198
0199
0200 boost::asio::mutable_buffer output_buffer_;
0201
0202
0203 std::vector<unsigned char> input_buffer_space_;
0204
0205
0206 boost::asio::mutable_buffer input_buffer_;
0207
0208
0209 boost::asio::const_buffer input_;
0210 };
0211
0212 }
0213 }
0214 }
0215 }
0216
0217 #include <boost/asio/detail/pop_options.hpp>
0218
0219 #endif