| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SSL_CONNECTION_STATUS_FLAGS_H_ | 5 #ifndef NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ |
| 6 #define NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ | 6 #define NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ |
| 7 | 7 |
| 8 namespace net { | 8 namespace net { |
| 9 | 9 |
| 10 // Status flags for SSLInfo::connection_status. | 10 // Status flags for SSLInfo::connection_status. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // The next three bits are reserved for the SSL version. | 29 // The next three bits are reserved for the SSL version. |
| 30 SSL_CONNECTION_VERSION_SHIFT = 20, | 30 SSL_CONNECTION_VERSION_SHIFT = 20, |
| 31 SSL_CONNECTION_VERSION_MASK = 7, | 31 SSL_CONNECTION_VERSION_MASK = 7, |
| 32 | 32 |
| 33 // 1 << 31 (the sign bit) is reserved so that the SSL connection status will | 33 // 1 << 31 (the sign bit) is reserved so that the SSL connection status will |
| 34 // never be negative. | 34 // never be negative. |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 // NOTE: the SSL version enum constants must be between 0 and | 37 // NOTE: the SSL version enum constants must be between 0 and |
| 38 // SSL_CONNECTION_VERSION_MASK, inclusive. | 38 // SSL_CONNECTION_VERSION_MASK, inclusive. |
| 39 enum { | 39 enum SSL_CONNECTION_VERSION { |
| 40 SSL_CONNECTION_VERSION_UNKNOWN = 0, // Unknown SSL version. | 40 SSL_CONNECTION_VERSION_UNKNOWN = 0, // Unknown SSL version. |
| 41 SSL_CONNECTION_VERSION_SSL2 = 1, | 41 SSL_CONNECTION_VERSION_SSL2 = 1, |
| 42 SSL_CONNECTION_VERSION_SSL3 = 2, | 42 SSL_CONNECTION_VERSION_SSL3 = 2, |
| 43 SSL_CONNECTION_VERSION_TLS1 = 3, | 43 SSL_CONNECTION_VERSION_TLS1 = 3, |
| 44 SSL_CONNECTION_VERSION_TLS1_1 = 4, | 44 SSL_CONNECTION_VERSION_TLS1_1 = 4, |
| 45 SSL_CONNECTION_VERSION_TLS1_2 = 5, | 45 SSL_CONNECTION_VERSION_TLS1_2 = 5, |
| 46 SSL_CONNECTION_VERSION_MAX, | 46 SSL_CONNECTION_VERSION_MAX, |
| 47 }; | 47 }; |
| 48 COMPILE_ASSERT(SSL_CONNECTION_VERSION_MAX - 1 <= SSL_CONNECTION_VERSION_MASK, | 48 COMPILE_ASSERT(SSL_CONNECTION_VERSION_MAX - 1 <= SSL_CONNECTION_VERSION_MASK, |
| 49 SSL_CONNECTION_VERSION_MASK_too_small); | 49 SSL_CONNECTION_VERSION_MASK_too_small); |
| 50 | 50 |
| 51 inline int SSLConnectionStatusToCipherSuite(int connection_status) { | 51 inline int SSLConnectionStatusToCipherSuite(int connection_status) { |
| 52 return (connection_status >> SSL_CONNECTION_CIPHERSUITE_SHIFT) & | 52 return (connection_status >> SSL_CONNECTION_CIPHERSUITE_SHIFT) & |
| 53 SSL_CONNECTION_CIPHERSUITE_MASK; | 53 SSL_CONNECTION_CIPHERSUITE_MASK; |
| 54 } | 54 } |
| 55 | 55 |
| 56 inline int SSLConnectionStatusToVersion(int connection_status) { | 56 inline int SSLConnectionStatusToVersion(int connection_status) { |
| 57 return (connection_status >> SSL_CONNECTION_VERSION_SHIFT) & | 57 return (connection_status >> SSL_CONNECTION_VERSION_SHIFT) & |
| 58 SSL_CONNECTION_VERSION_MASK; | 58 SSL_CONNECTION_VERSION_MASK; |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace net | 61 } // namespace net |
| 62 | 62 |
| 63 #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ | 63 #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ |
| OLD | NEW |