| 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/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 perspective_(perspective), | 252 perspective_(perspective), |
| 253 connected_(true), | 253 connected_(true), |
| 254 can_truncate_connection_ids_(true), | 254 can_truncate_connection_ids_(true), |
| 255 mtu_discovery_target_(0), | 255 mtu_discovery_target_(0), |
| 256 mtu_probe_count_(0), | 256 mtu_probe_count_(0), |
| 257 packets_between_mtu_probes_(kPacketsBetweenMtuProbesBase), | 257 packets_between_mtu_probes_(kPacketsBetweenMtuProbesBase), |
| 258 next_mtu_probe_at_(kPacketsBetweenMtuProbesBase), | 258 next_mtu_probe_at_(kPacketsBetweenMtuProbesBase), |
| 259 largest_received_packet_size_(0), | 259 largest_received_packet_size_(0), |
| 260 goaway_sent_(false), | 260 goaway_sent_(false), |
| 261 goaway_received_(false), | 261 goaway_received_(false), |
| 262 multipath_enabled_(false), | |
| 263 write_error_occured_(false), | 262 write_error_occured_(false), |
| 264 no_stop_waiting_frames_(false) { | 263 no_stop_waiting_frames_(false) { |
| 265 QUIC_DLOG(INFO) << ENDPOINT | 264 QUIC_DLOG(INFO) << ENDPOINT |
| 266 << "Created connection with connection_id: " << connection_id; | 265 << "Created connection with connection_id: " << connection_id; |
| 267 framer_.set_visitor(this); | 266 framer_.set_visitor(this); |
| 268 stats_.connection_creation_time = clock_->ApproximateNow(); | 267 stats_.connection_creation_time = clock_->ApproximateNow(); |
| 269 // TODO(ianswett): Supply the NetworkChangeVisitor as a constructor argument | 268 // TODO(ianswett): Supply the NetworkChangeVisitor as a constructor argument |
| 270 // and make it required non-null, because it's always used. | 269 // and make it required non-null, because it's always used. |
| 271 sent_packet_manager_.SetNetworkChangeVisitor(this); | 270 sent_packet_manager_.SetNetworkChangeVisitor(this); |
| 272 // Allow the packet writer to potentially reduce the packet size to a value | 271 // Allow the packet writer to potentially reduce the packet size to a value |
| (...skipping 27 matching lines...) Expand all Loading... |
| 300 | 299 |
| 301 void QuicConnection::SetFromConfig(const QuicConfig& config) { | 300 void QuicConnection::SetFromConfig(const QuicConfig& config) { |
| 302 if (config.negotiated()) { | 301 if (config.negotiated()) { |
| 303 // Handshake complete, set handshake timeout to Infinite. | 302 // Handshake complete, set handshake timeout to Infinite. |
| 304 SetNetworkTimeouts(QuicTime::Delta::Infinite(), | 303 SetNetworkTimeouts(QuicTime::Delta::Infinite(), |
| 305 config.IdleNetworkTimeout()); | 304 config.IdleNetworkTimeout()); |
| 306 if (config.SilentClose()) { | 305 if (config.SilentClose()) { |
| 307 idle_timeout_connection_close_behavior_ = | 306 idle_timeout_connection_close_behavior_ = |
| 308 ConnectionCloseBehavior::SILENT_CLOSE; | 307 ConnectionCloseBehavior::SILENT_CLOSE; |
| 309 } | 308 } |
| 310 if (FLAGS_quic_reloadable_flag_quic_enable_multipath && | |
| 311 config.MultipathEnabled()) { | |
| 312 multipath_enabled_ = true; | |
| 313 } | |
| 314 } else { | 309 } else { |
| 315 SetNetworkTimeouts(config.max_time_before_crypto_handshake(), | 310 SetNetworkTimeouts(config.max_time_before_crypto_handshake(), |
| 316 config.max_idle_time_before_crypto_handshake()); | 311 config.max_idle_time_before_crypto_handshake()); |
| 317 } | 312 } |
| 318 | 313 |
| 319 sent_packet_manager_.SetFromConfig(config); | 314 sent_packet_manager_.SetFromConfig(config); |
| 320 if (config.HasReceivedBytesForConnectionId() && | 315 if (config.HasReceivedBytesForConnectionId() && |
| 321 can_truncate_connection_ids_) { | 316 can_truncate_connection_ids_) { |
| 322 packet_generator_.SetConnectionIdLength( | 317 packet_generator_.SetConnectionIdLength( |
| 323 config.ReceivedBytesForConnectionId()); | 318 config.ReceivedBytesForConnectionId()); |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 if (!Near(header.packet_number, last_header_.packet_number)) { | 1302 if (!Near(header.packet_number, last_header_.packet_number)) { |
| 1308 QUIC_DLOG(INFO) << ENDPOINT << "Packet " << header.packet_number | 1303 QUIC_DLOG(INFO) << ENDPOINT << "Packet " << header.packet_number |
| 1309 << " out of bounds. Discarding"; | 1304 << " out of bounds. Discarding"; |
| 1310 CloseConnection(QUIC_INVALID_PACKET_HEADER, "Packet number out of bounds.", | 1305 CloseConnection(QUIC_INVALID_PACKET_HEADER, "Packet number out of bounds.", |
| 1311 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 1306 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1312 return false; | 1307 return false; |
| 1313 } | 1308 } |
| 1314 | 1309 |
| 1315 // Multipath is not enabled, but a packet with multipath flag on is | 1310 // Multipath is not enabled, but a packet with multipath flag on is |
| 1316 // received. | 1311 // received. |
| 1317 if (!multipath_enabled_ && header.public_header.multipath_flag) { | 1312 if (header.public_header.multipath_flag) { |
| 1318 const string error_details = | 1313 const string error_details = |
| 1319 "Received a packet with multipath flag but multipath is not enabled."; | 1314 "Received a packet with multipath flag but multipath is not enabled."; |
| 1320 QUIC_BUG << error_details; | 1315 QUIC_BUG << error_details; |
| 1321 CloseConnection(QUIC_BAD_MULTIPATH_FLAG, error_details, | 1316 CloseConnection(QUIC_BAD_MULTIPATH_FLAG, error_details, |
| 1322 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 1317 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1323 return false; | 1318 return false; |
| 1324 } | 1319 } |
| 1325 | 1320 |
| 1326 if (version_negotiation_state_ != NEGOTIATED_VERSION) { | 1321 if (version_negotiation_state_ != NEGOTIATED_VERSION) { |
| 1327 if (perspective_ == Perspective::IS_SERVER) { | 1322 if (perspective_ == Perspective::IS_SERVER) { |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 | 2396 |
| 2402 void QuicConnection::CheckIfApplicationLimited() { | 2397 void QuicConnection::CheckIfApplicationLimited() { |
| 2403 if (queued_packets_.empty() && | 2398 if (queued_packets_.empty() && |
| 2404 !sent_packet_manager_.HasPendingRetransmissions() && | 2399 !sent_packet_manager_.HasPendingRetransmissions() && |
| 2405 !visitor_->WillingAndAbleToWrite()) { | 2400 !visitor_->WillingAndAbleToWrite()) { |
| 2406 sent_packet_manager_.OnApplicationLimited(); | 2401 sent_packet_manager_.OnApplicationLimited(); |
| 2407 } | 2402 } |
| 2408 } | 2403 } |
| 2409 | 2404 |
| 2410 } // namespace net | 2405 } // namespace net |
| OLD | NEW |