]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/include/boost/asio/ssl/detail/stream_core.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / ssl / detail / stream_core.hpp
1 //
2 // ssl/detail/stream_core.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10
11 #ifndef BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP
12 #define BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19
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)
29
30 #include <boost/asio/detail/push_options.hpp>
31
32 namespace boost {
33 namespace asio {
34 namespace ssl {
35 namespace detail {
36
37 #if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
38
39 struct stream_core
40 {
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 };
44
45 stream_core(SSL_CTX* context, boost::asio::io_service& io_service)
46 : engine_(context),
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_))
53 {
54 pending_read_.expires_at(neg_infin());
55 pending_write_.expires_at(neg_infin());
56 }
57
58 ~stream_core()
59 {
60 }
61
62 // The SSL engine.
63 engine engine_;
64
65 #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
66 // Timer used for storing queued read operations.
67 boost::asio::deadline_timer pending_read_;
68
69 // Timer used for storing queued write operations.
70 boost::asio::deadline_timer pending_write_;
71
72 // Helper function for obtaining a time value that always fires.
73 static boost::asio::deadline_timer::time_type neg_infin()
74 {
75 return boost::posix_time::neg_infin;
76 }
77
78 // Helper function for obtaining a time value that never fires.
79 static boost::asio::deadline_timer::time_type pos_infin()
80 {
81 return boost::posix_time::pos_infin;
82 }
83 #else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
84 // Timer used for storing queued read operations.
85 boost::asio::steady_timer pending_read_;
86
87 // Timer used for storing queued write operations.
88 boost::asio::steady_timer pending_write_;
89
90 // Helper function for obtaining a time value that always fires.
91 static boost::asio::steady_timer::time_point neg_infin()
92 {
93 return (boost::asio::steady_timer::time_point::min)();
94 }
95
96 // Helper function for obtaining a time value that never fires.
97 static boost::asio::steady_timer::time_point pos_infin()
98 {
99 return (boost::asio::steady_timer::time_point::max)();
100 }
101 #endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
102
103 // Buffer space used to prepare output intended for the transport.
104 std::vector<unsigned char> output_buffer_space_;
105
106 // A buffer that may be used to prepare output intended for the transport.
107 const boost::asio::mutable_buffers_1 output_buffer_;
108
109 // Buffer space used to read input intended for the engine.
110 std::vector<unsigned char> input_buffer_space_;
111
112 // A buffer that may be used to read input intended for the engine.
113 const boost::asio::mutable_buffers_1 input_buffer_;
114
115 // The buffer pointing to the engine's unconsumed input.
116 boost::asio::const_buffer input_;
117 };
118
119 #endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
120
121 } // namespace detail
122 } // namespace ssl
123 } // namespace asio
124 } // namespace boost
125
126 #include <boost/asio/detail/pop_options.hpp>
127
128 #endif // BOOST_ASIO_SSL_DETAIL_STREAM_CORE_HPP