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_dispatcher.cc b/quic/core/quic_dispatcher.cc
index c628993..f1fbb32 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -286,8 +286,8 @@
if (packet_info.destination_connection_id.length() !=
expected_server_connection_id_length_ &&
!should_update_expected_server_connection_id_length_ &&
- !QuicUtils::VariableLengthConnectionIdAllowedForVersion(
- packet_info.version.transport_version)) {
+ packet_info.version.IsKnown() &&
+ !packet_info.version.AllowsVariableLengthConnectionIds()) {
SetLastError(QUIC_INVALID_PACKET_HEADER);
QUIC_DLOG(ERROR) << "Invalid Connection Id Length";
return;
@@ -330,8 +330,7 @@
if (server_connection_id.length() == expected_server_connection_id_length_) {
return server_connection_id;
}
- DCHECK(QuicUtils::VariableLengthConnectionIdAllowedForVersion(
- version.transport_version));
+ DCHECK(version.AllowsVariableLengthConnectionIds());
QuicConnectionId new_connection_id =
GenerateNewServerConnectionId(version, server_connection_id);
@@ -372,8 +371,7 @@
server_connection_id.length() < expected_server_connection_id_length_ &&
!allow_short_initial_server_connection_ids_) {
DCHECK(packet_info.version_flag);
- DCHECK(QuicUtils::VariableLengthConnectionIdAllowedForVersion(
- packet_info.version.transport_version));
+ DCHECK(packet_info.version.AllowsVariableLengthConnectionIds());
QUIC_DLOG(INFO) << "Packet with short destination connection ID "
<< server_connection_id << " expected "
<< static_cast<int>(expected_server_connection_id_length_);