namespace net {
+namespace test {
+class QuicConfigPeer;
+} // namespace test
+
class CryptoHandshakeMessage;
// Describes whether or not a given QuicTag is required or optional in the
// handshake message.
enum QuicConfigPresence {
- // This value can be absent from the handshake message. Default value is
- // selected as the negotiated value in such a case.
+ // This negotiable value can be absent from the handshake message. Default
+ // value is selected as the negotiated value in such a case.
PRESENCE_OPTIONAL,
- // This value is required in the handshake message otherwise the Process*Hello
- // function returns an error.
+ // This negotiable value is required in the handshake message otherwise the
+ // Process*Hello function returns an error.
PRESENCE_REQUIRED,
};
+// Whether the CryptoHandshakeMessage is from the client or server.
+enum HelloType {
+ CLIENT,
+ SERVER,
+};
+
// An abstract base class that stores a value that can be sent in CHLO/SHLO
// message. These values can be OPTIONAL or REQUIRED, depending on |presence_|.
class NET_EXPORT_PRIVATE QuicConfigValue {
// Serialises tag name and value(s) to |out|.
virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const = 0;
- // Selects a mutually acceptable value from those offered in |client_hello|
- // and those defined in the subclass.
- virtual QuicErrorCode ProcessClientHello(
- const CryptoHandshakeMessage& client_hello,
- std::string* error_details) = 0;
-
- // Selects a mutually acceptable value from those offered in |server_hello|
+ // Selects a mutually acceptable value from those offered in |peer_hello|
// and those defined in the subclass.
- virtual QuicErrorCode ProcessServerHello(
- const CryptoHandshakeMessage& server_hello,
+ virtual QuicErrorCode ProcessPeerHello(
+ const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
std::string* error_details) = 0;
protected:
virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
// Sets |negotiated_value_| to the minimum of |max_value_| and the
- // corresponding value from |client_hello|. If the corresponding value is
+ // corresponding value from |peer_hello|. If the corresponding value is
// missing and PRESENCE_OPTIONAL then |negotiated_value_| is set to
// |default_value_|.
- virtual QuicErrorCode ProcessClientHello(
- const CryptoHandshakeMessage& client_hello,
- std::string* error_details) OVERRIDE;
-
- // Sets the |negotiated_value_| to the corresponding value from
- // |server_hello|. Returns error if the value received in |server_hello| is
- // greater than |max_value_|. If the corresponding value is missing and
- // PRESENCE_OPTIONAL then |negotiated_value_| is set to |0|,
- virtual QuicErrorCode ProcessServerHello(
- const CryptoHandshakeMessage& server_hello,
+ virtual QuicErrorCode ProcessPeerHello(
+ const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
std::string* error_details) OVERRIDE;
private:
// Selects the tag common to both tags in |client_hello| for |name_| and
// |possible_values_| with preference to tag in |possible_values_|. The
// selected tag is set as |negotiated_tag_|.
- virtual QuicErrorCode ProcessClientHello(
- const CryptoHandshakeMessage& client_hello,
- std::string* error_details) OVERRIDE;
-
- // Sets the value for |name_| tag in |server_hello| as |negotiated_value_|.
- // Returns error if the value received in |server_hello| isn't present in
- // |possible_values_|.
- virtual QuicErrorCode ProcessServerHello(
- const CryptoHandshakeMessage& server_hello,
+ virtual QuicErrorCode ProcessPeerHello(
+ const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
std::string* error_details) OVERRIDE;
private:
// Stores uint32 from CHLO or SHLO messages that are not negotiated.
class NET_EXPORT_PRIVATE QuicFixedUint32 : public QuicConfigValue {
public:
- QuicFixedUint32(QuicTag name,
- QuicConfigPresence presence,
- uint32 default_value);
+ QuicFixedUint32(QuicTag name, QuicConfigPresence presence);
virtual ~QuicFixedUint32();
- // Returns the value in the *HLO message (or the default if not).
- uint32 GetUint32() const;
+ bool HasSendValue() const;
+
+ uint32 GetSendValue() const;
+
+ void SetSendValue(uint32 value);
+
+ bool HasReceivedValue() const;
+
+ uint32 GetReceivedValue() const;
+
+ void SetReceivedValue(uint32 value);
+
+ // If has_send_value is true, serialises |tag_| and |send_value_| to |out|.
+ virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
+
+ // Sets |value_| to the corresponding value from |peer_hello_| if it exists.
+ virtual QuicErrorCode ProcessPeerHello(
+ const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
+ std::string* error_details) OVERRIDE;
+
+ private:
+ uint32 send_value_;
+ bool has_send_value_;
+ uint32 receive_value_;
+ bool has_receive_value_;
+};
+
+// Stores tag from CHLO or SHLO messages that are not negotiated.
+class NET_EXPORT_PRIVATE QuicFixedTag : public QuicConfigValue {
+ public:
+ QuicFixedTag(QuicTag name, QuicConfigPresence presence);
+ virtual ~QuicFixedTag();
+
+ bool HasSendValue() const;
+
+ QuicTag GetSendValue() const;
+
+ void SetSendValue(QuicTag value);
+
+ bool HasReceivedValue() const;
- void set_value(uint32 value) { value_ = value; }
+ QuicTag GetReceivedValue() const;
- // Serialises |name_| and |value_| to |out|.
+ void SetReceivedValue(QuicTag value);
+
+ // If has_send_value is true, serialises |tag_| and |send_value_| to |out|.
virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
// Sets |value_| to the corresponding value from |client_hello_| if it exists.
- virtual QuicErrorCode ProcessClientHello(
- const CryptoHandshakeMessage& client_hello,
+ virtual QuicErrorCode ProcessPeerHello(
+ const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
std::string* error_details) OVERRIDE;
- // Sets |value_| to the corresponding value from |server_hello_| if it exists.
- virtual QuicErrorCode ProcessServerHello(
- const CryptoHandshakeMessage& server_hello,
+ private:
+ QuicTag send_value_;
+ bool has_send_value_;
+ QuicTag receive_value_;
+ bool has_receive_value_;
+};
+
+// Stores tag from CHLO or SHLO messages that are not negotiated.
+class NET_EXPORT_PRIVATE QuicFixedTagVector : public QuicConfigValue {
+ public:
+ QuicFixedTagVector(QuicTag name, QuicConfigPresence presence);
+ virtual ~QuicFixedTagVector();
+
+ bool HasSendValues() const;
+
+ QuicTagVector GetSendValues() const;
+
+ void SetSendValues(const QuicTagVector& values);
+
+ bool HasReceivedValues() const;
+
+ QuicTagVector GetReceivedValues() const;
+
+ void SetReceivedValues(const QuicTagVector& values);
+
+ // If has_send_value is true, serialises |tag_vector_| and |send_value_| to
+ // |out|.
+ virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
+
+ // Sets |receive_values_| to the corresponding value from |client_hello_| if
+ // it exists.
+ virtual QuicErrorCode ProcessPeerHello(
+ const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
std::string* error_details) OVERRIDE;
private:
- uint32 value_;
+ QuicTagVector send_values_;
+ bool has_send_values_;
+ QuicTagVector receive_values_;
+ bool has_receive_values_;
};
// QuicConfig contains non-crypto configuration options that are negotiated in
QuicConfig();
~QuicConfig();
- void set_congestion_control(const QuicTagVector& congestion_control,
- QuicTag default_congestion_control);
+ void set_congestion_feedback(const QuicTagVector& congestion_feedback,
+ QuicTag default_congestion_feedback);
+
+ QuicTag congestion_feedback() const;
+
+ void SetConnectionOptionsToSend(const QuicTagVector& connection_options);
+
+ bool HasReceivedConnectionOptions() const;
+
+ QuicTagVector ReceivedConnectionOptions() const;
+
+ bool HasSendConnectionOptions() const;
- QuicTag congestion_control() const;
+ QuicTagVector SendConnectionOptions() const;
+
+ void SetLossDetectionToSend(QuicTag loss_detection);
+
+ bool HasReceivedLossDetection() const;
+
+ QuicTag ReceivedLossDetection() const;
void set_idle_connection_state_lifetime(
QuicTime::Delta max_idle_connection_state_lifetime,
QuicTime::Delta max_time_before_crypto_handshake() const;
- // Sets the server's TCP sender's max and default initial congestion window
- // in packets.
- void set_server_initial_congestion_window(size_t max_initial_window,
- size_t default_initial_window);
+ // Sets the peer's default initial congestion window in packets.
+ void SetInitialCongestionWindowToSend(size_t initial_window);
- uint32 server_initial_congestion_window() const;
+ bool HasReceivedInitialCongestionWindow() const;
+
+ uint32 ReceivedInitialCongestionWindow() const;
// Sets an estimated initial round trip time in us.
- void set_initial_round_trip_time_us(size_t max_rtt, size_t default_rtt);
+ void SetInitialRoundTripTimeUsToSend(size_t rtt_us);
+
+ bool HasReceivedInitialRoundTripTimeUs() const;
+
+ uint32 ReceivedInitialRoundTripTimeUs() const;
+
+ bool HasInitialRoundTripTimeUsToSend() const;
+
+ uint32 GetInitialRoundTripTimeUsToSend() const;
+
+ // TODO(rjshade): Remove all InitialFlowControlWindow methods when removing
+ // QUIC_VERSION_19.
+ // Sets an initial stream flow control window size to transmit to the peer.
+ void SetInitialFlowControlWindowToSend(uint32 window_bytes);
- uint32 initial_round_trip_time_us() const;
+ uint32 GetInitialFlowControlWindowToSend() const;
- void set_peer_initial_flow_control_window_bytes(uint32 window);
+ bool HasReceivedInitialFlowControlWindowBytes() const;
- uint32 peer_initial_flow_control_window_bytes() const;
+ uint32 ReceivedInitialFlowControlWindowBytes() const;
+
+ // Sets an initial stream flow control window size to transmit to the peer.
+ void SetInitialStreamFlowControlWindowToSend(uint32 window_bytes);
+
+ uint32 GetInitialStreamFlowControlWindowToSend() const;
+
+ bool HasReceivedInitialStreamFlowControlWindowBytes() const;
+
+ uint32 ReceivedInitialStreamFlowControlWindowBytes() const;
+
+ // Sets an initial session flow control window size to transmit to the peer.
+ void SetInitialSessionFlowControlWindowToSend(uint32 window_bytes);
+
+ uint32 GetInitialSessionFlowControlWindowToSend() const;
+
+ bool HasReceivedInitialSessionFlowControlWindowBytes() const;
+
+ uint32 ReceivedInitialSessionFlowControlWindowBytes() const;
+
+ // Sets socket receive buffer to transmit to the peer.
+ void SetSocketReceiveBufferToSend(uint32 window_bytes);
+
+ uint32 GetSocketReceiveBufferToSend() const;
+
+ bool HasReceivedSocketReceiveBuffer() const;
+
+ uint32 ReceivedSocketReceiveBuffer() const;
bool negotiated();
// SetDefaults sets the members to sensible, default values.
void SetDefaults();
- // Enabled pacing.
- void EnablePacing(bool enable_pacing);
-
- // ToHandshakeMessage serializes the settings in this object as a series of
+ // ToHandshakeMessage serialises the settings in this object as a series of
// tags /value pairs and adds them to |out|.
void ToHandshakeMessage(CryptoHandshakeMessage* out) const;
- // Calls ProcessClientHello on each negotiable parameter. On failure returns
- // the corresponding QuicErrorCode and sets detailed error in |error_details|.
- QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello,
- std::string* error_details);
-
- // Calls ProcessServerHello on each negotiable parameter. On failure returns
+ // Calls ProcessPeerHello on each negotiable parameter. On failure returns
// the corresponding QuicErrorCode and sets detailed error in |error_details|.
- QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello,
- std::string* error_details);
+ QuicErrorCode ProcessPeerHello(const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
+ std::string* error_details);
private:
+ friend class test::QuicConfigPeer;
+
// Congestion control feedback type.
- QuicNegotiableTag congestion_control_;
+ QuicNegotiableTag congestion_feedback_;
+ // Connection options.
+ QuicFixedTagVector connection_options_;
+ // Loss detection feedback type.
+ QuicFixedTag loss_detection_;
// Idle connection state lifetime
QuicNegotiableUint32 idle_connection_state_lifetime_seconds_;
// Keepalive timeout, or 0 to turn off keepalive probes
// finished. (Not negotiated).
QuicTime::Delta max_time_before_crypto_handshake_;
// Initial congestion window in packets.
- QuicNegotiableUint32 server_initial_congestion_window_;
+ QuicFixedUint32 initial_congestion_window_;
// Initial round trip time estimate in microseconds.
- QuicNegotiableUint32 initial_round_trip_time_us_;
- // Peer's initial flow control receive window in bytes.
- QuicFixedUint32 peer_initial_flow_control_window_bytes_;
+ QuicFixedUint32 initial_round_trip_time_us_;
+
+ // TODO(rjshade): Remove when removing QUIC_VERSION_19.
+ // Initial flow control receive window in bytes.
+ QuicFixedUint32 initial_flow_control_window_bytes_;
+
+ // Initial stream flow control receive window in bytes.
+ QuicFixedUint32 initial_stream_flow_control_window_bytes_;
+ // Initial session flow control receive window in bytes.
+ QuicFixedUint32 initial_session_flow_control_window_bytes_;
+
+ // Socket receive buffer in bytes.
+ QuicFixedUint32 socket_receive_buffer_;
};
} // namespace net