OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_QUIC_CRYPTO_STRIKE_REGISTER_H_ | 5 #ifndef NET_QUIC_CRYPTO_STRIKE_REGISTER_H_ |
6 #define NET_QUIC_CRYPTO_STRIKE_REGISTER_H_ | 6 #define NET_QUIC_CRYPTO_STRIKE_REGISTER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // We address the nodes by their index in the array. This means that 0 is a | 74 // We address the nodes by their index in the array. This means that 0 is a |
75 // valid index. Therefore this is our invalid index. It also has a one bit | 75 // valid index. Therefore this is our invalid index. It also has a one bit |
76 // in the LSB position because we tend to store indexes shifted up 8 bits | 76 // in the LSB position because we tend to store indexes shifted up 8 bits |
77 // and this distinguishes kNil from (kExternalFlag | 0) << 8. | 77 // and this distinguishes kNil from (kExternalFlag | 0) << 8. |
78 static const uint32 kNil; | 78 static const uint32 kNil; |
79 | 79 |
80 // Our pointers from internal nodes can either point to an internal or | 80 // Our pointers from internal nodes can either point to an internal or |
81 // external node. We flag the 24th bit to mark a pointer as external. | 81 // external node. We flag the 24th bit to mark a pointer as external. |
82 static const uint32 kExternalFlag; | 82 static const uint32 kExternalFlag; |
83 | 83 |
| 84 // Allows early validation before a strike register is created. |
| 85 static void ValidateStrikeRegisterConfig(unsigned max_entries); |
| 86 |
84 // Construct a new set which can hold, at most, |max_entries| (which must be | 87 // Construct a new set which can hold, at most, |max_entries| (which must be |
85 // less than 2**23). See the comments around StartupType about initial | 88 // less than 2**23). See the comments around StartupType about initial |
86 // behaviour. Otherwise, all nonces that are outside +/- |window_secs| from | 89 // behaviour. Otherwise, all nonces that are outside +/- |window_secs| from |
87 // the current time will be rejected. Additionally, all nonces that have an | 90 // the current time will be rejected. Additionally, all nonces that have an |
88 // orbit value other than |orbit| will be rejected. | 91 // orbit value other than |orbit| will be rejected. |
89 // | 92 // |
90 // (Note that this code is independent of the actual units of time used, but | 93 // (Note that this code is independent of the actual units of time used, but |
91 // you should use seconds.) | 94 // you should use seconds.) |
92 StrikeRegister(unsigned max_entries, | 95 StrikeRegister(unsigned max_entries, |
93 uint32 current_time_external, | 96 uint32 current_time_external, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 uint32 internal_node_head_; | 179 uint32 internal_node_head_; |
177 // internal_nodes_ can't be a scoped_ptr because the type isn't defined in | 180 // internal_nodes_ can't be a scoped_ptr because the type isn't defined in |
178 // this header. | 181 // this header. |
179 InternalNode* internal_nodes_; | 182 InternalNode* internal_nodes_; |
180 scoped_ptr<uint8[]> external_nodes_; | 183 scoped_ptr<uint8[]> external_nodes_; |
181 }; | 184 }; |
182 | 185 |
183 } // namespace net | 186 } // namespace net |
184 | 187 |
185 #endif // NET_QUIC_CRYPTO_STRIKE_REGISTER_H_ | 188 #endif // NET_QUIC_CRYPTO_STRIKE_REGISTER_H_ |
OLD | NEW |