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/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 : config_(config), | 194 : config_(config), |
195 crypto_config_(crypto_config), | 195 crypto_config_(crypto_config), |
196 compressed_certs_cache_( | 196 compressed_certs_cache_( |
197 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), | 197 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), |
198 helper_(std::move(helper)), | 198 helper_(std::move(helper)), |
199 session_helper_(std::move(session_helper)), | 199 session_helper_(std::move(session_helper)), |
200 alarm_factory_(std::move(alarm_factory)), | 200 alarm_factory_(std::move(alarm_factory)), |
201 delete_sessions_alarm_( | 201 delete_sessions_alarm_( |
202 alarm_factory_->CreateAlarm(new DeleteSessionsAlarm(this))), | 202 alarm_factory_->CreateAlarm(new DeleteSessionsAlarm(this))), |
203 supported_versions_(supported_versions), | 203 supported_versions_(supported_versions), |
| 204 disable_quic_pre_30_(FLAGS_quic_disable_pre_30), |
| 205 allowed_supported_versions_(supported_versions), |
204 current_packet_(nullptr), | 206 current_packet_(nullptr), |
205 framer_(supported_versions, | 207 framer_(supported_versions, |
206 /*unused*/ QuicTime::Zero(), | 208 /*unused*/ QuicTime::Zero(), |
207 Perspective::IS_SERVER), | 209 Perspective::IS_SERVER), |
208 last_error_(QUIC_NO_ERROR) { | 210 last_error_(QUIC_NO_ERROR) { |
209 framer_.set_visitor(this); | 211 framer_.set_visitor(this); |
210 } | 212 } |
211 | 213 |
212 QuicDispatcher::~QuicDispatcher() { | 214 QuicDispatcher::~QuicDispatcher() { |
213 STLDeleteValues(&session_map_); | 215 STLDeleteValues(&session_map_); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { | 278 if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { |
277 // Set the framer's version based on the recorded version for this | 279 // Set the framer's version based on the recorded version for this |
278 // connection and continue processing for non-public-reset packets. | 280 // connection and continue processing for non-public-reset packets. |
279 return HandlePacketForTimeWait(header); | 281 return HandlePacketForTimeWait(header); |
280 } | 282 } |
281 | 283 |
282 // The packet has an unknown connection ID. | 284 // The packet has an unknown connection ID. |
283 | 285 |
284 // Unless the packet provides a version, assume that we can continue | 286 // Unless the packet provides a version, assume that we can continue |
285 // processing using our preferred version. | 287 // processing using our preferred version. |
286 QuicVersion version = supported_versions_.front(); | 288 QuicVersion version = GetSupportedVersions().front(); |
287 if (header.version_flag) { | 289 if (header.version_flag) { |
288 QuicVersion packet_version = header.versions.front(); | 290 QuicVersion packet_version = header.versions.front(); |
289 if (!framer_.IsSupportedVersion(packet_version)) { | 291 if (!framer_.IsSupportedVersion(packet_version)) { |
290 if (ShouldCreateSessionForUnknownVersion(framer_.last_version_tag())) { | 292 if (ShouldCreateSessionForUnknownVersion(framer_.last_version_tag())) { |
291 return true; | 293 return true; |
292 } | 294 } |
293 // Since the version is not supported, send a version negotiation | 295 // Since the version is not supported, send a version negotiation |
294 // packet and stop processing the current packet. | 296 // packet and stop processing the current packet. |
295 time_wait_list_manager()->SendVersionNegotiationPacket( | 297 time_wait_list_manager()->SendVersionNegotiationPacket( |
296 connection_id, supported_versions_, current_server_address_, | 298 connection_id, GetSupportedVersions(), current_server_address_, |
297 current_client_address_); | 299 current_client_address_); |
298 return false; | 300 return false; |
299 } | 301 } |
300 version = packet_version; | 302 version = packet_version; |
301 } | 303 } |
302 // Set the framer's version and continue processing. | 304 // Set the framer's version and continue processing. |
303 framer_.set_version(version); | 305 framer_.set_version(version); |
304 return true; | 306 return true; |
305 } | 307 } |
306 | 308 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 DCHECK(false); | 594 DCHECK(false); |
593 } | 595 } |
594 | 596 |
595 QuicServerSessionBase* QuicDispatcher::CreateQuicSession( | 597 QuicServerSessionBase* QuicDispatcher::CreateQuicSession( |
596 QuicConnectionId connection_id, | 598 QuicConnectionId connection_id, |
597 const IPEndPoint& client_address) { | 599 const IPEndPoint& client_address) { |
598 // The QuicServerSessionBase takes ownership of |connection| below. | 600 // The QuicServerSessionBase takes ownership of |connection| below. |
599 QuicConnection* connection = new QuicConnection( | 601 QuicConnection* connection = new QuicConnection( |
600 connection_id, client_address, helper_.get(), alarm_factory_.get(), | 602 connection_id, client_address, helper_.get(), alarm_factory_.get(), |
601 CreatePerConnectionWriter(), | 603 CreatePerConnectionWriter(), |
602 /* owns_writer= */ true, Perspective::IS_SERVER, supported_versions_); | 604 /* owns_writer= */ true, Perspective::IS_SERVER, GetSupportedVersions()); |
603 | 605 |
604 QuicServerSessionBase* session = new QuicSimpleServerSession( | 606 QuicServerSessionBase* session = new QuicSimpleServerSession( |
605 config_, connection, this, session_helper_.get(), crypto_config_, | 607 config_, connection, this, session_helper_.get(), crypto_config_, |
606 &compressed_certs_cache_); | 608 &compressed_certs_cache_); |
607 session->Initialize(); | 609 session->Initialize(); |
608 return session; | 610 return session; |
609 } | 611 } |
610 | 612 |
611 void QuicDispatcher::OnConnectionRejectedStatelessly() {} | 613 void QuicDispatcher::OnConnectionRejectedStatelessly() {} |
612 | 614 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 rejector.reply().GetSerialized().AsStringPiece()); | 715 rejector.reply().GetSerialized().AsStringPiece()); |
714 OnConnectionRejectedStatelessly(); | 716 OnConnectionRejectedStatelessly(); |
715 return kFateTimeWait; | 717 return kFateTimeWait; |
716 } | 718 } |
717 } | 719 } |
718 | 720 |
719 QUIC_BUG << "Rejector has unknown invalid state."; | 721 QUIC_BUG << "Rejector has unknown invalid state."; |
720 return kFateDrop; | 722 return kFateDrop; |
721 } | 723 } |
722 | 724 |
| 725 const QuicVersionVector& QuicDispatcher::GetSupportedVersions() { |
| 726 // Filter (or un-filter) the list of supported versions based on the flag. |
| 727 if (disable_quic_pre_30_ != FLAGS_quic_disable_pre_30) { |
| 728 DCHECK_EQ(supported_versions_.capacity(), |
| 729 allowed_supported_versions_.capacity()); |
| 730 disable_quic_pre_30_ = FLAGS_quic_disable_pre_30; |
| 731 supported_versions_ = FilterSupportedVersions(allowed_supported_versions_); |
| 732 } |
| 733 return supported_versions_; |
| 734 } |
| 735 |
723 } // namespace net | 736 } // namespace net |
OLD | NEW |