2 // ssl/detail/stream_core.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP
12 #define BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
21 # if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
22 # include <boost/asio/deadline_timer.hpp>
23 # else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
24 # include <boost/asio/steady_timer.hpp>
25 # endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
26 # include <boost/asio/ssl/detail/engine.hpp>
27 # include <boost/asio/buffer.hpp>
28 #endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
30 #include <boost/asio/detail/push_options.hpp>
37 #if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
41 // According to the OpenSSL documentation, this is the buffer size that is
42 // sufficient to hold the largest possible TLS record.
43 enum { max_tls_record_size = 17 * 1024 };
45 stream_core(SSL_CTX* context, boost::asio::io_service& io_service)
47 pending_read_(io_service),
48 pending_write_(io_service),
49 output_buffer_space_(max_tls_record_size),
50 output_buffer_(boost::asio::buffer(output_buffer_space_)),
51 input_buffer_space_(max_tls_record_size),
52 input_buffer_(boost::asio::buffer(input_buffer_space_))
54 pending_read_.expires_at(neg_infin());
55 pending_write_.expires_at(neg_infin());
65 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
66 // Timer used for storing queued read operations.
67 boost::asio::deadline_timer pending_read_;
69 // Timer used for storing queued write operations.
70 boost::asio::deadline_timer pending_write_;
72 // Helper function for obtaining a time value that always fires.
73 static boost::asio::deadline_timer::time_type neg_infin()
75 return boost::posix_time::neg_infin;
78 // Helper function for obtaining a time value that never fires.
79 static boost::asio::deadline_timer::time_type pos_infin()
81 return boost::posix_time::pos_infin;
83 #else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
84 // Timer used for storing queued read operations.
85 boost::asio::steady_timer pending_read_;
87 // Timer used for storing queued write operations.
88 boost::asio::steady_timer pending_write_;
90 // Helper function for obtaining a time value that always fires.
91 static boost::asio::steady_timer::time_point neg_infin()
93 return (boost::asio::steady_timer::time_point::min)();
96 // Helper function for obtaining a time value that never fires.
97 static boost::asio::steady_timer::time_point pos_infin()
99 return (boost::asio::steady_timer::time_point::max)();
101 #endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
103 // Buffer space used to prepare output intended for the transport.
104 std::vector<unsigned char> output_buffer_space_;
106 // A buffer that may be used to prepare output intended for the transport.
107 const boost::asio::mutable_buffers_1 output_buffer_;
109 // Buffer space used to read input intended for the engine.
110 std::vector<unsigned char> input_buffer_space_;
112 // A buffer that may be used to read input intended for the engine.
113 const boost::asio::mutable_buffers_1 input_buffer_;
115 // The buffer pointing to the engine's unconsumed input.
116 boost::asio::const_buffer input_;
119 #endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
121 } // namespace detail
126 #include <boost/asio/detail/pop_options.hpp>
128 #endif // BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP