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 #include "net/quic/quic_crypto_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "net/quic/crypto/crypto_protocol.h" | 8 #include "net/quic/crypto/crypto_protocol.h" |
9 #include "net/quic/crypto/crypto_utils.h" | 9 #include "net/quic/crypto/crypto_utils.h" |
10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 num_client_hellos_++; | 250 num_client_hellos_++; |
251 | 251 |
252 CryptoHandshakeMessage out; | 252 CryptoHandshakeMessage out; |
253 if (!cached->IsComplete(session()->connection()->clock()->WallNow())) { | 253 if (!cached->IsComplete(session()->connection()->clock()->WallNow())) { |
254 crypto_config_->FillInchoateClientHello( | 254 crypto_config_->FillInchoateClientHello( |
255 server_id_, | 255 server_id_, |
256 session()->connection()->supported_versions().front(), | 256 session()->connection()->supported_versions().front(), |
257 cached, &crypto_negotiated_params_, &out); | 257 cached, &crypto_negotiated_params_, &out); |
258 // Pad the inchoate client hello to fill up a packet. | 258 // Pad the inchoate client hello to fill up a packet. |
259 const size_t kFramingOverhead = 50; // A rough estimate. | 259 const QuicByteCount kFramingOverhead = 50; // A rough estimate. |
260 const size_t max_packet_size = | 260 const QuicByteCount max_packet_size = |
261 session()->connection()->max_packet_length(); | 261 session()->connection()->max_packet_length(); |
262 if (max_packet_size <= kFramingOverhead) { | 262 if (max_packet_size <= kFramingOverhead) { |
263 DLOG(DFATAL) << "max_packet_length (" << max_packet_size | 263 DLOG(DFATAL) << "max_packet_length (" << max_packet_size |
264 << ") has no room for framing overhead."; | 264 << ") has no room for framing overhead."; |
265 CloseConnection(QUIC_INTERNAL_ERROR); | 265 CloseConnection(QUIC_INTERNAL_ERROR); |
266 return; | 266 return; |
267 } | 267 } |
268 if (kClientHelloMinimumSize > max_packet_size - kFramingOverhead) { | 268 if (kClientHelloMinimumSize > max_packet_size - kFramingOverhead) { |
269 DLOG(DFATAL) << "Client hello won't fit in a single packet."; | 269 DLOG(DFATAL) << "Client hello won't fit in a single packet."; |
270 CloseConnection(QUIC_INTERNAL_ERROR); | 270 CloseConnection(QUIC_INTERNAL_ERROR); |
271 return; | 271 return; |
272 } | 272 } |
273 out.set_minimum_size(max_packet_size - kFramingOverhead); | 273 out.set_minimum_size( |
| 274 static_cast<size_t>(max_packet_size - kFramingOverhead)); |
274 next_state_ = STATE_RECV_REJ; | 275 next_state_ = STATE_RECV_REJ; |
275 SendHandshakeMessage(out); | 276 SendHandshakeMessage(out); |
276 return; | 277 return; |
277 } | 278 } |
278 | 279 |
279 session()->config()->ToHandshakeMessage(&out); | 280 session()->config()->ToHandshakeMessage(&out); |
280 string error_details; | 281 string error_details; |
281 QuicErrorCode error = crypto_config_->FillClientHello( | 282 QuicErrorCode error = crypto_config_->FillClientHello( |
282 server_id_, | 283 server_id_, |
283 session()->connection()->connection_id(), | 284 session()->connection()->connection_id(), |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } | 593 } |
593 } | 594 } |
594 return false; | 595 return false; |
595 } | 596 } |
596 | 597 |
597 QuicClientSessionBase* QuicCryptoClientStream::client_session() { | 598 QuicClientSessionBase* QuicCryptoClientStream::client_session() { |
598 return reinterpret_cast<QuicClientSessionBase*>(session()); | 599 return reinterpret_cast<QuicClientSessionBase*>(session()); |
599 } | 600 } |
600 | 601 |
601 } // namespace net | 602 } // namespace net |
OLD | NEW |