Add datatypes needed for IETF CONNECTION_CLOSE support.
This CL adds datatypes that are needed to support IETF QUIC's CONNECTION_CLOSE.
The types are
- union QuicConnectionCloseErrorCode: a union that allows the frame's error
code field to be accessed using the correct type (QuicErrorCode,
QuicIetfTransportErrorCode, or uint16_t), and
- enum QuicConnectionCloseType: indicates the type of connection close
(Google-QUIC, IETF QUIC Connection Close/Application, or IETF QUIC
Connection Close/Transport).
QuicConnectionCloseFrame is updated to include these fields.
QuicFramer is updated to set them to reasonable defaults/etc.
Code that refers to QuicConnectionCloseFrame::error_code has been
modified to get the error code value from the QuicErrorCode member
of the QuicConnectionCloseErrorCode union.
There are no logic or functional changes. Additional CLs will add the necessary functionality.
gfe-relnote: Not flag protected, all code changes due to field name/etc changes.
ENUM_VALUE_OK=This value change is OK, it is the maximum value/limit of the enum
The design, including rationale and approximate plan for Cls is in
https://docs.google.com/document/d/1LB1Dhyw7tVLmFFEqmW6_xxnNiExNtlShJXrNU3CDM0M/edit?usp=sharing
PiperOrigin-RevId: 242647040
Change-Id: I3e45879777d83e7a8aeb2e19257b8bafcd0101bd
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index f170cbc..4fd6936 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -590,7 +590,7 @@
if (version == QUIC_VERSION_99) {
return QuicDataWriter::GetVarInt62Len(
TruncatedErrorStringSize(frame.error_details)) +
- QuicDataWriter::GetVarInt62Len(frame.frame_type) +
+ QuicDataWriter::GetVarInt62Len(frame.transport_close_frame_type) +
kQuicFrameTypeSize + kQuicIetfQuicErrorCodeSize;
}
return kQuicFrameTypeSize + kQuicErrorCodeSize + kQuicErrorDetailsLengthSize;
@@ -2905,7 +2905,12 @@
}
case IETF_CONNECTION_CLOSE: {
QuicConnectionCloseFrame frame;
- if (!ProcessIetfConnectionCloseFrame(reader, &frame)) {
+ if (!ProcessIetfConnectionCloseFrame(
+ reader,
+ ((frame_type == IETF_CONNECTION_CLOSE)
+ ? IETF_QUIC_TRANSPORT_CONNECTION_CLOSE
+ : IETF_QUIC_APPLICATION_CONNECTION_CLOSE),
+ &frame)) {
return RaiseError(QUIC_INVALID_CONNECTION_CLOSE_DATA);
}
if (!visitor_->OnConnectionCloseFrame(frame)) {
@@ -3724,6 +3729,8 @@
bool QuicFramer::ProcessConnectionCloseFrame(QuicDataReader* reader,
QuicConnectionCloseFrame* frame) {
uint32_t error_code;
+ frame->close_type = GOOGLE_QUIC_CONNECTION_CLOSE;
+
if (!reader->ReadUInt32(&error_code)) {
set_detailed_error("Unable to read connection close error code.");
return false;
@@ -3734,7 +3741,7 @@
error_code = QUIC_LAST_ERROR;
}
- frame->error_code = static_cast<QuicErrorCode>(error_code);
+ frame->quic_error_code = static_cast<QuicErrorCode>(error_code);
QuicStringPiece error_details;
if (!reader->ReadStringPiece16(&error_details)) {
@@ -5068,7 +5075,7 @@
if (version_.transport_version == QUIC_VERSION_99) {
return AppendIetfConnectionCloseFrame(frame, writer);
}
- uint32_t error_code = static_cast<uint32_t>(frame.error_code);
+ uint32_t error_code = static_cast<uint32_t>(frame.quic_error_code);
if (!writer->WriteUInt32(error_code)) {
return false;
}
@@ -5180,11 +5187,12 @@
bool QuicFramer::AppendIetfConnectionCloseFrame(
const QuicConnectionCloseFrame& frame,
QuicDataWriter* writer) {
- if (!writer->WriteUInt16(static_cast<const uint16_t>(frame.error_code))) {
+ if (!writer->WriteUInt16(frame.application_error_code)) {
set_detailed_error("Can not write connection close frame error code");
return false;
}
- if (!writer->WriteVarInt62(frame.frame_type)) {
+
+ if (!writer->WriteVarInt62(frame.transport_close_frame_type)) {
set_detailed_error("Writing frame type failed.");
return false;
}
@@ -5215,15 +5223,17 @@
bool QuicFramer::ProcessIetfConnectionCloseFrame(
QuicDataReader* reader,
+ QuicConnectionCloseType type,
QuicConnectionCloseFrame* frame) {
+ frame->close_type = type;
uint16_t code;
if (!reader->ReadUInt16(&code)) {
set_detailed_error("Unable to read connection close error code.");
return false;
}
- frame->ietf_error_code = static_cast<QuicIetfTransportErrorCodes>(code);
+ frame->transport_error_code = static_cast<QuicIetfTransportErrorCodes>(code);
- if (!reader->ReadVarInt62(&frame->frame_type)) {
+ if (!reader->ReadVarInt62(&frame->transport_close_frame_type)) {
set_detailed_error("Unable to read connection close frame type.");
return false;
}