Add helper functions for PROTOCOL_QUIC_CRYPTO versions.
gfe-relnote: n/a (add functions that are currently only used in tests)
PiperOrigin-RevId: 298882420
Change-Id: If759ab3850d8054a257d3129cfb2c2bccf155a1f
diff --git a/quic/core/quic_versions.cc b/quic/core/quic_versions.cc
index 3458c99..9cccff9 100644
--- a/quic/core/quic_versions.cc
+++ b/quic/core/quic_versions.cc
@@ -229,6 +229,28 @@
return out;
}
+ParsedQuicVersionVector AllSupportedVersionsWithQuicCrypto() {
+ ParsedQuicVersionVector versions;
+ for (const ParsedQuicVersion& version : AllSupportedVersions()) {
+ if (version.handshake_protocol == PROTOCOL_QUIC_CRYPTO) {
+ versions.push_back(version);
+ }
+ }
+ QUIC_BUG_IF(versions.empty()) << "No version with QUIC crypto found.";
+ return versions;
+}
+
+ParsedQuicVersionVector CurrentSupportedVersionsWithQuicCrypto() {
+ ParsedQuicVersionVector versions;
+ for (const ParsedQuicVersion& version : CurrentSupportedVersions()) {
+ if (version.handshake_protocol == PROTOCOL_QUIC_CRYPTO) {
+ versions.push_back(version);
+ }
+ }
+ QUIC_BUG_IF(versions.empty()) << "No version with QUIC crypto found.";
+ return versions;
+}
+
ParsedQuicVersion ParseQuicVersionLabel(QuicVersionLabel version_label) {
for (const ParsedQuicVersion& version : AllSupportedVersions()) {
if (version_label == CreateQuicVersionLabel(version)) {
diff --git a/quic/core/quic_versions.h b/quic/core/quic_versions.h
index bc15354..3151fa2 100644
--- a/quic/core/quic_versions.h
+++ b/quic/core/quic_versions.h
@@ -363,6 +363,18 @@
QUIC_EXPORT_PRIVATE ParsedQuicVersionVector
FilterSupportedVersions(ParsedQuicVersionVector versions);
+// Returns a subset of AllSupportedVersions() with
+// handshake_protocol == PROTOCOL_QUIC_CRYPTO, in the same order.
+// Deprecated; only to be used in components that do not yet support
+// PROTOCOL_TLS1_3.
+ParsedQuicVersionVector AllSupportedVersionsWithQuicCrypto();
+
+// Returns a subset of CurrentSupportedVersions() with
+// handshake_protocol == PROTOCOL_QUIC_CRYPTO, in the same order.
+// Deprecated; only to be used in components that do not yet support
+// PROTOCOL_TLS1_3.
+ParsedQuicVersionVector CurrentSupportedVersionsWithQuicCrypto();
+
// Returns QUIC version of |index| in result of |versions|. Returns
// QUIC_VERSION_UNSUPPORTED if |index| is out of bounds.
QUIC_EXPORT_PRIVATE QuicTransportVersionVector