Refactor some QUIC version code
Our VersionSupportsFeatureFoo functions currently take multiple forms (QuicUtils::VersionSupportsFeatureFoo(), VersionHasFeatureFoo(QuicTransportVersion) and ParsedQuicVersion::HasFeatureFoo()). This CL starts consolidating these on ParsedQuicVersion in an effort to clean this up.
This CL also adds a few DCHECKs to validate the assumption that we only use valid versions outside of the early parsing code in the dispatcher.
Note that VersionAllowsVariableLengthConnectionIds now only allows known versions so callers that deal with unknown versions need to check ParsedQuicVersion::IsKnown before calling VersionAllowsVariableLengthConnectionIds.
gfe-relnote: refactor, no behavior change, not flag-protected
PiperOrigin-RevId: 289536281
Change-Id: Iafa1ab9c228d9a8fe0ab4c998437526a1b7191dd
diff --git a/quic/core/quic_utils.cc b/quic/core/quic_utils.cc
index e37d019..733ee39 100644
--- a/quic/core/quic_utils.cc
+++ b/quic/core/quic_utils.cc
@@ -517,18 +517,9 @@
}
// static
-bool QuicUtils::VariableLengthConnectionIdAllowedForVersion(
- QuicTransportVersion version) {
- // We allow variable length connection IDs for unsupported versions to
- // ensure that IETF version negotiation works when other implementations
- // trigger version negotiation with custom connection ID lengths.
- return version > QUIC_VERSION_46 || version == QUIC_VERSION_UNSUPPORTED;
-}
-
-// static
QuicConnectionId QuicUtils::CreateZeroConnectionId(
QuicTransportVersion version) {
- if (!VariableLengthConnectionIdAllowedForVersion(version)) {
+ if (!VersionAllowsVariableLengthConnectionIds(version)) {
char connection_id_bytes[8] = {0, 0, 0, 0, 0, 0, 0, 0};
return QuicConnectionId(static_cast<char*>(connection_id_bytes),
QUICHE_ARRAYSIZE(connection_id_bytes));
@@ -558,7 +549,7 @@
const uint8_t connection_id_length8 =
static_cast<uint8_t>(connection_id_length);
// Versions that do not support variable lengths only support length 8.
- if (!VariableLengthConnectionIdAllowedForVersion(transport_version)) {
+ if (!VersionAllowsVariableLengthConnectionIds(transport_version)) {
return connection_id_length8 == kQuicDefaultConnectionIdLength;
}
// Versions that do support variable length but do not have length-prefixed