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 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 | 10 |
(...skipping 31 matching lines...) Loading... |
42 SSL_CONNECTION_VERSION_UNKNOWN = 0, // Unknown SSL version. | 42 SSL_CONNECTION_VERSION_UNKNOWN = 0, // Unknown SSL version. |
43 SSL_CONNECTION_VERSION_SSL2 = 1, | 43 SSL_CONNECTION_VERSION_SSL2 = 1, |
44 SSL_CONNECTION_VERSION_SSL3 = 2, | 44 SSL_CONNECTION_VERSION_SSL3 = 2, |
45 SSL_CONNECTION_VERSION_TLS1 = 3, | 45 SSL_CONNECTION_VERSION_TLS1 = 3, |
46 SSL_CONNECTION_VERSION_TLS1_1 = 4, | 46 SSL_CONNECTION_VERSION_TLS1_1 = 4, |
47 SSL_CONNECTION_VERSION_TLS1_2 = 5, | 47 SSL_CONNECTION_VERSION_TLS1_2 = 5, |
48 // Reserve 6 for TLS 1.3. | 48 // Reserve 6 for TLS 1.3. |
49 SSL_CONNECTION_VERSION_QUIC = 7, | 49 SSL_CONNECTION_VERSION_QUIC = 7, |
50 SSL_CONNECTION_VERSION_MAX, | 50 SSL_CONNECTION_VERSION_MAX, |
51 }; | 51 }; |
52 COMPILE_ASSERT(SSL_CONNECTION_VERSION_MAX - 1 <= SSL_CONNECTION_VERSION_MASK, | 52 static_assert(SSL_CONNECTION_VERSION_MAX - 1 <= SSL_CONNECTION_VERSION_MASK, |
53 SSL_CONNECTION_VERSION_MASK_too_small); | 53 "SSL_CONNECTION_VERSION_MASK too small"); |
54 | 54 |
55 inline uint16 SSLConnectionStatusToCipherSuite(int connection_status) { | 55 inline uint16 SSLConnectionStatusToCipherSuite(int connection_status) { |
56 return static_cast<uint16>(connection_status); | 56 return static_cast<uint16>(connection_status); |
57 } | 57 } |
58 | 58 |
59 inline int SSLConnectionStatusToVersion(int connection_status) { | 59 inline int SSLConnectionStatusToVersion(int connection_status) { |
60 return (connection_status >> SSL_CONNECTION_VERSION_SHIFT) & | 60 return (connection_status >> SSL_CONNECTION_VERSION_SHIFT) & |
61 SSL_CONNECTION_VERSION_MASK; | 61 SSL_CONNECTION_VERSION_MASK; |
62 } | 62 } |
63 | 63 |
(...skipping 13 matching lines...) Loading... |
77 *connection_status &= | 77 *connection_status &= |
78 ~(SSL_CONNECTION_VERSION_MASK << SSL_CONNECTION_VERSION_SHIFT); | 78 ~(SSL_CONNECTION_VERSION_MASK << SSL_CONNECTION_VERSION_SHIFT); |
79 // Set the new version. | 79 // Set the new version. |
80 *connection_status |= | 80 *connection_status |= |
81 ((version & SSL_CONNECTION_VERSION_MASK) << SSL_CONNECTION_VERSION_SHIFT); | 81 ((version & SSL_CONNECTION_VERSION_MASK) << SSL_CONNECTION_VERSION_SHIFT); |
82 } | 82 } |
83 | 83 |
84 } // namespace net | 84 } // namespace net |
85 | 85 |
86 #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ | 86 #endif // NET_SSL_SSL_CONNECTION_STATUS_FLAGS_H_ |
OLD | NEW |