Have framer store frame type currently being processed
This CL has QuicFramer save the frame type for the frame that it currently
is extracting from the packet and processing. This is done so that the
IETF QUIC Transport Connection Close can get the type of frame that
precipitated the close. If the frame-type was not saved like this then
it would need to be passed around in the call stack -- one more parameter
threaded throughout many calls in QUIC.
This done only when IETF Framing (version 99) is enabled.
Tests in quic_framer_test.cc have been modified to check that the right
frame type has been saved (done in all of the On...Frame upcalls, so that
the testing is fairly complete). Also checks that the saved type is 0
when not processing a frame (eg, when doing header processing) OR when not
doing IETF QUIC Framing.
gfe-relnote: N/A is only for Version 99/IETF QUIC Framing.
PiperOrigin-RevId: 265888094
Change-Id: If068d49c9f72b4e3c0e8eb3e7ab7460abde85f8a
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index c667e9b..9890f36 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -426,7 +426,8 @@
supports_multiple_packet_number_spaces_(false),
last_written_packet_number_length_(0),
peer_ack_delay_exponent_(kDefaultAckDelayExponent),
- local_ack_delay_exponent_(kDefaultAckDelayExponent) {
+ local_ack_delay_exponent_(kDefaultAckDelayExponent),
+ current_received_frame_type_(0) {
DCHECK(!supported_versions.empty());
version_ = supported_versions_[0];
decrypter_[ENCRYPTION_INITIAL] = QuicMakeUnique<NullDecrypter>(perspective);
@@ -1877,13 +1878,16 @@
// Handle the payload.
if (VersionHasIetfQuicFrames(version_.transport_version)) {
+ current_received_frame_type_ = 0;
if (!ProcessIetfFrameData(&reader, *header)) {
+ current_received_frame_type_ = 0;
DCHECK_NE(QUIC_NO_ERROR, error_); // ProcessIetfFrameData sets the error.
DCHECK_NE("", detailed_error_);
QUIC_DLOG(WARNING) << ENDPOINT << "Unable to process frame data. Error: "
<< detailed_error_;
return false;
}
+ current_received_frame_type_ = 0;
} else {
if (!ProcessFrameData(&reader, *header)) {
DCHECK_NE(QUIC_NO_ERROR, error_); // ProcessFrameData sets the error.
@@ -3045,6 +3049,7 @@
set_detailed_error("Unable to read frame type.");
return RaiseError(QUIC_INVALID_FRAME_DATA);
}
+ current_received_frame_type_ = frame_type;
// Is now the number of bytes into which the frame type was encoded.
encoded_bytes -= reader->BytesRemaining();