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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 418 } |
419 break; | 419 break; |
420 default: | 420 default: |
421 *error_details = "Bad " + QuicUtils::TagToString(tag_); | 421 *error_details = "Bad " + QuicUtils::TagToString(tag_); |
422 break; | 422 break; |
423 } | 423 } |
424 return error; | 424 return error; |
425 } | 425 } |
426 | 426 |
427 QuicConfig::QuicConfig() | 427 QuicConfig::QuicConfig() |
428 : congestion_feedback_(kCGST, PRESENCE_REQUIRED), | 428 : max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), |
| 429 max_idle_time_before_crypto_handshake_(QuicTime::Delta::Zero()), |
| 430 congestion_feedback_(kCGST, PRESENCE_REQUIRED), |
429 connection_options_(kCOPT, PRESENCE_OPTIONAL), | 431 connection_options_(kCOPT, PRESENCE_OPTIONAL), |
430 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), | 432 idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), |
431 keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL), | 433 keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL), |
432 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), | 434 max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), |
433 max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), | |
434 initial_congestion_window_(kSWND, PRESENCE_OPTIONAL), | 435 initial_congestion_window_(kSWND, PRESENCE_OPTIONAL), |
435 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), | 436 initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), |
436 // TODO(rjshade): Make this PRESENCE_REQUIRED when QUIC_VERSION_16 is | 437 // TODO(rjshade): Remove this when retiring QUIC_VERSION_19. |
437 // retired. | |
438 initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL), | 438 initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL), |
439 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring | 439 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
440 // QUIC_VERSION_19. | 440 // QUIC_VERSION_19. |
441 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), | 441 initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), |
442 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring | 442 // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
443 // QUIC_VERSION_19. | 443 // QUIC_VERSION_19. |
444 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), | 444 initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), |
445 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL) { | 445 socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL) { |
446 } | 446 } |
447 | 447 |
448 QuicConfig::~QuicConfig() {} | 448 QuicConfig::~QuicConfig() {} |
449 | 449 |
450 void QuicConfig::set_congestion_feedback( | 450 void QuicConfig::SetCongestionFeedback( |
451 const QuicTagVector& congestion_feedback, | 451 const QuicTagVector& congestion_feedback, |
452 QuicTag default_congestion_feedback) { | 452 QuicTag default_congestion_feedback) { |
453 congestion_feedback_.set(congestion_feedback, default_congestion_feedback); | 453 congestion_feedback_.set(congestion_feedback, default_congestion_feedback); |
454 } | 454 } |
455 | 455 |
456 QuicTag QuicConfig::congestion_feedback() const { | 456 QuicTag QuicConfig::CongestionFeedback() const { |
457 return congestion_feedback_.GetTag(); | 457 return congestion_feedback_.GetTag(); |
458 } | 458 } |
459 | 459 |
460 void QuicConfig::SetConnectionOptionsToSend( | 460 void QuicConfig::SetConnectionOptionsToSend( |
461 const QuicTagVector& connection_options) { | 461 const QuicTagVector& connection_options) { |
462 connection_options_.SetSendValues(connection_options); | 462 connection_options_.SetSendValues(connection_options); |
463 } | 463 } |
464 | 464 |
465 bool QuicConfig::HasReceivedConnectionOptions() const { | 465 bool QuicConfig::HasReceivedConnectionOptions() const { |
466 return connection_options_.HasReceivedValues(); | 466 return connection_options_.HasReceivedValues(); |
467 } | 467 } |
468 | 468 |
469 QuicTagVector QuicConfig::ReceivedConnectionOptions() const { | 469 QuicTagVector QuicConfig::ReceivedConnectionOptions() const { |
470 return connection_options_.GetReceivedValues(); | 470 return connection_options_.GetReceivedValues(); |
471 } | 471 } |
472 | 472 |
473 bool QuicConfig::HasSendConnectionOptions() const { | 473 bool QuicConfig::HasSendConnectionOptions() const { |
474 return connection_options_.HasSendValues(); | 474 return connection_options_.HasSendValues(); |
475 } | 475 } |
476 | 476 |
477 QuicTagVector QuicConfig::SendConnectionOptions() const { | 477 QuicTagVector QuicConfig::SendConnectionOptions() const { |
478 return connection_options_.GetSendValues(); | 478 return connection_options_.GetSendValues(); |
479 } | 479 } |
480 | 480 |
481 void QuicConfig::set_idle_connection_state_lifetime( | 481 void QuicConfig::SetIdleConnectionStateLifetime( |
482 QuicTime::Delta max_idle_connection_state_lifetime, | 482 QuicTime::Delta max_idle_connection_state_lifetime, |
483 QuicTime::Delta default_idle_conection_state_lifetime) { | 483 QuicTime::Delta default_idle_conection_state_lifetime) { |
484 idle_connection_state_lifetime_seconds_.set( | 484 idle_connection_state_lifetime_seconds_.set( |
485 max_idle_connection_state_lifetime.ToSeconds(), | 485 max_idle_connection_state_lifetime.ToSeconds(), |
486 default_idle_conection_state_lifetime.ToSeconds()); | 486 default_idle_conection_state_lifetime.ToSeconds()); |
487 } | 487 } |
488 | 488 |
489 QuicTime::Delta QuicConfig::idle_connection_state_lifetime() const { | 489 QuicTime::Delta QuicConfig::IdleConnectionStateLifetime() const { |
490 return QuicTime::Delta::FromSeconds( | 490 return QuicTime::Delta::FromSeconds( |
491 idle_connection_state_lifetime_seconds_.GetUint32()); | 491 idle_connection_state_lifetime_seconds_.GetUint32()); |
492 } | 492 } |
493 | 493 |
494 QuicTime::Delta QuicConfig::keepalive_timeout() const { | 494 QuicTime::Delta QuicConfig::KeepaliveTimeout() const { |
495 return QuicTime::Delta::FromSeconds( | 495 return QuicTime::Delta::FromSeconds( |
496 keepalive_timeout_seconds_.GetUint32()); | 496 keepalive_timeout_seconds_.GetUint32()); |
497 } | 497 } |
498 | 498 |
499 void QuicConfig::set_max_streams_per_connection(size_t max_streams, | 499 void QuicConfig::SetMaxStreamsPerConnection(size_t max_streams, |
500 size_t default_streams) { | 500 size_t default_streams) { |
501 max_streams_per_connection_.set(max_streams, default_streams); | 501 max_streams_per_connection_.set(max_streams, default_streams); |
502 } | 502 } |
503 | 503 |
504 uint32 QuicConfig::max_streams_per_connection() const { | 504 uint32 QuicConfig::MaxStreamsPerConnection() const { |
505 return max_streams_per_connection_.GetUint32(); | 505 return max_streams_per_connection_.GetUint32(); |
506 } | 506 } |
507 | 507 |
508 void QuicConfig::set_max_time_before_crypto_handshake( | |
509 QuicTime::Delta max_time_before_crypto_handshake) { | |
510 max_time_before_crypto_handshake_ = max_time_before_crypto_handshake; | |
511 } | |
512 | |
513 QuicTime::Delta QuicConfig::max_time_before_crypto_handshake() const { | |
514 return max_time_before_crypto_handshake_; | |
515 } | |
516 | |
517 void QuicConfig::SetInitialCongestionWindowToSend(size_t initial_window) { | 508 void QuicConfig::SetInitialCongestionWindowToSend(size_t initial_window) { |
518 initial_congestion_window_.SetSendValue(initial_window); | 509 initial_congestion_window_.SetSendValue(initial_window); |
519 } | 510 } |
520 | 511 |
521 bool QuicConfig::HasReceivedInitialCongestionWindow() const { | 512 bool QuicConfig::HasReceivedInitialCongestionWindow() const { |
522 return initial_congestion_window_.HasReceivedValue(); | 513 return initial_congestion_window_.HasReceivedValue(); |
523 } | 514 } |
524 | 515 |
525 uint32 QuicConfig::ReceivedInitialCongestionWindow() const { | 516 uint32 QuicConfig::ReceivedInitialCongestionWindow() const { |
526 return initial_congestion_window_.GetReceivedValue(); | 517 return initial_congestion_window_.GetReceivedValue(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 } | 612 } |
622 | 613 |
623 bool QuicConfig::HasReceivedSocketReceiveBuffer() const { | 614 bool QuicConfig::HasReceivedSocketReceiveBuffer() const { |
624 return socket_receive_buffer_.HasReceivedValue(); | 615 return socket_receive_buffer_.HasReceivedValue(); |
625 } | 616 } |
626 | 617 |
627 uint32 QuicConfig::ReceivedSocketReceiveBuffer() const { | 618 uint32 QuicConfig::ReceivedSocketReceiveBuffer() const { |
628 return socket_receive_buffer_.GetReceivedValue(); | 619 return socket_receive_buffer_.GetReceivedValue(); |
629 } | 620 } |
630 | 621 |
631 bool QuicConfig::negotiated() { | 622 bool QuicConfig::negotiated() const { |
632 // TODO(ianswett): Add the negotiated parameters once and iterate over all | 623 // TODO(ianswett): Add the negotiated parameters once and iterate over all |
633 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and | 624 // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and |
634 // ProcessServerHello. | 625 // ProcessServerHello. |
635 return congestion_feedback_.negotiated() && | 626 return congestion_feedback_.negotiated() && |
636 idle_connection_state_lifetime_seconds_.negotiated() && | 627 idle_connection_state_lifetime_seconds_.negotiated() && |
637 keepalive_timeout_seconds_.negotiated() && | 628 keepalive_timeout_seconds_.negotiated() && |
638 max_streams_per_connection_.negotiated(); | 629 max_streams_per_connection_.negotiated(); |
639 } | 630 } |
640 | 631 |
641 void QuicConfig::SetDefaults() { | 632 void QuicConfig::SetDefaults() { |
642 QuicTagVector congestion_feedback; | 633 QuicTagVector congestion_feedback; |
643 congestion_feedback.push_back(kQBIC); | 634 congestion_feedback.push_back(kQBIC); |
644 congestion_feedback_.set(congestion_feedback, kQBIC); | 635 congestion_feedback_.set(congestion_feedback, kQBIC); |
645 idle_connection_state_lifetime_seconds_.set(kMaximumIdleTimeoutSecs, | 636 idle_connection_state_lifetime_seconds_.set(kMaximumIdleTimeoutSecs, |
646 kDefaultInitialTimeoutSecs); | 637 kDefaultIdleTimeoutSecs); |
647 // kKATO is optional. Return 0 if not negotiated. | 638 // kKATO is optional. Return 0 if not negotiated. |
648 keepalive_timeout_seconds_.set(0, 0); | 639 keepalive_timeout_seconds_.set(0, 0); |
649 set_max_streams_per_connection(kDefaultMaxStreamsPerConnection, | 640 SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection, |
650 kDefaultMaxStreamsPerConnection); | 641 kDefaultMaxStreamsPerConnection); |
651 max_time_before_crypto_handshake_ = QuicTime::Delta::FromSeconds( | 642 max_time_before_crypto_handshake_ = |
652 kDefaultMaxTimeForCryptoHandshakeSecs); | 643 QuicTime::Delta::FromSeconds(kMaxTimeForCryptoHandshakeSecs); |
| 644 max_idle_time_before_crypto_handshake_ = |
| 645 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs); |
653 | 646 |
654 SetInitialFlowControlWindowToSend(kDefaultFlowControlSendWindow); | 647 SetInitialFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
655 SetInitialStreamFlowControlWindowToSend(kDefaultFlowControlSendWindow); | 648 SetInitialStreamFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
656 SetInitialSessionFlowControlWindowToSend(kDefaultFlowControlSendWindow); | 649 SetInitialSessionFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
657 } | 650 } |
658 | 651 |
659 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { | 652 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
660 congestion_feedback_.ToHandshakeMessage(out); | 653 congestion_feedback_.ToHandshakeMessage(out); |
661 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); | 654 idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); |
662 keepalive_timeout_seconds_.ToHandshakeMessage(out); | 655 keepalive_timeout_seconds_.ToHandshakeMessage(out); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 peer_hello, hello_type, error_details); | 711 peer_hello, hello_type, error_details); |
719 } | 712 } |
720 if (error == QUIC_NO_ERROR) { | 713 if (error == QUIC_NO_ERROR) { |
721 error = connection_options_.ProcessPeerHello( | 714 error = connection_options_.ProcessPeerHello( |
722 peer_hello, hello_type, error_details); | 715 peer_hello, hello_type, error_details); |
723 } | 716 } |
724 return error; | 717 return error; |
725 } | 718 } |
726 | 719 |
727 } // namespace net | 720 } // namespace net |
OLD | NEW |