Make some parameters 64bit in QuicConfig
QuicConfig was originally built for QUIC_CRYPTO which exchanges most of its parameters as 32bit values. IETF QUIC however exchanges 62bit integers over the wire.
For example, our flow control code deals in QuicStreamOffset which is uint64_t and the IETF QUIC transport parameters can encode values up to 2^62-1, but they transit through QuicConfig which can only store 32 bits.
This CL allows the config to handle 64bit values, without changing the wire encoding. This CL still encodes these values as uint32 when using QUIC_CRYPTO.
gfe-relnote: refactor QuicConfig, no behavior change, not flag protected
PiperOrigin-RevId: 309275731
Change-Id: I9d8831af66b34dcaf8599e75c49daa1d8de3fcc4
diff --git a/quic/core/quic_config.cc b/quic/core/quic_config.cc
index 6a2bd97..640219a 100644
--- a/quic/core/quic_config.cc
+++ b/quic/core/quic_config.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <cstring>
+#include <limits>
#include <string>
#include <utility>
@@ -163,6 +164,11 @@
}
void QuicFixedUint32::ToHandshakeMessage(CryptoHandshakeMessage* out) const {
+ if (tag_ == 0) {
+ QUIC_BUG
+ << "This parameter does not support writing to CryptoHandshakeMessage";
+ return;
+ }
if (has_send_value_) {
out->SetValue(tag_, send_value_);
}
@@ -173,6 +179,12 @@
HelloType /*hello_type*/,
std::string* error_details) {
DCHECK(error_details != nullptr);
+ if (tag_ == 0) {
+ *error_details =
+ "This parameter does not support reading from CryptoHandshakeMessage";
+ QUIC_BUG << *error_details;
+ return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND;
+ }
QuicErrorCode error = peer_hello.GetUint32(tag_, &receive_value_);
switch (error) {
case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND:
@@ -191,6 +203,92 @@
return error;
}
+QuicFixedUint62::QuicFixedUint62(QuicTag name, QuicConfigPresence presence)
+ : QuicConfigValue(name, presence),
+ has_send_value_(false),
+ has_receive_value_(false) {}
+
+QuicFixedUint62::~QuicFixedUint62() {}
+
+bool QuicFixedUint62::HasSendValue() const {
+ return has_send_value_;
+}
+
+uint64_t QuicFixedUint62::GetSendValue() const {
+ if (!has_send_value_) {
+ QUIC_BUG << "No send value to get for tag:" << QuicTagToString(tag_);
+ return 0;
+ }
+ return send_value_;
+}
+
+void QuicFixedUint62::SetSendValue(uint64_t value) {
+ if (value > kVarInt62MaxValue) {
+ QUIC_BUG << "QuicFixedUint62 invalid value " << value;
+ value = kVarInt62MaxValue;
+ }
+ has_send_value_ = true;
+ send_value_ = value;
+}
+
+bool QuicFixedUint62::HasReceivedValue() const {
+ return has_receive_value_;
+}
+
+uint64_t QuicFixedUint62::GetReceivedValue() const {
+ if (!has_receive_value_) {
+ QUIC_BUG << "No receive value to get for tag:" << QuicTagToString(tag_);
+ return 0;
+ }
+ return receive_value_;
+}
+
+void QuicFixedUint62::SetReceivedValue(uint64_t value) {
+ has_receive_value_ = true;
+ receive_value_ = value;
+}
+
+void QuicFixedUint62::ToHandshakeMessage(CryptoHandshakeMessage* out) const {
+ if (!has_send_value_) {
+ return;
+ }
+ uint32_t send_value32;
+ if (send_value_ > std::numeric_limits<uint32_t>::max()) {
+ QUIC_BUG << "Attempting to send " << send_value_
+ << " for tag:" << QuicTagToString(tag_);
+ send_value32 = std::numeric_limits<uint32_t>::max();
+ } else {
+ send_value32 = static_cast<uint32_t>(send_value_);
+ }
+ out->SetValue(tag_, send_value32);
+}
+
+QuicErrorCode QuicFixedUint62::ProcessPeerHello(
+ const CryptoHandshakeMessage& peer_hello,
+ HelloType /*hello_type*/,
+ std::string* error_details) {
+ DCHECK(error_details != nullptr);
+ uint32_t receive_value32;
+ QuicErrorCode error = peer_hello.GetUint32(tag_, &receive_value32);
+ // GetUint32 is guaranteed to always initialize receive_value32.
+ receive_value_ = receive_value32;
+ switch (error) {
+ case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND:
+ if (presence_ == PRESENCE_OPTIONAL) {
+ return QUIC_NO_ERROR;
+ }
+ *error_details = "Missing " + QuicTagToString(tag_);
+ break;
+ case QUIC_NO_ERROR:
+ has_receive_value_ = true;
+ break;
+ default:
+ *error_details = "Bad " + QuicTagToString(tag_);
+ break;
+ }
+ return error;
+}
+
QuicFixedUint128::QuicFixedUint128(QuicTag tag, QuicConfigPresence presence)
: QuicConfigValue(tag, presence),
has_send_value_(false),
@@ -579,11 +677,11 @@
return ack_delay_exponent_.GetReceivedValue();
}
-void QuicConfig::SetMaxPacketSizeToSend(uint32_t max_packet_size) {
+void QuicConfig::SetMaxPacketSizeToSend(uint64_t max_packet_size) {
max_packet_size_.SetSendValue(max_packet_size);
}
-uint32_t QuicConfig::GetMaxPacketSizeToSend() const {
+uint64_t QuicConfig::GetMaxPacketSizeToSend() const {
return max_packet_size_.GetSendValue();
}
@@ -591,16 +689,16 @@
return max_packet_size_.HasReceivedValue();
}
-uint32_t QuicConfig::ReceivedMaxPacketSize() const {
+uint64_t QuicConfig::ReceivedMaxPacketSize() const {
return max_packet_size_.GetReceivedValue();
}
void QuicConfig::SetMaxDatagramFrameSizeToSend(
- uint32_t max_datagram_frame_size) {
+ uint64_t max_datagram_frame_size) {
max_datagram_frame_size_.SetSendValue(max_datagram_frame_size);
}
-uint32_t QuicConfig::GetMaxDatagramFrameSizeToSend() const {
+uint64_t QuicConfig::GetMaxDatagramFrameSizeToSend() const {
return max_datagram_frame_size_.GetSendValue();
}
@@ -608,7 +706,7 @@
return max_datagram_frame_size_.HasReceivedValue();
}
-uint32_t QuicConfig::ReceivedMaxDatagramFrameSize() const {
+uint64_t QuicConfig::ReceivedMaxDatagramFrameSize() const {
return max_datagram_frame_size_.GetReceivedValue();
}
@@ -649,7 +747,7 @@
}
void QuicConfig::SetInitialStreamFlowControlWindowToSend(
- uint32_t window_bytes) {
+ uint64_t window_bytes) {
if (window_bytes < kMinimumFlowControlSendWindow) {
QUIC_BUG << "Initial stream flow control receive window (" << window_bytes
<< ") cannot be set lower than minimum ("
@@ -659,7 +757,7 @@
initial_stream_flow_control_window_bytes_.SetSendValue(window_bytes);
}
-uint32_t QuicConfig::GetInitialStreamFlowControlWindowToSend() const {
+uint64_t QuicConfig::GetInitialStreamFlowControlWindowToSend() const {
return initial_stream_flow_control_window_bytes_.GetSendValue();
}
@@ -667,17 +765,17 @@
return initial_stream_flow_control_window_bytes_.HasReceivedValue();
}
-uint32_t QuicConfig::ReceivedInitialStreamFlowControlWindowBytes() const {
+uint64_t QuicConfig::ReceivedInitialStreamFlowControlWindowBytes() const {
return initial_stream_flow_control_window_bytes_.GetReceivedValue();
}
void QuicConfig::SetInitialMaxStreamDataBytesIncomingBidirectionalToSend(
- uint32_t window_bytes) {
+ uint64_t window_bytes) {
initial_max_stream_data_bytes_incoming_bidirectional_.SetSendValue(
window_bytes);
}
-uint32_t QuicConfig::GetInitialMaxStreamDataBytesIncomingBidirectionalToSend()
+uint64_t QuicConfig::GetInitialMaxStreamDataBytesIncomingBidirectionalToSend()
const {
if (initial_max_stream_data_bytes_incoming_bidirectional_.HasSendValue()) {
return initial_max_stream_data_bytes_incoming_bidirectional_.GetSendValue();
@@ -691,19 +789,19 @@
.HasReceivedValue();
}
-uint32_t QuicConfig::ReceivedInitialMaxStreamDataBytesIncomingBidirectional()
+uint64_t QuicConfig::ReceivedInitialMaxStreamDataBytesIncomingBidirectional()
const {
return initial_max_stream_data_bytes_incoming_bidirectional_
.GetReceivedValue();
}
void QuicConfig::SetInitialMaxStreamDataBytesOutgoingBidirectionalToSend(
- uint32_t window_bytes) {
+ uint64_t window_bytes) {
initial_max_stream_data_bytes_outgoing_bidirectional_.SetSendValue(
window_bytes);
}
-uint32_t QuicConfig::GetInitialMaxStreamDataBytesOutgoingBidirectionalToSend()
+uint64_t QuicConfig::GetInitialMaxStreamDataBytesOutgoingBidirectionalToSend()
const {
if (initial_max_stream_data_bytes_outgoing_bidirectional_.HasSendValue()) {
return initial_max_stream_data_bytes_outgoing_bidirectional_.GetSendValue();
@@ -717,18 +815,18 @@
.HasReceivedValue();
}
-uint32_t QuicConfig::ReceivedInitialMaxStreamDataBytesOutgoingBidirectional()
+uint64_t QuicConfig::ReceivedInitialMaxStreamDataBytesOutgoingBidirectional()
const {
return initial_max_stream_data_bytes_outgoing_bidirectional_
.GetReceivedValue();
}
void QuicConfig::SetInitialMaxStreamDataBytesUnidirectionalToSend(
- uint32_t window_bytes) {
+ uint64_t window_bytes) {
initial_max_stream_data_bytes_unidirectional_.SetSendValue(window_bytes);
}
-uint32_t QuicConfig::GetInitialMaxStreamDataBytesUnidirectionalToSend() const {
+uint64_t QuicConfig::GetInitialMaxStreamDataBytesUnidirectionalToSend() const {
if (initial_max_stream_data_bytes_unidirectional_.HasSendValue()) {
return initial_max_stream_data_bytes_unidirectional_.GetSendValue();
}
@@ -739,12 +837,12 @@
return initial_max_stream_data_bytes_unidirectional_.HasReceivedValue();
}
-uint32_t QuicConfig::ReceivedInitialMaxStreamDataBytesUnidirectional() const {
+uint64_t QuicConfig::ReceivedInitialMaxStreamDataBytesUnidirectional() const {
return initial_max_stream_data_bytes_unidirectional_.GetReceivedValue();
}
void QuicConfig::SetInitialSessionFlowControlWindowToSend(
- uint32_t window_bytes) {
+ uint64_t window_bytes) {
if (window_bytes < kMinimumFlowControlSendWindow) {
QUIC_BUG << "Initial session flow control receive window (" << window_bytes
<< ") cannot be set lower than default ("
@@ -754,7 +852,7 @@
initial_session_flow_control_window_bytes_.SetSendValue(window_bytes);
}
-uint32_t QuicConfig::GetInitialSessionFlowControlWindowToSend() const {
+uint64_t QuicConfig::GetInitialSessionFlowControlWindowToSend() const {
return initial_session_flow_control_window_bytes_.GetSendValue();
}
@@ -762,7 +860,7 @@
return initial_session_flow_control_window_bytes_.HasReceivedValue();
}
-uint32_t QuicConfig::ReceivedInitialSessionFlowControlWindowBytes() const {
+uint64_t QuicConfig::ReceivedInitialSessionFlowControlWindowBytes() const {
return initial_session_flow_control_window_bytes_.GetReceivedValue();
}
@@ -1055,8 +1153,10 @@
}
initial_session_flow_control_window_bytes_.SetReceivedValue(
- std::min<uint64_t>(params.initial_max_data.value(),
- std::numeric_limits<uint32_t>::max()));
+ params.initial_max_data.value());
+
+ // IETF QUIC specifies stream IDs and stream counts as 62-bit integers but
+ // our implementation uses uint32_t to represent them to save memory.
max_bidirectional_streams_.SetReceivedValue(
std::min<uint64_t>(params.initial_max_streams_bidi.value(),
std::numeric_limits<uint32_t>::max()));
@@ -1071,19 +1171,15 @@
// received transport parameters, so a local stream is one initiated by our
// peer, which means an incoming stream.
initial_max_stream_data_bytes_incoming_bidirectional_.SetReceivedValue(
- std::min<uint64_t>(params.initial_max_stream_data_bidi_local.value(),
- std::numeric_limits<uint32_t>::max()));
+ params.initial_max_stream_data_bidi_local.value());
initial_max_stream_data_bytes_outgoing_bidirectional_.SetReceivedValue(
- std::min<uint64_t>(params.initial_max_stream_data_bidi_remote.value(),
- std::numeric_limits<uint32_t>::max()));
+ params.initial_max_stream_data_bidi_remote.value());
initial_max_stream_data_bytes_unidirectional_.SetReceivedValue(
- std::min<uint64_t>(params.initial_max_stream_data_uni.value(),
- std::numeric_limits<uint32_t>::max()));
+ params.initial_max_stream_data_uni.value());
if (GetQuicReloadableFlag(quic_negotiate_ack_delay_time)) {
QUIC_RELOADABLE_FLAG_COUNT_N(quic_negotiate_ack_delay_time, 4, 4);
- max_ack_delay_ms_.SetReceivedValue(std::min<uint32_t>(
- params.max_ack_delay.value(), std::numeric_limits<uint32_t>::max()));
+ max_ack_delay_ms_.SetReceivedValue(params.max_ack_delay.value());
}
if (params.ack_delay_exponent.IsValid()) {
ack_delay_exponent_.SetReceivedValue(params.ack_delay_exponent.value());
diff --git a/quic/core/quic_config.h b/quic/core/quic_config.h
index 57e89be..eca7a80 100644
--- a/quic/core/quic_config.h
+++ b/quic/core/quic_config.h
@@ -156,6 +156,43 @@
bool has_receive_value_;
};
+// Stores 62bit numbers from handshake messages that unilaterally shared by each
+// endpoint. IMPORTANT: these are serialized as 32-bit unsigned integers when
+// using QUIC_CRYPTO versions and CryptoHandshakeMessage.
+class QUIC_EXPORT_PRIVATE QuicFixedUint62 : public QuicConfigValue {
+ public:
+ QuicFixedUint62(QuicTag name, QuicConfigPresence presence);
+ ~QuicFixedUint62() override;
+
+ bool HasSendValue() const;
+
+ uint64_t GetSendValue() const;
+
+ void SetSendValue(uint64_t value);
+
+ bool HasReceivedValue() const;
+
+ uint64_t GetReceivedValue() const;
+
+ void SetReceivedValue(uint64_t value);
+
+ // If has_send_value is true, serialises |tag_| and |send_value_| to |out|.
+ // IMPORTANT: this method serializes |send_value_| as an unsigned 32bit
+ // integer.
+ void ToHandshakeMessage(CryptoHandshakeMessage* out) const override;
+
+ // Sets |value_| to the corresponding value from |peer_hello_| if it exists.
+ QuicErrorCode ProcessPeerHello(const CryptoHandshakeMessage& peer_hello,
+ HelloType hello_type,
+ std::string* error_details) override;
+
+ private:
+ uint64_t send_value_;
+ bool has_send_value_;
+ uint64_t receive_value_;
+ bool has_receive_value_;
+};
+
// Stores uint128 from CHLO or SHLO messages that are not negotiated.
class QUIC_EXPORT_PRIVATE QuicFixedUint128 : public QuicConfigValue {
public:
@@ -373,48 +410,48 @@
uint32_t GetInitialRoundTripTimeUsToSend() const;
// Sets an initial stream flow control window size to transmit to the peer.
- void SetInitialStreamFlowControlWindowToSend(uint32_t window_bytes);
- uint32_t GetInitialStreamFlowControlWindowToSend() const;
+ void SetInitialStreamFlowControlWindowToSend(uint64_t window_bytes);
+ uint64_t GetInitialStreamFlowControlWindowToSend() const;
bool HasReceivedInitialStreamFlowControlWindowBytes() const;
- uint32_t ReceivedInitialStreamFlowControlWindowBytes() const;
+ uint64_t ReceivedInitialStreamFlowControlWindowBytes() const;
// Specifies the initial flow control window (max stream data) for
// incoming bidirectional streams. Incoming means streams initiated by our
// peer. If not set, GetInitialMaxStreamDataBytesIncomingBidirectionalToSend
// returns the value passed to SetInitialStreamFlowControlWindowToSend.
void SetInitialMaxStreamDataBytesIncomingBidirectionalToSend(
- uint32_t window_bytes);
- uint32_t GetInitialMaxStreamDataBytesIncomingBidirectionalToSend() const;
+ uint64_t window_bytes);
+ uint64_t GetInitialMaxStreamDataBytesIncomingBidirectionalToSend() const;
bool HasReceivedInitialMaxStreamDataBytesIncomingBidirectional() const;
- uint32_t ReceivedInitialMaxStreamDataBytesIncomingBidirectional() const;
+ uint64_t ReceivedInitialMaxStreamDataBytesIncomingBidirectional() const;
// Specifies the initial flow control window (max stream data) for
// outgoing bidirectional streams. Outgoing means streams initiated by us.
// If not set, GetInitialMaxStreamDataBytesOutgoingBidirectionalToSend
// returns the value passed to SetInitialStreamFlowControlWindowToSend.
void SetInitialMaxStreamDataBytesOutgoingBidirectionalToSend(
- uint32_t window_bytes);
- uint32_t GetInitialMaxStreamDataBytesOutgoingBidirectionalToSend() const;
+ uint64_t window_bytes);
+ uint64_t GetInitialMaxStreamDataBytesOutgoingBidirectionalToSend() const;
bool HasReceivedInitialMaxStreamDataBytesOutgoingBidirectional() const;
- uint32_t ReceivedInitialMaxStreamDataBytesOutgoingBidirectional() const;
+ uint64_t ReceivedInitialMaxStreamDataBytesOutgoingBidirectional() const;
// Specifies the initial flow control window (max stream data) for
// unidirectional streams. If not set,
// GetInitialMaxStreamDataBytesUnidirectionalToSend returns the value passed
// to SetInitialStreamFlowControlWindowToSend.
- void SetInitialMaxStreamDataBytesUnidirectionalToSend(uint32_t window_bytes);
- uint32_t GetInitialMaxStreamDataBytesUnidirectionalToSend() const;
+ void SetInitialMaxStreamDataBytesUnidirectionalToSend(uint64_t window_bytes);
+ uint64_t GetInitialMaxStreamDataBytesUnidirectionalToSend() const;
bool HasReceivedInitialMaxStreamDataBytesUnidirectional() const;
- uint32_t ReceivedInitialMaxStreamDataBytesUnidirectional() const;
+ uint64_t ReceivedInitialMaxStreamDataBytesUnidirectional() const;
// Sets an initial session flow control window size to transmit to the peer.
- void SetInitialSessionFlowControlWindowToSend(uint32_t window_bytes);
+ void SetInitialSessionFlowControlWindowToSend(uint64_t window_bytes);
- uint32_t GetInitialSessionFlowControlWindowToSend() const;
+ uint64_t GetInitialSessionFlowControlWindowToSend() const;
bool HasReceivedInitialSessionFlowControlWindowBytes() const;
- uint32_t ReceivedInitialSessionFlowControlWindowBytes() const;
+ uint64_t ReceivedInitialSessionFlowControlWindowBytes() const;
void SetDisableConnectionMigration();
@@ -453,16 +490,16 @@
uint32_t ReceivedAckDelayExponent() const;
// IETF QUIC max_packet_size transport parameter.
- void SetMaxPacketSizeToSend(uint32_t max_packet_size);
- uint32_t GetMaxPacketSizeToSend() const;
+ void SetMaxPacketSizeToSend(uint64_t max_packet_size);
+ uint64_t GetMaxPacketSizeToSend() const;
bool HasReceivedMaxPacketSize() const;
- uint32_t ReceivedMaxPacketSize() const;
+ uint64_t ReceivedMaxPacketSize() const;
// IETF QUIC max_datagram_frame_size transport parameter.
- void SetMaxDatagramFrameSizeToSend(uint32_t max_datagram_frame_size);
- uint32_t GetMaxDatagramFrameSizeToSend() const;
+ void SetMaxDatagramFrameSizeToSend(uint64_t max_datagram_frame_size);
+ uint64_t GetMaxDatagramFrameSizeToSend() const;
bool HasReceivedMaxDatagramFrameSize() const;
- uint32_t ReceivedMaxDatagramFrameSize() const;
+ uint64_t ReceivedMaxDatagramFrameSize() const;
bool negotiated() const;
@@ -522,6 +559,7 @@
// Connection options which only affect the client side.
QuicFixedTagVector client_connection_options_;
// Idle network timeout in seconds.
+ // Uses the max_idle_timeout transport parameter in IETF QUIC.
QuicNegotiableUint32 idle_network_timeout_seconds_;
// Whether to use silent close. Defaults to 0 (false) and is otherwise true.
QuicNegotiableUint32 silent_close_;
@@ -532,6 +570,7 @@
// advertising.
// The ReceivedValue is the limit on locally-created streams that
// the peer advertised.
+ // Uses the initial_max_streams_bidi transport parameter in IETF QUIC.
QuicFixedUint32 max_bidirectional_streams_;
// Maximum number of unidirectional streams that the connection can
// support.
@@ -539,27 +578,36 @@
// advertising.
// The ReceivedValue is the limit on locally-created streams that the peer
// advertised.
+ // Uses the initial_max_streams_uni transport parameter in IETF QUIC.
QuicFixedUint32 max_unidirectional_streams_;
- // The number of bytes required for the connection ID.
+ // The number of bytes required for the connection ID. This is only used in
+ // the legacy header format used only by Q043 at this point.
QuicFixedUint32 bytes_for_connection_id_;
// Initial round trip time estimate in microseconds.
QuicFixedUint32 initial_round_trip_time_us_;
// Initial IETF QUIC stream flow control receive windows in bytes.
// Incoming bidirectional streams.
- QuicFixedUint32 initial_max_stream_data_bytes_incoming_bidirectional_;
+ // Uses the initial_max_stream_data_bidi_{local,remote} transport parameter
+ // in IETF QUIC, depending on whether we're sending or receiving.
+ QuicFixedUint62 initial_max_stream_data_bytes_incoming_bidirectional_;
// Outgoing bidirectional streams.
- QuicFixedUint32 initial_max_stream_data_bytes_outgoing_bidirectional_;
+ // Uses the initial_max_stream_data_bidi_{local,remote} transport parameter
+ // in IETF QUIC, depending on whether we're sending or receiving.
+ QuicFixedUint62 initial_max_stream_data_bytes_outgoing_bidirectional_;
// Unidirectional streams.
- QuicFixedUint32 initial_max_stream_data_bytes_unidirectional_;
+ // Uses the initial_max_stream_data_uni transport parameter in IETF QUIC.
+ QuicFixedUint62 initial_max_stream_data_bytes_unidirectional_;
// Initial Google QUIC stream flow control receive window in bytes.
- QuicFixedUint32 initial_stream_flow_control_window_bytes_;
+ QuicFixedUint62 initial_stream_flow_control_window_bytes_;
// Initial session flow control receive window in bytes.
- QuicFixedUint32 initial_session_flow_control_window_bytes_;
+ // Uses the initial_max_data transport parameter in IETF QUIC.
+ QuicFixedUint62 initial_session_flow_control_window_bytes_;
- // Whether tell peer not to attempt connection migration.
+ // Whether active connection migration is allowed.
+ // Uses the disable_active_migration transport parameter in IETF QUIC.
QuicFixedUint32 connection_migration_disabled_;
// An alternate server address the client could connect to.
@@ -569,6 +617,7 @@
QuicFixedUint32 support_max_header_list_size_;
// Stateless reset token used in IETF public reset packet.
+ // Uses the stateless_reset_token transport parameter in IETF QUIC.
QuicFixedUint128 stateless_reset_token_;
// List of QuicTags whose presence immediately causes the session to
@@ -579,20 +628,23 @@
// Maximum ack delay. The sent value is the value used on this node.
// The received value is the value received from the peer and used by
// the peer.
+ // Uses the max_ack_delay transport parameter in IETF QUIC.
QuicFixedUint32 max_ack_delay_ms_;
- // ack_delay_exponent parameter negotiated in IETF QUIC transport
- // parameter negotiation. The sent exponent is the exponent that this
- // node uses when serializing an ACK frame (and the peer should use when
- // deserializing the frame); the received exponent is the value the peer uses
- // to serialize frames and this node uses to deserialize them.
+ // The sent exponent is the exponent that this node uses when serializing an
+ // ACK frame (and the peer should use when deserializing the frame);
+ // the received exponent is the value the peer uses to serialize frames and
+ // this node uses to deserialize them.
+ // Uses the ack_delay_exponent transport parameter in IETF QUIC.
QuicFixedUint32 ack_delay_exponent_;
- // max_packet_size IETF QUIC transport parameter.
- QuicFixedUint32 max_packet_size_;
+ // Maximum packet size in bytes.
+ // Uses the max_packet_size transport parameter in IETF QUIC.
+ QuicFixedUint62 max_packet_size_;
- // max_datagram_frame_size IETF QUIC transport parameter.
- QuicFixedUint32 max_datagram_frame_size_;
+ // Maximum DATAGRAM/MESSAGE frame size in bytes.
+ // Uses the max_datagram_frame_size transport parameter in IETF QUIC.
+ QuicFixedUint62 max_datagram_frame_size_;
// Custom transport parameters that can be sent and received in the TLS
// handshake.
diff --git a/quic/core/quic_constants.h b/quic/core/quic_constants.h
index b6b6c74..587e8e2 100644
--- a/quic/core/quic_constants.h
+++ b/quic/core/quic_constants.h
@@ -72,9 +72,9 @@
// Minimum size of initial flow control window, for both stream and session.
// This is only enforced when version.AllowsLowFlowControlLimits() is false.
-const uint32_t kMinimumFlowControlSendWindow = 16 * 1024; // 16 KB
+const QuicByteCount kMinimumFlowControlSendWindow = 16 * 1024; // 16 KB
// Default size of initial flow control window, for both stream and session.
-const uint32_t kDefaultFlowControlSendWindow = 16 * 1024; // 16 KB
+const QuicByteCount kDefaultFlowControlSendWindow = 16 * 1024; // 16 KB
// Maximum flow control receive window limits for connection and stream.
const QuicByteCount kStreamReceiveWindowLimit = 16 * 1024 * 1024; // 16 MB
diff --git a/quic/core/quic_crypto_stream.cc b/quic/core/quic_crypto_stream.cc
index f0c7e06..20704fb 100644
--- a/quic/core/quic_crypto_stream.cc
+++ b/quic/core/quic_crypto_stream.cc
@@ -224,7 +224,7 @@
}
}
-void QuicCryptoStream::OnStreamDataConsumed(size_t bytes_consumed) {
+void QuicCryptoStream::OnStreamDataConsumed(QuicByteCount bytes_consumed) {
if (QuicVersionUsesCryptoFrames(session()->transport_version())) {
QUIC_BUG << "Stream data consumed when CRYPTO frames should be in use";
}
diff --git a/quic/core/quic_crypto_stream.h b/quic/core/quic_crypto_stream.h
index d3d1082..49d3704 100644
--- a/quic/core/quic_crypto_stream.h
+++ b/quic/core/quic_crypto_stream.h
@@ -111,7 +111,7 @@
void NeuterStreamDataOfEncryptionLevel(EncryptionLevel level);
// Override to record the encryption level of consumed data.
- void OnStreamDataConsumed(size_t bytes_consumed) override;
+ void OnStreamDataConsumed(QuicByteCount bytes_consumed) override;
// Returns whether there are any bytes pending retransmission in CRYPTO
// frames.
diff --git a/quic/core/quic_stream.cc b/quic/core/quic_stream.cc
index c43d914..7355aea 100644
--- a/quic/core/quic_stream.cc
+++ b/quic/core/quic_stream.cc
@@ -29,15 +29,15 @@
namespace {
-size_t DefaultFlowControlWindow(ParsedQuicVersion version) {
+QuicByteCount DefaultFlowControlWindow(ParsedQuicVersion version) {
if (!version.AllowsLowFlowControlLimits()) {
return kDefaultFlowControlSendWindow;
}
return 0;
}
-size_t GetInitialStreamFlowControlWindowToSend(QuicSession* session,
- QuicStreamId stream_id) {
+QuicByteCount GetInitialStreamFlowControlWindowToSend(QuicSession* session,
+ QuicStreamId stream_id) {
ParsedQuicVersion version = session->connection()->version();
if (version.handshake_protocol != PROTOCOL_TLS1_3) {
return session->config()->GetInitialStreamFlowControlWindowToSend();
@@ -60,8 +60,8 @@
->GetInitialMaxStreamDataBytesIncomingBidirectionalToSend();
}
-size_t GetReceivedFlowControlWindow(QuicSession* session,
- QuicStreamId stream_id) {
+QuicByteCount GetReceivedFlowControlWindow(QuicSession* session,
+ QuicStreamId stream_id) {
ParsedQuicVersion version = session->connection()->version();
if (version.handshake_protocol != PROTOCOL_TLS1_3) {
if (session->config()->HasReceivedInitialStreamFlowControlWindowBytes()) {
@@ -189,7 +189,7 @@
}
// This count includes duplicate data received.
- size_t frame_payload_size = frame.data_length;
+ QuicByteCount frame_payload_size = frame.data_length;
stream_bytes_read_ += frame_payload_size;
// Flow control is interested in tracking highest received offset.
@@ -257,7 +257,7 @@
return true;
}
-void PendingStream::MarkConsumed(size_t num_bytes) {
+void PendingStream::MarkConsumed(QuicByteCount num_bytes) {
sequencer_.MarkConsumed(num_bytes);
}
@@ -452,7 +452,7 @@
}
// This count includes duplicate data received.
- size_t frame_payload_size = frame.data_length;
+ QuicByteCount frame_payload_size = frame.data_length;
stream_bytes_read_ += frame_payload_size;
// Flow control is interested in tracking highest received offset.
@@ -1042,7 +1042,7 @@
(send_buffer_.stream_bytes_outstanding() || fin_outstanding_);
}
-size_t QuicStream::ReadableBytes() const {
+QuicByteCount QuicStream::ReadableBytes() const {
return sequencer_.ReadableBytes();
}
@@ -1064,7 +1064,7 @@
}
// Size of buffered data.
- size_t write_length = BufferedDataBytes();
+ QuicByteCount write_length = BufferedDataBytes();
// A FIN with zero data payload should not be flow control blocked.
bool fin_with_zero_data = (fin_buffered_ && write_length == 0);
@@ -1089,7 +1089,7 @@
fin = false;
// Writing more data would be a violation of flow control.
- write_length = static_cast<size_t>(send_window);
+ write_length = send_window;
QUIC_DVLOG(1) << "stream " << id() << " shortens write length to "
<< write_length << " due to flow control";
}
@@ -1168,7 +1168,7 @@
return send_buffer_.bytes_acked();
}
-void QuicStream::OnStreamDataConsumed(size_t bytes_consumed) {
+void QuicStream::OnStreamDataConsumed(QuicByteCount bytes_consumed) {
send_buffer_.OnStreamDataConsumed(bytes_consumed);
}
diff --git a/quic/core/quic_stream.h b/quic/core/quic_stream.h
index cc7ce4d..fe9d04c 100644
--- a/quic/core/quic_stream.h
+++ b/quic/core/quic_stream.h
@@ -76,7 +76,7 @@
const QuicStreamSequencer* sequencer() const { return &sequencer_; }
- void MarkConsumed(size_t num_bytes);
+ void MarkConsumed(QuicByteCount num_bytes);
// Tells the sequencer to ignore all incoming data itself and not call
// OnDataAvailable().
@@ -201,7 +201,7 @@
bool IsWaitingForAcks() const;
// Number of bytes available to read.
- size_t ReadableBytes() const;
+ QuicByteCount ReadableBytes() const;
QuicRstStreamErrorCode stream_error() const { return stream_error_; }
QuicErrorCode connection_error() const { return connection_error_; }
@@ -392,7 +392,7 @@
virtual void OnCanWriteNewData() {}
// Called when |bytes_consumed| bytes has been consumed.
- virtual void OnStreamDataConsumed(size_t bytes_consumed);
+ virtual void OnStreamDataConsumed(QuicByteCount bytes_consumed);
// Called by the stream sequencer as bytes are consumed from the buffer.
// If the receive window has dropped below the threshold, then send a
diff --git a/quic/core/quic_stream_test.cc b/quic/core/quic_stream_test.cc
index f2269bb..3e47835 100644
--- a/quic/core/quic_stream_test.cc
+++ b/quic/core/quic_stream_test.cc
@@ -49,7 +49,7 @@
const char kData1[] = "FooAndBar";
const char kData2[] = "EepAndBaz";
-const size_t kDataLen = 9;
+const QuicByteCount kDataLen = 9;
class TestStream : public QuicStream {
public:
@@ -125,7 +125,7 @@
QuicConsumedData CloseStreamOnWriteError(
QuicStreamId id,
- size_t /*write_length*/,
+ QuicByteCount /*write_length*/,
QuicStreamOffset /*offset*/,
StreamSendingState /*state*/,
TransmissionType /*type*/,
@@ -271,7 +271,7 @@
TEST_P(QuicStreamTest, WriteAllData) {
Initialize();
- size_t length =
+ QuicByteCount length =
1 + QuicPacketCreator::StreamFramePacketOverhead(
connection_->transport_version(), PACKET_8BYTE_CONNECTION_ID,
PACKET_0BYTE_CONNECTION_ID, !kIncludeVersion,
@@ -360,7 +360,7 @@
Initialize();
EXPECT_FALSE(HasWriteBlockedStreams());
- size_t length =
+ QuicByteCount length =
1 + QuicPacketCreator::StreamFramePacketOverhead(
connection_->transport_version(), PACKET_8BYTE_CONNECTION_ID,
PACKET_0BYTE_CONNECTION_ID, !kIncludeVersion,
@@ -1076,8 +1076,9 @@
EXPECT_FALSE(stream_->CanWriteNewData());
// Send buffered data to make buffered data size < threshold.
- size_t data_to_write = 3 * data.length() - 200 -
- GetQuicFlag(FLAGS_quic_buffered_data_threshold) + 1;
+ QuicByteCount data_to_write =
+ 3 * data.length() - 200 -
+ GetQuicFlag(FLAGS_quic_buffered_data_threshold) + 1;
EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _))
.WillOnce(InvokeWithoutArgs([this, data_to_write]() {
return session_->ConsumeData(stream_->id(), data_to_write, 200u, NO_FIN,
@@ -1182,7 +1183,7 @@
Initialize();
char data[1024];
- std::vector<std::pair<char*, size_t>> buffers;
+ std::vector<std::pair<char*, QuicByteCount>> buffers;
buffers.push_back(std::make_pair(data, QUICHE_ARRAYSIZE(data)));
buffers.push_back(std::make_pair(data, QUICHE_ARRAYSIZE(data)));
QuicTestMemSliceVector vector1(buffers);
@@ -1210,8 +1211,9 @@
EXPECT_EQ(2 * QUICHE_ARRAYSIZE(data) - 100, stream_->BufferedDataBytes());
EXPECT_FALSE(stream_->fin_buffered());
- size_t data_to_write = 2 * QUICHE_ARRAYSIZE(data) - 100 -
- GetQuicFlag(FLAGS_quic_buffered_data_threshold) + 1;
+ QuicByteCount data_to_write =
+ 2 * QUICHE_ARRAYSIZE(data) - 100 -
+ GetQuicFlag(FLAGS_quic_buffered_data_threshold) + 1;
EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _))
.WillOnce(InvokeWithoutArgs([this, data_to_write]() {
return session_->ConsumeData(stream_->id(), data_to_write, 100u, NO_FIN,
@@ -1245,7 +1247,7 @@
Initialize();
QuicStreamPeer::SetStreamBytesWritten(kMaxStreamLength - 5u, stream_);
char data[5];
- std::vector<std::pair<char*, size_t>> buffers;
+ std::vector<std::pair<char*, QuicByteCount>> buffers;
buffers.push_back(std::make_pair(data, QUICHE_ARRAYSIZE(data)));
QuicTestMemSliceVector vector1(buffers);
QuicMemSliceSpan span1 = vector1.span();
@@ -1258,7 +1260,7 @@
QuicConsumedData consumed = stream_->WriteMemSlices(span1, false);
EXPECT_EQ(5u, consumed.bytes_consumed);
- std::vector<std::pair<char*, size_t>> buffers2;
+ std::vector<std::pair<char*, QuicByteCount>> buffers2;
buffers2.push_back(std::make_pair(data, 1u));
QuicTestMemSliceVector vector2(buffers);
QuicMemSliceSpan span2 = vector2.span();
diff --git a/quic/core/quic_types.h b/quic/core/quic_types.h
index 0d84b07..a3d43b8 100644
--- a/quic/core/quic_types.h
+++ b/quic/core/quic_types.h
@@ -23,7 +23,6 @@
using QuicPacketLength = uint16_t;
using QuicControlFrameId = uint32_t;
-using QuicHeaderId = uint32_t;
using QuicMessageId = uint32_t;
using QuicDatagramFlowId = uint64_t;
diff --git a/quic/quartc/quartc_stream.cc b/quic/quartc/quartc_stream.cc
index 9edf370..01494c5 100644
--- a/quic/quartc/quartc_stream.cc
+++ b/quic/quartc/quartc_stream.cc
@@ -56,7 +56,7 @@
delegate_->OnClose(this);
}
-void QuartcStream::OnStreamDataConsumed(size_t bytes_consumed) {
+void QuartcStream::OnStreamDataConsumed(QuicByteCount bytes_consumed) {
QuicStream::OnStreamDataConsumed(bytes_consumed);
if (delegate_) {
diff --git a/quic/quartc/quartc_stream.h b/quic/quartc/quartc_stream.h
index 40e8328..7f3c28d 100644
--- a/quic/quartc/quartc_stream.h
+++ b/quic/quartc/quartc_stream.h
@@ -34,7 +34,7 @@
void OnClose() override;
- void OnStreamDataConsumed(size_t bytes_consumed) override;
+ void OnStreamDataConsumed(QuicByteCount bytes_consumed) override;
void OnDataBuffered(
QuicStreamOffset offset,