]>
Commit | Line | Data |
---|---|---|
1 | // | |
2 | // ssl/error.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_ERROR_HPP | |
12 | #define BOOST_ASIO_SSL_ERROR_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 | #include <boost/system/error_code.hpp> | |
20 | ||
21 | #include <boost/asio/detail/push_options.hpp> | |
22 | ||
23 | namespace boost { | |
24 | namespace asio { | |
25 | namespace error { | |
26 | ||
27 | enum ssl_errors | |
28 | { | |
29 | // Error numbers are those produced by openssl. | |
30 | }; | |
31 | ||
32 | extern BOOST_ASIO_DECL | |
33 | const boost::system::error_category& get_ssl_category(); | |
34 | ||
35 | static const boost::system::error_category& ssl_category | |
36 | = boost::asio::error::get_ssl_category(); | |
37 | ||
38 | } // namespace error | |
39 | namespace ssl { | |
40 | namespace error { | |
41 | ||
42 | enum stream_errors | |
43 | { | |
44 | #if defined(GENERATING_DOCUMENTATION) | |
45 | /// The underlying stream closed before the ssl stream gracefully shut down. | |
46 | stream_truncated | |
47 | #elif (OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(OPENSSL_IS_BORINGSSL) | |
48 | stream_truncated = ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ) | |
49 | #else | |
50 | stream_truncated = 1 | |
51 | #endif | |
52 | }; | |
53 | ||
54 | extern BOOST_ASIO_DECL | |
55 | const boost::system::error_category& get_stream_category(); | |
56 | ||
57 | static const boost::system::error_category& stream_category | |
58 | = boost::asio::ssl::error::get_stream_category(); | |
59 | ||
60 | } // namespace error | |
61 | } // namespace ssl | |
62 | } // namespace asio | |
63 | } // namespace boost | |
64 | ||
65 | namespace boost { | |
66 | namespace system { | |
67 | ||
68 | template<> struct is_error_code_enum<boost::asio::error::ssl_errors> | |
69 | { | |
70 | static const bool value = true; | |
71 | }; | |
72 | ||
73 | template<> struct is_error_code_enum<boost::asio::ssl::error::stream_errors> | |
74 | { | |
75 | static const bool value = true; | |
76 | }; | |
77 | ||
78 | } // namespace system | |
79 | } // namespace boost | |
80 | ||
81 | namespace boost { | |
82 | namespace asio { | |
83 | namespace error { | |
84 | ||
85 | inline boost::system::error_code make_error_code(ssl_errors e) | |
86 | { | |
87 | return boost::system::error_code( | |
88 | static_cast<int>(e), get_ssl_category()); | |
89 | } | |
90 | ||
91 | } // namespace error | |
92 | namespace ssl { | |
93 | namespace error { | |
94 | ||
95 | inline boost::system::error_code make_error_code(stream_errors e) | |
96 | { | |
97 | return boost::system::error_code( | |
98 | static_cast<int>(e), get_stream_category()); | |
99 | } | |
100 | ||
101 | } // namespace error | |
102 | } // namespace ssl | |
103 | } // namespace asio | |
104 | } // namespace boost | |
105 | ||
106 | #include <boost/asio/detail/pop_options.hpp> | |
107 | ||
108 | #if defined(BOOST_ASIO_HEADER_ONLY) | |
109 | # include <boost/asio/ssl/impl/error.ipp> | |
110 | #endif // defined(BOOST_ASIO_HEADER_ONLY) | |
111 | ||
112 | #endif // BOOST_ASIO_SSL_ERROR_HPP |