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 #include "net/quic/quic_config.h" | 5 #include "net/quic/quic_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/quic/crypto/crypto_handshake_message.h" | 10 #include "net/quic/crypto/crypto_handshake_message.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 max_undecryptable_packets_(0), | 341 max_undecryptable_packets_(0), |
342 connection_options_(kCOPT, PRESENCE_OPTIONAL), | 342 connection_options_(kCOPT, PRESENCE_OPTIONAL), |
343 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), | 343 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), |
344 silent_close_(kSCLS, PRESENCE_OPTIONAL), | 344 silent_close_(kSCLS, PRESENCE_OPTIONAL), |
345 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), | 345 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), |
346 bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL), | 346 bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL), |
347 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), | 347 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), |
348 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), | 348 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), |
349 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), | 349 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), |
350 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL), | 350 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL), |
351 multipath_enabled_(kMPTH, PRESENCE_OPTIONAL) { | 351 multipath_enabled_(kMPTH, PRESENCE_OPTIONAL), |
| 352 connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL) { |
352 SetDefaults(); | 353 SetDefaults(); |
353 } | 354 } |
354 | 355 |
355 QuicConfig::QuicConfig(const QuicConfig& other) = default; | 356 QuicConfig::QuicConfig(const QuicConfig& other) = default; |
356 | 357 |
357 QuicConfig::~QuicConfig() {} | 358 QuicConfig::~QuicConfig() {} |
358 | 359 |
359 bool QuicConfig::SetInitialReceivedConnectionOptions( | 360 bool QuicConfig::SetInitialReceivedConnectionOptions( |
360 const QuicTagVector& tags) { | 361 const QuicTagVector& tags) { |
361 if (HasReceivedConnectionOptions()) { | 362 if (HasReceivedConnectionOptions()) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 | 530 |
530 void QuicConfig::SetMultipathEnabled(bool multipath_enabled) { | 531 void QuicConfig::SetMultipathEnabled(bool multipath_enabled) { |
531 uint32_t value = multipath_enabled ? 1 : 0; | 532 uint32_t value = multipath_enabled ? 1 : 0; |
532 multipath_enabled_.set(value, value); | 533 multipath_enabled_.set(value, value); |
533 } | 534 } |
534 | 535 |
535 bool QuicConfig::MultipathEnabled() const { | 536 bool QuicConfig::MultipathEnabled() const { |
536 return multipath_enabled_.GetUint32() > 0; | 537 return multipath_enabled_.GetUint32() > 0; |
537 } | 538 } |
538 | 539 |
| 540 void QuicConfig::SetDisableConnectionMigration() { |
| 541 connection_migration_disabled_.SetSendValue(1); |
| 542 } |
| 543 |
| 544 bool QuicConfig::DisableConnectionMigration() const { |
| 545 return connection_migration_disabled_.HasReceivedValue(); |
| 546 } |
| 547 |
539 bool QuicConfig::negotiated() const { | 548 bool QuicConfig::negotiated() const { |
540 // TODO(ianswett): Add the negotiated parameters once and iterate over all | 549 // TODO(ianswett): Add the negotiated parameters once and iterate over all |
541 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and | 550 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and |
542 // ProcessServerHello. | 551 // ProcessServerHello. |
543 return idle_connection_state_lifetime_seconds_.negotiated() && | 552 return idle_connection_state_lifetime_seconds_.negotiated() && |
544 max_streams_per_connection_.negotiated(); | 553 max_streams_per_connection_.negotiated(); |
545 } | 554 } |
546 | 555 |
547 void QuicConfig::SetDefaults() { | 556 void QuicConfig::SetDefaults() { |
548 idle_connection_state_lifetime_seconds_.set(kMaximumIdleTimeoutSecs, | 557 idle_connection_state_lifetime_seconds_.set(kMaximumIdleTimeoutSecs, |
(...skipping 13 matching lines...) Expand all Loading... |
562 | 571 |
563 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { | 572 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
564 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); | 573 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); |
565 silent_close_.ToHandshakeMessage(out); | 574 silent_close_.ToHandshakeMessage(out); |
566 max_streams_per_connection_.ToHandshakeMessage(out); | 575 max_streams_per_connection_.ToHandshakeMessage(out); |
567 bytes_for_connection_id_.ToHandshakeMessage(out); | 576 bytes_for_connection_id_.ToHandshakeMessage(out); |
568 initial_round_trip_time_us_.ToHandshakeMessage(out); | 577 initial_round_trip_time_us_.ToHandshakeMessage(out); |
569 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); | 578 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); |
570 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); | 579 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); |
571 socket_receive_buffer_.ToHandshakeMessage(out); | 580 socket_receive_buffer_.ToHandshakeMessage(out); |
| 581 connection_migration_disabled_.ToHandshakeMessage(out); |
572 connection_options_.ToHandshakeMessage(out); | 582 connection_options_.ToHandshakeMessage(out); |
573 } | 583 } |
574 | 584 |
575 QuicErrorCode QuicConfig::ProcessPeerHello( | 585 QuicErrorCode QuicConfig::ProcessPeerHello( |
576 const CryptoHandshakeMessage& peer_hello, | 586 const CryptoHandshakeMessage& peer_hello, |
577 HelloType hello_type, | 587 HelloType hello_type, |
578 string* error_details) { | 588 string* error_details) { |
579 DCHECK(error_details != nullptr); | 589 DCHECK(error_details != nullptr); |
580 | 590 |
581 QuicErrorCode error = QUIC_NO_ERROR; | 591 QuicErrorCode error = QUIC_NO_ERROR; |
(...skipping 23 matching lines...) Expand all Loading... |
605 } | 615 } |
606 if (error == QUIC_NO_ERROR) { | 616 if (error == QUIC_NO_ERROR) { |
607 error = initial_session_flow_control_window_bytes_.ProcessPeerHello( | 617 error = initial_session_flow_control_window_bytes_.ProcessPeerHello( |
608 peer_hello, hello_type, error_details); | 618 peer_hello, hello_type, error_details); |
609 } | 619 } |
610 if (error == QUIC_NO_ERROR) { | 620 if (error == QUIC_NO_ERROR) { |
611 error = socket_receive_buffer_.ProcessPeerHello(peer_hello, hello_type, | 621 error = socket_receive_buffer_.ProcessPeerHello(peer_hello, hello_type, |
612 error_details); | 622 error_details); |
613 } | 623 } |
614 if (error == QUIC_NO_ERROR) { | 624 if (error == QUIC_NO_ERROR) { |
| 625 error = connection_migration_disabled_.ProcessPeerHello( |
| 626 peer_hello, hello_type, error_details); |
| 627 } |
| 628 if (error == QUIC_NO_ERROR) { |
615 error = connection_options_.ProcessPeerHello(peer_hello, hello_type, | 629 error = connection_options_.ProcessPeerHello(peer_hello, hello_type, |
616 error_details); | 630 error_details); |
617 } | 631 } |
618 return error; | 632 return error; |
619 } | 633 } |
620 | 634 |
621 } // namespace net | 635 } // namespace net |
OLD | NEW |