diff options
Diffstat (limited to 'boost/asio/ssl/detail')
-rw-r--r-- | boost/asio/ssl/detail/buffered_handshake_op.hpp | 112 | ||||
-rw-r--r-- | boost/asio/ssl/detail/engine.hpp | 6 | ||||
-rw-r--r-- | boost/asio/ssl/detail/handshake_op.hpp | 2 | ||||
-rw-r--r-- | boost/asio/ssl/detail/impl/engine.ipp | 26 | ||||
-rw-r--r-- | boost/asio/ssl/detail/impl/openssl_init.ipp | 52 | ||||
-rw-r--r-- | boost/asio/ssl/detail/io.hpp | 33 | ||||
-rw-r--r-- | boost/asio/ssl/detail/openssl_init.hpp | 17 | ||||
-rw-r--r-- | boost/asio/ssl/detail/openssl_types.hpp | 2 | ||||
-rw-r--r-- | boost/asio/ssl/detail/password_callback.hpp | 2 | ||||
-rw-r--r-- | boost/asio/ssl/detail/read_op.hpp | 2 | ||||
-rw-r--r-- | boost/asio/ssl/detail/shutdown_op.hpp | 2 | ||||
-rw-r--r-- | boost/asio/ssl/detail/stream_core.hpp | 52 | ||||
-rw-r--r-- | boost/asio/ssl/detail/verify_callback.hpp | 2 | ||||
-rw-r--r-- | boost/asio/ssl/detail/write_op.hpp | 2 |
14 files changed, 270 insertions, 42 deletions
diff --git a/boost/asio/ssl/detail/buffered_handshake_op.hpp b/boost/asio/ssl/detail/buffered_handshake_op.hpp new file mode 100644 index 0000000000..10608b0eb9 --- /dev/null +++ b/boost/asio/ssl/detail/buffered_handshake_op.hpp @@ -0,0 +1,112 @@ +// +// ssl/detail/buffered_handshake_op.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BOOST_ASIO_SSL_DETAIL_BUFFERED_HANDSHAKE_OP_HPP +#define BOOST_ASIO_SSL_DETAIL_BUFFERED_HANDSHAKE_OP_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include <boost/asio/detail/config.hpp> + +#if !defined(BOOST_ASIO_ENABLE_OLD_SSL) +# include <boost/asio/ssl/detail/engine.hpp> +#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL) + +#include <boost/asio/detail/push_options.hpp> + +namespace boost { +namespace asio { +namespace ssl { +namespace detail { + +#if !defined(BOOST_ASIO_ENABLE_OLD_SSL) + +template <typename ConstBufferSequence> +class buffered_handshake_op +{ +public: + buffered_handshake_op(stream_base::handshake_type type, + const ConstBufferSequence& buffers) + : type_(type), + buffers_(buffers), + total_buffer_size_(boost::asio::buffer_size(buffers_)) + { + } + + engine::want operator()(engine& eng, + boost::system::error_code& ec, + std::size_t& bytes_transferred) const + { + typename ConstBufferSequence::const_iterator iter = buffers_.begin(); + typename ConstBufferSequence::const_iterator end = buffers_.end(); + std::size_t accumulated_size = 0; + + for (;;) + { + engine::want want = eng.handshake(type_, ec); + if (want != engine::want_input_and_retry + || bytes_transferred == total_buffer_size_) + return want; + + // Find the next buffer piece to be fed to the engine. + while (iter != end) + { + const_buffer buffer(*iter); + + // Skip over any buffers which have already been consumed by the engine. + if (bytes_transferred >= accumulated_size + buffer_size(buffer)) + { + accumulated_size += buffer_size(buffer); + ++iter; + continue; + } + + // The current buffer may have been partially consumed by the engine on + // a previous iteration. If so, adjust the buffer to point to the + // unused portion. + if (bytes_transferred > accumulated_size) + buffer = buffer + (bytes_transferred - accumulated_size); + + // Pass the buffer to the engine, and update the bytes transferred to + // reflect the total number of bytes consumed so far. + bytes_transferred += buffer_size(buffer); + buffer = eng.put_input(buffer); + bytes_transferred -= buffer_size(buffer); + break; + } + } + } + + template <typename Handler> + void call_handler(Handler& handler, + const boost::system::error_code& ec, + const std::size_t& bytes_transferred) const + { + handler(ec, bytes_transferred); + } + +private: + stream_base::handshake_type type_; + ConstBufferSequence buffers_; + std::size_t total_buffer_size_; +}; + +#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL) + +} // namespace detail +} // namespace ssl +} // namespace asio +} // namespace boost + +#include <boost/asio/detail/pop_options.hpp> + +#endif // BOOST_ASIO_SSL_DETAIL_BUFFERED_HANDSHAKE_OP_HPP diff --git a/boost/asio/ssl/detail/engine.hpp b/boost/asio/ssl/detail/engine.hpp index 41c4ee7426..8b24a96f01 100644 --- a/boost/asio/ssl/detail/engine.hpp +++ b/boost/asio/ssl/detail/engine.hpp @@ -2,7 +2,7 @@ // ssl/detail/engine.hpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -73,6 +73,10 @@ public: BOOST_ASIO_DECL boost::system::error_code set_verify_mode( verify_mode v, boost::system::error_code& ec); + // Set the peer verification depth. + BOOST_ASIO_DECL boost::system::error_code set_verify_depth( + int depth, boost::system::error_code& ec); + // Set a peer certificate verification callback. BOOST_ASIO_DECL boost::system::error_code set_verify_callback( verify_callback_base* callback, boost::system::error_code& ec); diff --git a/boost/asio/ssl/detail/handshake_op.hpp b/boost/asio/ssl/detail/handshake_op.hpp index 3c57a4de96..b886bb52f6 100644 --- a/boost/asio/ssl/detail/handshake_op.hpp +++ b/boost/asio/ssl/detail/handshake_op.hpp @@ -2,7 +2,7 @@ // ssl/detail/handshake_op.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/boost/asio/ssl/detail/impl/engine.ipp b/boost/asio/ssl/detail/impl/engine.ipp index a7da0c1967..5aa9b5a68a 100644 --- a/boost/asio/ssl/detail/impl/engine.ipp +++ b/boost/asio/ssl/detail/impl/engine.ipp @@ -2,7 +2,7 @@ // ssl/detail/impl/engine.ipp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -39,7 +39,8 @@ engine::engine(SSL_CTX* context) { if (!ssl_) { - boost::system::error_code ec(::ERR_get_error(), + boost::system::error_code ec( + static_cast<int>(::ERR_get_error()), boost::asio::error::get_ssl_category()); boost::asio::detail::throw_error(ec, "engine"); } @@ -83,6 +84,15 @@ boost::system::error_code engine::set_verify_mode( return ec; } +boost::system::error_code engine::set_verify_depth( + int depth, boost::system::error_code& ec) +{ + ::SSL_set_verify_depth(ssl_, depth); + + ec = boost::system::error_code(); + return ec; +} + boost::system::error_code engine::set_verify_callback( verify_callback_base* callback, boost::system::error_code& ec) { @@ -166,7 +176,7 @@ boost::asio::mutable_buffers_1 engine::get_output( { int length = ::BIO_read(ext_bio_, boost::asio::buffer_cast<void*>(data), - boost::asio::buffer_size(data)); + static_cast<int>(boost::asio::buffer_size(data))); return boost::asio::buffer(data, length > 0 ? static_cast<std::size_t>(length) : 0); @@ -177,7 +187,7 @@ boost::asio::const_buffer engine::put_input( { int length = ::BIO_write(ext_bio_, boost::asio::buffer_cast<const void*>(data), - boost::asio::buffer_size(data)); + static_cast<int>(boost::asio::buffer_size(data))); return boost::asio::buffer(data + (length > 0 ? static_cast<std::size_t>(length) : 0)); @@ -228,7 +238,7 @@ engine::want engine::perform(int (engine::* op)(void*, std::size_t), std::size_t pending_output_before = ::BIO_ctrl_pending(ext_bio_); int result = (this->*op)(data, length); int ssl_error = ::SSL_get_error(ssl_, result); - int sys_error = ::ERR_get_error(); + int sys_error = static_cast<int>(::ERR_get_error()); std::size_t pending_output_after = ::BIO_ctrl_pending(ext_bio_); if (ssl_error == SSL_ERROR_SSL) @@ -296,12 +306,14 @@ int engine::do_shutdown(void*, std::size_t) int engine::do_read(void* data, std::size_t length) { - return ::SSL_read(ssl_, data, length < INT_MAX ? length : INT_MAX); + return ::SSL_read(ssl_, data, + length < INT_MAX ? static_cast<int>(length) : INT_MAX); } int engine::do_write(void* data, std::size_t length) { - return ::SSL_write(ssl_, data, length < INT_MAX ? length : INT_MAX); + return ::SSL_write(ssl_, data, + length < INT_MAX ? static_cast<int>(length) : INT_MAX); } #endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL) diff --git a/boost/asio/ssl/detail/impl/openssl_init.ipp b/boost/asio/ssl/detail/impl/openssl_init.ipp index fe62e6eabc..d732fef309 100644 --- a/boost/asio/ssl/detail/impl/openssl_init.ipp +++ b/boost/asio/ssl/detail/impl/openssl_init.ipp @@ -3,7 +3,7 @@ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com -// Copyright (c) 2005-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2005-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -18,7 +18,7 @@ #include <boost/asio/detail/config.hpp> #include <vector> -#include <boost/assert.hpp> +#include <boost/asio/detail/assert.hpp> #include <boost/asio/detail/mutex.hpp> #include <boost/asio/detail/tss_ptr.hpp> #include <boost/asio/ssl/detail/openssl_init.hpp> @@ -45,10 +45,22 @@ public: mutexes_[i].reset(new boost::asio::detail::mutex); ::CRYPTO_set_locking_callback(&do_init::openssl_locking_func); ::CRYPTO_set_id_callback(&do_init::openssl_id_func); + +#if !defined(SSL_OP_NO_COMPRESSION) \ + && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + null_compression_methods_ = sk_SSL_COMP_new_null(); +#endif // !defined(SSL_OP_NO_COMPRESSION) + // && (OPENSSL_VERSION_NUMBER >= 0x00908000L) } ~do_init() { +#if !defined(SSL_OP_NO_COMPRESSION) \ + && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + sk_SSL_COMP_free(null_compression_methods_); +#endif // !defined(SSL_OP_NO_COMPRESSION) + // && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + ::CRYPTO_set_id_callback(0); ::CRYPTO_set_locking_callback(0); ::ERR_free_strings(); @@ -61,18 +73,27 @@ public: #endif // !defined(OPENSSL_NO_ENGINE) } +#if !defined(SSL_OP_NO_COMPRESSION) \ + && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + STACK_OF(SSL_COMP)* get_null_compression_methods() const + { + return null_compression_methods_; + } +#endif // !defined(SSL_OP_NO_COMPRESSION) + // && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + private: static unsigned long openssl_id_func() { -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) +#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) return ::GetCurrentThreadId(); -#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +#else // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) void* id = instance()->thread_id_; if (id == 0) instance()->thread_id_ = id = &id; // Ugh. - BOOST_ASSERT(sizeof(unsigned long) >= sizeof(void*)); + BOOST_ASIO_ASSERT(sizeof(unsigned long) >= sizeof(void*)); return reinterpret_cast<unsigned long>(id); -#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__) +#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) } static void openssl_locking_func(int mode, int n, @@ -88,10 +109,16 @@ private: std::vector<boost::asio::detail::shared_ptr< boost::asio::detail::mutex> > mutexes_; -#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +#if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__) // The thread identifiers to be used by openssl. boost::asio::detail::tss_ptr<void> thread_id_; -#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) +#endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__) + +#if !defined(SSL_OP_NO_COMPRESSION) \ + && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + STACK_OF(SSL_COMP)* null_compression_methods_; +#endif // !defined(SSL_OP_NO_COMPRESSION) + // && (OPENSSL_VERSION_NUMBER >= 0x00908000L) }; boost::asio::detail::shared_ptr<openssl_init_base::do_init> @@ -101,6 +128,15 @@ openssl_init_base::instance() return init; } +#if !defined(SSL_OP_NO_COMPRESSION) \ + && (OPENSSL_VERSION_NUMBER >= 0x00908000L) +STACK_OF(SSL_COMP)* openssl_init_base::get_null_compression_methods() +{ + return instance()->get_null_compression_methods(); +} +#endif // !defined(SSL_OP_NO_COMPRESSION) + // && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + } // namespace detail } // namespace ssl } // namespace asio diff --git a/boost/asio/ssl/detail/io.hpp b/boost/asio/ssl/detail/io.hpp index e83934e313..ef821000ba 100644 --- a/boost/asio/ssl/detail/io.hpp +++ b/boost/asio/ssl/detail/io.hpp @@ -2,7 +2,7 @@ // ssl/detail/io.hpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -96,6 +96,8 @@ public: : next_layer_(next_layer), core_(core), op_(op), + start_(0), + want_(engine::want_nothing), bytes_transferred_(0), handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)) { @@ -106,6 +108,7 @@ public: : next_layer_(other.next_layer_), core_(other.core_), op_(other.op_), + start_(other.start_), want_(other.want_), ec_(other.ec_), bytes_transferred_(other.bytes_transferred_), @@ -117,6 +120,7 @@ public: : next_layer_(other.next_layer_), core_(other.core_), op_(other.op_), + start_(other.start_), want_(other.want_), ec_(other.ec_), bytes_transferred_(other.bytes_transferred_), @@ -128,7 +132,7 @@ public: void operator()(boost::system::error_code ec, std::size_t bytes_transferred = ~std::size_t(0), int start = 0) { - switch (start) + switch (start_ = start) { case 1: // Called after at least one async operation. do @@ -149,10 +153,10 @@ public: // cannot allow more than one read operation at a time on the // underlying transport. The pending_read_ timer's expiry is set to // pos_infin if a read is in progress, and neg_infin otherwise. - if (core_.pending_read_.expires_at() == boost::posix_time::neg_infin) + if (core_.pending_read_.expires_at() == core_.neg_infin()) { // Prevent other read operations from being started. - core_.pending_read_.expires_at(boost::posix_time::pos_infin); + core_.pending_read_.expires_at(core_.pos_infin()); // Start reading some data from the underlying transport. next_layer_.async_read_some( @@ -176,10 +180,10 @@ public: // cannot allow more than one write operation at a time on the // underlying transport. The pending_write_ timer's expiry is set to // pos_infin if a write is in progress, and neg_infin otherwise. - if (core_.pending_write_.expires_at() == boost::posix_time::neg_infin) + if (core_.pending_write_.expires_at() == core_.neg_infin()) { // Prevent other write operations from being started. - core_.pending_write_.expires_at(boost::posix_time::pos_infin); + core_.pending_write_.expires_at(core_.pos_infin()); // Start writing all the data to the underlying transport. boost::asio::async_write(next_layer_, @@ -234,7 +238,7 @@ public: core_.input_ = core_.engine_.put_input(core_.input_); // Release any waiting read operations. - core_.pending_read_.expires_at(boost::posix_time::neg_infin); + core_.pending_read_.expires_at(core_.neg_infin()); // Try the operation again. continue; @@ -242,7 +246,7 @@ public: case engine::want_output_and_retry: // Release any waiting write operations. - core_.pending_write_.expires_at(boost::posix_time::neg_infin); + core_.pending_write_.expires_at(core_.neg_infin()); // Try the operation again. continue; @@ -250,7 +254,7 @@ public: case engine::want_output: // Release any waiting write operations. - core_.pending_write_.expires_at(boost::posix_time::neg_infin); + core_.pending_write_.expires_at(core_.neg_infin()); // Fall through to call handler. @@ -275,6 +279,7 @@ public: Stream& next_layer_; stream_core& core_; Operation op_; + int start_; engine::want want_; boost::system::error_code ec_; std::size_t bytes_transferred_; @@ -297,6 +302,14 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size, pointer, size, this_handler->handler_); } +template <typename Stream, typename Operation, typename Handler> +inline bool asio_handler_is_continuation( + io_op<Stream, Operation, Handler>* this_handler) +{ + return this_handler->start_ == 0 ? true + : boost_asio_handler_cont_helpers::is_continuation(this_handler->handler_); +} + template <typename Function, typename Stream, typename Operation, typename Handler> inline void asio_handler_invoke(Function& function, @@ -317,7 +330,7 @@ inline void asio_handler_invoke(const Function& function, template <typename Stream, typename Operation, typename Handler> inline void async_io(Stream& next_layer, stream_core& core, - const Operation& op, Handler handler) + const Operation& op, Handler& handler) { io_op<Stream, Operation, Handler>( next_layer, core, op, handler)( diff --git a/boost/asio/ssl/detail/openssl_init.hpp b/boost/asio/ssl/detail/openssl_init.hpp index c68909d16b..985c14d9c5 100644 --- a/boost/asio/ssl/detail/openssl_init.hpp +++ b/boost/asio/ssl/detail/openssl_init.hpp @@ -2,7 +2,7 @@ // ssl/detail/openssl_init.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -19,6 +19,7 @@ #include <cstring> #include <boost/asio/detail/noncopyable.hpp> #include <boost/asio/detail/shared_ptr.hpp> +#include <boost/asio/ssl/detail/openssl_types.hpp> #include <boost/asio/detail/push_options.hpp> @@ -40,6 +41,14 @@ protected: // instance must be static in this function to ensure that it gets // initialised before any other global objects try to use it. BOOST_ASIO_DECL static boost::asio::detail::shared_ptr<do_init> instance(); + +#if !defined(SSL_OP_NO_COMPRESSION) \ + && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + // Get an empty stack of compression methods, to be used when disabling + // compression. + BOOST_ASIO_DECL static STACK_OF(SSL_COMP)* get_null_compression_methods(); +#endif // !defined(SSL_OP_NO_COMPRESSION) + // && (OPENSSL_VERSION_NUMBER >= 0x00908000L) }; template <bool Do_Init = true> @@ -62,6 +71,12 @@ public: { } +#if !defined(SSL_OP_NO_COMPRESSION) \ + && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + using openssl_init_base::get_null_compression_methods; +#endif // !defined(SSL_OP_NO_COMPRESSION) + // && (OPENSSL_VERSION_NUMBER >= 0x00908000L) + private: // Instance to force initialisation of openssl at global scope. static openssl_init instance_; diff --git a/boost/asio/ssl/detail/openssl_types.hpp b/boost/asio/ssl/detail/openssl_types.hpp index a3c3729332..58b4733db6 100644 --- a/boost/asio/ssl/detail/openssl_types.hpp +++ b/boost/asio/ssl/detail/openssl_types.hpp @@ -2,7 +2,7 @@ // ssl/detail/openssl_types.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/boost/asio/ssl/detail/password_callback.hpp b/boost/asio/ssl/detail/password_callback.hpp index 438320a00b..d64bf3a5be 100644 --- a/boost/asio/ssl/detail/password_callback.hpp +++ b/boost/asio/ssl/detail/password_callback.hpp @@ -2,7 +2,7 @@ // ssl/detail/password_callback.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/boost/asio/ssl/detail/read_op.hpp b/boost/asio/ssl/detail/read_op.hpp index abf329c7b7..e0a0ad0ee8 100644 --- a/boost/asio/ssl/detail/read_op.hpp +++ b/boost/asio/ssl/detail/read_op.hpp @@ -2,7 +2,7 @@ // ssl/detail/read_op.hpp // ~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/boost/asio/ssl/detail/shutdown_op.hpp b/boost/asio/ssl/detail/shutdown_op.hpp index cfeb8e572e..6a716f7090 100644 --- a/boost/asio/ssl/detail/shutdown_op.hpp +++ b/boost/asio/ssl/detail/shutdown_op.hpp @@ -2,7 +2,7 @@ // ssl/detail/shutdown_op.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/boost/asio/ssl/detail/stream_core.hpp b/boost/asio/ssl/detail/stream_core.hpp index b8f0afa4a1..663e258c03 100644 --- a/boost/asio/ssl/detail/stream_core.hpp +++ b/boost/asio/ssl/detail/stream_core.hpp @@ -2,7 +2,7 @@ // ssl/detail/stream_core.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -18,7 +18,11 @@ #include <boost/asio/detail/config.hpp> #if !defined(BOOST_ASIO_ENABLE_OLD_SSL) -# include <boost/asio/deadline_timer.hpp> +# if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) +# include <boost/asio/deadline_timer.hpp> +# else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) +# include <boost/asio/steady_timer.hpp> +# endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) # include <boost/asio/ssl/detail/engine.hpp> # include <boost/asio/buffer.hpp> #endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL) @@ -34,7 +38,7 @@ namespace detail { struct stream_core { - // According to the OpenSSL documentation, this is the buffer size that is is + // According to the OpenSSL documentation, this is the buffer size that is // sufficient to hold the largest possible TLS record. enum { max_tls_record_size = 17 * 1024 }; @@ -47,8 +51,8 @@ struct stream_core input_buffer_space_(max_tls_record_size), input_buffer_(boost::asio::buffer(input_buffer_space_)) { - pending_read_.expires_at(boost::posix_time::neg_infin); - pending_write_.expires_at(boost::posix_time::neg_infin); + pending_read_.expires_at(neg_infin()); + pending_write_.expires_at(neg_infin()); } ~stream_core() @@ -58,20 +62,52 @@ struct stream_core // The SSL engine. engine engine_; +#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) // Timer used for storing queued read operations. boost::asio::deadline_timer pending_read_; // Timer used for storing queued write operations. boost::asio::deadline_timer pending_write_; + // Helper function for obtaining a time value that always fires. + static boost::asio::deadline_timer::time_type neg_infin() + { + return boost::posix_time::neg_infin; + } + + // Helper function for obtaining a time value that never fires. + static boost::asio::deadline_timer::time_type pos_infin() + { + return boost::posix_time::pos_infin; + } +#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) + // Timer used for storing queued read operations. + boost::asio::steady_timer pending_read_; + + // Timer used for storing queued write operations. + boost::asio::steady_timer pending_write_; + + // Helper function for obtaining a time value that always fires. + static boost::asio::steady_timer::time_point neg_infin() + { + return (boost::asio::steady_timer::time_point::min)(); + } + + // Helper function for obtaining a time value that never fires. + static boost::asio::steady_timer::time_point pos_infin() + { + return (boost::asio::steady_timer::time_point::max)(); + } +#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) + // Buffer space used to prepare output intended for the transport. - std::vector<unsigned char> output_buffer_space_; + std::vector<unsigned char> output_buffer_space_; // A buffer that may be used to prepare output intended for the transport. - const boost::asio::mutable_buffers_1 output_buffer_; + const boost::asio::mutable_buffers_1 output_buffer_; // Buffer space used to read input intended for the engine. - std::vector<unsigned char> input_buffer_space_; + std::vector<unsigned char> input_buffer_space_; // A buffer that may be used to read input intended for the engine. const boost::asio::mutable_buffers_1 input_buffer_; diff --git a/boost/asio/ssl/detail/verify_callback.hpp b/boost/asio/ssl/detail/verify_callback.hpp index 2d497d1ce1..eb40f488f4 100644 --- a/boost/asio/ssl/detail/verify_callback.hpp +++ b/boost/asio/ssl/detail/verify_callback.hpp @@ -2,7 +2,7 @@ // ssl/detail/verify_callback.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/boost/asio/ssl/detail/write_op.hpp b/boost/asio/ssl/detail/write_op.hpp index 82ecbb9212..24020983df 100644 --- a/boost/asio/ssl/detail/write_op.hpp +++ b/boost/asio/ssl/detail/write_op.hpp @@ -2,7 +2,7 @@ // ssl/detail/write_op.hpp // ~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |