Chromium Code Reviews| Index: net/ssl/ssl_connection_status_flags.h |
| diff --git a/net/ssl/ssl_connection_status_flags.h b/net/ssl/ssl_connection_status_flags.h |
| index 05757558ed8e9b2acdd8c686359e30cbff8201b0..a01056a6cbcf84160bb65503201c5b9d1fd26ef5 100644 |
| --- a/net/ssl/ssl_connection_status_flags.h |
| +++ b/net/ssl/ssl_connection_status_flags.h |
| @@ -5,6 +5,9 @@ |
| #ifndef NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ |
| #define NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ |
| +#include "base/logging.h" |
| +#include "base/macros.h" |
| + |
| namespace net { |
| // Status flags for SSLInfo::connection_status. |
| @@ -60,6 +63,32 @@ inline int SSLConnectionStatusToVersion(int connection_status) { |
| SSL_CONNECTION_VERSION_MASK; |
| } |
| +inline void SSLConnectionStatusSetCipherSuite(int cipher_suite, |
| + int* connection_status) { |
| + int tmp = *connection_status; |
| + // Clear out the old ciphersuite. |
| + tmp &= ~(SSL_CONNECTION_CIPHERSUITE_MASK << SSL_CONNECTION_CIPHERSUITE_SHIFT); |
| + // Set the new ciphersuite. |
| + tmp |= ((cipher_suite & SSL_CONNECTION_CIPHERSUITE_MASK) |
| + << SSL_CONNECTION_CIPHERSUITE_SHIFT); |
| + |
| + *connection_status = tmp; |
| +} |
| + |
| +inline void SSLConnectionStatusSetVersion(int version, int* connection_status) { |
| + DCHECK_GT(version, 0); |
|
agl
2014/05/20 02:45:13
The minimum should be SSLv3 (and then be >=).
|
| + DCHECK_LT(version, SSL_CONNECTION_VERSION_MAX); |
| + |
| + int tmp = *connection_status; |
| + // Clear out the old version. |
| + tmp &= ~(SSL_CONNECTION_VERSION_MASK << SSL_CONNECTION_VERSION_SHIFT); |
| + // Set the new version. |
| + tmp |= |
| + ((version & SSL_CONNECTION_VERSION_MASK) << SSL_CONNECTION_VERSION_SHIFT); |
| + |
| + *connection_status = tmp; |
| +} |
| + |
| } // namespace net |
| #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ |