| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_SSL_OPENSSL_SSL_UTIL_H_ | 5 #ifndef NET_SSL_OPENSSL_SSL_UTIL_H_ |
| 6 #define NET_SSL_OPENSSL_SSL_UTIL_H_ | 6 #define NET_SSL_OPENSSL_SSL_UTIL_H_ |
| 7 | 7 |
| 8 #include "net/base/net_log.h" |
| 9 |
| 8 namespace crypto { | 10 namespace crypto { |
| 9 class OpenSSLErrStackTracer; | 11 class OpenSSLErrStackTracer; |
| 10 } | 12 } |
| 11 | 13 |
| 12 namespace tracked_objects { | 14 namespace tracked_objects { |
| 13 class Location; | 15 class Location; |
| 14 } | 16 } |
| 15 | 17 |
| 16 namespace net { | 18 namespace net { |
| 17 | 19 |
| 18 // Puts a net error, |err|, on the error stack in OpenSSL. The file and line are | 20 // Puts a net error, |err|, on the error stack in OpenSSL. The file and line are |
| 19 // extracted from |posted_from|. The function code of the error is left as 0. | 21 // extracted from |posted_from|. The function code of the error is left as 0. |
| 20 void OpenSSLPutNetError(const tracked_objects::Location& posted_from, int err); | 22 void OpenSSLPutNetError(const tracked_objects::Location& posted_from, int err); |
| 21 | 23 |
| 22 // Utility to construct the appropriate set & clear masks for use the OpenSSL | 24 // Utility to construct the appropriate set & clear masks for use the OpenSSL |
| 23 // options and mode configuration functions. (SSL_set_options etc) | 25 // options and mode configuration functions. (SSL_set_options etc) |
| 24 struct SslSetClearMask { | 26 struct SslSetClearMask { |
| 25 SslSetClearMask(); | 27 SslSetClearMask(); |
| 26 void ConfigureFlag(long flag, bool state); | 28 void ConfigureFlag(long flag, bool state); |
| 27 | 29 |
| 28 long set_mask; | 30 long set_mask; |
| 29 long clear_mask; | 31 long clear_mask; |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 // Converts an OpenSSL error code into a net error code, walking the OpenSSL | 34 // Converts an OpenSSL error code into a net error code, walking the OpenSSL |
| 33 // error stack if needed. Note that |tracer| is not currently used in the | 35 // error stack if needed. |
| 34 // implementation, but is passed in anyway as this ensures the caller will clear | 36 // |
| 35 // any residual codes left on the error stack. | 37 // Note that |tracer| is not currently used in the implementation, but is passed |
| 38 // in anyway as this ensures the caller will clear any residual codes left on |
| 39 // the error stack. |
| 36 int MapOpenSSLError(int err, const crypto::OpenSSLErrStackTracer& tracer); | 40 int MapOpenSSLError(int err, const crypto::OpenSSLErrStackTracer& tracer); |
| 37 | 41 |
| 42 // Converts an OpenSSL error code into a net error code, walking the OpenSSL |
| 43 // error stack if needed. If a value on the stack is used, the error code and |
| 44 // source file and line number are returned in |*out_error_code|, |*out_file|, |
| 45 // and |*out_line|, respectively. Otherwise they are set to 0 and NULL. |
| 46 // |
| 47 // Note that |tracer| is not currently used in the implementation, but is passed |
| 48 // in anyway as this ensures the caller will clear any residual codes left on |
| 49 // the error stack. |
| 50 int MapOpenSSLErrorWithDetails(int err, |
| 51 const crypto::OpenSSLErrStackTracer& tracer, |
| 52 uint32_t* out_error_code, |
| 53 const char** out_file, |
| 54 int* out_line); |
| 55 |
| 56 // Creates NetLog callback for an OpenSSL error. |
| 57 NetLog::ParametersCallback CreateNetLogOpenSSLErrorCallback(int net_error, |
| 58 int ssl_error, |
| 59 uint32_t error_code, |
| 60 const char* file, |
| 61 int line); |
| 62 |
| 38 } // namespace net | 63 } // namespace net |
| 39 | 64 |
| 40 #endif // NET_SSL_OPENSSL_SSL_UTIL_H_ | 65 #endif // NET_SSL_OPENSSL_SSL_UTIL_H_ |
| OLD | NEW |