Support LengthPrefixedConnectionIds in v99
This CL adds support for the invariants change from draft-22. It introduces a new parsing method QuicFramer::ParsePublicHeader which can parse both old and new formats, and uses it for v99 and also for all versions when gfe2_reloadable_flag_quic_use_parse_public_header is true.
gfe-relnote: change v99 encoding, protected by disabled v99 flag and by gfe2_reloadable_flag_quic_use_parse_public_header.
PiperOrigin-RevId: 260871822
Change-Id: I680d12141b2731401a818ed335af03e7c5365219
diff --git a/quic/core/quic_versions.cc b/quic/core/quic_versions.cc
index adfec06..d08ab4d 100644
--- a/quic/core/quic_versions.cc
+++ b/quic/core/quic_versions.cc
@@ -80,6 +80,15 @@
return transport_version >= QUIC_VERSION_99;
}
+bool ParsedQuicVersion::HasLengthPrefixedConnectionIds() const {
+ return VersionHasLengthPrefixedConnectionIds(transport_version);
+}
+
+bool VersionHasLengthPrefixedConnectionIds(
+ QuicTransportVersion transport_version) {
+ return transport_version >= QUIC_VERSION_99;
+}
+
std::ostream& operator<<(std::ostream& os, const ParsedQuicVersion& version) {
os << ParsedQuicVersionToString(version);
return os;
@@ -407,6 +416,34 @@
return result;
}
+bool QuicVersionLabelUses4BitConnectionIdLength(
+ QuicVersionLabel version_label) {
+ // As we deprecate old versions, we still need the ability to send valid
+ // version negotiation packets for those versions. This function keeps track
+ // of the versions that ever supported the 4bit connection ID length encoding
+ // that we know about. Google QUIC 43 and earlier used a different encoding,
+ // and Google QUIC 49 will start using the new length prefixed encoding.
+ // Similarly, only IETF drafts 11 to 21 used this encoding.
+
+ // Check Q044, Q045, Q046, Q047 and Q048.
+ for (uint8_t c = '4'; c <= '8'; ++c) {
+ if (version_label == MakeVersionLabel('Q', '0', '4', c)) {
+ return true;
+ }
+ }
+ // Check T048.
+ if (version_label == MakeVersionLabel('T', '0', '4', '8')) {
+ return true;
+ }
+ // Check IETF draft versions in [11,21].
+ for (uint8_t draft_number = 11; draft_number <= 21; ++draft_number) {
+ if (version_label == MakeVersionLabel(0xff, 0x00, 0x00, draft_number)) {
+ return true;
+ }
+ }
+ return false;
+}
+
ParsedQuicVersion UnsupportedQuicVersion() {
return ParsedQuicVersion(PROTOCOL_UNSUPPORTED, QUIC_VERSION_UNSUPPORTED);
}
@@ -441,6 +478,7 @@
// Enable necessary flags.
SetQuicFlag(FLAGS_quic_supports_tls_handshake, true);
SetQuicReloadableFlag(quic_simplify_stop_waiting, true);
+ SetQuicReloadableFlag(quic_use_parse_public_header, true);
SetQuicRestartFlag(quic_do_not_override_connection_id, true);
SetQuicRestartFlag(quic_use_allocated_connection_ids, true);
SetQuicRestartFlag(quic_dispatcher_hands_chlo_extractor_one_version, true);