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/core/quic_config.h" | 5 #include "net/quic/core/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/core/crypto/crypto_handshake_message.h" | 10 #include "net/quic/core/crypto/crypto_handshake_message.h" |
11 #include "net/quic/core/crypto/crypto_protocol.h" | 11 #include "net/quic/core/crypto/crypto_protocol.h" |
12 #include "net/quic/core/quic_bug_tracker.h" | 12 #include "net/quic/core/quic_bug_tracker.h" |
| 13 #include "net/quic/core/quic_flags.h" |
13 #include "net/quic/core/quic_socket_address_coder.h" | 14 #include "net/quic/core/quic_socket_address_coder.h" |
14 #include "net/quic/core/quic_utils.h" | 15 #include "net/quic/core/quic_utils.h" |
15 | 16 |
16 using std::min; | 17 using std::min; |
17 using std::string; | 18 using std::string; |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 | 21 |
21 // Reads the value corresponding to |name_| from |msg| into |out|. If the | 22 // Reads the value corresponding to |name_| from |msg| into |out|. If the |
22 // |name_| is absent in |msg| and |presence| is set to OPTIONAL |out| is set | 23 // |name_| is absent in |msg| and |presence| is set to OPTIONAL |out| is set |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 max_streams_per_connection_(kMSPC, PRESENCE_OPTIONAL), | 417 max_streams_per_connection_(kMSPC, PRESENCE_OPTIONAL), |
417 max_incoming_dynamic_streams_(kMIDS, PRESENCE_OPTIONAL), | 418 max_incoming_dynamic_streams_(kMIDS, PRESENCE_OPTIONAL), |
418 bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL), | 419 bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL), |
419 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), | 420 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), |
420 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), | 421 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), |
421 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), | 422 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), |
422 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL), | 423 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL), |
423 multipath_enabled_(kMPTH, PRESENCE_OPTIONAL), | 424 multipath_enabled_(kMPTH, PRESENCE_OPTIONAL), |
424 connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL), | 425 connection_migration_disabled_(kNCMR, PRESENCE_OPTIONAL), |
425 alternate_server_address_(kASAD, PRESENCE_OPTIONAL), | 426 alternate_server_address_(kASAD, PRESENCE_OPTIONAL), |
426 force_hol_blocking_(kFHL2, PRESENCE_OPTIONAL) { | 427 force_hol_blocking_(kFHL2, PRESENCE_OPTIONAL), |
| 428 support_max_header_list_size_(kSMHL, PRESENCE_OPTIONAL) { |
427 SetDefaults(); | 429 SetDefaults(); |
428 } | 430 } |
429 | 431 |
430 QuicConfig::QuicConfig(const QuicConfig& other) = default; | 432 QuicConfig::QuicConfig(const QuicConfig& other) = default; |
431 | 433 |
432 QuicConfig::~QuicConfig() {} | 434 QuicConfig::~QuicConfig() {} |
433 | 435 |
434 bool QuicConfig::SetInitialReceivedConnectionOptions( | 436 bool QuicConfig::SetInitialReceivedConnectionOptions( |
435 const QuicTagVector& tags) { | 437 const QuicTagVector& tags) { |
436 if (HasReceivedConnectionOptions()) { | 438 if (HasReceivedConnectionOptions()) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 } | 656 } |
655 | 657 |
656 bool QuicConfig::ForceHolBlocking(Perspective perspective) const { | 658 bool QuicConfig::ForceHolBlocking(Perspective perspective) const { |
657 if (perspective == Perspective::IS_SERVER) { | 659 if (perspective == Perspective::IS_SERVER) { |
658 return force_hol_blocking_.HasReceivedValue(); | 660 return force_hol_blocking_.HasReceivedValue(); |
659 } else { | 661 } else { |
660 return force_hol_blocking_.HasSendValue(); | 662 return force_hol_blocking_.HasSendValue(); |
661 } | 663 } |
662 } | 664 } |
663 | 665 |
| 666 void QuicConfig::SetSupportMaxHeaderListSize() { |
| 667 support_max_header_list_size_.SetSendValue(1); |
| 668 } |
| 669 |
| 670 bool QuicConfig::SupportMaxHeaderListSize() const { |
| 671 return support_max_header_list_size_.HasReceivedValue(); |
| 672 } |
| 673 |
664 bool QuicConfig::negotiated() const { | 674 bool QuicConfig::negotiated() const { |
665 // TODO(ianswett): Add the negotiated parameters once and iterate over all | 675 // TODO(ianswett): Add the negotiated parameters once and iterate over all |
666 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and | 676 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and |
667 // ProcessServerHello. | 677 // ProcessServerHello. |
668 return idle_network_timeout_seconds_.negotiated() && | 678 return idle_network_timeout_seconds_.negotiated() && |
669 max_streams_per_connection_.negotiated(); | 679 max_streams_per_connection_.negotiated(); |
670 } | 680 } |
671 | 681 |
672 void QuicConfig::SetDefaults() { | 682 void QuicConfig::SetDefaults() { |
673 idle_network_timeout_seconds_.set(kMaximumIdleTimeoutSecs, | 683 idle_network_timeout_seconds_.set(kMaximumIdleTimeoutSecs, |
674 kDefaultIdleTimeoutSecs); | 684 kDefaultIdleTimeoutSecs); |
675 silent_close_.set(1, 0); | 685 silent_close_.set(1, 0); |
676 SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection, | 686 SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection, |
677 kDefaultMaxStreamsPerConnection); | 687 kDefaultMaxStreamsPerConnection); |
678 SetMaxIncomingDynamicStreamsToSend(kDefaultMaxStreamsPerConnection); | 688 SetMaxIncomingDynamicStreamsToSend(kDefaultMaxStreamsPerConnection); |
679 max_time_before_crypto_handshake_ = | 689 max_time_before_crypto_handshake_ = |
680 QuicTime::Delta::FromSeconds(kMaxTimeForCryptoHandshakeSecs); | 690 QuicTime::Delta::FromSeconds(kMaxTimeForCryptoHandshakeSecs); |
681 max_idle_time_before_crypto_handshake_ = | 691 max_idle_time_before_crypto_handshake_ = |
682 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs); | 692 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs); |
683 max_undecryptable_packets_ = kDefaultMaxUndecryptablePackets; | 693 max_undecryptable_packets_ = kDefaultMaxUndecryptablePackets; |
684 | 694 |
685 SetInitialStreamFlowControlWindowToSend(kMinimumFlowControlSendWindow); | 695 SetInitialStreamFlowControlWindowToSend(kMinimumFlowControlSendWindow); |
686 SetInitialSessionFlowControlWindowToSend(kMinimumFlowControlSendWindow); | 696 SetInitialSessionFlowControlWindowToSend(kMinimumFlowControlSendWindow); |
| 697 if (FLAGS_quic_send_max_header_list_size) { |
| 698 SetSupportMaxHeaderListSize(); |
| 699 } |
687 } | 700 } |
688 | 701 |
689 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { | 702 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
690 idle_network_timeout_seconds_.ToHandshakeMessage(out); | 703 idle_network_timeout_seconds_.ToHandshakeMessage(out); |
691 silent_close_.ToHandshakeMessage(out); | 704 silent_close_.ToHandshakeMessage(out); |
692 max_streams_per_connection_.ToHandshakeMessage(out); | 705 max_streams_per_connection_.ToHandshakeMessage(out); |
693 max_incoming_dynamic_streams_.ToHandshakeMessage(out); | 706 max_incoming_dynamic_streams_.ToHandshakeMessage(out); |
694 bytes_for_connection_id_.ToHandshakeMessage(out); | 707 bytes_for_connection_id_.ToHandshakeMessage(out); |
695 initial_round_trip_time_us_.ToHandshakeMessage(out); | 708 initial_round_trip_time_us_.ToHandshakeMessage(out); |
696 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); | 709 initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); |
697 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); | 710 initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); |
698 socket_receive_buffer_.ToHandshakeMessage(out); | 711 socket_receive_buffer_.ToHandshakeMessage(out); |
699 connection_migration_disabled_.ToHandshakeMessage(out); | 712 connection_migration_disabled_.ToHandshakeMessage(out); |
700 connection_options_.ToHandshakeMessage(out); | 713 connection_options_.ToHandshakeMessage(out); |
701 alternate_server_address_.ToHandshakeMessage(out); | 714 alternate_server_address_.ToHandshakeMessage(out); |
702 force_hol_blocking_.ToHandshakeMessage(out); | 715 force_hol_blocking_.ToHandshakeMessage(out); |
| 716 support_max_header_list_size_.ToHandshakeMessage(out); |
703 } | 717 } |
704 | 718 |
705 QuicErrorCode QuicConfig::ProcessPeerHello( | 719 QuicErrorCode QuicConfig::ProcessPeerHello( |
706 const CryptoHandshakeMessage& peer_hello, | 720 const CryptoHandshakeMessage& peer_hello, |
707 HelloType hello_type, | 721 HelloType hello_type, |
708 string* error_details) { | 722 string* error_details) { |
709 DCHECK(error_details != nullptr); | 723 DCHECK(error_details != nullptr); |
710 | 724 |
711 QuicErrorCode error = QUIC_NO_ERROR; | 725 QuicErrorCode error = QUIC_NO_ERROR; |
712 if (error == QUIC_NO_ERROR) { | 726 if (error == QUIC_NO_ERROR) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 error_details); | 768 error_details); |
755 } | 769 } |
756 if (error == QUIC_NO_ERROR) { | 770 if (error == QUIC_NO_ERROR) { |
757 error = alternate_server_address_.ProcessPeerHello(peer_hello, hello_type, | 771 error = alternate_server_address_.ProcessPeerHello(peer_hello, hello_type, |
758 error_details); | 772 error_details); |
759 } | 773 } |
760 if (error == QUIC_NO_ERROR) { | 774 if (error == QUIC_NO_ERROR) { |
761 error = force_hol_blocking_.ProcessPeerHello(peer_hello, hello_type, | 775 error = force_hol_blocking_.ProcessPeerHello(peer_hello, hello_type, |
762 error_details); | 776 error_details); |
763 } | 777 } |
| 778 if (error == QUIC_NO_ERROR) { |
| 779 error = support_max_header_list_size_.ProcessPeerHello( |
| 780 peer_hello, hello_type, error_details); |
| 781 } |
764 return error; | 782 return error; |
765 } | 783 } |
766 | 784 |
767 } // namespace net | 785 } // namespace net |
OLD | NEW |