Set received crypto frame's encryption level.
gfe-relnote: not protected. only used in debug and tests.
PiperOrigin-RevId: 288066037
Change-Id: I10eeac5332329fa48dbd36a980f6757716f13179
diff --git a/quic/core/frames/quic_crypto_frame.cc b/quic/core/frames/quic_crypto_frame.cc
index 20254b8..d750da7 100644
--- a/quic/core/frames/quic_crypto_frame.cc
+++ b/quic/core/frames/quic_crypto_frame.cc
@@ -35,7 +35,8 @@
std::ostream& operator<<(std::ostream& os,
const QuicCryptoFrame& stream_frame) {
- os << "{ offset: " << stream_frame.offset
+ os << "{ level: " << static_cast<int>(stream_frame.level)
+ << ", offset: " << stream_frame.offset
<< ", length: " << stream_frame.data_length << " }\n";
return os;
}
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index acc0a89..31af81a 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -2907,7 +2907,7 @@
return RaiseError(QUIC_INVALID_FRAME_DATA);
}
QuicCryptoFrame frame;
- if (!ProcessCryptoFrame(reader, &frame)) {
+ if (!ProcessCryptoFrame(reader, GetEncryptionLevel(header), &frame)) {
return RaiseError(QUIC_INVALID_FRAME_DATA);
}
QUIC_DVLOG(2) << ENDPOINT << "Processing crypto frame " << frame;
@@ -3237,7 +3237,7 @@
}
case IETF_CRYPTO: {
QuicCryptoFrame frame;
- if (!ProcessCryptoFrame(reader, &frame)) {
+ if (!ProcessCryptoFrame(reader, GetEncryptionLevel(header), &frame)) {
return RaiseError(QUIC_INVALID_FRAME_DATA);
}
QUIC_DVLOG(2) << ENDPOINT << "Processing IETF crypto frame " << frame;
@@ -3404,7 +3404,9 @@
}
bool QuicFramer::ProcessCryptoFrame(QuicDataReader* reader,
+ EncryptionLevel encryption_level,
QuicCryptoFrame* frame) {
+ frame->level = encryption_level;
if (!reader->ReadVarInt62(&frame->offset)) {
set_detailed_error("Unable to read crypto data offset.");
return false;
diff --git a/quic/core/quic_framer.h b/quic/core/quic_framer.h
index 1583970..768aa33 100644
--- a/quic/core/quic_framer.h
+++ b/quic/core/quic_framer.h
@@ -900,7 +900,9 @@
QuicRstStreamFrame* frame);
bool ProcessStopSendingFrame(QuicDataReader* reader,
QuicStopSendingFrame* stop_sending_frame);
- bool ProcessCryptoFrame(QuicDataReader* reader, QuicCryptoFrame* frame);
+ bool ProcessCryptoFrame(QuicDataReader* reader,
+ EncryptionLevel encryption_level,
+ QuicCryptoFrame* frame);
// IETF frame appending methods. All methods append the type byte as well.
bool AppendIetfStreamFrame(const QuicStreamFrame& frame,
diff --git a/quic/core/quic_framer_test.cc b/quic/core/quic_framer_test.cc
index c3f5463..2daac1e 100644
--- a/quic/core/quic_framer_test.cc
+++ b/quic/core/quic_framer_test.cc
@@ -299,7 +299,7 @@
new std::string(frame.data_buffer, frame.data_length);
crypto_data_.push_back(QuicWrapUnique(string_data));
crypto_frames_.push_back(std::make_unique<QuicCryptoFrame>(
- ENCRYPTION_INITIAL, frame.offset, *string_data));
+ frame.level, frame.offset, *string_data));
if (VersionHasIetfQuicFrames(transport_version_)) {
EXPECT_EQ(IETF_CRYPTO, framer_->current_received_frame_type());
} else {
@@ -6471,7 +6471,7 @@
}
TEST_P(QuicFramerTest, CryptoFrame) {
- if (framer_.transport_version() < QUIC_VERSION_48) {
+ if (!QuicVersionUsesCryptoFrames(framer_.transport_version())) {
// CRYPTO frames aren't supported prior to v48.
return;
}
@@ -6546,6 +6546,7 @@
PACKET_8BYTE_CONNECTION_ID, PACKET_0BYTE_CONNECTION_ID));
ASSERT_EQ(1u, visitor_.crypto_frames_.size());
QuicCryptoFrame* frame = visitor_.crypto_frames_[0].get();
+ EXPECT_EQ(ENCRYPTION_FORWARD_SECURE, frame->level);
EXPECT_EQ(kStreamOffset, frame->offset);
EXPECT_EQ("hello world!",
std::string(frame->data_buffer, frame->data_length));