]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/include/boost/asio/ssl/old/stream_service.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / ssl / old / stream_service.hpp
1 //
2 // ssl/old/stream_service.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
6 // Copyright (c) 2005-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 //
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 //
11
12 #ifndef BOOST_ASIO_SSL_OLD_STREAM_SERVICE_HPP
13 #define BOOST_ASIO_SSL_OLD_STREAM_SERVICE_HPP
14
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
19 #include <boost/asio/detail/config.hpp>
20 #include <cstddef>
21 #include <boost/noncopyable.hpp>
22 #include <boost/asio/io_service.hpp>
23 #include <boost/asio/ssl/basic_context.hpp>
24 #include <boost/asio/ssl/old/detail/openssl_stream_service.hpp>
25 #include <boost/asio/ssl/stream_base.hpp>
26
27 #include <boost/asio/detail/push_options.hpp>
28
29 namespace boost {
30 namespace asio {
31 namespace ssl {
32 namespace old {
33
34 /// Default service implementation for an SSL stream.
35 class stream_service
36 #if defined(GENERATING_DOCUMENTATION)
37 : public boost::asio::io_service::service
38 #else
39 : public boost::asio::detail::service_base<stream_service>
40 #endif
41 {
42 private:
43 // The type of the platform-specific implementation.
44 typedef old::detail::openssl_stream_service service_impl_type;
45
46 public:
47 #if defined(GENERATING_DOCUMENTATION)
48 /// The unique service identifier.
49 static boost::asio::io_service::id id;
50 #endif
51
52 /// The type of a stream implementation.
53 #if defined(GENERATING_DOCUMENTATION)
54 typedef implementation_defined impl_type;
55 #else
56 typedef service_impl_type::impl_type impl_type;
57 #endif
58
59 /// Construct a new stream service for the specified io_service.
60 explicit stream_service(boost::asio::io_service& io_service)
61 : boost::asio::detail::service_base<stream_service>(io_service),
62 service_impl_(boost::asio::use_service<service_impl_type>(io_service))
63 {
64 }
65
66 /// Return a null stream implementation.
67 impl_type null() const
68 {
69 return service_impl_.null();
70 }
71
72 /// Create a new stream implementation.
73 template <typename Stream, typename Context_Service>
74 void create(impl_type& impl, Stream& next_layer,
75 basic_context<Context_Service>& context)
76 {
77 service_impl_.create(impl, next_layer, context);
78 }
79
80 /// Destroy a stream implementation.
81 template <typename Stream>
82 void destroy(impl_type& impl, Stream& next_layer)
83 {
84 service_impl_.destroy(impl, next_layer);
85 }
86
87 /// Perform SSL handshaking.
88 template <typename Stream>
89 boost::system::error_code handshake(impl_type& impl, Stream& next_layer,
90 stream_base::handshake_type type, boost::system::error_code& ec)
91 {
92 return service_impl_.handshake(impl, next_layer, type, ec);
93 }
94
95 /// Start an asynchronous SSL handshake.
96 template <typename Stream, typename HandshakeHandler>
97 void async_handshake(impl_type& impl, Stream& next_layer,
98 stream_base::handshake_type type, HandshakeHandler handler)
99 {
100 service_impl_.async_handshake(impl, next_layer, type, handler);
101 }
102
103 /// Shut down SSL on the stream.
104 template <typename Stream>
105 boost::system::error_code shutdown(impl_type& impl, Stream& next_layer,
106 boost::system::error_code& ec)
107 {
108 return service_impl_.shutdown(impl, next_layer, ec);
109 }
110
111 /// Asynchronously shut down SSL on the stream.
112 template <typename Stream, typename ShutdownHandler>
113 void async_shutdown(impl_type& impl, Stream& next_layer,
114 ShutdownHandler handler)
115 {
116 service_impl_.async_shutdown(impl, next_layer, handler);
117 }
118
119 /// Write some data to the stream.
120 template <typename Stream, typename ConstBufferSequence>
121 std::size_t write_some(impl_type& impl, Stream& next_layer,
122 const ConstBufferSequence& buffers, boost::system::error_code& ec)
123 {
124 return service_impl_.write_some(impl, next_layer, buffers, ec);
125 }
126
127 /// Start an asynchronous write.
128 template <typename Stream, typename ConstBufferSequence,
129 typename WriteHandler>
130 void async_write_some(impl_type& impl, Stream& next_layer,
131 const ConstBufferSequence& buffers, WriteHandler handler)
132 {
133 service_impl_.async_write_some(impl, next_layer, buffers, handler);
134 }
135
136 /// Read some data from the stream.
137 template <typename Stream, typename MutableBufferSequence>
138 std::size_t read_some(impl_type& impl, Stream& next_layer,
139 const MutableBufferSequence& buffers, boost::system::error_code& ec)
140 {
141 return service_impl_.read_some(impl, next_layer, buffers, ec);
142 }
143
144 /// Start an asynchronous read.
145 template <typename Stream, typename MutableBufferSequence,
146 typename ReadHandler>
147 void async_read_some(impl_type& impl, Stream& next_layer,
148 const MutableBufferSequence& buffers, ReadHandler handler)
149 {
150 service_impl_.async_read_some(impl, next_layer, buffers, handler);
151 }
152
153 /// Peek at the incoming data on the stream.
154 template <typename Stream, typename MutableBufferSequence>
155 std::size_t peek(impl_type& impl, Stream& next_layer,
156 const MutableBufferSequence& buffers, boost::system::error_code& ec)
157 {
158 return service_impl_.peek(impl, next_layer, buffers, ec);
159 }
160
161 /// Determine the amount of data that may be read without blocking.
162 template <typename Stream>
163 std::size_t in_avail(impl_type& impl, Stream& next_layer,
164 boost::system::error_code& ec)
165 {
166 return service_impl_.in_avail(impl, next_layer, ec);
167 }
168
169 private:
170 // Destroy all user-defined handler objects owned by the service.
171 void shutdown_service()
172 {
173 }
174
175 // The service that provides the platform-specific implementation.
176 service_impl_type& service_impl_;
177 };
178
179 } // namespace old
180 } // namespace ssl
181 } // namespace asio
182 } // namespace boost
183
184 #include <boost/asio/detail/pop_options.hpp>
185
186 #endif // BOOST_ASIO_SSL_OLD_STREAM_SERVICE_HPP