Rename QUIC MESSAGE_FRAME to DATAGRAM_FRAME. Message frame is an archaic name. PiperOrigin-RevId: 800631107
diff --git a/build/source_list.bzl b/build/source_list.bzl index d019d69..0d3e7ad 100644 --- a/build/source_list.bzl +++ b/build/source_list.bzl
@@ -227,13 +227,13 @@ "quic/core/frames/quic_blocked_frame.h", "quic/core/frames/quic_connection_close_frame.h", "quic/core/frames/quic_crypto_frame.h", + "quic/core/frames/quic_datagram_frame.h", "quic/core/frames/quic_frame.h", "quic/core/frames/quic_goaway_frame.h", "quic/core/frames/quic_handshake_done_frame.h", "quic/core/frames/quic_immediate_ack_frame.h", "quic/core/frames/quic_inlined_frame.h", "quic/core/frames/quic_max_streams_frame.h", - "quic/core/frames/quic_message_frame.h", "quic/core/frames/quic_mtu_discovery_frame.h", "quic/core/frames/quic_new_connection_id_frame.h", "quic/core/frames/quic_new_token_frame.h", @@ -580,12 +580,12 @@ "quic/core/frames/quic_blocked_frame.cc", "quic/core/frames/quic_connection_close_frame.cc", "quic/core/frames/quic_crypto_frame.cc", + "quic/core/frames/quic_datagram_frame.cc", "quic/core/frames/quic_frame.cc", "quic/core/frames/quic_goaway_frame.cc", "quic/core/frames/quic_handshake_done_frame.cc", "quic/core/frames/quic_immediate_ack_frame.cc", "quic/core/frames/quic_max_streams_frame.cc", - "quic/core/frames/quic_message_frame.cc", "quic/core/frames/quic_new_connection_id_frame.cc", "quic/core/frames/quic_new_token_frame.cc", "quic/core/frames/quic_padding_frame.cc",
diff --git a/build/source_list.gni b/build/source_list.gni index 8563629..0b489e9 100644 --- a/build/source_list.gni +++ b/build/source_list.gni
@@ -227,13 +227,13 @@ "src/quiche/quic/core/frames/quic_blocked_frame.h", "src/quiche/quic/core/frames/quic_connection_close_frame.h", "src/quiche/quic/core/frames/quic_crypto_frame.h", + "src/quiche/quic/core/frames/quic_datagram_frame.h", "src/quiche/quic/core/frames/quic_frame.h", "src/quiche/quic/core/frames/quic_goaway_frame.h", "src/quiche/quic/core/frames/quic_handshake_done_frame.h", "src/quiche/quic/core/frames/quic_immediate_ack_frame.h", "src/quiche/quic/core/frames/quic_inlined_frame.h", "src/quiche/quic/core/frames/quic_max_streams_frame.h", - "src/quiche/quic/core/frames/quic_message_frame.h", "src/quiche/quic/core/frames/quic_mtu_discovery_frame.h", "src/quiche/quic/core/frames/quic_new_connection_id_frame.h", "src/quiche/quic/core/frames/quic_new_token_frame.h", @@ -580,12 +580,12 @@ "src/quiche/quic/core/frames/quic_blocked_frame.cc", "src/quiche/quic/core/frames/quic_connection_close_frame.cc", "src/quiche/quic/core/frames/quic_crypto_frame.cc", + "src/quiche/quic/core/frames/quic_datagram_frame.cc", "src/quiche/quic/core/frames/quic_frame.cc", "src/quiche/quic/core/frames/quic_goaway_frame.cc", "src/quiche/quic/core/frames/quic_handshake_done_frame.cc", "src/quiche/quic/core/frames/quic_immediate_ack_frame.cc", "src/quiche/quic/core/frames/quic_max_streams_frame.cc", - "src/quiche/quic/core/frames/quic_message_frame.cc", "src/quiche/quic/core/frames/quic_new_connection_id_frame.cc", "src/quiche/quic/core/frames/quic_new_token_frame.cc", "src/quiche/quic/core/frames/quic_padding_frame.cc",
diff --git a/build/source_list.json b/build/source_list.json index 3819711..2bfce87 100644 --- a/build/source_list.json +++ b/build/source_list.json
@@ -226,13 +226,13 @@ "quiche/quic/core/frames/quic_blocked_frame.h", "quiche/quic/core/frames/quic_connection_close_frame.h", "quiche/quic/core/frames/quic_crypto_frame.h", + "quiche/quic/core/frames/quic_datagram_frame.h", "quiche/quic/core/frames/quic_frame.h", "quiche/quic/core/frames/quic_goaway_frame.h", "quiche/quic/core/frames/quic_handshake_done_frame.h", "quiche/quic/core/frames/quic_immediate_ack_frame.h", "quiche/quic/core/frames/quic_inlined_frame.h", "quiche/quic/core/frames/quic_max_streams_frame.h", - "quiche/quic/core/frames/quic_message_frame.h", "quiche/quic/core/frames/quic_mtu_discovery_frame.h", "quiche/quic/core/frames/quic_new_connection_id_frame.h", "quiche/quic/core/frames/quic_new_token_frame.h", @@ -579,12 +579,12 @@ "quiche/quic/core/frames/quic_blocked_frame.cc", "quiche/quic/core/frames/quic_connection_close_frame.cc", "quiche/quic/core/frames/quic_crypto_frame.cc", + "quiche/quic/core/frames/quic_datagram_frame.cc", "quiche/quic/core/frames/quic_frame.cc", "quiche/quic/core/frames/quic_goaway_frame.cc", "quiche/quic/core/frames/quic_handshake_done_frame.cc", "quiche/quic/core/frames/quic_immediate_ack_frame.cc", "quiche/quic/core/frames/quic_max_streams_frame.cc", - "quiche/quic/core/frames/quic_message_frame.cc", "quiche/quic/core/frames/quic_new_connection_id_frame.cc", "quiche/quic/core/frames/quic_new_token_frame.cc", "quiche/quic/core/frames/quic_padding_frame.cc",
diff --git a/quiche/quic/core/chlo_extractor.cc b/quiche/quic/core/chlo_extractor.cc index 1a105c5..169deed 100644 --- a/quiche/quic/core/chlo_extractor.cc +++ b/quiche/quic/core/chlo_extractor.cc
@@ -80,7 +80,7 @@ bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; bool OnBlockedFrame(const QuicBlockedFrame& frame) override; bool OnPaddingFrame(const QuicPaddingFrame& frame) override; - bool OnMessageFrame(const QuicMessageFrame& frame) override; + bool OnDatagramFrame(const QuicDatagramFrame& frame) override; bool OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) override; bool OnAckFrequencyFrame(const QuicAckFrequencyFrame& frame) override; bool OnImmediateAckFrame(const QuicImmediateAckFrame& frame) override; @@ -299,7 +299,7 @@ return true; } -bool ChloFramerVisitor::OnMessageFrame(const QuicMessageFrame& /*frame*/) { +bool ChloFramerVisitor::OnDatagramFrame(const QuicDatagramFrame& /*frame*/) { return true; }
diff --git a/quiche/quic/core/frames/quic_datagram_frame.cc b/quiche/quic/core/frames/quic_datagram_frame.cc new file mode 100644 index 0000000..6b55898 --- /dev/null +++ b/quiche/quic/core/frames/quic_datagram_frame.cc
@@ -0,0 +1,45 @@ +// Copyright (c) 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "quiche/quic/core/frames/quic_datagram_frame.h" + +#include <ostream> +#include <utility> + +#include "quiche/quic/core/quic_constants.h" +#include "quiche/quic/platform/api/quic_logging.h" +#include "quiche/common/quiche_mem_slice.h" + +namespace quic { + +QuicDatagramFrame::QuicDatagramFrame(QuicDatagramId datagram_id) + : datagram_id(datagram_id), data(nullptr), datagram_length(0) {} + +QuicDatagramFrame::QuicDatagramFrame(QuicDatagramId datagram_id, + absl::Span<quiche::QuicheMemSlice> span) + : datagram_id(datagram_id), data(nullptr), datagram_length(0) { + for (quiche::QuicheMemSlice& slice : span) { + if (slice.empty()) { + continue; + } + datagram_length += slice.length(); + datagram_data.push_back(std::move(slice)); + } +} +QuicDatagramFrame::QuicDatagramFrame(QuicDatagramId datagram_id, + quiche::QuicheMemSlice slice) + : QuicDatagramFrame(datagram_id, absl::MakeSpan(&slice, 1)) {} + +QuicDatagramFrame::QuicDatagramFrame(const char* data, QuicPacketLength length) + : datagram_id(0), data(data), datagram_length(length) {} + +QuicDatagramFrame::~QuicDatagramFrame() {} + +std::ostream& operator<<(std::ostream& os, const QuicDatagramFrame& s) { + os << " datagram_id: " << s.datagram_id + << ", datagram_length: " << s.datagram_length << " }\n"; + return os; +} + +} // namespace quic
diff --git a/quiche/quic/core/frames/quic_datagram_frame.h b/quiche/quic/core/frames/quic_datagram_frame.h new file mode 100644 index 0000000..f19a743 --- /dev/null +++ b/quiche/quic/core/frames/quic_datagram_frame.h
@@ -0,0 +1,51 @@ +// Copyright (c) 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef QUICHE_QUIC_CORE_FRAMES_QUIC_DATAGRAM_FRAME_H_ +#define QUICHE_QUIC_CORE_FRAMES_QUIC_DATAGRAM_FRAME_H_ + +#include "absl/container/inlined_vector.h" +#include "absl/types/span.h" +#include "quiche/quic/core/quic_types.h" +#include "quiche/quic/platform/api/quic_export.h" +#include "quiche/common/quiche_mem_slice.h" + +namespace quic { + +using QuicDatagramData = absl::InlinedVector<quiche::QuicheMemSlice, 1>; + +struct QUICHE_EXPORT QuicDatagramFrame { + QuicDatagramFrame() = default; + explicit QuicDatagramFrame(QuicDatagramId datagram_id); + QuicDatagramFrame(QuicDatagramId datagram_id, + absl::Span<quiche::QuicheMemSlice> span); + QuicDatagramFrame(QuicDatagramId datagram_id, quiche::QuicheMemSlice slice); + QuicDatagramFrame(const char* data, QuicPacketLength length); + + QuicDatagramFrame(const QuicDatagramFrame& other) = delete; + QuicDatagramFrame& operator=(const QuicDatagramFrame& other) = delete; + + QuicDatagramFrame(QuicDatagramFrame&& other) = default; + QuicDatagramFrame& operator=(QuicDatagramFrame&& other) = default; + + ~QuicDatagramFrame(); + + friend QUICHE_EXPORT std::ostream& operator<<(std::ostream& os, + const QuicDatagramFrame& s); + + // datagram_id is only used on the sender side and does not get serialized on + // wire. + QuicDatagramId datagram_id = 0; + // Not owned, only used on read path. + const char* data = nullptr; + // Total length of datagram_data, must be fit into one packet. + QuicPacketLength datagram_length = 0; + + // The actual datagram data which is reference counted, used on write path. + QuicDatagramData datagram_data; +}; + +} // namespace quic + +#endif // QUICHE_QUIC_CORE_FRAMES_QUIC_DATAGRAM_FRAME_H_
diff --git a/quiche/quic/core/frames/quic_frame.cc b/quiche/quic/core/frames/quic_frame.cc index 0c4c411..8451bb9 100644 --- a/quiche/quic/core/frames/quic_frame.cc +++ b/quiche/quic/core/frames/quic_frame.cc
@@ -79,8 +79,8 @@ QuicFrame::QuicFrame(QuicStopSendingFrame frame) : stop_sending_frame(frame) {} -QuicFrame::QuicFrame(QuicMessageFrame* frame) - : type(MESSAGE_FRAME), message_frame(frame) {} +QuicFrame::QuicFrame(QuicDatagramFrame* frame) + : type(DATAGRAM_FRAME), datagram_frame(frame) {} QuicFrame::QuicFrame(QuicNewTokenFrame* frame) : type(NEW_TOKEN_FRAME), new_token_frame(frame) {} @@ -152,8 +152,8 @@ case RETIRE_CONNECTION_ID_FRAME: delete frame->retire_connection_id_frame; break; - case MESSAGE_FRAME: - delete frame->message_frame; + case DATAGRAM_FRAME: + delete frame->datagram_frame; break; case CRYPTO_FRAME: delete frame->crypto_frame; @@ -183,9 +183,9 @@ } } -bool HasMessageFrame(const QuicFrames& frames) { +bool HasDatagramFrame(const QuicFrames& frames) { for (const QuicFrame& frame : frames) { - if (frame.type == MESSAGE_FRAME) { + if (frame.type == DATAGRAM_FRAME) { return true; } } @@ -417,14 +417,16 @@ case STOP_SENDING_FRAME: copy = QuicFrame(QuicStopSendingFrame(frame.stop_sending_frame)); break; - case MESSAGE_FRAME: - copy = QuicFrame(new QuicMessageFrame(frame.message_frame->message_id)); - copy.message_frame->data = frame.message_frame->data; - copy.message_frame->message_length = frame.message_frame->message_length; - for (const auto& slice : frame.message_frame->message_data) { + case DATAGRAM_FRAME: + copy = + QuicFrame(new QuicDatagramFrame(frame.datagram_frame->datagram_id)); + copy.datagram_frame->data = frame.datagram_frame->data; + copy.datagram_frame->datagram_length = + frame.datagram_frame->datagram_length; + for (const auto& slice : frame.datagram_frame->datagram_data) { quiche::QuicheBuffer buffer = quiche::QuicheBuffer::Copy(allocator, slice.AsStringView()); - copy.message_frame->message_data.push_back( + copy.datagram_frame->datagram_data.push_back( quiche::QuicheMemSlice(std::move(buffer))); } break; @@ -539,8 +541,8 @@ case STOP_SENDING_FRAME: os << "type { STOP_SENDING } " << frame.stop_sending_frame; break; - case MESSAGE_FRAME: - os << "type { MESSAGE_FRAME }" << *(frame.message_frame); + case DATAGRAM_FRAME: + os << "type { DATAGRAM_FRAME }" << *(frame.datagram_frame); break; case NEW_TOKEN_FRAME: os << "type { NEW_TOKEN_FRAME }" << *(frame.new_token_frame);
diff --git a/quiche/quic/core/frames/quic_frame.h b/quiche/quic/core/frames/quic_frame.h index 3485e4e..a9eb9d7 100644 --- a/quiche/quic/core/frames/quic_frame.h +++ b/quiche/quic/core/frames/quic_frame.h
@@ -16,11 +16,11 @@ #include "quiche/quic/core/frames/quic_blocked_frame.h" #include "quiche/quic/core/frames/quic_connection_close_frame.h" #include "quiche/quic/core/frames/quic_crypto_frame.h" +#include "quiche/quic/core/frames/quic_datagram_frame.h" #include "quiche/quic/core/frames/quic_goaway_frame.h" #include "quiche/quic/core/frames/quic_handshake_done_frame.h" #include "quiche/quic/core/frames/quic_immediate_ack_frame.h" #include "quiche/quic/core/frames/quic_max_streams_frame.h" -#include "quiche/quic/core/frames/quic_message_frame.h" #include "quiche/quic/core/frames/quic_mtu_discovery_frame.h" #include "quiche/quic/core/frames/quic_new_connection_id_frame.h" #include "quiche/quic/core/frames/quic_new_token_frame.h" @@ -75,7 +75,7 @@ explicit QuicFrame(QuicNewConnectionIdFrame* frame); explicit QuicFrame(QuicRetireConnectionIdFrame* frame); explicit QuicFrame(QuicNewTokenFrame* frame); - explicit QuicFrame(QuicMessageFrame* message_frame); + explicit QuicFrame(QuicDatagramFrame* datagram_frame); explicit QuicFrame(QuicCryptoFrame* crypto_frame); explicit QuicFrame(QuicAckFrequencyFrame* ack_frequency_frame); explicit QuicFrame(QuicResetStreamAtFrame* reset_stream_at_frame); @@ -118,7 +118,7 @@ QuicGoAwayFrame* goaway_frame; QuicNewConnectionIdFrame* new_connection_id_frame; QuicRetireConnectionIdFrame* retire_connection_id_frame; - QuicMessageFrame* message_frame; + QuicDatagramFrame* datagram_frame; QuicCryptoFrame* crypto_frame; QuicAckFrequencyFrame* ack_frequency_frame; QuicNewTokenFrame* new_token_frame; @@ -150,7 +150,7 @@ QuicStreamId stream_id); // Returns true if |frames| contains at least one message frame. -QUICHE_EXPORT bool HasMessageFrame(const QuicFrames& frames); +QUICHE_EXPORT bool HasDatagramFrame(const QuicFrames& frames); // Returns true if |type| is a retransmittable control frame. QUICHE_EXPORT bool IsControlFrame(QuicFrameType type);
diff --git a/quiche/quic/core/frames/quic_frames_test.cc b/quiche/quic/core/frames/quic_frames_test.cc index eeed473..5f99eff 100644 --- a/quiche/quic/core/frames/quic_frames_test.cc +++ b/quiche/quic/core/frames/quic_frames_test.cc
@@ -598,8 +598,8 @@ TEST_F(QuicFramesTest, CopyQuicFrames) { QuicFrames frames; - QuicMessageFrame* message_frame = - new QuicMessageFrame(1, MemSliceFromString("message")); + QuicDatagramFrame* Datagram_frame = + new QuicDatagramFrame(1, MemSliceFromString("Datagram")); // Construct a frame list. for (uint8_t i = 0; i < NUM_FRAME_TYPES; ++i) { switch (i) { @@ -657,8 +657,8 @@ case STOP_SENDING_FRAME: frames.push_back(QuicFrame(QuicStopSendingFrame())); break; - case MESSAGE_FRAME: - frames.push_back(QuicFrame(message_frame)); + case DATAGRAM_FRAME: + frames.push_back(QuicFrame(Datagram_frame)); break; case NEW_TOKEN_FRAME: frames.push_back(QuicFrame(new QuicNewTokenFrame())); @@ -690,14 +690,15 @@ ASSERT_EQ(NUM_FRAME_TYPES, copy.size()); for (uint8_t i = 0; i < NUM_FRAME_TYPES; ++i) { EXPECT_EQ(i, copy[i].type); - if (i == MESSAGE_FRAME) { - // Verify message frame is correctly copied. - EXPECT_EQ(1u, copy[i].message_frame->message_id); - EXPECT_EQ(nullptr, copy[i].message_frame->data); - EXPECT_EQ(7u, copy[i].message_frame->message_length); - ASSERT_EQ(1u, copy[i].message_frame->message_data.size()); - EXPECT_EQ(0, memcmp(copy[i].message_frame->message_data[0].data(), - frames[i].message_frame->message_data[0].data(), 7)); + if (i == DATAGRAM_FRAME) { + // Verify datagram frame is correctly copied. + EXPECT_EQ(1u, copy[i].datagram_frame->datagram_id); + EXPECT_EQ(nullptr, copy[i].datagram_frame->data); + EXPECT_EQ(8u, copy[i].datagram_frame->datagram_length); + ASSERT_EQ(1u, copy[i].datagram_frame->datagram_data.size()); + EXPECT_EQ(0, + memcmp(copy[i].datagram_frame->datagram_data[0].data(), + frames[i].datagram_frame->datagram_data[0].data(), 8)); } else if (i == PATH_CHALLENGE_FRAME) { EXPECT_EQ(copy[i].path_challenge_frame.control_frame_id, frames[i].path_challenge_frame.control_frame_id); @@ -903,15 +904,15 @@ EXPECT_EQ(QuicPacketNumber(49u), queue.Max()); } -TEST_F(QuicFramesTest, HasMessageFrame) { +TEST_F(QuicFramesTest, HasDatagramFrame) { QuicFrames frames; frames.push_back(QuicFrame(QuicHandshakeDoneFrame())); - EXPECT_FALSE(HasMessageFrame(frames)); + EXPECT_FALSE(HasDatagramFrame(frames)); frames.push_back( - QuicFrame(new QuicMessageFrame(1, MemSliceFromString("message")))); - EXPECT_TRUE(HasMessageFrame(frames)); + QuicFrame(new QuicDatagramFrame(1, MemSliceFromString("datagram")))); + EXPECT_TRUE(HasDatagramFrame(frames)); DeleteFrames(&frames); }
diff --git a/quiche/quic/core/frames/quic_message_frame.cc b/quiche/quic/core/frames/quic_message_frame.cc deleted file mode 100644 index 6e6bd56..0000000 --- a/quiche/quic/core/frames/quic_message_frame.cc +++ /dev/null
@@ -1,45 +0,0 @@ -// Copyright (c) 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "quiche/quic/core/frames/quic_message_frame.h" - -#include <ostream> -#include <utility> - -#include "quiche/quic/core/quic_constants.h" -#include "quiche/quic/platform/api/quic_logging.h" -#include "quiche/common/quiche_mem_slice.h" - -namespace quic { - -QuicMessageFrame::QuicMessageFrame(QuicMessageId message_id) - : message_id(message_id), data(nullptr), message_length(0) {} - -QuicMessageFrame::QuicMessageFrame(QuicMessageId message_id, - absl::Span<quiche::QuicheMemSlice> span) - : message_id(message_id), data(nullptr), message_length(0) { - for (quiche::QuicheMemSlice& slice : span) { - if (slice.empty()) { - continue; - } - message_length += slice.length(); - message_data.push_back(std::move(slice)); - } -} -QuicMessageFrame::QuicMessageFrame(QuicMessageId message_id, - quiche::QuicheMemSlice slice) - : QuicMessageFrame(message_id, absl::MakeSpan(&slice, 1)) {} - -QuicMessageFrame::QuicMessageFrame(const char* data, QuicPacketLength length) - : message_id(0), data(data), message_length(length) {} - -QuicMessageFrame::~QuicMessageFrame() {} - -std::ostream& operator<<(std::ostream& os, const QuicMessageFrame& s) { - os << " message_id: " << s.message_id - << ", message_length: " << s.message_length << " }\n"; - return os; -} - -} // namespace quic
diff --git a/quiche/quic/core/frames/quic_message_frame.h b/quiche/quic/core/frames/quic_message_frame.h deleted file mode 100644 index 3afb18e..0000000 --- a/quiche/quic/core/frames/quic_message_frame.h +++ /dev/null
@@ -1,51 +0,0 @@ -// Copyright (c) 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef QUICHE_QUIC_CORE_FRAMES_QUIC_MESSAGE_FRAME_H_ -#define QUICHE_QUIC_CORE_FRAMES_QUIC_MESSAGE_FRAME_H_ - -#include "absl/container/inlined_vector.h" -#include "absl/types/span.h" -#include "quiche/quic/core/quic_types.h" -#include "quiche/quic/platform/api/quic_export.h" -#include "quiche/common/quiche_mem_slice.h" - -namespace quic { - -using QuicMessageData = absl::InlinedVector<quiche::QuicheMemSlice, 1>; - -struct QUICHE_EXPORT QuicMessageFrame { - QuicMessageFrame() = default; - explicit QuicMessageFrame(QuicMessageId message_id); - QuicMessageFrame(QuicMessageId message_id, - absl::Span<quiche::QuicheMemSlice> span); - QuicMessageFrame(QuicMessageId message_id, quiche::QuicheMemSlice slice); - QuicMessageFrame(const char* data, QuicPacketLength length); - - QuicMessageFrame(const QuicMessageFrame& other) = delete; - QuicMessageFrame& operator=(const QuicMessageFrame& other) = delete; - - QuicMessageFrame(QuicMessageFrame&& other) = default; - QuicMessageFrame& operator=(QuicMessageFrame&& other) = default; - - ~QuicMessageFrame(); - - friend QUICHE_EXPORT std::ostream& operator<<(std::ostream& os, - const QuicMessageFrame& s); - - // message_id is only used on the sender side and does not get serialized on - // wire. - QuicMessageId message_id = 0; - // Not owned, only used on read path. - const char* data = nullptr; - // Total length of message_data, must be fit into one packet. - QuicPacketLength message_length = 0; - - // The actual message data which is reference counted, used on write path. - QuicMessageData message_data; -}; - -} // namespace quic - -#endif // QUICHE_QUIC_CORE_FRAMES_QUIC_MESSAGE_FRAME_H_
diff --git a/quiche/quic/core/http/end_to_end_test.cc b/quiche/quic/core/http/end_to_end_test.cc index c92efe2..5103cae 100644 --- a/quiche/quic/core/http/end_to_end_test.cc +++ b/quiche/quic/core/http/end_to_end_test.cc
@@ -5536,7 +5536,7 @@ EXPECT_THAT(client_->stream_error(), IsStreamError(QUIC_STREAM_TTL_EXPIRED)); } -TEST_P(EndToEndTest, SendMessages) { +TEST_P(EndToEndTest, SendDatagrams) { ASSERT_TRUE(Initialize()); EXPECT_TRUE(client_->client()->WaitForOneRttKeysAvailable()); QuicSession* client_session = GetClientSession(); @@ -5546,43 +5546,43 @@ SetPacketLossPercentage(30); ASSERT_GT(kMaxOutgoingPacketSize, - client_session->GetCurrentLargestMessagePayload()); - ASSERT_LT(0, client_session->GetCurrentLargestMessagePayload()); + client_session->GetCurrentLargestDatagramPayload()); + ASSERT_LT(0, client_session->GetCurrentLargestDatagramPayload()); - std::string message_string(kMaxOutgoingPacketSize, 'a'); + std::string datagram_string(kMaxOutgoingPacketSize, 'a'); QuicRandom* random = QuicConnectionPeer::GetHelper(client_connection)->GetRandomGenerator(); { QuicConnection::ScopedPacketFlusher flusher(client_session->connection()); - // Verify the largest message gets successfully sent. - EXPECT_EQ(MessageResult(MESSAGE_STATUS_SUCCESS, 1), - client_session->SendMessage(MemSliceFromString(absl::string_view( - message_string.data(), - client_session->GetCurrentLargestMessagePayload())))); - // Send more messages with size (0, largest_payload] until connection is + // Verify the largest datagram gets successfully sent. + EXPECT_EQ(DatagramResult(DATAGRAM_STATUS_SUCCESS, 1), + client_session->SendDatagram(MemSliceFromString(absl::string_view( + datagram_string.data(), + client_session->GetCurrentLargestDatagramPayload())))); + // Send more datagrams with size (0, largest_payload] until connection is // write blocked. - const int kTestMaxNumberOfMessages = 100; - for (size_t i = 2; i <= kTestMaxNumberOfMessages; ++i) { - size_t message_length = + const int kTestMaxNumberOfDatagrams = 100; + for (size_t i = 2; i <= kTestMaxNumberOfDatagrams; ++i) { + size_t datagram_length = random->RandUint64() % - client_session->GetGuaranteedLargestMessagePayload() + + client_session->GetGuaranteedLargestDatagramPayload() + 1; - MessageResult result = client_session->SendMessage(MemSliceFromString( - absl::string_view(message_string.data(), message_length))); - if (result.status == MESSAGE_STATUS_BLOCKED) { + DatagramResult result = client_session->SendDatagram(MemSliceFromString( + absl::string_view(datagram_string.data(), datagram_length))); + if (result.status == DATAGRAM_STATUS_BLOCKED) { // Connection is write blocked. break; } - EXPECT_EQ(MessageResult(MESSAGE_STATUS_SUCCESS, i), result); + EXPECT_EQ(DatagramResult(DATAGRAM_STATUS_SUCCESS, i), result); } } client_->WaitForDelayedAcks(); - EXPECT_EQ(MESSAGE_STATUS_TOO_LARGE, + EXPECT_EQ(DATAGRAM_STATUS_TOO_LARGE, client_session - ->SendMessage(MemSliceFromString(absl::string_view( - message_string.data(), - client_session->GetCurrentLargestMessagePayload() + 1))) + ->SendDatagram(MemSliceFromString(absl::string_view( + datagram_string.data(), + client_session->GetCurrentLargestDatagramPayload() + 1))) .status); EXPECT_THAT(client_->connection_error(), IsQuicNoError()); }
diff --git a/quiche/quic/core/http/quic_spdy_session.cc b/quiche/quic/core/http/quic_spdy_session.cc index 54c896e..da91c57 100644 --- a/quiche/quic/core/http/quic_spdy_session.cc +++ b/quiche/quic/core/http/quic_spdy_session.cc
@@ -1764,20 +1764,20 @@ } } -MessageStatus QuicSpdySession::SendHttp3Datagram(QuicStreamId stream_id, - absl::string_view payload) { +DatagramStatus QuicSpdySession::SendHttp3Datagram(QuicStreamId stream_id, + absl::string_view payload) { if (!SupportsH3Datagram()) { if (LocalHttpDatagramSupport() == HttpDatagramSupport::kNone) { QUIC_BUG(http datagram disabled locally) << "Cannot send HTTP Datagram when disabled locally"; - return MESSAGE_STATUS_UNSUPPORTED; + return DATAGRAM_STATUS_UNSUPPORTED; } else if (!settings_received_) { QUIC_DLOG(INFO) << "Refusing to send HTTP Datagram before SETTINGS received"; - return MESSAGE_STATUS_SETTINGS_NOT_RECEIVED; + return DATAGRAM_STATUS_SETTINGS_NOT_RECEIVED; } else { QUIC_DLOG(INFO) << "Refusing to send HTTP Datagram without peer support"; - return MESSAGE_STATUS_UNSUPPORTED; + return DATAGRAM_STATUS_UNSUPPORTED; } } // Stream ID is sent divided by four as per the specification. @@ -1790,12 +1790,12 @@ if (!writer.WriteVarInt62(stream_id_to_write)) { QUIC_BUG(h3 datagram stream ID write fail) << "Failed to write HTTP/3 datagram stream ID"; - return MESSAGE_STATUS_INTERNAL_ERROR; + return DATAGRAM_STATUS_INTERNAL_ERROR; } if (!writer.WriteBytes(payload.data(), payload.length())) { QUIC_BUG(h3 datagram payload write fail) << "Failed to write HTTP/3 datagram payload"; - return MESSAGE_STATUS_INTERNAL_ERROR; + return DATAGRAM_STATUS_INTERNAL_ERROR; } quiche::QuicheMemSlice slice(std::move(buffer)); @@ -1809,13 +1809,13 @@ datagram_queue()->SetMaxTimeInQueue(max_time_in_queue); } -void QuicSpdySession::OnMessageReceived(absl::string_view message) { - QuicSession::OnMessageReceived(message); +void QuicSpdySession::OnDatagramReceived(absl::string_view datagram) { + QuicSession::OnDatagramReceived(datagram); if (!SupportsH3Datagram()) { QUIC_DLOG(INFO) << "Ignoring unexpected received HTTP/3 datagram"; return; } - QuicDataReader reader(message); + QuicDataReader reader(datagram); uint64_t stream_id64; if (!reader.ReadVarInt62(&stream_id64)) { QUIC_DLOG(ERROR) << "Failed to parse stream ID in received HTTP/3 datagram"; @@ -1980,12 +1980,12 @@ } void QuicSpdySession::OnDatagramProcessed( - std::optional<MessageStatus> /*status*/) { + std::optional<DatagramStatus> /*status*/) { // TODO(b/184598230): make this work with multiple datagram flows. } void QuicSpdySession::DatagramObserver::OnDatagramProcessed( - std::optional<MessageStatus> status) { + std::optional<DatagramStatus> status) { session_->OnDatagramProcessed(status); }
diff --git a/quiche/quic/core/http/quic_spdy_session.h b/quiche/quic/core/http/quic_spdy_session.h index 9ebbc43..6560cd3 100644 --- a/quiche/quic/core/http/quic_spdy_session.h +++ b/quiche/quic/core/http/quic_spdy_session.h
@@ -403,14 +403,14 @@ } // This must not be used except by QuicSpdyStream::SendHttp3Datagram. - MessageStatus SendHttp3Datagram(QuicStreamId stream_id, - absl::string_view payload); + DatagramStatus SendHttp3Datagram(QuicStreamId stream_id, + absl::string_view payload); // This must not be used except by QuicSpdyStream::SetMaxDatagramTimeInQueue. void SetMaxDatagramTimeInQueueForStreamId(QuicStreamId stream_id, QuicTime::Delta max_time_in_queue); // Override from QuicSession to support HTTP/3 datagrams. - void OnMessageReceived(absl::string_view message) override; + void OnDatagramReceived(absl::string_view datagram) override; // Indicates whether the HTTP/3 session supports WebTransport. bool SupportsWebTransport(); @@ -554,7 +554,7 @@ void MaybeBundleOpportunistically() override; // Called whenever a datagram is dequeued or dropped from datagram_queue(). - virtual void OnDatagramProcessed(std::optional<MessageStatus> status); + virtual void OnDatagramProcessed(std::optional<DatagramStatus> status); // Returns which version of the HTTP/3 datagram extension we should advertise // in settings and accept remote settings for. @@ -594,7 +594,7 @@ class QUICHE_EXPORT DatagramObserver : public QuicDatagramQueue::Observer { public: explicit DatagramObserver(QuicSpdySession* session) : session_(session) {} - void OnDatagramProcessed(std::optional<MessageStatus> status) override; + void OnDatagramProcessed(std::optional<DatagramStatus> status) override; private: QuicSpdySession* session_; // not owned
diff --git a/quiche/quic/core/http/quic_spdy_stream.cc b/quiche/quic/core/http/quic_spdy_stream.cc index f3b07ed..2aefeab 100644 --- a/quiche/quic/core/http/quic_spdy_stream.cc +++ b/quiche/quic/core/http/quic_spdy_stream.cc
@@ -1671,7 +1671,7 @@ WriteCapsule(capsule, /*fin=*/false); } -MessageStatus QuicSpdyStream::SendHttp3Datagram(absl::string_view payload) { +DatagramStatus QuicSpdyStream::SendHttp3Datagram(absl::string_view payload) { return spdy_session_->SendHttp3Datagram(id(), payload); } @@ -1833,10 +1833,11 @@ } QuicByteCount max_datagram_size = - session()->GetGuaranteedLargestMessagePayload(); + session()->GetGuaranteedLargestDatagramPayload(); if (max_datagram_size < prefix_size) { QUIC_BUG(max_datagram_size smaller than prefix_size) - << "GetGuaranteedLargestMessagePayload() returned a datagram size that " + << "GetGuaranteedLargestDatagramPayload() returned a datagram size " + "that " "is not sufficient to fit stream ID into it."; return 0; }
diff --git a/quiche/quic/core/http/quic_spdy_stream.h b/quiche/quic/core/http/quic_spdy_stream.h index fab5441..8d44e07 100644 --- a/quiche/quic/core/http/quic_spdy_stream.h +++ b/quiche/quic/core/http/quic_spdy_stream.h
@@ -305,7 +305,7 @@ // Sends an HTTP/3 datagram. The stream ID is not part of |payload|. Virtual // to allow mocking in tests. - virtual MessageStatus SendHttp3Datagram(absl::string_view payload); + virtual DatagramStatus SendHttp3Datagram(absl::string_view payload); // Registers |visitor| to receive HTTP/3 datagrams and enables Capsule // Protocol by registering a CapsuleParser. |visitor| must be valid until a
diff --git a/quiche/quic/core/http/quic_spdy_stream_test.cc b/quiche/quic/core/http/quic_spdy_stream_test.cc index 575a64f..c4736fd 100644 --- a/quiche/quic/core/http/quic_spdy_stream_test.cc +++ b/quiche/quic/core/http/quic_spdy_stream_test.cc
@@ -3542,7 +3542,7 @@ } stream_->RegisterHttp3DatagramVisitor(&h3_datagram_visitor); - session_->OnMessageReceived( + session_->OnDatagramReceived( absl::string_view(datagram.data(), datagram.size())); EXPECT_THAT( h3_datagram_visitor.received_h3_datagrams(), @@ -3552,7 +3552,7 @@ SavingHttp3DatagramVisitor h3_datagram_visitor2; stream_->ReplaceHttp3DatagramVisitor(&h3_datagram_visitor2); EXPECT_TRUE(h3_datagram_visitor2.received_h3_datagrams().empty()); - session_->OnMessageReceived( + session_->OnDatagramReceived( absl::string_view(datagram.data(), datagram.size())); EXPECT_THAT( h3_datagram_visitor2.received_h3_datagrams(), @@ -3571,10 +3571,10 @@ QuicSpdySessionPeer::SetHttpDatagramSupport(session_.get(), HttpDatagramSupport::kRfc); std::string http_datagram_payload = {1, 2, 3, 4, 5, 6}; - EXPECT_CALL(*connection_, SendMessage(1, _, false)) - .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); + EXPECT_CALL(*connection_, SendDatagram(1, _, false)) + .WillOnce(Return(DATAGRAM_STATUS_SUCCESS)); EXPECT_EQ(stream_->SendHttp3Datagram(http_datagram_payload), - MESSAGE_STATUS_SUCCESS); + DATAGRAM_STATUS_SUCCESS); } TEST_P(QuicSpdyStreamTest, SendHttpDatagramWithoutLocalSupport) { @@ -3596,7 +3596,7 @@ session_->set_local_http_datagram_support(HttpDatagramSupport::kRfc); std::string http_datagram_payload = {1, 2, 3, 4, 5, 6}; EXPECT_EQ(stream_->SendHttp3Datagram(http_datagram_payload), - MESSAGE_STATUS_SETTINGS_NOT_RECEIVED); + DATAGRAM_STATUS_SETTINGS_NOT_RECEIVED); } TEST_P(QuicSpdyStreamTest, SendHttpDatagramWithoutPeerSupport) { @@ -3612,7 +3612,7 @@ std::string http_datagram_payload = {1, 2, 3, 4, 5, 6}; EXPECT_EQ(stream_->SendHttp3Datagram(http_datagram_payload), - MESSAGE_STATUS_UNSUPPORTED); + DATAGRAM_STATUS_UNSUPPORTED); } TEST_P(QuicSpdyStreamTest, GetMaxDatagramSize) {
diff --git a/quiche/quic/core/http/web_transport_http3.cc b/quiche/quic/core/http/web_transport_http3.cc index e2d1466..bfb5e4a 100644 --- a/quiche/quic/core/http/web_transport_http3.cc +++ b/quiche/quic/core/http/web_transport_http3.cc
@@ -273,7 +273,7 @@ webtransport::DatagramStatus WebTransportHttp3::SendOrQueueDatagram( absl::string_view datagram) { - return MessageStatusToWebTransportStatus( + return DatagramStatusToWebTransportStatus( connect_stream_->SendHttp3Datagram(datagram)); }
diff --git a/quiche/quic/core/quic_connection.cc b/quiche/quic/core/quic_connection.cc index 06050ee..c70d676 100644 --- a/quiche/quic/core/quic_connection.cc +++ b/quiche/quic/core/quic_connection.cc
@@ -42,12 +42,12 @@ #include "quiche/quic/core/frames/quic_blocked_frame.h" #include "quiche/quic/core/frames/quic_connection_close_frame.h" #include "quiche/quic/core/frames/quic_crypto_frame.h" +#include "quiche/quic/core/frames/quic_datagram_frame.h" #include "quiche/quic/core/frames/quic_frame.h" #include "quiche/quic/core/frames/quic_goaway_frame.h" #include "quiche/quic/core/frames/quic_handshake_done_frame.h" #include "quiche/quic/core/frames/quic_immediate_ack_frame.h" #include "quiche/quic/core/frames/quic_max_streams_frame.h" -#include "quiche/quic/core/frames/quic_message_frame.h" #include "quiche/quic/core/frames/quic_new_connection_id_frame.h" #include "quiche/quic/core/frames/quic_new_token_frame.h" #include "quiche/quic/core/frames/quic_padding_frame.h" @@ -2075,24 +2075,24 @@ return true; } -bool QuicConnection::OnMessageFrame(const QuicMessageFrame& frame) { +bool QuicConnection::OnDatagramFrame(const QuicDatagramFrame& frame) { QUIC_BUG_IF(quic_bug_12714_16, !connected_) - << "Processing MESSAGE frame when connection is closed. Received packet " + << "Processing DATAGRAM frame when connection is closed. Received packet " "info: " << last_received_packet_info_; - // Since a message frame was received, this is not a connectivity probe. + // Since a datagram frame was received, this is not a connectivity probe. // A probe only contains a PING and full padding. - if (!UpdatePacketContent(MESSAGE_FRAME)) { + if (!UpdatePacketContent(DATAGRAM_FRAME)) { return false; } if (debug_visitor_ != nullptr) { - debug_visitor_->OnMessageFrame(frame); + debug_visitor_->OnDatagramFrame(frame); } MaybeUpdateAckTimeout(); - visitor_->OnMessageReceived( - absl::string_view(frame.data, frame.message_length)); + visitor_->OnDatagramReceived( + absl::string_view(frame.data, frame.datagram_length)); return connected_; } @@ -5913,25 +5913,25 @@ uber_received_packet_manager_.ResetAckStates(encryption_level_); } -MessageStatus QuicConnection::SendMessage( - QuicMessageId message_id, absl::Span<quiche::QuicheMemSlice> message, +DatagramStatus QuicConnection::SendDatagram( + QuicDatagramId datagram_id, absl::Span<quiche::QuicheMemSlice> datagram, bool flush) { - if (MemSliceSpanTotalSize(message) > GetCurrentLargestMessagePayload()) { - return MESSAGE_STATUS_TOO_LARGE; + if (MemSliceSpanTotalSize(datagram) > GetCurrentLargestDatagramPayload()) { + return DATAGRAM_STATUS_TOO_LARGE; } if (!connected_ || (!flush && !CanWrite(HAS_RETRANSMITTABLE_DATA))) { - return MESSAGE_STATUS_BLOCKED; + return DATAGRAM_STATUS_BLOCKED; } ScopedPacketFlusher flusher(this); - return packet_creator_.AddMessageFrame(message_id, message); + return packet_creator_.AddDatagramFrame(datagram_id, datagram); } -QuicPacketLength QuicConnection::GetCurrentLargestMessagePayload() const { - return packet_creator_.GetCurrentLargestMessagePayload(); +QuicPacketLength QuicConnection::GetCurrentLargestDatagramPayload() const { + return packet_creator_.GetCurrentLargestDatagramPayload(); } -QuicPacketLength QuicConnection::GetGuaranteedLargestMessagePayload() const { - return packet_creator_.GetGuaranteedLargestMessagePayload(); +QuicPacketLength QuicConnection::GetGuaranteedLargestDatagramPayload() const { + return packet_creator_.GetGuaranteedLargestDatagramPayload(); } uint32_t QuicConnection::cipher_id() const {
diff --git a/quiche/quic/core/quic_connection.h b/quiche/quic/core/quic_connection.h index c9ebfe3..afcf107 100644 --- a/quiche/quic/core/quic_connection.h +++ b/quiche/quic/core/quic_connection.h
@@ -43,12 +43,12 @@ #include "quiche/quic/core/frames/quic_blocked_frame.h" #include "quiche/quic/core/frames/quic_connection_close_frame.h" #include "quiche/quic/core/frames/quic_crypto_frame.h" +#include "quiche/quic/core/frames/quic_datagram_frame.h" #include "quiche/quic/core/frames/quic_frame.h" #include "quiche/quic/core/frames/quic_goaway_frame.h" #include "quiche/quic/core/frames/quic_handshake_done_frame.h" #include "quiche/quic/core/frames/quic_immediate_ack_frame.h" #include "quiche/quic/core/frames/quic_max_streams_frame.h" -#include "quiche/quic/core/frames/quic_message_frame.h" #include "quiche/quic/core/frames/quic_new_connection_id_frame.h" #include "quiche/quic/core/frames/quic_new_token_frame.h" #include "quiche/quic/core/frames/quic_padding_frame.h" @@ -151,7 +151,7 @@ virtual void OnGoAway(const QuicGoAwayFrame& frame) = 0; // Called when |message| has been received. - virtual void OnMessageReceived(absl::string_view message) = 0; + virtual void OnDatagramReceived(absl::string_view datagram) = 0; // Called when a HANDSHAKE_DONE frame has been received. virtual void OnHandshakeDoneReceived() = 0; @@ -415,8 +415,8 @@ // Called when a NewTokenFrame has been parsed. virtual void OnNewTokenFrame(const QuicNewTokenFrame& /*frame*/) {} - // Called when a MessageFrame has been parsed. - virtual void OnMessageFrame(const QuicMessageFrame& /*frame*/) {} + // Called when a DatagramFrame has been parsed. + virtual void OnDatagramFrame(const QuicDatagramFrame& /*frame*/) {} // Called when a HandshakeDoneFrame has been parsed. virtual void OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& /*frame*/) {} @@ -790,7 +790,7 @@ bool OnRetireConnectionIdFrame( const QuicRetireConnectionIdFrame& frame) override; bool OnNewTokenFrame(const QuicNewTokenFrame& frame) override; - bool OnMessageFrame(const QuicMessageFrame& frame) override; + bool OnDatagramFrame(const QuicDatagramFrame& frame) override; bool OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) override; bool OnAckFrequencyFrame(const QuicAckFrequencyFrame& frame) override; bool OnImmediateAckFrame(const QuicImmediateAckFrame& frame) override; @@ -1110,20 +1110,20 @@ void SetTransmissionType(TransmissionType type); // Tries to send |message| and returns the message status. - // If |flush| is false, this will return a MESSAGE_STATUS_BLOCKED + // If |flush| is false, this will return a DATAGRAM_STATUS_BLOCKED // when the connection is deemed unwritable. - virtual MessageStatus SendMessage(QuicMessageId message_id, - absl::Span<quiche::QuicheMemSlice> message, - bool flush); + virtual DatagramStatus SendDatagram( + QuicDatagramId datagram_id, absl::Span<quiche::QuicheMemSlice> datagram, + bool flush); - // Returns the largest payload that will fit into a single MESSAGE frame. + // Returns the largest payload that will fit into a single DATAGRAM frame. // Because overhead can vary during a connection, this method should be - // checked for every message. - QuicPacketLength GetCurrentLargestMessagePayload() const; - // Returns the largest payload that will fit into a single MESSAGE frame at + // checked for every datagram. + QuicPacketLength GetCurrentLargestDatagramPayload() const; + // Returns the largest payload that will fit into a single DATAGRAM frame at // any point during the connection. This assumes the version and // connection ID lengths do not change. - QuicPacketLength GetGuaranteedLargestMessagePayload() const; + QuicPacketLength GetGuaranteedLargestDatagramPayload() const; void SetUnackedMapInitialCapacity();
diff --git a/quiche/quic/core/quic_connection_test.cc b/quiche/quic/core/quic_connection_test.cc index acfa855..d85bcda 100644 --- a/quiche/quic/core/quic_connection_test.cc +++ b/quiche/quic/core/quic_connection_test.cc
@@ -1088,11 +1088,11 @@ void SendPing() { notifier_.WriteOrBufferPing(); } - MessageStatus SendMessage(absl::string_view message) { + DatagramStatus SendDatagram(absl::string_view message) { connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); quiche::QuicheMemSlice slice(quiche::QuicheBuffer::Copy( connection_.helper()->GetStreamSendBufferAllocator(), message)); - return connection_.SendMessage(1, absl::MakeSpan(&slice, 1), false); + return connection_.SendDatagram(1, absl::MakeSpan(&slice, 1), false); } void ProcessAckPacket(uint64_t packet_number, QuicAckFrame* frame) { @@ -8657,7 +8657,7 @@ EXPECT_EQ(0, connection_close_frame_count_); } -TEST_P(QuicConnectionTest, SendMessage) { +TEST_P(QuicConnectionTest, SendDatagram) { if (connection_.version().UsesTls()) { QuicConfig config; QuicConfigPeer::SetReceivedMaxDatagramFrameSize( @@ -8667,35 +8667,35 @@ EXPECT_CALL(*send_algorithm_, EnableECT0()).WillOnce(Return(false)); connection_.SetFromConfig(config); } - std::string message(connection_.GetCurrentLargestMessagePayload() * 2, 'a'); + std::string datagram(connection_.GetCurrentLargestDatagramPayload() * 2, 'a'); quiche::QuicheMemSlice slice; { QuicConnection::ScopedPacketFlusher flusher(&connection_); connection_.SendStreamData3(); - // Send a message which cannot fit into current open packet, and 2 packets + // Send a datagram which cannot fit into current open packet, and 2 packets // get sent, one contains stream frame, and the other only contains the - // message frame. + // datagram frame. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); slice = MemSliceFromString(absl::string_view( - message.data(), connection_.GetCurrentLargestMessagePayload())); - EXPECT_EQ(MESSAGE_STATUS_SUCCESS, - connection_.SendMessage(1, absl::MakeSpan(&slice, 1), false)); + datagram.data(), connection_.GetCurrentLargestDatagramPayload())); + EXPECT_EQ(DATAGRAM_STATUS_SUCCESS, + connection_.SendDatagram(1, absl::MakeSpan(&slice, 1), false)); } - // Fail to send a message if connection is congestion control blocked. + // Fail to send a datagram if connection is congestion control blocked. EXPECT_CALL(*send_algorithm_, CanSend(_)).WillOnce(Return(false)); slice = MemSliceFromString("message"); - EXPECT_EQ(MESSAGE_STATUS_BLOCKED, - connection_.SendMessage(2, absl::MakeSpan(&slice, 1), false)); + EXPECT_EQ(DATAGRAM_STATUS_BLOCKED, + connection_.SendDatagram(2, absl::MakeSpan(&slice, 1), false)); - // Always fail to send a message which cannot fit into one packet. + // Always fail to send a datagram which cannot fit into one packet. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); slice = MemSliceFromString(absl::string_view( - message.data(), connection_.GetCurrentLargestMessagePayload() + 1)); - EXPECT_EQ(MESSAGE_STATUS_TOO_LARGE, - connection_.SendMessage(3, absl::MakeSpan(&slice, 1), false)); + datagram.data(), connection_.GetCurrentLargestDatagramPayload() + 1)); + EXPECT_EQ(DATAGRAM_STATUS_TOO_LARGE, + connection_.SendDatagram(3, absl::MakeSpan(&slice, 1), false)); } -TEST_P(QuicConnectionTest, GetCurrentLargestMessagePayload) { +TEST_P(QuicConnectionTest, GetCurrentLargestDatagramPayload) { QuicPacketLength expected_largest_payload = 1215; if (connection_.version().SendsVariableLengthPacketNumberInLongHeader()) { expected_largest_payload += 3; @@ -8707,8 +8707,8 @@ expected_largest_payload -= 1; } if (connection_.version().UsesTls()) { - // QUIC+TLS disallows DATAGRAM/MESSAGE frames before the handshake. - EXPECT_EQ(connection_.GetCurrentLargestMessagePayload(), 0); + // QUIC+TLS disallows DATAGRAM frames before the handshake. + EXPECT_EQ(connection_.GetCurrentLargestDatagramPayload(), 0); QuicConfig config; QuicConfigPeer::SetReceivedMaxDatagramFrameSize( &config, kMaxAcceptedDatagramFrameSize); @@ -8717,15 +8717,15 @@ EXPECT_CALL(*send_algorithm_, EnableECT0()).WillOnce(Return(false)); connection_.SetFromConfig(config); // Verify the value post-handshake. - EXPECT_EQ(connection_.GetCurrentLargestMessagePayload(), + EXPECT_EQ(connection_.GetCurrentLargestDatagramPayload(), expected_largest_payload); } else { - EXPECT_EQ(connection_.GetCurrentLargestMessagePayload(), + EXPECT_EQ(connection_.GetCurrentLargestDatagramPayload(), expected_largest_payload); } } -TEST_P(QuicConnectionTest, GetGuaranteedLargestMessagePayload) { +TEST_P(QuicConnectionTest, GetGuaranteedLargestDatagramPayload) { QuicPacketLength expected_largest_payload = 1215; if (connection_.version().HasLongHeaderLengths()) { expected_largest_payload -= 2; @@ -8735,7 +8735,7 @@ } if (connection_.version().UsesTls()) { // QUIC+TLS disallows DATAGRAM/MESSAGE frames before the handshake. - EXPECT_EQ(connection_.GetGuaranteedLargestMessagePayload(), 0); + EXPECT_EQ(connection_.GetGuaranteedLargestDatagramPayload(), 0); QuicConfig config; QuicConfigPeer::SetReceivedMaxDatagramFrameSize( &config, kMaxAcceptedDatagramFrameSize); @@ -8744,10 +8744,10 @@ EXPECT_CALL(*send_algorithm_, EnableECT0()).WillOnce(Return(false)); connection_.SetFromConfig(config); // Verify the value post-handshake. - EXPECT_EQ(connection_.GetGuaranteedLargestMessagePayload(), + EXPECT_EQ(connection_.GetGuaranteedLargestDatagramPayload(), expected_largest_payload); } else { - EXPECT_EQ(connection_.GetGuaranteedLargestMessagePayload(), + EXPECT_EQ(connection_.GetGuaranteedLargestDatagramPayload(), expected_largest_payload); } } @@ -8760,8 +8760,8 @@ constexpr QuicPacketLength kPayloadSizeLimit = kFrameSizeLimit - kQuicFrameTypeSize; // QUIC+TLS disallows DATAGRAM/MESSAGE frames before the handshake. - EXPECT_EQ(connection_.GetCurrentLargestMessagePayload(), 0); - EXPECT_EQ(connection_.GetGuaranteedLargestMessagePayload(), 0); + EXPECT_EQ(connection_.GetCurrentLargestDatagramPayload(), 0); + EXPECT_EQ(connection_.GetGuaranteedLargestDatagramPayload(), 0); QuicConfig config; QuicConfigPeer::SetReceivedMaxDatagramFrameSize(&config, kFrameSizeLimit); EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); @@ -8769,8 +8769,8 @@ EXPECT_CALL(*send_algorithm_, EnableECT0()).WillOnce(Return(false)); connection_.SetFromConfig(config); // Verify the value post-handshake. - EXPECT_EQ(connection_.GetCurrentLargestMessagePayload(), kPayloadSizeLimit); - EXPECT_EQ(connection_.GetGuaranteedLargestMessagePayload(), + EXPECT_EQ(connection_.GetCurrentLargestDatagramPayload(), kPayloadSizeLimit); + EXPECT_EQ(connection_.GetGuaranteedLargestDatagramPayload(), kPayloadSizeLimit); } @@ -10992,7 +10992,7 @@ connection_.OnHandshakeComplete(); EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet()); - EXPECT_EQ(MESSAGE_STATUS_SUCCESS, SendMessage("message")); + EXPECT_EQ(DATAGRAM_STATUS_SUCCESS, SendDatagram("message")); EXPECT_TRUE(connection_.GetRetransmissionAlarm()->IsSet()); // PTO fires, verify a PING packet gets sent because there is no data to @@ -15901,7 +15901,7 @@ EXPECT_CALL(visitor_, OnMaxStreamsFrame(_)); EXPECT_CALL(visitor_, OnStreamsBlockedFrame(_)); EXPECT_CALL(visitor_, OnStopSendingFrame(_)); - EXPECT_CALL(visitor_, OnMessageReceived("")); + EXPECT_CALL(visitor_, OnDatagramReceived("")); EXPECT_CALL(visitor_, OnNewTokenReceived("")); SetClientConnectionId(TestConnectionId(12)); @@ -15920,7 +15920,7 @@ retire_connection_id_frame.sequence_number = 1u; QuicStopSendingFrame stop_sending_frame; QuicPathResponseFrame path_response_frame; - QuicMessageFrame message_frame; + QuicDatagramFrame message_frame; QuicNewTokenFrame new_token_frame; QuicAckFrequencyFrame ack_frequency_frame; QuicResetStreamAtFrame reset_stream_at_frame; @@ -16001,7 +16001,7 @@ case PATH_RESPONSE_FRAME: frame = QuicFrame(path_response_frame); break; - case MESSAGE_FRAME: + case DATAGRAM_FRAME: frame = QuicFrame(&message_frame); break; case CRYPTO_FRAME:
diff --git a/quiche/quic/core/quic_datagram_queue.cc b/quiche/quic/core/quic_datagram_queue.cc index 6fac3e0..4b2cc55 100644 --- a/quiche/quic/core/quic_datagram_queue.cc +++ b/quiche/quic/core/quic_datagram_queue.cc
@@ -29,15 +29,15 @@ clock_(session->connection()->clock()), observer_(std::move(observer)) {} -MessageStatus QuicDatagramQueue::SendOrQueueDatagram( +DatagramStatus QuicDatagramQueue::SendOrQueueDatagram( quiche::QuicheMemSlice datagram) { // If the queue is non-empty, always queue the daragram. This ensures that // the datagrams are sent in the same order that they were sent by the // application. if (queue_.empty()) { - MessageResult result = session_->SendMessage(absl::MakeSpan(&datagram, 1), - /*flush=*/force_flush_); - if (result.status != MESSAGE_STATUS_BLOCKED) { + DatagramResult result = session_->SendDatagram(absl::MakeSpan(&datagram, 1), + /*flush=*/force_flush_); + if (result.status != DATAGRAM_STATUS_BLOCKED) { if (observer_) { observer_->OnDatagramProcessed(result.status); } @@ -47,18 +47,18 @@ queue_.emplace_back(Datagram{std::move(datagram), clock_->ApproximateNow() + GetMaxTimeInQueue()}); - return MESSAGE_STATUS_BLOCKED; + return DATAGRAM_STATUS_BLOCKED; } -std::optional<MessageStatus> QuicDatagramQueue::TrySendingNextDatagram() { +std::optional<DatagramStatus> QuicDatagramQueue::TrySendingNextDatagram() { RemoveExpiredDatagrams(); if (queue_.empty()) { return std::nullopt; } - MessageResult result = - session_->SendMessage(absl::MakeSpan(&queue_.front().datagram, 1)); - if (result.status != MESSAGE_STATUS_BLOCKED) { + DatagramResult result = + session_->SendDatagram(absl::MakeSpan(&queue_.front().datagram, 1)); + if (result.status != DATAGRAM_STATUS_BLOCKED) { queue_.pop_front(); if (observer_) { observer_->OnDatagramProcessed(result.status); @@ -70,11 +70,11 @@ size_t QuicDatagramQueue::SendDatagrams() { size_t num_datagrams = 0; for (;;) { - std::optional<MessageStatus> status = TrySendingNextDatagram(); + std::optional<DatagramStatus> status = TrySendingNextDatagram(); if (!status.has_value()) { break; } - if (*status == MESSAGE_STATUS_BLOCKED) { + if (*status == DATAGRAM_STATUS_BLOCKED) { break; } num_datagrams++;
diff --git a/quiche/quic/core/quic_datagram_queue.h b/quiche/quic/core/quic_datagram_queue.h index fa4c308..6e3bb8f 100644 --- a/quiche/quic/core/quic_datagram_queue.h +++ b/quiche/quic/core/quic_datagram_queue.h
@@ -34,7 +34,7 @@ // This function is called synchronously in `QuicDatagramQueue` methods. // `status` is nullopt when the datagram is dropped due to being in the // queue for too long. - virtual void OnDatagramProcessed(std::optional<MessageStatus> status) = 0; + virtual void OnDatagramProcessed(std::optional<DatagramStatus> status) = 0; }; // |session| is not owned and must outlive this object. @@ -44,12 +44,12 @@ QuicDatagramQueue(QuicSession* session, std::unique_ptr<Observer> observer); // Adds the datagram to the end of the queue. May send it immediately; if - // not, MESSAGE_STATUS_BLOCKED is returned. - MessageStatus SendOrQueueDatagram(quiche::QuicheMemSlice datagram); + // not, DATAGRAM_STATUS_BLOCKED is returned. + DatagramStatus SendOrQueueDatagram(quiche::QuicheMemSlice datagram); // Attempts to send a single datagram from the queue. Returns the result of - // SendMessage(), or nullopt if there were no unexpired datagrams to send. - std::optional<MessageStatus> TrySendingNextDatagram(); + // SendDatagram(), or nullopt if there were no unexpired datagrams to send. + std::optional<DatagramStatus> TrySendingNextDatagram(); // Sends all of the unexpired datagrams until either the connection becomes // write-blocked or the queue is empty. Returns the number of datagrams sent.
diff --git a/quiche/quic/core/quic_datagram_queue_test.cc b/quiche/quic/core/quic_datagram_queue_test.cc index 05b905c..de95419 100644 --- a/quiche/quic/core/quic_datagram_queue_test.cc +++ b/quiche/quic/core/quic_datagram_queue_test.cc
@@ -39,7 +39,7 @@ public: class Context : public quiche::QuicheReferenceCounted { public: - std::vector<std::optional<MessageStatus>> statuses; + std::vector<std::optional<DatagramStatus>> statuses; }; QuicDatagramQueueObserver() : context_(new Context()) {} @@ -47,7 +47,7 @@ QuicDatagramQueueObserver& operator=(const QuicDatagramQueueObserver&) = delete; - void OnDatagramProcessed(std::optional<MessageStatus> status) override { + void OnDatagramProcessed(std::optional<DatagramStatus> status) override { context_->statuses.push_back(std::move(status)); } @@ -93,39 +93,37 @@ }; TEST_F(QuicDatagramQueueTest, SendDatagramImmediately) { - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); - MessageStatus status = queue_.SendOrQueueDatagram(CreateMemSlice("test")); - EXPECT_EQ(MESSAGE_STATUS_SUCCESS, status); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_SUCCESS)); + DatagramStatus status = queue_.SendOrQueueDatagram(CreateMemSlice("test")); + EXPECT_EQ(DATAGRAM_STATUS_SUCCESS, status); EXPECT_EQ(0u, queue_.queue_size()); } TEST_F(QuicDatagramQueueTest, SendDatagramAfterBuffering) { - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); - MessageStatus initial_status = + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_BLOCKED)); + DatagramStatus initial_status = queue_.SendOrQueueDatagram(CreateMemSlice("test")); - EXPECT_EQ(MESSAGE_STATUS_BLOCKED, initial_status); + EXPECT_EQ(DATAGRAM_STATUS_BLOCKED, initial_status); EXPECT_EQ(1u, queue_.queue_size()); // Verify getting write blocked does not remove the datagram from the queue. - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); - std::optional<MessageStatus> status = queue_.TrySendingNextDatagram(); - ASSERT_TRUE(status.has_value()); - EXPECT_EQ(MESSAGE_STATUS_BLOCKED, *status); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_BLOCKED)); + std::optional<DatagramStatus> status = queue_.TrySendingNextDatagram(); + EXPECT_TRUE(status.has_value() && DATAGRAM_STATUS_BLOCKED == *status); EXPECT_EQ(1u, queue_.queue_size()); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_SUCCESS)); status = queue_.TrySendingNextDatagram(); - ASSERT_TRUE(status.has_value()); - EXPECT_EQ(MESSAGE_STATUS_SUCCESS, *status); + EXPECT_TRUE(status.has_value() && DATAGRAM_STATUS_SUCCESS == *status); EXPECT_EQ(0u, queue_.queue_size()); } TEST_F(QuicDatagramQueueTest, EmptyBuffer) { - std::optional<MessageStatus> status = queue_.TrySendingNextDatagram(); + std::optional<DatagramStatus> status = queue_.TrySendingNextDatagram(); EXPECT_FALSE(status.has_value()); size_t num_messages = queue_.SendDatagrams(); @@ -133,19 +131,19 @@ } TEST_F(QuicDatagramQueueTest, MultipleDatagrams) { - // Note that SendMessage() is called only once here, since all the remaining + // Note that SendDatagram() is called only once here, since all the remaining // messages are automatically queued due to the queue being non-empty. - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_BLOCKED)); queue_.SendOrQueueDatagram(CreateMemSlice("a")); queue_.SendOrQueueDatagram(CreateMemSlice("b")); queue_.SendOrQueueDatagram(CreateMemSlice("c")); queue_.SendOrQueueDatagram(CreateMemSlice("d")); queue_.SendOrQueueDatagram(CreateMemSlice("e")); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) .Times(5) - .WillRepeatedly(Return(MESSAGE_STATUS_SUCCESS)); + .WillRepeatedly(Return(DATAGRAM_STATUS_SUCCESS)); size_t num_messages = queue_.SendDatagrams(); EXPECT_EQ(5u, num_messages); } @@ -166,8 +164,8 @@ constexpr QuicTime::Delta expiry = QuicTime::Delta::FromMilliseconds(100); queue_.SetMaxTimeInQueue(expiry); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_BLOCKED)); queue_.SendOrQueueDatagram(CreateMemSlice("a")); helper_.AdvanceTime(0.6 * expiry); queue_.SendOrQueueDatagram(CreateMemSlice("b")); @@ -175,12 +173,12 @@ queue_.SendOrQueueDatagram(CreateMemSlice("c")); std::vector<std::string> messages; - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillRepeatedly([&messages](QuicMessageId /*id*/, + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillRepeatedly([&messages](QuicDatagramId /*id*/, absl::Span<quiche::QuicheMemSlice> message, bool /*flush*/) { messages.push_back(std::string(message[0].AsStringView())); - return MESSAGE_STATUS_SUCCESS; + return DATAGRAM_STATUS_SUCCESS; }); EXPECT_EQ(2u, queue_.SendDatagrams()); EXPECT_THAT(messages, ElementsAre("b", "c")); @@ -190,14 +188,14 @@ constexpr QuicTime::Delta expiry = QuicTime::Delta::FromMilliseconds(100); queue_.SetMaxTimeInQueue(expiry); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_BLOCKED)); queue_.SendOrQueueDatagram(CreateMemSlice("a")); queue_.SendOrQueueDatagram(CreateMemSlice("b")); queue_.SendOrQueueDatagram(CreateMemSlice("c")); helper_.AdvanceTime(100 * expiry); - EXPECT_CALL(*connection_, SendMessage(_, _, _)).Times(0); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)).Times(0); EXPECT_EQ(0u, queue_.SendDatagrams()); } @@ -220,34 +218,34 @@ TEST_F(QuicDatagramQueueWithObserverTest, ObserveSuccessImmediately) { EXPECT_TRUE(context_->statuses.empty()); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_SUCCESS)); - EXPECT_EQ(MESSAGE_STATUS_SUCCESS, + EXPECT_EQ(DATAGRAM_STATUS_SUCCESS, queue_.SendOrQueueDatagram(CreateMemSlice("a"))); - EXPECT_THAT(context_->statuses, ElementsAre(MESSAGE_STATUS_SUCCESS)); + EXPECT_THAT(context_->statuses, ElementsAre(DATAGRAM_STATUS_SUCCESS)); } TEST_F(QuicDatagramQueueWithObserverTest, ObserveFailureImmediately) { EXPECT_TRUE(context_->statuses.empty()); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_TOO_LARGE)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_TOO_LARGE)); - EXPECT_EQ(MESSAGE_STATUS_TOO_LARGE, + EXPECT_EQ(DATAGRAM_STATUS_TOO_LARGE, queue_.SendOrQueueDatagram(CreateMemSlice("a"))); - EXPECT_THAT(context_->statuses, ElementsAre(MESSAGE_STATUS_TOO_LARGE)); + EXPECT_THAT(context_->statuses, ElementsAre(DATAGRAM_STATUS_TOO_LARGE)); } TEST_F(QuicDatagramQueueWithObserverTest, BlockingShouldNotBeObserved) { EXPECT_TRUE(context_->statuses.empty()); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillRepeatedly(Return(MESSAGE_STATUS_BLOCKED)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillRepeatedly(Return(DATAGRAM_STATUS_BLOCKED)); - EXPECT_EQ(MESSAGE_STATUS_BLOCKED, + EXPECT_EQ(DATAGRAM_STATUS_BLOCKED, queue_.SendOrQueueDatagram(CreateMemSlice("a"))); EXPECT_EQ(0u, queue_.SendDatagrams()); @@ -257,19 +255,19 @@ TEST_F(QuicDatagramQueueWithObserverTest, ObserveSuccessAfterBuffering) { EXPECT_TRUE(context_->statuses.empty()); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_BLOCKED)); - EXPECT_EQ(MESSAGE_STATUS_BLOCKED, + EXPECT_EQ(DATAGRAM_STATUS_BLOCKED, queue_.SendOrQueueDatagram(CreateMemSlice("a"))); EXPECT_TRUE(context_->statuses.empty()); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_SUCCESS)); EXPECT_EQ(1u, queue_.SendDatagrams()); - EXPECT_THAT(context_->statuses, ElementsAre(MESSAGE_STATUS_SUCCESS)); + EXPECT_THAT(context_->statuses, ElementsAre(DATAGRAM_STATUS_SUCCESS)); } TEST_F(QuicDatagramQueueWithObserverTest, ObserveExpiry) { @@ -278,15 +276,15 @@ EXPECT_TRUE(context_->statuses.empty()); - EXPECT_CALL(*connection_, SendMessage(_, _, _)) - .WillOnce(Return(MESSAGE_STATUS_BLOCKED)); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)) + .WillOnce(Return(DATAGRAM_STATUS_BLOCKED)); - EXPECT_EQ(MESSAGE_STATUS_BLOCKED, + EXPECT_EQ(DATAGRAM_STATUS_BLOCKED, queue_.SendOrQueueDatagram(CreateMemSlice("a"))); EXPECT_TRUE(context_->statuses.empty()); - EXPECT_CALL(*connection_, SendMessage(_, _, _)).Times(0); + EXPECT_CALL(*connection_, SendDatagram(_, _, _)).Times(0); helper_.AdvanceTime(100 * expiry); EXPECT_TRUE(context_->statuses.empty());
diff --git a/quiche/quic/core/quic_error_codes.cc b/quiche/quic/core/quic_error_codes.cc index 3863584..3353f46 100644 --- a/quiche/quic/core/quic_error_codes.cc +++ b/quiche/quic/core/quic_error_codes.cc
@@ -188,7 +188,7 @@ RETURN_STRING_LITERAL(QUIC_INVALID_PATH_RESPONSE_DATA); RETURN_STRING_LITERAL(QUIC_CONNECTION_MIGRATION_HANDSHAKE_UNCONFIRMED); RETURN_STRING_LITERAL(QUIC_PEER_PORT_CHANGE_HANDSHAKE_UNCONFIRMED); - RETURN_STRING_LITERAL(QUIC_INVALID_MESSAGE_DATA); + RETURN_STRING_LITERAL(QUIC_INVALID_DATAGRAM_DATA); RETURN_STRING_LITERAL(IETF_QUIC_PROTOCOL_VIOLATION); RETURN_STRING_LITERAL(QUIC_INVALID_NEW_TOKEN); RETURN_STRING_LITERAL(QUIC_DATA_RECEIVED_ON_WRITE_UNIDIRECTIONAL_STREAM); @@ -391,7 +391,7 @@ return {true, static_cast<uint64_t>(INTERNAL_ERROR)}; case QUIC_INVALID_ACK_DATA: return {true, static_cast<uint64_t>(FRAME_ENCODING_ERROR)}; - case QUIC_INVALID_MESSAGE_DATA: + case QUIC_INVALID_DATAGRAM_DATA: return {true, static_cast<uint64_t>(FRAME_ENCODING_ERROR)}; case QUIC_INVALID_VERSION_NEGOTIATION_PACKET: return {true, static_cast<uint64_t>(PROTOCOL_VIOLATION)};
diff --git a/quiche/quic/core/quic_error_codes.h b/quiche/quic/core/quic_error_codes.h index 64a3fbb..415e79f 100644 --- a/quiche/quic/core/quic_error_codes.h +++ b/quiche/quic/core/quic_error_codes.h
@@ -169,7 +169,7 @@ // ACK frame data is malformed. QUIC_INVALID_ACK_DATA = 9, // Message frame data is malformed. - QUIC_INVALID_MESSAGE_DATA = 112, + QUIC_INVALID_DATAGRAM_DATA = 112, // Version negotiation packet is malformed. QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10,
diff --git a/quiche/quic/core/quic_framer.cc b/quiche/quic/core/quic_framer.cc index 977082a..2b34775 100644 --- a/quiche/quic/core/quic_framer.cc +++ b/quiche/quic/core/quic_framer.cc
@@ -36,6 +36,7 @@ #include "quiche/quic/core/crypto/quic_encrypter.h" #include "quiche/quic/core/crypto/quic_random.h" #include "quiche/quic/core/frames/quic_ack_frequency_frame.h" +#include "quiche/quic/core/frames/quic_datagram_frame.h" #include "quiche/quic/core/frames/quic_immediate_ack_frame.h" #include "quiche/quic/core/frames/quic_reset_stream_at_frame.h" #include "quiche/quic/core/quic_connection_id.h" @@ -460,8 +461,8 @@ } // static -size_t QuicFramer::GetMessageFrameSize(bool last_frame_in_packet, - QuicByteCount length) { +size_t QuicFramer::GetDatagramFrameSize(bool last_frame_in_packet, + QuicByteCount length) { return kQuicFrameTypeSize + (last_frame_in_packet ? 0 : QuicDataWriter::GetVarInt62Len(length)) + length; @@ -708,7 +709,7 @@ case STOP_WAITING_FRAME: case MTU_DISCOVERY_FRAME: case PADDING_FRAME: - case MESSAGE_FRAME: + case DATAGRAM_FRAME: case CRYPTO_FRAME: case NUM_FRAME_TYPES: QUICHE_DCHECK(false); @@ -1004,10 +1005,10 @@ set_detailed_error( "Attempt to append STOP_SENDING frame and not in IETF QUIC."); return RaiseError(QUIC_INTERNAL_ERROR); - case MESSAGE_FRAME: - if (!AppendMessageFrameAndTypeByte(*frame.message_frame, - last_frame_in_packet, &writer)) { - QUIC_BUG(quic_bug_10850_27) << "AppendMessageFrame failed"; + case DATAGRAM_FRAME: + if (!AppendDatagramFrameAndTypeByte(*frame.datagram_frame, + last_frame_in_packet, &writer)) { + QUIC_BUG(quic_bug_10850_27) << "AppendDatagramFrame failed"; return 0; } break; @@ -1192,11 +1193,11 @@ return 0; } break; - case MESSAGE_FRAME: - if (!AppendMessageFrameAndTypeByte(*frame.message_frame, - last_frame_in_packet, writer)) { + case DATAGRAM_FRAME: + if (!AppendDatagramFrameAndTypeByte(*frame.datagram_frame, + last_frame_in_packet, writer)) { QUIC_BUG(quic_bug_10850_49) - << "AppendMessageFrame failed: " << detailed_error(); + << "AppendDatagramFrame failed: " << detailed_error(); return 0; } break; @@ -2703,19 +2704,19 @@ QUIC_DVLOG(2) << ENDPOINT << "Processing ping frame " << ping_frame; continue; } - case IETF_EXTENSION_MESSAGE_NO_LENGTH: + case IETF_EXTENSION_DATAGRAM_NO_LENGTH: ABSL_FALLTHROUGH_INTENDED; - case IETF_EXTENSION_MESSAGE: { - QUIC_CODE_COUNT(quic_legacy_message_frame_codepoint_read); - QuicMessageFrame message_frame; - if (!ProcessMessageFrame(reader, - frame_type == IETF_EXTENSION_MESSAGE_NO_LENGTH, - &message_frame)) { - return RaiseError(QUIC_INVALID_MESSAGE_DATA); + case IETF_EXTENSION_DATAGRAM: { + QUIC_CODE_COUNT(quic_legacy_datagram_frame_codepoint_read); + QuicDatagramFrame datagram_frame; + if (!ProcessDatagramFrame( + reader, frame_type == IETF_EXTENSION_DATAGRAM_NO_LENGTH, + &datagram_frame)) { + return RaiseError(QUIC_INVALID_DATAGRAM_DATA); } - QUIC_DVLOG(2) << ENDPOINT << "Processing message frame " - << message_frame; - if (!visitor_->OnMessageFrame(message_frame)) { + QUIC_DVLOG(2) << ENDPOINT << "Processing datagram frame " + << datagram_frame; + if (!visitor_->OnDatagramFrame(datagram_frame)) { QUIC_DVLOG(1) << ENDPOINT << "Visitor asked to stop further processing."; // Returning true since there was no parsing error. @@ -3098,18 +3099,18 @@ } break; } - case IETF_EXTENSION_MESSAGE_NO_LENGTH_V99: + case IETF_EXTENSION_DATAGRAM_NO_LENGTH_V99: ABSL_FALLTHROUGH_INTENDED; - case IETF_EXTENSION_MESSAGE_V99: { - QuicMessageFrame message_frame; - if (!ProcessMessageFrame( - reader, frame_type == IETF_EXTENSION_MESSAGE_NO_LENGTH_V99, - &message_frame)) { - return RaiseError(QUIC_INVALID_MESSAGE_DATA); + case IETF_EXTENSION_DATAGRAM_V99: { + QuicDatagramFrame datagram_frame; + if (!ProcessDatagramFrame( + reader, frame_type == IETF_EXTENSION_DATAGRAM_NO_LENGTH_V99, + &datagram_frame)) { + return RaiseError(QUIC_INVALID_DATAGRAM_DATA); } - QUIC_DVLOG(2) << ENDPOINT << "Processing IETF message frame " - << message_frame; - if (!visitor_->OnMessageFrame(message_frame)) { + QUIC_DVLOG(2) << ENDPOINT << "Processing IETF datagram frame " + << datagram_frame; + if (!visitor_->OnDatagramFrame(datagram_frame)) { QUIC_DVLOG(1) << ENDPOINT << "Visitor asked to stop further processing."; // Returning true since there was no parsing error. @@ -4014,30 +4015,30 @@ } } -bool QuicFramer::ProcessMessageFrame(QuicDataReader* reader, - bool no_message_length, - QuicMessageFrame* frame) { - if (no_message_length) { +bool QuicFramer::ProcessDatagramFrame(QuicDataReader* reader, + bool no_datagram_length, + QuicDatagramFrame* frame) { + if (no_datagram_length) { absl::string_view remaining(reader->ReadRemainingPayload()); frame->data = remaining.data(); - frame->message_length = remaining.length(); + frame->datagram_length = remaining.length(); return true; } - uint64_t message_length; - if (!reader->ReadVarInt62(&message_length)) { - set_detailed_error("Unable to read message length"); + uint64_t datagram_length; + if (!reader->ReadVarInt62(&datagram_length)) { + set_detailed_error("Unable to read datagram length"); return false; } - absl::string_view message_piece; - if (!reader->ReadStringPiece(&message_piece, message_length)) { - set_detailed_error("Unable to read message data"); + absl::string_view datagram_piece; + if (!reader->ReadStringPiece(&datagram_piece, datagram_length)) { + set_detailed_error("Unable to read datagram data"); return false; } - frame->data = message_piece.data(); - frame->message_length = message_length; + frame->data = datagram_piece.data(); + frame->datagram_length = datagram_length; return true; } @@ -4826,9 +4827,9 @@ case MTU_DISCOVERY_FRAME: // MTU discovery frames are serialized as ping frames. return kQuicFrameTypeSize; - case MESSAGE_FRAME: - return GetMessageFrameSize(last_frame_in_packet, - frame.message_frame->message_length); + case DATAGRAM_FRAME: + return GetDatagramFrameSize(last_frame_in_packet, + frame.datagram_frame->datagram_length); case PADDING_FRAME: QUICHE_DCHECK(false); return 0; @@ -4887,7 +4888,7 @@ set_detailed_error( "Attempt to append STOP_SENDING frame and not in IETF QUIC."); return RaiseError(QUIC_INTERNAL_ERROR); - case MESSAGE_FRAME: + case DATAGRAM_FRAME: return true; default: @@ -4997,7 +4998,7 @@ case STOP_SENDING_FRAME: type_byte = IETF_STOP_SENDING; break; - case MESSAGE_FRAME: + case DATAGRAM_FRAME: return true; case CRYPTO_FRAME: type_byte = IETF_CRYPTO; @@ -5882,25 +5883,25 @@ return writer->WritePaddingBytes(frame.num_padding_bytes - 1); } -bool QuicFramer::AppendMessageFrameAndTypeByte(const QuicMessageFrame& frame, - bool last_frame_in_packet, - QuicDataWriter* writer) { +bool QuicFramer::AppendDatagramFrameAndTypeByte(const QuicDatagramFrame& frame, + bool last_frame_in_packet, + QuicDataWriter* writer) { uint8_t type_byte; if (VersionHasIetfQuicFrames(version_.transport_version)) { - type_byte = last_frame_in_packet ? IETF_EXTENSION_MESSAGE_NO_LENGTH_V99 - : IETF_EXTENSION_MESSAGE_V99; + type_byte = last_frame_in_packet ? IETF_EXTENSION_DATAGRAM_NO_LENGTH_V99 + : IETF_EXTENSION_DATAGRAM_V99; } else { - QUIC_CODE_COUNT(quic_legacy_message_frame_codepoint_write); - type_byte = last_frame_in_packet ? IETF_EXTENSION_MESSAGE_NO_LENGTH - : IETF_EXTENSION_MESSAGE; + QUIC_CODE_COUNT(quic_legacy_datagram_frame_codepoint_write); + type_byte = last_frame_in_packet ? IETF_EXTENSION_DATAGRAM_NO_LENGTH + : IETF_EXTENSION_DATAGRAM; } if (!writer->WriteUInt8(type_byte)) { return false; } - if (!last_frame_in_packet && !writer->WriteVarInt62(frame.message_length)) { + if (!last_frame_in_packet && !writer->WriteVarInt62(frame.datagram_length)) { return false; } - for (const auto& slice : frame.message_data) { + for (const auto& slice : frame.datagram_data) { if (!writer->WriteBytes(slice.data(), slice.length())) { return false; }
diff --git a/quiche/quic/core/quic_framer.h b/quiche/quic/core/quic_framer.h index 7cacc3f..91d67d5 100644 --- a/quiche/quic/core/quic_framer.h +++ b/quiche/quic/core/quic_framer.h
@@ -16,6 +16,7 @@ #include "quiche/quic/core/crypto/quic_decrypter.h" #include "quiche/quic/core/crypto/quic_encrypter.h" #include "quiche/quic/core/crypto/quic_random.h" +#include "quiche/quic/core/frames/quic_datagram_frame.h" #include "quiche/quic/core/frames/quic_immediate_ack_frame.h" #include "quiche/quic/core/frames/quic_reset_stream_at_frame.h" #include "quiche/quic/core/quic_connection_id.h" @@ -217,8 +218,8 @@ // Called when a NewTokenFrame has been parsed. virtual bool OnNewTokenFrame(const QuicNewTokenFrame& frame) = 0; - // Called when a message frame has been parsed. - virtual bool OnMessageFrame(const QuicMessageFrame& frame) = 0; + // Called when a Datagrame frame has been parsed. + virtual bool OnDatagramFrame(const QuicDatagramFrame& frame) = 0; // Called when a handshake done frame has been parsed. virtual bool OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) = 0; @@ -361,8 +362,8 @@ // data length provided, but not counting the size of the data payload. static size_t GetMinCryptoFrameSize(QuicStreamOffset offset, QuicPacketLength data_length); - static size_t GetMessageFrameSize(bool last_frame_in_packet, - QuicByteCount length); + static size_t GetDatagramFrameSize(bool last_frame_in_packet, + QuicByteCount length); // Size in bytes of all ack frame fields without the missing packets or ack // blocks. static size_t GetMinAckFrameSize(QuicTransportVersion version, @@ -905,8 +906,8 @@ QuicWindowUpdateFrame* frame); bool ProcessBlockedFrame(QuicDataReader* reader, QuicBlockedFrame* frame); void ProcessPaddingFrame(QuicDataReader* reader, QuicPaddingFrame* frame); - bool ProcessMessageFrame(QuicDataReader* reader, bool no_message_length, - QuicMessageFrame* frame); + bool ProcessDatagramFrame(QuicDataReader* reader, bool no_datagram_length, + QuicDatagramFrame* frame); bool DecryptPayload(size_t udp_packet_length, absl::string_view encrypted, absl::string_view associated_data, @@ -1000,9 +1001,9 @@ QuicDataWriter* writer); bool AppendPaddingFrame(const QuicPaddingFrame& frame, QuicDataWriter* writer); - bool AppendMessageFrameAndTypeByte(const QuicMessageFrame& frame, - bool last_frame_in_packet, - QuicDataWriter* writer); + bool AppendDatagramFrameAndTypeByte(const QuicDatagramFrame& frame, + bool last_frame_in_packet, + QuicDataWriter* writer); // IETF frame processing methods. bool ProcessIetfStreamFrame(QuicDataReader* reader, uint8_t frame_type,
diff --git a/quiche/quic/core/quic_framer_test.cc b/quiche/quic/core/quic_framer_test.cc index ecefa2a..e43c385 100644 --- a/quiche/quic/core/quic_framer_test.cc +++ b/quiche/quic/core/quic_framer_test.cc
@@ -428,14 +428,14 @@ return true; } - bool OnMessageFrame(const QuicMessageFrame& frame) override { + bool OnDatagramFrame(const QuicDatagramFrame& frame) override { ++frame_count_; - message_frames_.push_back( - std::make_unique<QuicMessageFrame>(frame.data, frame.message_length)); + datagram_frames_.push_back( + std::make_unique<QuicDatagramFrame>(frame.data, frame.datagram_length)); if (VersionHasIetfQuicFrames(transport_version_)) { - EXPECT_TRUE(IETF_EXTENSION_MESSAGE_NO_LENGTH_V99 == + EXPECT_TRUE(IETF_EXTENSION_DATAGRAM_NO_LENGTH_V99 == framer_->current_received_frame_type() || - IETF_EXTENSION_MESSAGE_V99 == + IETF_EXTENSION_DATAGRAM_V99 == framer_->current_received_frame_type()); } else { EXPECT_EQ(0u, framer_->current_received_frame_type()); @@ -667,7 +667,7 @@ std::vector<std::unique_ptr<QuicStopWaitingFrame>> stop_waiting_frames_; std::vector<std::unique_ptr<QuicPaddingFrame>> padding_frames_; std::vector<std::unique_ptr<QuicPingFrame>> ping_frames_; - std::vector<std::unique_ptr<QuicMessageFrame>> message_frames_; + std::vector<std::unique_ptr<QuicDatagramFrame>> datagram_frames_; std::vector<std::unique_ptr<QuicHandshakeDoneFrame>> handshake_done_frames_; std::vector<std::unique_ptr<QuicAckFrequencyFrame>> ack_frequency_frames_; std::vector<std::unique_ptr<QuicImmediateAckFrame>> immediate_ack_frames_; @@ -4986,7 +4986,7 @@ EXPECT_EQ(visitor_.reset_stream_at_frames_.size(), 0); } -TEST_P(QuicFramerTest, MessageFrame) { +TEST_P(QuicFramerTest, DatagramFrame) { SetDecrypterLevel(ENCRYPTION_FORWARD_SECURE); // clang-format off PacketFragments packet = { @@ -4999,19 +4999,19 @@ // packet number {"", {0x12, 0x34, 0x56, 0x78}}, - // message frame type. + // datagram frame type. {"", { 0x21 }}, - // message length - {"Unable to read message length", + // datagram length + {"Unable to read datagram length", {0x07}}, - // message data - {"Unable to read message data", + // datagram data + {"Unable to read datagram data", {'m', 'e', 's', 's', 'a', 'g', 'e'}}, - // message frame no length. + // datagram frame no length. {"", { 0x20 }}, - // message data + // datagram data {{}, {'m', 'e', 's', 's', 'a', 'g', 'e', '2'}}, }; @@ -5025,19 +5025,19 @@ // packet number {"", {0x12, 0x34, 0x56, 0x78}}, - // message frame type. + // datagram frame type. {"", { 0x31 }}, - // message length - {"Unable to read message length", + // datagram length + {"Unable to read datagram length", {0x07}}, - // message data - {"Unable to read message data", + // datagram data + {"Unable to read datagram data", {'m', 'e', 's', 's', 'a', 'g', 'e'}}, - // message frame no length. + // datagram frame no length. {"", { 0x30 }}, - // message data + // datagram data {{}, {'m', 'e', 's', 's', 'a', 'g', 'e', '2'}}, }; @@ -5057,14 +5057,14 @@ *encrypted, !kIncludeVersion, !kIncludeDiversificationNonce, kPacket8ByteConnectionId, kPacket0ByteConnectionId)); - ASSERT_EQ(2u, visitor_.message_frames_.size()); - EXPECT_EQ(7u, visitor_.message_frames_[0]->message_length); - EXPECT_EQ(8u, visitor_.message_frames_[1]->message_length); + ASSERT_EQ(2u, visitor_.datagram_frames_.size()); + EXPECT_EQ(7u, visitor_.datagram_frames_[0]->datagram_length); + EXPECT_EQ(8u, visitor_.datagram_frames_[1]->datagram_length); if (VersionHasIetfQuicFrames(framer_.transport_version())) { - CheckFramingBoundaries(packet_ietf, QUIC_INVALID_MESSAGE_DATA); + CheckFramingBoundaries(packet_ietf, QUIC_INVALID_DATAGRAM_DATA); } else { - CheckFramingBoundaries(packet, QUIC_INVALID_MESSAGE_DATA); + CheckFramingBoundaries(packet, QUIC_INVALID_DATAGRAM_DATA); } } @@ -8368,7 +8368,7 @@ ABSL_ARRAYSIZE(packet)); } -TEST_P(QuicFramerTest, BuildMessagePacket) { +TEST_P(QuicFramerTest, BuildDatagramPacket) { QuicFramerPeer::SetPerspective(&framer_, Perspective::IS_CLIENT); QuicPacketHeader header; header.destination_connection_id = FramerTestConnectionId(); @@ -8376,8 +8376,8 @@ header.version_flag = false; header.packet_number = kPacketNumber; - QuicMessageFrame frame(1, MemSliceFromString("message")); - QuicMessageFrame frame2(2, MemSliceFromString("message2")); + QuicDatagramFrame frame(1, MemSliceFromString("message")); + QuicDatagramFrame frame2(2, MemSliceFromString("message2")); QuicFrames frames = {QuicFrame(&frame), QuicFrame(&frame2)}; // clang-format off @@ -8389,15 +8389,15 @@ // packet number 0x12, 0x34, 0x56, 0x78, - // frame type (message frame) + // frame type (datagram frame) 0x21, // Length 0x07, - // Message Data + // Datagram Data 'm', 'e', 's', 's', 'a', 'g', 'e', - // frame type (message frame no length) + // frame type (datagram frame no length) 0x20, - // Message Data + // Datagram Data 'm', 'e', 's', 's', 'a', 'g', 'e', '2' }; @@ -8409,15 +8409,15 @@ // packet number 0x12, 0x34, 0x56, 0x78, - // frame type (IETF_MESSAGE frame) + // frame type (IETF_DATAGRAM frame) 0x31, // Length 0x07, - // Message Data + // Datagram Data 'm', 'e', 's', 's', 'a', 'g', 'e', - // frame type (message frame no length) + // frame type (datagram frame no length) 0x30, - // Message Data + // Datagram Data 'm', 'e', 's', 's', 'a', 'g', 'e', '2' }; // clang-format on
diff --git a/quiche/quic/core/quic_generic_session.cc b/quiche/quic/core/quic_generic_session.cc index 2323806..a687f74 100644 --- a/quiche/quic/core/quic_generic_session.cc +++ b/quiche/quic/core/quic_generic_session.cc
@@ -178,8 +178,8 @@ return stream_ptr; } -void QuicGenericSessionBase::OnMessageReceived(absl::string_view message) { - visitor_->OnDatagramReceived(message); +void QuicGenericSessionBase::OnDatagramReceived(absl::string_view datagram) { + visitor_->OnDatagramReceived(datagram); } void QuicGenericSessionBase::OnCanCreateNewOutgoingStream(bool unidirectional) { @@ -203,7 +203,7 @@ absl::string_view datagram) { quiche::QuicheBuffer buffer = quiche::QuicheBuffer::Copy( quiche::SimpleBufferAllocator::Get(), datagram); - return MessageStatusToWebTransportStatus( + return DatagramStatusToWebTransportStatus( datagram_queue()->SendOrQueueDatagram( quiche::QuicheMemSlice(std::move(buffer)))); }
diff --git a/quiche/quic/core/quic_generic_session.h b/quiche/quic/core/quic_generic_session.h index a3e7a0c..aea69ad 100644 --- a/quiche/quic/core/quic_generic_session.h +++ b/quiche/quic/core/quic_generic_session.h
@@ -80,7 +80,7 @@ } void OnTlsHandshakeComplete() override; - void OnMessageReceived(absl::string_view message) override; + void OnDatagramReceived(absl::string_view datagram) override; // webtransport::Session implementation. webtransport::Stream* AcceptIncomingBidirectionalStream() override; @@ -123,7 +123,7 @@ } QuicByteCount GetMaxDatagramSize() const override { - return GetGuaranteedLargestMessagePayload(); + return GetGuaranteedLargestDatagramPayload(); } private:
diff --git a/quiche/quic/core/quic_generic_session_test.cc b/quiche/quic/core/quic_generic_session_test.cc index 752dedf..985403b 100644 --- a/quiche/quic/core/quic_generic_session_test.cc +++ b/quiche/quic/core/quic_generic_session_test.cc
@@ -81,7 +81,7 @@ class CountingDatagramObserver : public QuicDatagramQueue::Observer { public: CountingDatagramObserver(int& total) : total_(total) {} - void OnDatagramProcessed(std::optional<MessageStatus>) { ++total_; } + void OnDatagramProcessed(std::optional<DatagramStatus>) { ++total_; } private: int& total_; @@ -400,7 +400,7 @@ (10000 * simulator::TestHarness::kRtt).ToAbsl()); for (int i = 0; i < 1000; i++) { client_->session()->SendOrQueueDatagram(std::string( - client_->session()->GetGuaranteedLargestMessagePayload(), 'a')); + client_->session()->GetGuaranteedLargestDatagramPayload(), 'a')); } size_t received = 0; @@ -453,7 +453,7 @@ (0.2 * simulator::TestHarness::kRtt).ToAbsl()); for (int i = 0; i < 1000; i++) { client_->session()->SendOrQueueDatagram(std::string( - client_->session()->GetGuaranteedLargestMessagePayload(), 'a')); + client_->session()->GetGuaranteedLargestDatagramPayload(), 'a')); } size_t received = 0; @@ -481,7 +481,7 @@ (10000 * simulator::TestHarness::kRtt).ToAbsl()); for (int i = 0; i < 1000; i++) { client_->session()->SendOrQueueDatagram(std::string( - client_->session()->GetGuaranteedLargestMessagePayload(), 'a')); + client_->session()->GetGuaranteedLargestDatagramPayload(), 'a')); } size_t received = 0;
diff --git a/quiche/quic/core/quic_packet_creator.cc b/quiche/quic/core/quic_packet_creator.cc index 67ea97f..e81d548 100644 --- a/quiche/quic/core/quic_packet_creator.cc +++ b/quiche/quic/core/quic_packet_creator.cc
@@ -360,20 +360,20 @@ return BytesFree() > min_stream_frame_size; } -bool QuicPacketCreator::HasRoomForMessageFrame(QuicByteCount length) { - const size_t message_frame_size = - QuicFramer::GetMessageFrameSize(/*last_frame_in_packet=*/true, length); - if (static_cast<QuicByteCount>(message_frame_size) > +bool QuicPacketCreator::HasRoomForDatagramFrame(QuicByteCount length) { + const size_t datagram_frame_size = + QuicFramer::GetDatagramFrameSize(/*last_frame_in_packet=*/true, length); + if (static_cast<QuicByteCount>(datagram_frame_size) > max_datagram_frame_size_) { return false; } - if (BytesFree() >= message_frame_size) { + if (BytesFree() >= datagram_frame_size) { return true; } if (!RemoveSoftMaxPacketLength()) { return false; } - return BytesFree() >= message_frame_size; + return BytesFree() >= datagram_frame_size; } // static @@ -498,7 +498,7 @@ packet_.encrypted_buffer = nullptr; packet_.encrypted_length = 0; packet_.has_ack_frequency = false; - packet_.has_message = false; + packet_.has_datagram = false; packet_.fate = SEND_TO_WRITER; QUIC_BUG_IF(quic_bug_12398_6, packet_.release_encrypted_buffer != nullptr) << ENDPOINT << "packet_.release_encrypted_buffer should be empty"; @@ -722,8 +722,8 @@ } size_t QuicPacketCreator::ExpansionOnNewFrame() const { - // If the last frame in the packet is a message frame, then it will expand to - // include the varint message length when a new frame is added. + // If the last frame in the packet is a datagram frame, then it will expand to + // include the varint datagram length when a new frame is added. if (queued_frames_.empty()) { return 0; } @@ -734,9 +734,9 @@ // static size_t QuicPacketCreator::ExpansionOnNewFrameWithLastFrame( const QuicFrame& last_frame, QuicTransportVersion version) { - if (last_frame.type == MESSAGE_FRAME) { + if (last_frame.type == DATAGRAM_FRAME) { return QuicDataWriter::GetVarInt62Len( - last_frame.message_frame->message_length); + last_frame.datagram_frame->datagram_length); } if (last_frame.type != STREAM_FRAME) { return 0; @@ -1825,31 +1825,31 @@ next_transmission_type_ = type; } -MessageStatus QuicPacketCreator::AddMessageFrame( - QuicMessageId message_id, absl::Span<quiche::QuicheMemSlice> message) { +DatagramStatus QuicPacketCreator::AddDatagramFrame( + QuicDatagramId datagram_id, absl::Span<quiche::QuicheMemSlice> datagram) { QUIC_BUG_IF(quic_bug_10752_33, !flusher_attached_) << ENDPOINT << "Packet flusher is not attached when " - "generator tries to add message frame."; + "generator tries to add datagram frame."; MaybeBundleOpportunistically(); - const QuicByteCount message_length = MemSliceSpanTotalSize(message); - if (message_length > GetCurrentLargestMessagePayload()) { - return MESSAGE_STATUS_TOO_LARGE; + const QuicByteCount datagram_length = MemSliceSpanTotalSize(datagram); + if (datagram_length > GetCurrentLargestDatagramPayload()) { + return DATAGRAM_STATUS_TOO_LARGE; } - if (!HasRoomForMessageFrame(message_length)) { + if (!HasRoomForDatagramFrame(datagram_length)) { FlushCurrentPacket(); } - QuicMessageFrame* frame = new QuicMessageFrame(message_id, message); + QuicDatagramFrame* frame = new QuicDatagramFrame(datagram_id, datagram); const bool success = AddFrame(QuicFrame(frame), next_transmission_type_); if (!success) { QUIC_BUG(quic_bug_10752_34) - << ENDPOINT << "Failed to send message " << message_id; + << ENDPOINT << "Failed to send datagram " << datagram_id; delete frame; - return MESSAGE_STATUS_INTERNAL_ERROR; + return DATAGRAM_STATUS_INTERNAL_ERROR; } - QUICHE_DCHECK_EQ(MemSliceSpanTotalSize(message), + QUICHE_DCHECK_EQ(MemSliceSpanTotalSize(datagram), 0u); // Ensure the old slices are empty. - return MESSAGE_STATUS_SUCCESS; + return DATAGRAM_STATUS_SUCCESS; } quiche::QuicheVariableLengthIntegerLength QuicPacketCreator::GetLengthLength() @@ -1951,7 +1951,7 @@ frame.type != MAX_STREAMS_FRAME && frame.type != STREAMS_BLOCKED_FRAME && frame.type != PATH_RESPONSE_FRAME && frame.type != PATH_CHALLENGE_FRAME && frame.type != STOP_SENDING_FRAME && - frame.type != MESSAGE_FRAME && frame.type != NEW_TOKEN_FRAME && + frame.type != DATAGRAM_FRAME && frame.type != NEW_TOKEN_FRAME && frame.type != RETIRE_CONNECTION_ID_FRAME && frame.type != ACK_FREQUENCY_FRAME)) << ENDPOINT << frame.type << " not allowed at " @@ -2023,8 +2023,8 @@ packet_.has_stop_waiting = true; } else if (frame.type == ACK_FREQUENCY_FRAME) { packet_.has_ack_frequency = true; - } else if (frame.type == MESSAGE_FRAME) { - packet_.has_message = true; + } else if (frame.type == DATAGRAM_FRAME) { + packet_.has_datagram = true; } if (debug_delegate_ != nullptr) { debug_delegate_->OnFrameAddedToPacket(frame); @@ -2216,14 +2216,14 @@ client_connection_id_ = client_connection_id; } -QuicPacketLength QuicPacketCreator::GetCurrentLargestMessagePayload() const { +QuicPacketLength QuicPacketCreator::GetCurrentLargestDatagramPayload() const { const size_t packet_header_size = GetPacketHeaderSize( framer_->transport_version(), GetDestinationConnectionIdLength(), GetSourceConnectionIdLength(), IncludeVersionInHeader(), IncludeNonceInPublicHeader(), GetPacketNumberLength(), // No Retry token on packets containing application data. quiche::VARIABLE_LENGTH_INTEGER_LENGTH_0, 0, GetLengthLength()); - // This is the largest possible message payload when the length field is + // This is the largest possible datagram payload when the length field is // omitted. size_t max_plaintext_size = latched_hard_max_packet_length_ == 0 @@ -2237,7 +2237,8 @@ return largest_frame - std::min(largest_frame, kQuicFrameTypeSize); } -QuicPacketLength QuicPacketCreator::GetGuaranteedLargestMessagePayload() const { +QuicPacketLength QuicPacketCreator::GetGuaranteedLargestDatagramPayload() + const { // QUIC Crypto server packets may include a diversification nonce. const bool may_include_nonce = framer_->version().handshake_protocol == PROTOCOL_QUIC_CRYPTO && @@ -2258,7 +2259,7 @@ PACKET_4BYTE_PACKET_NUMBER, // No Retry token on packets containing application data. quiche::VARIABLE_LENGTH_INTEGER_LENGTH_0, 0, length_length); - // This is the largest possible message payload when the length field is + // This is the largest possible datagram payload when the length field is // omitted. size_t max_plaintext_size = latched_hard_max_packet_length_ == 0 @@ -2271,8 +2272,8 @@ } const QuicPacketLength largest_payload = largest_frame - std::min(largest_frame, kQuicFrameTypeSize); - // This must always be less than or equal to GetCurrentLargestMessagePayload. - QUICHE_DCHECK_LE(largest_payload, GetCurrentLargestMessagePayload()) + // This must always be less than or equal to GetCurrentLargestDatagramPayload. + QUICHE_DCHECK_LE(largest_payload, GetCurrentLargestDatagramPayload()) << ENDPOINT; return largest_payload; }
diff --git a/quiche/quic/core/quic_packet_creator.h b/quiche/quic/core/quic_packet_creator.h index d4ca9b8..c07dd8d 100644 --- a/quiche/quic/core/quic_packet_creator.h +++ b/quiche/quic/core/quic_packet_creator.h
@@ -175,10 +175,10 @@ bool HasRoomForStreamFrame(QuicStreamId id, QuicStreamOffset offset, size_t data_size); - // Returns true if current open packet can accommodate a message frame of + // Returns true if current open packet can accommodate a datagram frame of // |length|. // TODO(fayang): mark this const by moving RemoveSoftMaxPacketLength out. - bool HasRoomForMessageFrame(QuicByteCount length); + bool HasRoomForDatagramFrame(QuicByteCount length); // Serializes all added frames into a single packet and invokes the delegate_ // to further process the SerializedPacket. @@ -354,7 +354,7 @@ // Sets the maximum packet length. void SetMaxPacketLength(QuicByteCount length); - // Sets the maximum DATAGRAM/MESSAGE frame size we can send. + // Sets the maximum DATAGRAM frame size we can send. void SetMaxDatagramFrameSize(QuicByteCount max_datagram_frame_size); // Set a soft maximum packet length in the creator. If a packet cannot be @@ -425,16 +425,16 @@ // Set transmission type of next constructed packets. void SetTransmissionType(TransmissionType type); - // Tries to add a message frame containing |message| and returns the status. - MessageStatus AddMessageFrame(QuicMessageId message_id, - absl::Span<quiche::QuicheMemSlice> message); + // Tries to add a datagram frame containing |datagram| and returns the status. + DatagramStatus AddDatagramFrame(QuicDatagramId datagram_id, + absl::Span<quiche::QuicheMemSlice> datagram); - // Returns the largest payload that will fit into a single MESSAGE frame. - QuicPacketLength GetCurrentLargestMessagePayload() const; - // Returns the largest payload that will fit into a single MESSAGE frame at + // Returns the largest payload that will fit into a single DATAGRAM frame. + QuicPacketLength GetCurrentLargestDatagramPayload() const; + // Returns the largest payload that will fit into a single DATAGRAM frame at // any point during the connection. This assumes the version and // connection ID lengths do not change. - QuicPacketLength GetGuaranteedLargestMessagePayload() const; + QuicPacketLength GetGuaranteedLargestDatagramPayload() const; // Packet number of next created packet. QuicPacketNumber NextSendingPacketNumber() const; @@ -717,7 +717,7 @@ // set to a soft value. QuicByteCount latched_hard_max_packet_length_; - // The maximum length of a MESSAGE/DATAGRAM frame that our peer is willing to + // The maximum length of a DATAGRAM frame that our peer is willing to // accept. There is no limit for QUIC_CRYPTO connections, but QUIC+TLS // negotiates this during the handshake. QuicByteCount max_datagram_frame_size_;
diff --git a/quiche/quic/core/quic_packet_creator_test.cc b/quiche/quic/core/quic_packet_creator_test.cc index 00dee87..176e731 100644 --- a/quiche/quic/core/quic_packet_creator_test.cc +++ b/quiche/quic/core/quic_packet_creator_test.cc
@@ -1798,7 +1798,7 @@ SerializeAllFrames(frames_); } -TEST_P(QuicPacketCreatorTest, AddMessageFrame) { +TEST_P(QuicPacketCreatorTest, AddDatagramFrame) { if (client_framer_.version().UsesTls()) { creator_.SetMaxDatagramFrameSize(kMaxAcceptedDatagramFrameSize); } @@ -1808,23 +1808,23 @@ .WillRepeatedly( Invoke(this, &QuicPacketCreatorTest::ClearSerializedPacketForTests)); // Verify that there is enough room for the largest message payload. - EXPECT_TRUE(creator_.HasRoomForMessageFrame( - creator_.GetCurrentLargestMessagePayload())); - std::string large_message(creator_.GetCurrentLargestMessagePayload(), 'a'); - QuicMessageFrame* message_frame = - new QuicMessageFrame(1, MemSliceFromString(large_message)); + EXPECT_TRUE(creator_.HasRoomForDatagramFrame( + creator_.GetCurrentLargestDatagramPayload())); + std::string large_message(creator_.GetCurrentLargestDatagramPayload(), 'a'); + QuicDatagramFrame* message_frame = + new QuicDatagramFrame(1, MemSliceFromString(large_message)); EXPECT_TRUE(creator_.AddFrame(QuicFrame(message_frame), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); creator_.FlushCurrentPacket(); - QuicMessageFrame* frame2 = - new QuicMessageFrame(2, MemSliceFromString("message")); + QuicDatagramFrame* frame2 = + new QuicDatagramFrame(2, MemSliceFromString("message")); EXPECT_TRUE(creator_.AddFrame(QuicFrame(frame2), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); // Verify if a new frame is added, 1 byte message length will be added. EXPECT_EQ(1u, creator_.ExpansionOnNewFrame()); - QuicMessageFrame* frame3 = - new QuicMessageFrame(3, MemSliceFromString("message2")); + QuicDatagramFrame* frame3 = + new QuicDatagramFrame(3, MemSliceFromString("message2")); EXPECT_TRUE(creator_.AddFrame(QuicFrame(frame3), NOT_RETRANSMISSION)); EXPECT_EQ(1u, creator_.ExpansionOnNewFrame()); creator_.FlushCurrentPacket(); @@ -1835,20 +1835,20 @@ const std::string data("test"); EXPECT_TRUE(creator_.ConsumeDataToFillCurrentPacket( stream_id, data, 0u, false, false, NOT_RETRANSMISSION, &frame)); - QuicMessageFrame* frame4 = - new QuicMessageFrame(4, MemSliceFromString("message")); + QuicDatagramFrame* frame4 = + new QuicDatagramFrame(4, MemSliceFromString("message")); EXPECT_TRUE(creator_.AddFrame(QuicFrame(frame4), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); // Verify there is not enough room for largest payload. - EXPECT_FALSE(creator_.HasRoomForMessageFrame( - creator_.GetCurrentLargestMessagePayload())); + EXPECT_FALSE(creator_.HasRoomForDatagramFrame( + creator_.GetCurrentLargestDatagramPayload())); // Add largest message will causes the flush of the stream frame. - QuicMessageFrame frame5(5, MemSliceFromString(large_message)); + QuicDatagramFrame frame5(5, MemSliceFromString(large_message)); EXPECT_FALSE(creator_.AddFrame(QuicFrame(&frame5), NOT_RETRANSMISSION)); EXPECT_FALSE(creator_.HasPendingFrames()); } -TEST_P(QuicPacketCreatorTest, MessageFrameConsumption) { +TEST_P(QuicPacketCreatorTest, DatagramFrameConsumption) { if (client_framer_.version().UsesTls()) { creator_.SetMaxDatagramFrameSize(kMaxAcceptedDatagramFrameSize); } @@ -1859,11 +1859,11 @@ creator_.set_encryption_level(level); // Test all possible sizes of message frames. for (size_t message_size = 0; - message_size <= creator_.GetCurrentLargestMessagePayload(); + message_size <= creator_.GetCurrentLargestDatagramPayload(); ++message_size) { - QuicMessageFrame* frame = - new QuicMessageFrame(0, MemSliceFromString(absl::string_view( - message_data.data(), message_size))); + QuicDatagramFrame* frame = + new QuicDatagramFrame(0, MemSliceFromString(absl::string_view( + message_data.data(), message_size))); EXPECT_TRUE(creator_.AddFrame(QuicFrame(frame), NOT_RETRANSMISSION)); EXPECT_TRUE(creator_.HasPendingFrames()); @@ -1872,14 +1872,14 @@ // Verify BytesFree returns bytes available for the next frame, which // should subtract the message length. size_t expected_bytes_free = - creator_.GetCurrentLargestMessagePayload() - message_size < + creator_.GetCurrentLargestDatagramPayload() - message_size < expansion_bytes ? 0 - : creator_.GetCurrentLargestMessagePayload() - expansion_bytes - + : creator_.GetCurrentLargestDatagramPayload() - expansion_bytes - message_size; EXPECT_EQ(expected_bytes_free, creator_.BytesFree()); - EXPECT_LE(creator_.GetGuaranteedLargestMessagePayload(), - creator_.GetCurrentLargestMessagePayload()); + EXPECT_LE(creator_.GetGuaranteedLargestDatagramPayload(), + creator_.GetCurrentLargestDatagramPayload()); EXPECT_CALL(delegate_, OnSerializedPacket(_)) .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); creator_.FlushCurrentPacket(); @@ -1889,7 +1889,7 @@ } } -TEST_P(QuicPacketCreatorTest, GetGuaranteedLargestMessagePayload) { +TEST_P(QuicPacketCreatorTest, GetGuaranteedLargestDatagramPayload) { ParsedQuicVersion version = GetParam().version; if (version.UsesTls()) { creator_.SetMaxDatagramFrameSize(kMaxAcceptedDatagramFrameSize); @@ -1902,42 +1902,42 @@ expected_largest_payload -= 1; } EXPECT_EQ(expected_largest_payload, - creator_.GetGuaranteedLargestMessagePayload()); - EXPECT_TRUE(creator_.HasRoomForMessageFrame( - creator_.GetGuaranteedLargestMessagePayload())); + creator_.GetGuaranteedLargestDatagramPayload()); + EXPECT_TRUE(creator_.HasRoomForDatagramFrame( + creator_.GetGuaranteedLargestDatagramPayload())); // Now test whether SetMaxDatagramFrameSize works. creator_.SetMaxDatagramFrameSize(expected_largest_payload + 1 + kQuicFrameTypeSize); EXPECT_EQ(expected_largest_payload, - creator_.GetGuaranteedLargestMessagePayload()); - EXPECT_TRUE(creator_.HasRoomForMessageFrame( - creator_.GetGuaranteedLargestMessagePayload())); + creator_.GetGuaranteedLargestDatagramPayload()); + EXPECT_TRUE(creator_.HasRoomForDatagramFrame( + creator_.GetGuaranteedLargestDatagramPayload())); creator_.SetMaxDatagramFrameSize(expected_largest_payload + kQuicFrameTypeSize); EXPECT_EQ(expected_largest_payload, - creator_.GetGuaranteedLargestMessagePayload()); - EXPECT_TRUE(creator_.HasRoomForMessageFrame( - creator_.GetGuaranteedLargestMessagePayload())); + creator_.GetGuaranteedLargestDatagramPayload()); + EXPECT_TRUE(creator_.HasRoomForDatagramFrame( + creator_.GetGuaranteedLargestDatagramPayload())); creator_.SetMaxDatagramFrameSize(expected_largest_payload - 1 + kQuicFrameTypeSize); EXPECT_EQ(expected_largest_payload - 1, - creator_.GetGuaranteedLargestMessagePayload()); - EXPECT_TRUE(creator_.HasRoomForMessageFrame( - creator_.GetGuaranteedLargestMessagePayload())); + creator_.GetGuaranteedLargestDatagramPayload()); + EXPECT_TRUE(creator_.HasRoomForDatagramFrame( + creator_.GetGuaranteedLargestDatagramPayload())); constexpr QuicPacketLength kFrameSizeLimit = 1000; constexpr QuicPacketLength kPayloadSizeLimit = kFrameSizeLimit - kQuicFrameTypeSize; creator_.SetMaxDatagramFrameSize(kFrameSizeLimit); - EXPECT_EQ(creator_.GetGuaranteedLargestMessagePayload(), kPayloadSizeLimit); - EXPECT_TRUE(creator_.HasRoomForMessageFrame(kPayloadSizeLimit)); - EXPECT_FALSE(creator_.HasRoomForMessageFrame(kPayloadSizeLimit + 1)); + EXPECT_EQ(creator_.GetGuaranteedLargestDatagramPayload(), kPayloadSizeLimit); + EXPECT_TRUE(creator_.HasRoomForDatagramFrame(kPayloadSizeLimit)); + EXPECT_FALSE(creator_.HasRoomForDatagramFrame(kPayloadSizeLimit + 1)); } -TEST_P(QuicPacketCreatorTest, GetCurrentLargestMessagePayload) { +TEST_P(QuicPacketCreatorTest, GetCurrentLargestDatagramPayload) { ParsedQuicVersion version = GetParam().version; if (version.UsesTls()) { creator_.SetMaxDatagramFrameSize(kMaxAcceptedDatagramFrameSize); @@ -1953,23 +1953,23 @@ expected_largest_payload -= 1; } EXPECT_EQ(expected_largest_payload, - creator_.GetCurrentLargestMessagePayload()); + creator_.GetCurrentLargestDatagramPayload()); // Now test whether SetMaxDatagramFrameSize works. creator_.SetMaxDatagramFrameSize(expected_largest_payload + 1 + kQuicFrameTypeSize); EXPECT_EQ(expected_largest_payload, - creator_.GetCurrentLargestMessagePayload()); + creator_.GetCurrentLargestDatagramPayload()); creator_.SetMaxDatagramFrameSize(expected_largest_payload + kQuicFrameTypeSize); EXPECT_EQ(expected_largest_payload, - creator_.GetCurrentLargestMessagePayload()); + creator_.GetCurrentLargestDatagramPayload()); creator_.SetMaxDatagramFrameSize(expected_largest_payload - 1 + kQuicFrameTypeSize); EXPECT_EQ(expected_largest_payload - 1, - creator_.GetCurrentLargestMessagePayload()); + creator_.GetCurrentLargestDatagramPayload()); } TEST_P(QuicPacketCreatorTest, PacketTransmissionType) { @@ -2408,12 +2408,12 @@ if (client_framer_.version().UsesTls()) { creator_.SetMaxDatagramFrameSize(kMaxAcceptedDatagramFrameSize); } - // Verify GetCurrentLargestMessagePayload is based on the actual + // Verify GetCurrentLargestDatagramPayload is based on the actual // max_packet_length. - EXPECT_LT(1u, creator_.GetCurrentLargestMessagePayload()); + EXPECT_LT(1u, creator_.GetCurrentLargestDatagramPayload()); EXPECT_EQ(overhead, creator_.max_packet_length()); - ASSERT_TRUE(creator_.HasRoomForMessageFrame( - creator_.GetCurrentLargestMessagePayload())); + ASSERT_TRUE(creator_.HasRoomForDatagramFrame( + creator_.GetCurrentLargestDatagramPayload())); EXPECT_EQ(previous_max_packet_length, creator_.max_packet_length()); // Verify creator can consume crypto data because max_packet_length_ gets @@ -2670,14 +2670,14 @@ return QuicPacketCreator::ConsumeData(id, data.length(), offset, state); } - MessageStatus AddMessageFrame(QuicMessageId message_id, - quiche::QuicheMemSlice message) { + DatagramStatus AddDatagramFrame(QuicDatagramId datagram_id, + quiche::QuicheMemSlice message) { if (!has_ack() && delegate_->ShouldGeneratePacket(NO_RETRANSMITTABLE_DATA, NOT_HANDSHAKE)) { EXPECT_CALL(*delegate_, MaybeBundleOpportunistically(_)).Times(1); } - return QuicPacketCreator::AddMessageFrame(message_id, - absl::MakeSpan(&message, 1)); + return QuicPacketCreator::AddDatagramFrame(datagram_id, + absl::MakeSpan(&message, 1)); } size_t ConsumeCryptoData(EncryptionLevel level, absl::string_view data, @@ -4241,7 +4241,7 @@ } } -TEST_F(QuicPacketCreatorMultiplePacketsTest, AddMessageFrame) { +TEST_F(QuicPacketCreatorMultiplePacketsTest, AddDatagramFrame) { if (framer_.version().UsesTls()) { creator_.SetMaxDatagramFrameSize(kMaxAcceptedDatagramFrameSize); } @@ -4253,23 +4253,24 @@ creator_.ConsumeData(QuicUtils::GetFirstBidirectionalStreamId( framer_.transport_version(), Perspective::IS_CLIENT), "foo", 0, FIN); - EXPECT_EQ(MESSAGE_STATUS_SUCCESS, - creator_.AddMessageFrame(1, MemSliceFromString("message"))); + EXPECT_EQ(DATAGRAM_STATUS_SUCCESS, + creator_.AddDatagramFrame(1, MemSliceFromString("message"))); EXPECT_TRUE(creator_.HasPendingFrames()); EXPECT_TRUE(creator_.HasPendingRetransmittableFrames()); // Add a message which causes the flush of current packet. - EXPECT_EQ(MESSAGE_STATUS_SUCCESS, - creator_.AddMessageFrame( + EXPECT_EQ(DATAGRAM_STATUS_SUCCESS, + creator_.AddDatagramFrame( 2, MemSliceFromString(std::string( - creator_.GetCurrentLargestMessagePayload(), 'a')))); + creator_.GetCurrentLargestDatagramPayload(), 'a')))); EXPECT_TRUE(creator_.HasPendingRetransmittableFrames()); // Failed to send messages which cannot fit into one packet. - EXPECT_EQ(MESSAGE_STATUS_TOO_LARGE, - creator_.AddMessageFrame( - 3, MemSliceFromString(std::string( - creator_.GetCurrentLargestMessagePayload() + 10, 'a')))); + EXPECT_EQ( + DATAGRAM_STATUS_TOO_LARGE, + creator_.AddDatagramFrame( + 3, MemSliceFromString(std::string( + creator_.GetCurrentLargestDatagramPayload() + 10, 'a')))); } TEST_F(QuicPacketCreatorMultiplePacketsTest, ConnectionId) {
diff --git a/quiche/quic/core/quic_packets.cc b/quiche/quic/core/quic_packets.cc index 0346ae1..1ed9ab8 100644 --- a/quiche/quic/core/quic_packets.cc +++ b/quiche/quic/core/quic_packets.cc
@@ -447,7 +447,7 @@ transmission_type(NOT_RETRANSMISSION), has_ack_frame_copy(false), has_ack_frequency(false), - has_message(false), + has_datagram(false), fate(SEND_TO_WRITER) {} SerializedPacket::SerializedPacket(SerializedPacket&& other) @@ -462,7 +462,7 @@ largest_acked(other.largest_acked), has_ack_frame_copy(other.has_ack_frame_copy), has_ack_frequency(other.has_ack_frequency), - has_message(other.has_message), + has_datagram(other.has_datagram), fate(other.fate), peer_address(other.peer_address), bytes_not_retransmitted(other.bytes_not_retransmitted), @@ -510,7 +510,7 @@ copy->transmission_type = serialized.transmission_type; copy->largest_acked = serialized.largest_acked; copy->has_ack_frequency = serialized.has_ack_frequency; - copy->has_message = serialized.has_message; + copy->has_datagram = serialized.has_datagram; copy->fate = serialized.fate; copy->peer_address = serialized.peer_address; copy->bytes_not_retransmitted = serialized.bytes_not_retransmitted;
diff --git a/quiche/quic/core/quic_packets.h b/quiche/quic/core/quic_packets.h index ccac3fe..df121b1 100644 --- a/quiche/quic/core/quic_packets.h +++ b/quiche/quic/core/quic_packets.h
@@ -425,7 +425,7 @@ // nonretransmittable_frames. bool has_ack_frame_copy; bool has_ack_frequency; - bool has_message; + bool has_datagram; SerializedPacketFate fate; QuicSocketAddress peer_address; // Sum of bytes from frames that are not retransmissions. This field is only
diff --git a/quiche/quic/core/quic_sent_packet_manager.cc b/quiche/quic/core/quic_sent_packet_manager.cc index 216c545..6d11224 100644 --- a/quiche/quic/core/quic_sent_packet_manager.cc +++ b/quiche/quic/core/quic_sent_packet_manager.cc
@@ -749,13 +749,13 @@ has_retransmittable_data); } - // Deallocate message data in QuicMessageFrame immediately after packet + // Deallocate datagram data in QuicDatagramFrame immediately after packet // sent. - if (packet.has_message) { + if (packet.has_datagram) { for (auto& frame : mutable_packet->retransmittable_frames) { - if (frame.type == MESSAGE_FRAME) { - frame.message_frame->message_data.clear(); - frame.message_frame->message_length = 0; + if (frame.type == DATAGRAM_FRAME) { + frame.datagram_frame->datagram_data.clear(); + frame.datagram_frame->datagram_length = 0; } } } @@ -1709,8 +1709,8 @@ if (frame.type == QuicFrameType::STREAM_FRAME) { overhead_good_bytes_ += frame.stream_frame.data_length; } - if (frame.type == QuicFrameType::MESSAGE_FRAME) { - overhead_good_bytes_ += frame.message_frame->message_length; + if (frame.type == QuicFrameType::DATAGRAM_FRAME) { + overhead_good_bytes_ += frame.datagram_frame->datagram_length; } } }
diff --git a/quiche/quic/core/quic_sent_packet_manager_test.cc b/quiche/quic/core/quic_sent_packet_manager_test.cc index 75e9540..529d7bd 100644 --- a/quiche/quic/core/quic_sent_packet_manager_test.cc +++ b/quiche/quic/core/quic_sent_packet_manager_test.cc
@@ -21,8 +21,8 @@ #include "quiche/quic/core/crypto/quic_random.h" #include "quiche/quic/core/frames/quic_ack_frame.h" #include "quiche/quic/core/frames/quic_ack_frequency_frame.h" +#include "quiche/quic/core/frames/quic_datagram_frame.h" #include "quiche/quic/core/frames/quic_frame.h" -#include "quiche/quic/core/frames/quic_message_frame.h" #include "quiche/quic/core/frames/quic_path_challenge_frame.h" #include "quiche/quic/core/frames/quic_ping_frame.h" #include "quiche/quic/core/frames/quic_stream_frame.h" @@ -3152,30 +3152,30 @@ EXPECT_EQ(manager_.peer_max_ack_delay(), extra_1_ms); } -TEST_F(QuicSentPacketManagerTest, ClearDataInMessageFrameAfterPacketSent) { +TEST_F(QuicSentPacketManagerTest, ClearDataInDatagramFrameAfterPacketSent) { EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); - QuicMessageFrame* message_frame = nullptr; + QuicDatagramFrame* datagram_frame = nullptr; { quiche::QuicheMemSlice slice(quiche::QuicheBuffer(&allocator_, 1024)); - message_frame = new QuicMessageFrame(/*message_id=*/1, std::move(slice)); - EXPECT_FALSE(message_frame->message_data.empty()); - EXPECT_EQ(message_frame->message_length, 1024); + datagram_frame = new QuicDatagramFrame(/*datagram_id=*/1, std::move(slice)); + EXPECT_FALSE(datagram_frame->datagram_data.empty()); + EXPECT_EQ(datagram_frame->datagram_length, 1024); SerializedPacket packet(QuicPacketNumber(1), PACKET_4BYTE_PACKET_NUMBER, /*encrypted_buffer=*/nullptr, kDefaultLength, /*has_ack=*/false, /*has_stop_waiting*/ false); packet.encryption_level = ENCRYPTION_FORWARD_SECURE; - packet.retransmittable_frames.push_back(QuicFrame(message_frame)); - packet.has_message = true; + packet.retransmittable_frames.push_back(QuicFrame(datagram_frame)); + packet.has_datagram = true; manager_.OnPacketSent(&packet, clock_.Now(), NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, /*measure_rtt=*/true, ECN_NOT_ECT); } - EXPECT_TRUE(message_frame->message_data.empty()); - EXPECT_EQ(message_frame->message_length, 0); + EXPECT_TRUE(datagram_frame->datagram_data.empty()); + EXPECT_EQ(datagram_frame->datagram_length, 0); } // TODO(b/389762349): Re-enable these tests when sending AckFrequency is @@ -3745,7 +3745,7 @@ nullptr, kDefaultLength, false, false); packet.encryption_level = ENCRYPTION_FORWARD_SECURE; packet.retransmittable_frames.push_back(QuicFrame( - new QuicMessageFrame(i, quiche::QuicheMemSlice::Copy(buffer)))); + new QuicDatagramFrame(i, quiche::QuicheMemSlice::Copy(buffer)))); manager_.OnPacketSent(&packet, clock_.Now(), NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, true, ECN_NOT_ECT); }
diff --git a/quiche/quic/core/quic_session.cc b/quiche/quic/core/quic_session.cc index 9137d3f..05b4853 100644 --- a/quiche/quic/core/quic_session.cc +++ b/quiche/quic/core/quic_session.cc
@@ -140,7 +140,7 @@ transport_goaway_sent_(false), transport_goaway_received_(false), liveness_testing_in_progress_(false), - last_message_id_(0), + last_datagram_id_(0), currently_writing_stream_id_(0), num_outgoing_draining_streams_(0), closed_streams_clean_up_alarm_(nullptr), @@ -542,12 +542,12 @@ transport_goaway_received_ = true; } -void QuicSession::OnMessageReceived(absl::string_view message) { - QUIC_DVLOG(1) << ENDPOINT << "Received message of length " - << message.length(); - QUIC_DVLOG(2) << ENDPOINT << "Contents of message of length " - << message.length() << ":" << std::endl - << quiche::QuicheTextUtils::HexDump(message); +void QuicSession::OnDatagramReceived(absl::string_view datagram) { + QUIC_DVLOG(1) << ENDPOINT << "Received datagram of length " + << datagram.length(); + QUIC_DVLOG(2) << ENDPOINT << "Contents of datagram of length " + << datagram.length() << ":" << std::endl + << quiche::QuicheTextUtils::HexDump(datagram); } void QuicSession::OnHandshakeDoneReceived() { @@ -2483,8 +2483,8 @@ QuicTime::Delta ack_delay_time, QuicTime receive_timestamp, bool is_retransmission) { - if (frame.type == MESSAGE_FRAME) { - OnMessageAcked(frame.message_frame->message_id, receive_timestamp); + if (frame.type == DATAGRAM_FRAME) { + OnDatagramAcked(frame.datagram_frame->datagram_id, receive_timestamp); return true; } if (frame.type == CRYPTO_FRAME) { @@ -2533,9 +2533,9 @@ } void QuicSession::OnFrameLost(const QuicFrame& frame) { - if (frame.type == MESSAGE_FRAME) { + if (frame.type == DATAGRAM_FRAME) { ++total_datagrams_lost_; - OnMessageLost(frame.message_frame->message_id); + OnDatagramLost(frame.datagram_frame->datagram_id); return; } if (frame.type == CRYPTO_FRAME) { @@ -2565,8 +2565,8 @@ TransmissionType type) { QuicConnection::ScopedPacketFlusher retransmission_flusher(connection_); for (const QuicFrame& frame : frames) { - if (frame.type == MESSAGE_FRAME) { - // Do not retransmit MESSAGE frames. + if (frame.type == DATAGRAM_FRAME) { + // Do not retransmit DATAGRAM frames. continue; } if (frame.type == CRYPTO_FRAME) { @@ -2593,7 +2593,7 @@ } bool QuicSession::IsFrameOutstanding(const QuicFrame& frame) const { - if (frame.type == MESSAGE_FRAME) { + if (frame.type == DATAGRAM_FRAME) { return false; } if (frame.type == CRYPTO_FRAME) { @@ -2758,50 +2758,50 @@ connection_->SetTransmissionType(type); } -MessageResult QuicSession::SendMessage( - absl::Span<quiche::QuicheMemSlice> message) { - return SendMessage(message, /*flush=*/false); +DatagramResult QuicSession::SendDatagram( + absl::Span<quiche::QuicheMemSlice> datagram) { + return SendDatagram(datagram, /*flush=*/false); } -MessageResult QuicSession::SendMessage(quiche::QuicheMemSlice message) { - return SendMessage(absl::MakeSpan(&message, 1), /*flush=*/false); +DatagramResult QuicSession::SendDatagram(quiche::QuicheMemSlice datagram) { + return SendDatagram(absl::MakeSpan(&datagram, 1), /*flush=*/false); } -MessageResult QuicSession::SendMessage( - absl::Span<quiche::QuicheMemSlice> message, bool flush) { +DatagramResult QuicSession::SendDatagram( + absl::Span<quiche::QuicheMemSlice> datagram, bool flush) { QUICHE_DCHECK(connection_->connected()) - << ENDPOINT << "Try to write messages when connection is closed."; + << ENDPOINT << "Try to write datagrams when connection is closed."; if (!IsEncryptionEstablished()) { - return {MESSAGE_STATUS_ENCRYPTION_NOT_ESTABLISHED, 0}; + return {DATAGRAM_STATUS_ENCRYPTION_NOT_ESTABLISHED, 0}; } QuicConnection::ScopedEncryptionLevelContext context( connection(), GetEncryptionLevelToSendApplicationData()); - MessageStatus result = - connection_->SendMessage(last_message_id_ + 1, message, flush); - if (result == MESSAGE_STATUS_SUCCESS) { - return {result, ++last_message_id_}; + DatagramStatus result = + connection_->SendDatagram(last_datagram_id_ + 1, datagram, flush); + if (result == DATAGRAM_STATUS_SUCCESS) { + return {result, ++last_datagram_id_}; } return {result, 0}; } -void QuicSession::OnMessageAcked(QuicMessageId message_id, - QuicTime /*receive_timestamp*/) { - QUIC_DVLOG(1) << ENDPOINT << "message " << message_id << " gets acked."; +void QuicSession::OnDatagramAcked(QuicDatagramId datagram_id, + QuicTime /*receive_timestamp*/) { + QUIC_DVLOG(1) << ENDPOINT << "datagram " << datagram_id << " gets acked."; } -void QuicSession::OnMessageLost(QuicMessageId message_id) { - QUIC_DVLOG(1) << ENDPOINT << "message " << message_id +void QuicSession::OnDatagramLost(QuicDatagramId datagram_id) { + QUIC_DVLOG(1) << ENDPOINT << "datagram " << datagram_id << " is considered lost"; } void QuicSession::CleanUpClosedStreams() { closed_streams_.clear(); } -QuicPacketLength QuicSession::GetCurrentLargestMessagePayload() const { - return connection_->GetCurrentLargestMessagePayload(); +QuicPacketLength QuicSession::GetCurrentLargestDatagramPayload() const { + return connection_->GetCurrentLargestDatagramPayload(); } -QuicPacketLength QuicSession::GetGuaranteedLargestMessagePayload() const { - return connection_->GetGuaranteedLargestMessagePayload(); +QuicPacketLength QuicSession::GetGuaranteedLargestDatagramPayload() const { + return connection_->GetGuaranteedLargestDatagramPayload(); } QuicStreamId QuicSession::next_outgoing_bidirectional_stream_id() const {
diff --git a/quiche/quic/core/quic_session.h b/quiche/quic/core/quic_session.h index 290d75a..2c3e658 100644 --- a/quiche/quic/core/quic_session.h +++ b/quiche/quic/core/quic_session.h
@@ -139,7 +139,7 @@ void OnRstStream(const QuicRstStreamFrame& frame) override; void OnResetStreamAt(const QuicResetStreamAtFrame& frame) override; void OnGoAway(const QuicGoAwayFrame& frame) override; - void OnMessageReceived(absl::string_view message) override; + void OnDatagramReceived(absl::string_view datagram) override; void OnHandshakeDoneReceived() override; void OnNewTokenReceived(absl::string_view token) override; void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; @@ -234,47 +234,48 @@ const QuicSocketAddress& peer_address, const QuicReceivedPacket& packet); - // Sends |message| as a QUIC DATAGRAM frame (QUIC MESSAGE frame in gQUIC). + // Sends |datagram| as a QUIC DATAGRAM frame. // See <https://datatracker.ietf.org/doc/html/draft-ietf-quic-datagram> for // more details. // - // Returns a MessageResult struct which includes the status of the write - // operation and a message ID. The message ID (not sent on the wire) can be - // used to track the message; OnMessageAcked and OnMessageLost are called when - // a specific message gets acked or lost. + // Returns a DatagramResult struct which includes the status of the write + // operation and a datagram ID. The datagram ID (not sent on the wire) can be + // used to track the datagram; OnDatagramAcked and OnDatagramLost are called + // when a specific datagram gets acked or lost. // - // If the write operation is successful, all of the slices in |message| are - // consumed, leaving them empty. If MESSAGE_STATUS_INTERNAL_ERROR is + // If the write operation is successful, all of the slices in |datagram| are + // consumed, leaving them empty. If DATAGRAM_STATUS_INTERNAL_ERROR is // returned, the slices in question may or may not be consumed; it is no - // longer safe to access those. For all other status codes, |message| is kept - // intact. + // longer safe to access those. For all other status codes, |datagram| is + // kept intact. // - // Note that SendMessage will fail with status = MESSAGE_STATUS_BLOCKED + // Note that SendDatagram will fail with status = DATAGRAM_STATUS_BLOCKED // if the connection is congestion control blocked or the underlying socket is - // write blocked. In this case the caller can retry sending message again when - // connection becomes available, for example after getting OnCanWrite() + // write blocked. In this case the caller can retry sending datagram again + // when connection becomes available, for example after getting OnCanWrite() // callback. // - // SendMessage flushes the current packet even it is not full; if the + // SendDatagram flushes the current packet even it is not full; if the // application needs to bundle other data in the same packet, consider using // QuicConnection::ScopedPacketFlusher around the relevant write operations. - MessageResult SendMessage(absl::Span<quiche::QuicheMemSlice> message); + DatagramResult SendDatagram(absl::Span<quiche::QuicheMemSlice> datagram); - // Same as above SendMessage, except caller can specify if the given |message| - // should be flushed even if the underlying connection is deemed unwritable. - MessageResult SendMessage(absl::Span<quiche::QuicheMemSlice> message, - bool flush); + // Same as above SendDatagram, except caller can specify if the given + // |datagram| should be flushed even if the underlying connection is deemed + // unwritable. + DatagramResult SendDatagram(absl::Span<quiche::QuicheMemSlice> datagram, + bool flush); - // Single-slice version of SendMessage(). Unlike the version above, this + // Single-slice version of SendDatagram(). Unlike the version above, this // version always takes ownership of the slice. - MessageResult SendMessage(quiche::QuicheMemSlice message); + DatagramResult SendDatagram(quiche::QuicheMemSlice datagram); - // Called when message with |message_id| gets acked. - virtual void OnMessageAcked(QuicMessageId message_id, - QuicTime receive_timestamp); + // Called when datagram with |datagram_id| gets acked. + virtual void OnDatagramAcked(QuicDatagramId datagram_id, + QuicTime receive_timestamp); - // Called when message with |message_id| is considered as lost. - virtual void OnMessageLost(QuicMessageId message_id); + // Called when datagram with |datagram_id| is considered as lost. + virtual void OnDatagramLost(QuicDatagramId datagram_id); // QuicControlFrameManager::DelegateInterface // Close the connection on error. @@ -497,15 +498,15 @@ const QuicSocketAddress& peer_address, QuicPacketWriter* writer, bool owns_writer); - // Returns the largest payload that will fit into a single MESSAGE frame. + // Returns the largest payload that will fit into a single DATAGRAM frame. // Because overhead can vary during a connection, this method should be - // checked for every message. - QuicPacketLength GetCurrentLargestMessagePayload() const; + // checked for every datagram. + QuicPacketLength GetCurrentLargestDatagramPayload() const; - // Returns the largest payload that will fit into a single MESSAGE frame at + // Returns the largest payload that will fit into a single DATAGRAM frame at // any point during the connection. This assumes the version and // connection ID lengths do not change. - QuicPacketLength GetGuaranteedLargestMessagePayload() const; + QuicPacketLength GetGuaranteedLargestDatagramPayload() const; bool transport_goaway_sent() const { return transport_goaway_sent_; } @@ -1076,8 +1077,8 @@ // event loop and gets reset for each event loop. QuicStreamCount new_incoming_streams_in_current_loop_ = 0u; - // Id of latest successfully sent message. - QuicMessageId last_message_id_; + // Id of latest successfully sent datagram. + QuicDatagramId last_datagram_id_; // The stream id which was last popped in OnCanWrite, or 0, if not under the // call stack of OnCanWrite.
diff --git a/quiche/quic/core/quic_session_test.cc b/quiche/quic/core/quic_session_test.cc index 257a69a..e5d2ae4 100644 --- a/quiche/quic/core/quic_session_test.cc +++ b/quiche/quic/core/quic_session_test.cc
@@ -2718,41 +2718,41 @@ session_.OnCanWrite(); } -TEST_P(QuicSessionTestServer, SendMessage) { - // Cannot send message when encryption is not established. +TEST_P(QuicSessionTestServer, SendDatagram) { + // Cannot send datagram when encryption is not established. EXPECT_FALSE(session_.OneRttKeysAvailable()); - EXPECT_EQ(MessageResult(MESSAGE_STATUS_ENCRYPTION_NOT_ESTABLISHED, 0), - session_.SendMessage(MemSliceFromString(""))); + EXPECT_EQ(DatagramResult(DATAGRAM_STATUS_ENCRYPTION_NOT_ESTABLISHED, 0), + session_.SendDatagram(MemSliceFromString(""))); CompleteHandshake(); EXPECT_TRUE(session_.OneRttKeysAvailable()); - EXPECT_CALL(*connection_, SendMessage(1, _, false)) - .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); - EXPECT_EQ(MessageResult(MESSAGE_STATUS_SUCCESS, 1), - session_.SendMessage(MemSliceFromString(""))); - // Verify message_id increases. - EXPECT_CALL(*connection_, SendMessage(2, _, false)) - .WillOnce(Return(MESSAGE_STATUS_TOO_LARGE)); - EXPECT_EQ(MessageResult(MESSAGE_STATUS_TOO_LARGE, 0), - session_.SendMessage(MemSliceFromString(""))); - // Verify unsent message does not consume a message_id. - EXPECT_CALL(*connection_, SendMessage(2, _, false)) - .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); - EXPECT_EQ(MessageResult(MESSAGE_STATUS_SUCCESS, 2), - session_.SendMessage(MemSliceFromString(""))); + EXPECT_CALL(*connection_, SendDatagram(1, _, false)) + .WillOnce(Return(DATAGRAM_STATUS_SUCCESS)); + EXPECT_EQ(DatagramResult(DATAGRAM_STATUS_SUCCESS, 1), + session_.SendDatagram(MemSliceFromString(""))); + // Verify datagram_id increases. + EXPECT_CALL(*connection_, SendDatagram(2, _, false)) + .WillOnce(Return(DATAGRAM_STATUS_TOO_LARGE)); + EXPECT_EQ(DatagramResult(DATAGRAM_STATUS_TOO_LARGE, 0), + session_.SendDatagram(MemSliceFromString(""))); + // Verify unsent datagram does not consume a datagram_id. + EXPECT_CALL(*connection_, SendDatagram(2, _, false)) + .WillOnce(Return(DATAGRAM_STATUS_SUCCESS)); + EXPECT_EQ(DatagramResult(DATAGRAM_STATUS_SUCCESS, 2), + session_.SendDatagram(MemSliceFromString(""))); - QuicMessageFrame frame(1); - QuicMessageFrame frame2(2); + QuicDatagramFrame frame(1); + QuicDatagramFrame frame2(2); EXPECT_FALSE(session_.IsFrameOutstanding(QuicFrame(&frame))); EXPECT_FALSE(session_.IsFrameOutstanding(QuicFrame(&frame2))); - // Lost message 2. - session_.OnMessageLost(2); + // Lost datagram 2. + session_.OnDatagramLost(2); EXPECT_FALSE(session_.IsFrameOutstanding(QuicFrame(&frame2))); - // message 1 gets acked. - session_.OnMessageAcked(1, QuicTime::Zero()); + // datagram 1 gets acked. + session_.OnDatagramAcked(1, QuicTime::Zero()); EXPECT_FALSE(session_.IsFrameOutstanding(QuicFrame(&frame))); }
diff --git a/quiche/quic/core/quic_trace_visitor.cc b/quiche/quic/core/quic_trace_visitor.cc index 4644e0d..3b5131a 100644 --- a/quiche/quic/core/quic_trace_visitor.cc +++ b/quiche/quic/core/quic_trace_visitor.cc
@@ -92,7 +92,7 @@ case PATH_RESPONSE_FRAME: case PATH_CHALLENGE_FRAME: case STOP_SENDING_FRAME: - case MESSAGE_FRAME: + case DATAGRAM_FRAME: case CRYPTO_FRAME: case NEW_TOKEN_FRAME: case RESET_STREAM_AT_FRAME: @@ -224,7 +224,7 @@ case PATH_RESPONSE_FRAME: case PATH_CHALLENGE_FRAME: case STOP_SENDING_FRAME: - case MESSAGE_FRAME: + case DATAGRAM_FRAME: case CRYPTO_FRAME: case NEW_TOKEN_FRAME: case ACK_FREQUENCY_FRAME:
diff --git a/quiche/quic/core/quic_types.cc b/quiche/quic/core/quic_types.cc index a974c40..e4988dd 100644 --- a/quiche/quic/core/quic_types.cc +++ b/quiche/quic/core/quic_types.cc
@@ -128,8 +128,9 @@ return os; } -MessageResult::MessageResult(MessageStatus status, QuicMessageId message_id) - : status(status), message_id(message_id) {} +DatagramResult::DatagramResult(DatagramStatus status, + QuicDatagramId datagram_id) + : status(status), datagram_id(datagram_id) {} #define RETURN_STRING_LITERAL(x) \ case x: \ @@ -156,7 +157,7 @@ RETURN_STRING_LITERAL(PATH_RESPONSE_FRAME) RETURN_STRING_LITERAL(PATH_CHALLENGE_FRAME) RETURN_STRING_LITERAL(STOP_SENDING_FRAME) - RETURN_STRING_LITERAL(MESSAGE_FRAME) + RETURN_STRING_LITERAL(DATAGRAM_FRAME) RETURN_STRING_LITERAL(NEW_TOKEN_FRAME) RETURN_STRING_LITERAL(RETIRE_CONNECTION_ID_FRAME) RETURN_STRING_LITERAL(ACK_FREQUENCY_FRAME) @@ -200,10 +201,10 @@ RETURN_STRING_LITERAL(IETF_PATH_RESPONSE); RETURN_STRING_LITERAL(IETF_CONNECTION_CLOSE); RETURN_STRING_LITERAL(IETF_APPLICATION_CLOSE); - RETURN_STRING_LITERAL(IETF_EXTENSION_MESSAGE_NO_LENGTH); - RETURN_STRING_LITERAL(IETF_EXTENSION_MESSAGE); - RETURN_STRING_LITERAL(IETF_EXTENSION_MESSAGE_NO_LENGTH_V99); - RETURN_STRING_LITERAL(IETF_EXTENSION_MESSAGE_V99); + RETURN_STRING_LITERAL(IETF_EXTENSION_DATAGRAM_NO_LENGTH); + RETURN_STRING_LITERAL(IETF_EXTENSION_DATAGRAM); + RETURN_STRING_LITERAL(IETF_EXTENSION_DATAGRAM_NO_LENGTH_V99); + RETURN_STRING_LITERAL(IETF_EXTENSION_DATAGRAM_V99); default: return absl::StrCat("Private value (", t, ")"); } @@ -259,30 +260,31 @@ } } -std::string MessageStatusToString(MessageStatus message_status) { +std::string DatagramStatusToString(DatagramStatus message_status) { switch (message_status) { - RETURN_STRING_LITERAL(MESSAGE_STATUS_SUCCESS); - RETURN_STRING_LITERAL(MESSAGE_STATUS_ENCRYPTION_NOT_ESTABLISHED); - RETURN_STRING_LITERAL(MESSAGE_STATUS_UNSUPPORTED); - RETURN_STRING_LITERAL(MESSAGE_STATUS_BLOCKED); - RETURN_STRING_LITERAL(MESSAGE_STATUS_TOO_LARGE); - RETURN_STRING_LITERAL(MESSAGE_STATUS_SETTINGS_NOT_RECEIVED); - RETURN_STRING_LITERAL(MESSAGE_STATUS_INTERNAL_ERROR); + RETURN_STRING_LITERAL(DATAGRAM_STATUS_SUCCESS); + RETURN_STRING_LITERAL(DATAGRAM_STATUS_ENCRYPTION_NOT_ESTABLISHED); + RETURN_STRING_LITERAL(DATAGRAM_STATUS_UNSUPPORTED); + RETURN_STRING_LITERAL(DATAGRAM_STATUS_BLOCKED); + RETURN_STRING_LITERAL(DATAGRAM_STATUS_TOO_LARGE); + RETURN_STRING_LITERAL(DATAGRAM_STATUS_SETTINGS_NOT_RECEIVED); + RETURN_STRING_LITERAL(DATAGRAM_STATUS_INTERNAL_ERROR); default: return absl::StrCat("Unknown(", static_cast<int>(message_status), ")"); } } -std::string MessageResultToString(MessageResult message_result) { - if (message_result.status != MESSAGE_STATUS_SUCCESS) { - return absl::StrCat("{", MessageStatusToString(message_result.status), "}"); +std::string DatagramResultToString(DatagramResult datagram_result) { + if (datagram_result.status != DATAGRAM_STATUS_SUCCESS) { + return absl::StrCat("{", DatagramStatusToString(datagram_result.status), + "}"); } - return absl::StrCat("{MESSAGE_STATUS_SUCCESS,id=", message_result.message_id, - "}"); + return absl::StrCat( + "{DATAGRAM_STATUS_SUCCESS,id=", datagram_result.datagram_id, "}"); } -std::ostream& operator<<(std::ostream& os, const MessageResult& mr) { - os << MessageResultToString(mr); +std::ostream& operator<<(std::ostream& os, const DatagramResult& mr) { + os << DatagramResultToString(mr); return os; }
diff --git a/quiche/quic/core/quic_types.h b/quiche/quic/core/quic_types.h index 78bf922..f621307 100644 --- a/quiche/quic/core/quic_types.h +++ b/quiche/quic/core/quic_types.h
@@ -30,7 +30,7 @@ using QuicPacketLength = uint16_t; using QuicControlFrameId = uint32_t; -using QuicMessageId = uint32_t; +using QuicDatagramId = uint32_t; // IMPORTANT: IETF QUIC defines stream IDs and stream counts as being unsigned // 62-bit numbers. However, we have decided to only support up to 2^32-1 streams @@ -272,7 +272,7 @@ PATH_RESPONSE_FRAME, PATH_CHALLENGE_FRAME, STOP_SENDING_FRAME, - MESSAGE_FRAME, + DATAGRAM_FRAME, NEW_TOKEN_FRAME, RETIRE_CONNECTION_ID_FRAME, ACK_FREQUENCY_FRAME, @@ -340,10 +340,10 @@ // The MESSAGE frame type has not yet been fully standardized. // QUIC versions starting with 46 and before 99 use 0x20-0x21. // IETF QUIC (v99) uses 0x30-0x31, see draft-pauly-quic-datagram. - IETF_EXTENSION_MESSAGE_NO_LENGTH = 0x20, - IETF_EXTENSION_MESSAGE = 0x21, - IETF_EXTENSION_MESSAGE_NO_LENGTH_V99 = 0x30, - IETF_EXTENSION_MESSAGE_V99 = 0x31, + IETF_EXTENSION_DATAGRAM_NO_LENGTH = 0x20, + IETF_EXTENSION_DATAGRAM = 0x21, + IETF_EXTENSION_DATAGRAM_NO_LENGTH_V99 = 0x30, + IETF_EXTENSION_DATAGRAM_V99 = 0x31, // An QUIC extension frame for sender control of acknowledgement delays IETF_ACK_FREQUENCY = 0xaf, @@ -653,44 +653,45 @@ FLAGS_LONG_HEADER = 1 << 7, }; -enum MessageStatus { - MESSAGE_STATUS_SUCCESS, - MESSAGE_STATUS_ENCRYPTION_NOT_ESTABLISHED, // Failed to send message because - // encryption is not established - // yet. - MESSAGE_STATUS_UNSUPPORTED, // Failed to send message because MESSAGE frame - // is not supported by the connection. - MESSAGE_STATUS_BLOCKED, // Failed to send message because connection is - // congestion control blocked or underlying socket is - // write blocked. - MESSAGE_STATUS_TOO_LARGE, // Failed to send message because the message is - // too large to fit into a single packet. - MESSAGE_STATUS_SETTINGS_NOT_RECEIVED, // Failed to send message because - // SETTINGS frame has not been received - // yet. - MESSAGE_STATUS_INTERNAL_ERROR, // Failed to send message because connection - // reaches an invalid state. +enum DatagramStatus { + DATAGRAM_STATUS_SUCCESS, + DATAGRAM_STATUS_ENCRYPTION_NOT_ESTABLISHED, // Failed to send message because + // encryption is not established + // yet. + DATAGRAM_STATUS_UNSUPPORTED, // Failed to send message because MESSAGE frame + // is not supported by the connection. + DATAGRAM_STATUS_BLOCKED, // Failed to send message because connection is + // congestion control blocked or underlying socket + // is write blocked. + DATAGRAM_STATUS_TOO_LARGE, // Failed to send message because the message is + // too large to fit into a single packet. + DATAGRAM_STATUS_SETTINGS_NOT_RECEIVED, // Failed to send message because + // SETTINGS frame has not been + // received yet. + DATAGRAM_STATUS_INTERNAL_ERROR, // Failed to send message because connection + // reaches an invalid state. }; -QUICHE_EXPORT std::string MessageStatusToString(MessageStatus message_status); +QUICHE_EXPORT std::string DatagramStatusToString(DatagramStatus message_status); -// Used to return the result of SendMessage calls -struct QUICHE_EXPORT MessageResult { - MessageResult(MessageStatus status, QuicMessageId message_id); +// Used to return the result of SendDatagram calls +struct QUICHE_EXPORT DatagramResult { + DatagramResult(DatagramStatus status, QuicDatagramId datagram_id); - bool operator==(const MessageResult& other) const { - return status == other.status && message_id == other.message_id; + bool operator==(const DatagramResult& other) const { + return status == other.status && datagram_id == other.datagram_id; } QUICHE_EXPORT friend std::ostream& operator<<(std::ostream& os, - const MessageResult& mr); + const DatagramResult& mr); - MessageStatus status; - // Only valid when status is MESSAGE_STATUS_SUCCESS. - QuicMessageId message_id; + DatagramStatus status; + // Only valid when status is DATAGRAM_STATUS_SUCCESS. + QuicDatagramId datagram_id; }; -QUICHE_EXPORT std::string MessageResultToString(MessageResult message_result); +QUICHE_EXPORT std::string DatagramResultToString( + DatagramResult datagram_result); enum WriteStreamDataResult { WRITE_SUCCESS,
diff --git a/quiche/quic/core/quic_unacked_packet_map.cc b/quiche/quic/core/quic_unacked_packet_map.cc index 419982b..80401dd 100644 --- a/quiche/quic/core/quic_unacked_packet_map.cc +++ b/quiche/quic/core/quic_unacked_packet_map.cc
@@ -54,7 +54,7 @@ kPathResponseFrameBitfield = 1 << 16, kPathChallengeFrameBitfield = 1 << 17, kStopSendingFrameBitfield = 1 << 18, - kMessageFrameBitfield = 1 << 19, + kDatagramFrameBitfield = 1 << 19, kNewTokenFrameBitfield = 1 << 20, kRetireConnectionIdFrameBitfield = 1 << 21, kAckFrequencyFrameBitfield = 1 << 22, @@ -102,8 +102,8 @@ return kPathChallengeFrameBitfield; case STOP_SENDING_FRAME: return kStopSendingFrameBitfield; - case MESSAGE_FRAME: - return kMessageFrameBitfield; + case DATAGRAM_FRAME: + return kDatagramFrameBitfield; case NEW_TOKEN_FRAME: return kNewTokenFrameBitfield; case RETIRE_CONNECTION_ID_FRAME: @@ -506,7 +506,8 @@ const QuicFrames* frames = &info->retransmittable_frames; quiche::SimpleBufferAllocator allocator; std::optional<QuicFrames> frames_copy; - const bool use_copied_frames = !HasMessageFrame(info->retransmittable_frames); + const bool use_copied_frames = + !HasDatagramFrame(info->retransmittable_frames); if (use_copied_frames) { frames = &frames_copy.emplace( @@ -550,7 +551,8 @@ const QuicFrames* frames = &info->retransmittable_frames; quiche::SimpleBufferAllocator allocator; std::optional<QuicFrames> frames_copy; - const bool use_copied_frames = !HasMessageFrame(info->retransmittable_frames); + const bool use_copied_frames = + !HasDatagramFrame(info->retransmittable_frames); if (use_copied_frames) { frames = &frames_copy.emplace(
diff --git a/quiche/quic/core/tls_chlo_extractor.h b/quiche/quic/core/tls_chlo_extractor.h index f24da45..aeef76e 100644 --- a/quiche/quic/core/tls_chlo_extractor.h +++ b/quiche/quic/core/tls_chlo_extractor.h
@@ -175,7 +175,7 @@ bool OnPaddingFrame(const QuicPaddingFrame& /*frame*/) override { return true; } - bool OnMessageFrame(const QuicMessageFrame& /*frame*/) override { + bool OnDatagramFrame(const QuicDatagramFrame& /*frame*/) override { return true; } bool OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& /*frame*/) override {
diff --git a/quiche/quic/core/web_transport_interface.h b/quiche/quic/core/web_transport_interface.h index d3a6a12..a47f239 100644 --- a/quiche/quic/core/web_transport_interface.h +++ b/quiche/quic/core/web_transport_interface.h
@@ -22,31 +22,31 @@ using WebTransportVisitor = webtransport::SessionVisitor; using WebTransportSession = webtransport::Session; -inline webtransport::DatagramStatus MessageStatusToWebTransportStatus( - MessageStatus status) { +inline webtransport::DatagramStatus DatagramStatusToWebTransportStatus( + DatagramStatus status) { switch (status) { - case MESSAGE_STATUS_SUCCESS: + case DATAGRAM_STATUS_SUCCESS: return webtransport::DatagramStatus( webtransport::DatagramStatusCode::kSuccess, ""); - case MESSAGE_STATUS_BLOCKED: + case DATAGRAM_STATUS_BLOCKED: return webtransport::DatagramStatus( webtransport::DatagramStatusCode::kBlocked, "QUIC connection write-blocked"); - case MESSAGE_STATUS_TOO_LARGE: + case DATAGRAM_STATUS_TOO_LARGE: return webtransport::DatagramStatus( webtransport::DatagramStatusCode::kTooBig, "Datagram payload exceeded maximum allowed size"); - case MESSAGE_STATUS_ENCRYPTION_NOT_ESTABLISHED: - case MESSAGE_STATUS_INTERNAL_ERROR: - case MESSAGE_STATUS_UNSUPPORTED: - case MESSAGE_STATUS_SETTINGS_NOT_RECEIVED: + case DATAGRAM_STATUS_ENCRYPTION_NOT_ESTABLISHED: + case DATAGRAM_STATUS_INTERNAL_ERROR: + case DATAGRAM_STATUS_UNSUPPORTED: + case DATAGRAM_STATUS_SETTINGS_NOT_RECEIVED: return webtransport::DatagramStatus( webtransport::DatagramStatusCode::kInternalError, - absl::StrCat("Internal error: ", MessageStatusToString(status))); + absl::StrCat("Internal error: ", DatagramStatusToString(status))); default: return webtransport::DatagramStatus( webtransport::DatagramStatusCode::kInternalError, - absl::StrCat("Unknown status: ", MessageStatusToString(status))); + absl::StrCat("Unknown status: ", DatagramStatusToString(status))); } }
diff --git a/quiche/quic/masque/masque_client_session.cc b/quiche/quic/masque/masque_client_session.cc index dbef24e..98f3bdd 100644 --- a/quiche/quic/masque/masque_client_session.cc +++ b/quiche/quic/masque/masque_client_session.cc
@@ -87,13 +87,13 @@ crypto_config), owner_(owner) {} -void MasqueClientSession::OnMessageAcked(QuicMessageId message_id, - QuicTime /*receive_timestamp*/) { - QUIC_DVLOG(1) << "Received ack for DATAGRAM frame " << message_id; +void MasqueClientSession::OnDatagramAcked(QuicDatagramId datagram_id, + QuicTime /*receive_timestamp*/) { + QUIC_DVLOG(1) << "Received ack for DATAGRAM frame " << datagram_id; } -void MasqueClientSession::OnMessageLost(QuicMessageId message_id) { - QUIC_DVLOG(1) << "We believe DATAGRAM frame " << message_id << " was lost"; +void MasqueClientSession::OnDatagramLost(QuicDatagramId datagram_id) { + QUIC_DVLOG(1) << "We believe DATAGRAM frame " << datagram_id << " was lost"; } MasqueClientSession::ConnectUdpClientState* @@ -354,13 +354,13 @@ QUIC_BUG(IP packet write fail) << "Failed to write CONNECT-IP packet"; return; } - MessageStatus message_status = + DatagramStatus message_status = SendHttp3Datagram(connect_ip->stream()->id(), http_payload); QUIC_DVLOG(1) << "Sent encapsulated IP packet of length " << packet.size() << " with stream ID " << connect_ip->stream()->id() << " and got message status " - << MessageStatusToString(message_status); + << DatagramStatusToString(message_status); } void MasqueClientSession::SendEthernetFrame( @@ -387,13 +387,13 @@ QUIC_BUG(IP packet write fail) << "Failed to write CONNECT-ETHERNET frame"; return; } - MessageStatus message_status = + DatagramStatus message_status = SendHttp3Datagram(connect_ethernet->stream()->id(), http_payload); QUIC_DVLOG(1) << "Sent encapsulated Ethernet frame of length " << frame.size() << " with stream ID " << connect_ethernet->stream()->id() << " and got message status " - << MessageStatusToString(message_status); + << DatagramStatusToString(message_status); } void MasqueClientSession::SendConnectUdpBindPacket( @@ -433,13 +433,13 @@ http_payload.resize(1 + packet.size()); http_payload[0] = 0; memcpy(&http_payload[1], packet.data(), packet.size()); - MessageStatus message_status = + DatagramStatus message_status = SendHttp3Datagram(connect_udp->stream()->id(), http_payload); QUIC_DVLOG(1) << "Sent packet to " << target_server_address << " compressed with stream ID " << connect_udp->stream()->id() << " and got message status " - << MessageStatusToString(message_status); + << DatagramStatusToString(message_status); QUIC_DVLOG(2) << "Contents of outgoing HTTP Datagram of length " << http_payload.size() << ":" << std::endl << quiche::QuicheTextUtils::HexDump(http_payload);
diff --git a/quiche/quic/masque/masque_client_session.h b/quiche/quic/masque/masque_client_session.h index 6c6fe36..acf1f9f 100644 --- a/quiche/quic/masque/masque_client_session.h +++ b/quiche/quic/masque/masque_client_session.h
@@ -128,9 +128,9 @@ MasqueClientSession& operator=(const MasqueClientSession&) = delete; // From QuicSession. - void OnMessageAcked(QuicMessageId message_id, - QuicTime receive_timestamp) override; - void OnMessageLost(QuicMessageId message_id) override; + void OnDatagramAcked(QuicDatagramId datagram_id, + QuicTime receive_timestamp) override; + void OnDatagramLost(QuicDatagramId datagram_id) override; void OnConnectionClosed(const QuicConnectionCloseFrame& frame, ConnectionCloseSource source) override; void OnStreamClosed(QuicStreamId stream_id) override;
diff --git a/quiche/quic/masque/masque_encapsulated_client.cc b/quiche/quic/masque/masque_encapsulated_client.cc index f68f92e..addffd9 100644 --- a/quiche/quic/masque/masque_encapsulated_client.cc +++ b/quiche/quic/masque/masque_encapsulated_client.cc
@@ -341,7 +341,7 @@ MasqueClient* underlying_masque_client) { QuicByteCount max_packet_size = underlying_masque_client->masque_client_session() - ->GetGuaranteedLargestMessagePayload() - + ->GetGuaranteedLargestDatagramPayload() - /* max length of quarter stream ID */ sizeof(QuicStreamId) - /* context ID set to zero */ sizeof(uint8_t); QUICHE_CHECK_GE(max_packet_size, 1200u)
diff --git a/quiche/quic/masque/masque_server_session.cc b/quiche/quic/masque/masque_server_session.cc index d42df91..643484c 100644 --- a/quiche/quic/masque/masque_server_session.cc +++ b/quiche/quic/masque/masque_server_session.cc
@@ -172,13 +172,13 @@ (void)masque_mode_; } -void MasqueServerSession::OnMessageAcked(QuicMessageId message_id, - QuicTime /*receive_timestamp*/) { - QUIC_DVLOG(1) << "Received ack for DATAGRAM frame " << message_id; +void MasqueServerSession::OnDatagramAcked(QuicDatagramId datagram_id, + QuicTime /*receive_timestamp*/) { + QUIC_DVLOG(1) << "Received ack for DATAGRAM frame " << datagram_id; } -void MasqueServerSession::OnMessageLost(QuicMessageId message_id) { - QUIC_DVLOG(1) << "We believe DATAGRAM frame " << message_id << " was lost"; +void MasqueServerSession::OnDatagramLost(QuicDatagramId datagram_id) { + QUIC_DVLOG(1) << "We believe DATAGRAM frame " << datagram_id << " was lost"; } void MasqueServerSession::OnConnectionClosed( @@ -860,12 +860,12 @@ absl::string_view message( udp_payload_read_pos - final_header_length, read_result.packet_buffer.buffer_len + final_header_length); - MessageStatus message_status = it->stream()->SendHttp3Datagram(message); + DatagramStatus message_status = it->stream()->SendHttp3Datagram(message); QUIC_DVLOG(1) << "Sent UDP packet from " << expected_target_server_address << " of length " << read_result.packet_buffer.buffer_len << " with stream ID " << it->stream()->id() << " and got message status " - << MessageStatusToString(message_status) + << DatagramStatusToString(message_status) << " message size with header: " << message.size(); QUIC_DVLOG(2) << "Contents of outgoing HTTP Datagram of length " << message.size() << ":" << std::endl @@ -892,12 +892,12 @@ if (read_size < 0) { break; } - MessageStatus message_status = it->stream()->SendHttp3Datagram( + DatagramStatus message_status = it->stream()->SendHttp3Datagram( absl::string_view(datagram, 1 + read_size)); QUIC_DVLOG(1) << "Encapsulated IP packet of length " << read_size << " with stream ID " << it->stream()->id() << " and got message status " - << MessageStatusToString(message_status); + << DatagramStatusToString(message_status); } return true; } @@ -921,12 +921,12 @@ if (read_size < 0) { break; } - MessageStatus message_status = it->stream()->SendHttp3Datagram( + DatagramStatus message_status = it->stream()->SendHttp3Datagram( absl::string_view(datagram, 1 + read_size)); QUIC_DVLOG(1) << "Encapsulated Ethernet frame of length " << read_size << " with stream ID " << it->stream()->id() << " and got message status " - << MessageStatusToString(message_status); + << DatagramStatusToString(message_status); } return true; }
diff --git a/quiche/quic/masque/masque_server_session.h b/quiche/quic/masque/masque_server_session.h index 1091fdb..d6b79c3 100644 --- a/quiche/quic/masque/masque_server_session.h +++ b/quiche/quic/masque/masque_server_session.h
@@ -65,9 +65,9 @@ MasqueServerSession& operator=(const MasqueServerSession&) = delete; // From QuicSession. - void OnMessageAcked(QuicMessageId message_id, - QuicTime receive_timestamp) override; - void OnMessageLost(QuicMessageId message_id) override; + void OnDatagramAcked(QuicDatagramId datagram_id, + QuicTime receive_timestamp) override; + void OnDatagramLost(QuicDatagramId datagram_id) override; void OnConnectionClosed(const QuicConnectionCloseFrame& frame, ConnectionCloseSource source) override; void OnStreamClosed(QuicStreamId stream_id) override;
diff --git a/quiche/quic/qbone/qbone_control_stream.cc b/quiche/quic/qbone/qbone_control_stream.cc index 18f8f03..38ef9f8 100644 --- a/quiche/quic/qbone/qbone_control_stream.cc +++ b/quiche/quic/qbone/qbone_control_stream.cc
@@ -56,7 +56,7 @@ } } -bool QboneControlStreamBase::SendMessage(const proto2::Message& proto) { +bool QboneControlStreamBase::SendDatagram(const proto2::Message& proto) { std::string tmp; if (!proto.SerializeToString(&tmp)) { QUIC_BUG(quic_bug_11023_1) << "Failed to serialize QboneControlRequest";
diff --git a/quiche/quic/qbone/qbone_control_stream.h b/quiche/quic/qbone/qbone_control_stream.h index 379d735..26d6a84 100644 --- a/quiche/quic/qbone/qbone_control_stream.h +++ b/quiche/quic/qbone/qbone_control_stream.h
@@ -24,7 +24,7 @@ protected: virtual void OnMessage(const std::string& data) = 0; - bool SendMessage(const proto2::Message& proto); + bool SendDatagram(const proto2::Message& proto); private: uint16_t pending_message_size_; @@ -51,7 +51,7 @@ Handler* handler) : QboneControlStreamBase(pending, session), handler_(handler) {} - bool SendRequest(const Outgoing& request) { return SendMessage(request); } + bool SendRequest(const Outgoing& request) { return SendDatagram(request); } protected: void OnMessage(const std::string& data) override {
diff --git a/quiche/quic/qbone/qbone_session_base.cc b/quiche/quic/qbone/qbone_session_base.cc index 14da427..7704aa7 100644 --- a/quiche/quic/qbone/qbone_session_base.cc +++ b/quiche/quic/qbone/qbone_session_base.cc
@@ -85,9 +85,9 @@ QuicSession::OnStreamFrame(frame); } -void QboneSessionBase::OnMessageReceived(absl::string_view message) { - ++num_message_packets_; - ProcessPacketFromPeer(message); +void QboneSessionBase::OnDatagramReceived(absl::string_view datagram) { + ++num_datagram_packets_; + ProcessPacketFromPeer(datagram); } QuicStream* QboneSessionBase::CreateIncomingStream(QuicStreamId id) { @@ -137,13 +137,13 @@ return; } - if (send_packets_as_messages_) { + if (send_packets_as_datagrams_) { quiche::QuicheMemSlice slice(quiche::QuicheBuffer::Copy( connection()->helper()->GetStreamSendBufferAllocator(), packet)); - switch (SendMessage(absl::MakeSpan(&slice, 1), /*flush=*/true).status) { - case MESSAGE_STATUS_SUCCESS: + switch (SendDatagram(absl::MakeSpan(&slice, 1), /*flush=*/true).status) { + case DATAGRAM_STATUS_SUCCESS: break; - case MESSAGE_STATUS_TOO_LARGE: { + case DATAGRAM_STATUS_TOO_LARGE: { if (packet.size() < sizeof(ip6_hdr)) { QUIC_BUG(quic_bug_10987_2) << "Dropped malformed packet: IPv6 header too short"; @@ -153,7 +153,7 @@ icmp6_hdr icmp_header{}; icmp_header.icmp6_type = ICMP6_PACKET_TOO_BIG; icmp_header.icmp6_mtu = - connection()->GetGuaranteedLargestMessagePayload(); + connection()->GetGuaranteedLargestDatagramPayload(); CreateIcmpPacket(header->ip6_dst, header->ip6_src, icmp_header, packet, [this](absl::string_view icmp_packet) { @@ -162,21 +162,21 @@ }); break; } - case MESSAGE_STATUS_ENCRYPTION_NOT_ESTABLISHED: + case DATAGRAM_STATUS_ENCRYPTION_NOT_ESTABLISHED: QUIC_BUG(quic_bug_10987_3) - << "MESSAGE_STATUS_ENCRYPTION_NOT_ESTABLISHED"; + << "DATAGRAM_STATUS_ENCRYPTION_NOT_ESTABLISHED"; break; - case MESSAGE_STATUS_UNSUPPORTED: - QUIC_BUG(quic_bug_10987_4) << "MESSAGE_STATUS_UNSUPPORTED"; + case DATAGRAM_STATUS_UNSUPPORTED: + QUIC_BUG(quic_bug_10987_4) << "DATAGRAM_STATUS_UNSUPPORTED"; break; - case MESSAGE_STATUS_BLOCKED: - QUIC_BUG(quic_bug_10987_5) << "MESSAGE_STATUS_BLOCKED"; + case DATAGRAM_STATUS_BLOCKED: + QUIC_BUG(quic_bug_10987_5) << "DATAGRAM_STATUS_BLOCKED"; break; - case MESSAGE_STATUS_SETTINGS_NOT_RECEIVED: - QUIC_BUG(quic_bug_10987_8) << "MESSAGE_STATUS_SETTINGS_NOT_RECEIVED"; + case DATAGRAM_STATUS_SETTINGS_NOT_RECEIVED: + QUIC_BUG(quic_bug_10987_8) << "DATAGRAM_STATUS_SETTINGS_NOT_RECEIVED"; break; - case MESSAGE_STATUS_INTERNAL_ERROR: - QUIC_BUG(quic_bug_10987_6) << "MESSAGE_STATUS_INTERNAL_ERROR"; + case DATAGRAM_STATUS_INTERNAL_ERROR: + QUIC_BUG(quic_bug_10987_6) << "DATAGRAM_STATUS_INTERNAL_ERROR"; break; } return; @@ -202,8 +202,8 @@ return num_streamed_packets_; } -uint64_t QboneSessionBase::GetNumMessagePackets() const { - return num_message_packets_; +uint64_t QboneSessionBase::GetNumDatagramPackets() const { + return num_datagram_packets_; } uint64_t QboneSessionBase::GetNumFallbackToStream() const {
diff --git a/quiche/quic/qbone/qbone_session_base.h b/quiche/quic/qbone/qbone_session_base.h index e643f0d..ab0481a 100644 --- a/quiche/quic/qbone/qbone_session_base.h +++ b/quiche/quic/qbone/qbone_session_base.h
@@ -31,8 +31,8 @@ void Initialize() override; // This will check if the packet is wholly contained. void OnStreamFrame(const QuicStreamFrame& frame) override; - // Called whenever a MESSAGE frame is received. - void OnMessageReceived(absl::string_view message) override; + // Called whenever a DATAGRAM frame is received. + void OnDatagramReceived(absl::string_view datagram) override; virtual void ProcessPacketFromNetwork(absl::string_view packet) = 0; virtual void ProcessPacketFromPeer(absl::string_view packet) = 0; @@ -47,16 +47,16 @@ uint64_t GetNumStreamedPackets() const; // Returns the number of QBONE network packets that were received using QUIC - // MESSAGE frame. - uint64_t GetNumMessagePackets() const; + // DATAGRAM frame. + uint64_t GetNumDatagramPackets() const; - // Returns the number of times sending a MESSAGE frame failed, and the session - // used an ephemeral stream instead. + // Returns the number of times sending a DATAGRAM frame failed, and the + // session used an ephemeral stream instead. uint64_t GetNumFallbackToStream() const; void set_writer(QbonePacketWriter* writer); - void set_send_packets_as_messages(bool send_packets_as_messages) { - send_packets_as_messages_ = send_packets_as_messages; + void set_send_packets_as_datagrams(bool send_packets_as_datagrams) { + send_packets_as_datagrams_ = send_packets_as_datagrams; } protected: @@ -88,9 +88,9 @@ QbonePacketWriter* writer_; - // If true, send QUIC DATAGRAM (aka MESSAGE) frames instead of ephemeral + // If true, send QUIC DATAGRAM (aka DATAGRAM) frames instead of ephemeral // streams. Note that receiving DATAGRAM frames is always supported. - bool send_packets_as_messages_ = true; + bool send_packets_as_datagrams_ = true; private: // Used for the crypto handshake. @@ -98,10 +98,10 @@ // Statistics for the packets received by the session. uint64_t num_ephemeral_packets_ = 0; - uint64_t num_message_packets_ = 0; + uint64_t num_datagram_packets_ = 0; uint64_t num_streamed_packets_ = 0; - // Number of times the connection has failed to send packets as MESSAGE frame + // Number of times the connection has failed to send packets as DATAGRAM frame // and used streams as a fallback. uint64_t num_fallback_to_stream_ = 0; };
diff --git a/quiche/quic/qbone/qbone_session_test.cc b/quiche/quic/qbone/qbone_session_test.cc index 909f93b..9c943d7 100644 --- a/quiche/quic/qbone/qbone_session_test.cc +++ b/quiche/quic/qbone/qbone_session_test.cc
@@ -423,7 +423,7 @@ // Test handshake establishment and sending/receiving of data for two // directions. - void TestStreamConnection(bool use_messages) { + void TestStreamConnection(bool use_datagrams) { ASSERT_TRUE(server_peer_->OneRttKeysAvailable()); ASSERT_TRUE(client_peer_->OneRttKeysAvailable()); ASSERT_TRUE(server_peer_->IsEncryptionEstablished()); @@ -463,10 +463,10 @@ QUIC_LOG(INFO) << "Sending server -> client long data"; server_peer_->ProcessPacketFromNetwork(TestPacketIn(long_data)); runner_.Run(); - if (use_messages) { + if (use_datagrams) { ExpectICMPTooBigResponse( server_writer_->data(), - server_peer_->connection()->GetGuaranteedLargestMessagePayload(), + server_peer_->connection()->GetGuaranteedLargestDatagramPayload(), TestPacketOut(long_data)); } else { EXPECT_THAT(client_writer_->data(), Contains(TestPacketOut(long_data))); @@ -479,10 +479,10 @@ QUIC_LOG(INFO) << "Sending client -> server long data"; client_peer_->ProcessPacketFromNetwork(TestPacketIn(long_data)); runner_.Run(); - if (use_messages) { + if (use_datagrams) { ExpectICMPTooBigResponse( client_writer_->data(), - client_peer_->connection()->GetGuaranteedLargestMessagePayload(), + client_peer_->connection()->GetGuaranteedLargestDatagramPayload(), TestPacketIn(long_data)); } else { EXPECT_THAT(server_writer_->data(), Contains(TestPacketOut(long_data))); @@ -491,21 +491,21 @@ EXPECT_FALSE(client_peer_->ReceivedInchoateReject()); EXPECT_THAT(client_peer_->GetNumReceivedServerConfigUpdates(), Eq(0)); - if (!use_messages) { + if (!use_datagrams) { EXPECT_THAT(client_peer_->GetNumStreamedPackets(), Eq(1)); EXPECT_THAT(server_peer_->GetNumStreamedPackets(), Eq(1)); } - if (use_messages) { + if (use_datagrams) { EXPECT_THAT(client_peer_->GetNumEphemeralPackets(), Eq(0)); EXPECT_THAT(server_peer_->GetNumEphemeralPackets(), Eq(0)); - EXPECT_THAT(client_peer_->GetNumMessagePackets(), Eq(2)); - EXPECT_THAT(server_peer_->GetNumMessagePackets(), Eq(2)); + EXPECT_THAT(client_peer_->GetNumDatagramPackets(), Eq(2)); + EXPECT_THAT(server_peer_->GetNumDatagramPackets(), Eq(2)); } else { EXPECT_THAT(client_peer_->GetNumEphemeralPackets(), Eq(2)); EXPECT_THAT(server_peer_->GetNumEphemeralPackets(), Eq(2)); - EXPECT_THAT(client_peer_->GetNumMessagePackets(), Eq(0)); - EXPECT_THAT(server_peer_->GetNumMessagePackets(), Eq(0)); + EXPECT_THAT(client_peer_->GetNumDatagramPackets(), Eq(0)); + EXPECT_THAT(server_peer_->GetNumDatagramPackets(), Eq(0)); } // All streams are ephemeral and should be gone. @@ -552,16 +552,16 @@ TEST_P(QboneSessionTest, StreamConnection) { CreateClientAndServerSessions(); - client_peer_->set_send_packets_as_messages(false); - server_peer_->set_send_packets_as_messages(false); + client_peer_->set_send_packets_as_datagrams(false); + server_peer_->set_send_packets_as_datagrams(false); StartHandshake(); TestStreamConnection(false); } -TEST_P(QboneSessionTest, Messages) { +TEST_P(QboneSessionTest, Datagrams) { CreateClientAndServerSessions(); - client_peer_->set_send_packets_as_messages(true); - server_peer_->set_send_packets_as_messages(true); + client_peer_->set_send_packets_as_datagrams(true); + server_peer_->set_send_packets_as_datagrams(true); StartHandshake(); TestStreamConnection(true); }
diff --git a/quiche/quic/test_tools/quic_test_utils.cc b/quiche/quic/test_tools/quic_test_utils.cc index 47304be..30a4672 100644 --- a/quiche/quic/test_tools/quic_test_utils.cc +++ b/quiche/quic/test_tools/quic_test_utils.cc
@@ -429,7 +429,7 @@ return true; } -bool NoOpFramerVisitor::OnMessageFrame(const QuicMessageFrame& /*frame*/) { +bool NoOpFramerVisitor::OnDatagramFrame(const QuicDatagramFrame& /*frame*/) { return true; }
diff --git a/quiche/quic/test_tools/quic_test_utils.h b/quiche/quic/test_tools/quic_test_utils.h index d08657d..ad85c1c 100644 --- a/quiche/quic/test_tools/quic_test_utils.h +++ b/quiche/quic/test_tools/quic_test_utils.h
@@ -352,7 +352,7 @@ (override)); MOCK_METHOD(bool, OnBlockedFrame, (const QuicBlockedFrame& frame), (override)); - MOCK_METHOD(bool, OnMessageFrame, (const QuicMessageFrame& frame), + MOCK_METHOD(bool, OnDatagramFrame, (const QuicDatagramFrame& frame), (override)); MOCK_METHOD(bool, OnHandshakeDoneFrame, (const QuicHandshakeDoneFrame& frame), (override)); @@ -426,7 +426,7 @@ bool OnStreamsBlockedFrame(const QuicStreamsBlockedFrame& frame) override; bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; bool OnBlockedFrame(const QuicBlockedFrame& frame) override; - bool OnMessageFrame(const QuicMessageFrame& frame) override; + bool OnDatagramFrame(const QuicDatagramFrame& frame) override; bool OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) override; bool OnAckFrequencyFrame(const QuicAckFrequencyFrame& frame) override; bool OnImmediateAckFrame(const QuicImmediateAckFrame& frame) override; @@ -465,7 +465,8 @@ MOCK_METHOD(void, OnResetStreamAt, (const QuicResetStreamAtFrame& frame), (override)); MOCK_METHOD(void, OnGoAway, (const QuicGoAwayFrame& frame), (override)); - MOCK_METHOD(void, OnMessageReceived, (absl::string_view message), (override)); + MOCK_METHOD(void, OnDatagramReceived, (absl::string_view datagram), + (override)); MOCK_METHOD(void, OnHandshakeDoneReceived, (), (override)); MOCK_METHOD(void, OnNewTokenReceived, (absl::string_view token), (override)); MOCK_METHOD(void, OnConnectionClosed, @@ -664,8 +665,8 @@ MOCK_METHOD(void, OnStreamReset, (QuicStreamId, QuicRstStreamErrorCode), (override)); MOCK_METHOD(bool, SendControlFrame, (const QuicFrame& frame), (override)); - MOCK_METHOD(MessageStatus, SendMessage, - (QuicMessageId, absl::Span<quiche::QuicheMemSlice>, bool), + MOCK_METHOD(DatagramStatus, SendDatagram, + (QuicDatagramId, absl::Span<quiche::QuicheMemSlice>, bool), (override)); MOCK_METHOD(bool, SendPathChallenge, (const QuicPathFrameBuffer&, const QuicSocketAddress&, @@ -1370,7 +1371,7 @@ MOCK_METHOD(void, OnNewTokenFrame, (const QuicNewTokenFrame&), (override)); - MOCK_METHOD(void, OnMessageFrame, (const QuicMessageFrame&), (override)); + MOCK_METHOD(void, OnDatagramFrame, (const QuicDatagramFrame&), (override)); MOCK_METHOD(void, OnStopSendingFrame, (const QuicStopSendingFrame&), (override)); @@ -1939,8 +1940,8 @@ return framer_.ping_frames(); } - const std::vector<QuicMessageFrame>& message_frames() const { - return framer_.message_frames(); + const std::vector<QuicDatagramFrame>& datagram_frames() const { + return framer_.datagram_frames(); } const std::vector<QuicWindowUpdateFrame>& window_update_frames() const {
diff --git a/quiche/quic/test_tools/simple_quic_framer.cc b/quiche/quic/test_tools/simple_quic_framer.cc index 90b75e8..00e1c13 100644 --- a/quiche/quic/test_tools/simple_quic_framer.cc +++ b/quiche/quic/test_tools/simple_quic_framer.cc
@@ -222,9 +222,9 @@ return true; } - bool OnMessageFrame(const QuicMessageFrame& frame) override { - message_frames_.emplace_back(frame.data, frame.message_length); - frame_types_.push_back(MESSAGE_FRAME); + bool OnDatagramFrame(const QuicDatagramFrame& frame) override { + datagram_frames_.emplace_back(frame.data, frame.datagram_length); + frame_types_.push_back(DATAGRAM_FRAME); return true; } @@ -303,8 +303,8 @@ return stop_waiting_frames_; } const std::vector<QuicPingFrame>& ping_frames() const { return ping_frames_; } - const std::vector<QuicMessageFrame>& message_frames() const { - return message_frames_; + const std::vector<QuicDatagramFrame>& datagram_frames() const { + return datagram_frames_; } const std::vector<QuicWindowUpdateFrame>& window_update_frames() const { return window_update_frames_; @@ -352,7 +352,7 @@ std::vector<QuicNewConnectionIdFrame> new_connection_id_frames_; std::vector<QuicRetireConnectionIdFrame> retire_connection_id_frames_; std::vector<QuicNewTokenFrame> new_token_frames_; - std::vector<QuicMessageFrame> message_frames_; + std::vector<QuicDatagramFrame> datagram_frames_; std::vector<QuicHandshakeDoneFrame> handshake_done_frames_; std::vector<QuicAckFrequencyFrame> ack_frequency_frames_; std::vector<QuicImmediateAckFrame> immediate_ack_frames_; @@ -445,8 +445,9 @@ return visitor_->ping_frames(); } -const std::vector<QuicMessageFrame>& SimpleQuicFramer::message_frames() const { - return visitor_->message_frames(); +const std::vector<QuicDatagramFrame>& SimpleQuicFramer::datagram_frames() + const { + return visitor_->datagram_frames(); } const std::vector<QuicWindowUpdateFrame>&
diff --git a/quiche/quic/test_tools/simple_quic_framer.h b/quiche/quic/test_tools/simple_quic_framer.h index 53f883e..49a3a92 100644 --- a/quiche/quic/test_tools/simple_quic_framer.h +++ b/quiche/quic/test_tools/simple_quic_framer.h
@@ -42,7 +42,7 @@ const std::vector<QuicPathChallengeFrame>& path_challenge_frames() const; const std::vector<QuicPathResponseFrame>& path_response_frames() const; const std::vector<QuicPingFrame>& ping_frames() const; - const std::vector<QuicMessageFrame>& message_frames() const; + const std::vector<QuicDatagramFrame>& datagram_frames() const; const std::vector<QuicWindowUpdateFrame>& window_update_frames() const; const std::vector<QuicGoAwayFrame>& goaway_frames() const; const std::vector<QuicRstStreamFrame>& rst_stream_frames() const;
diff --git a/quiche/quic/test_tools/simulator/quic_endpoint.h b/quiche/quic/test_tools/simulator/quic_endpoint.h index f74718a..eb9d54a 100644 --- a/quiche/quic/test_tools/simulator/quic_endpoint.h +++ b/quiche/quic/test_tools/simulator/quic_endpoint.h
@@ -56,7 +56,7 @@ void OnRstStream(const QuicRstStreamFrame& /*frame*/) override {} void OnResetStreamAt(const QuicResetStreamAtFrame& /*frame*/) override {} void OnGoAway(const QuicGoAwayFrame& /*frame*/) override {} - void OnMessageReceived(absl::string_view /*message*/) override {} + void OnDatagramReceived(absl::string_view /*datagram*/) override {} void OnHandshakeDoneReceived() override {} void OnNewTokenReceived(absl::string_view /*token*/) override {} void OnConnectionClosed(const QuicConnectionCloseFrame& /*frame*/,
diff --git a/quiche/quic/tools/connect_udp_tunnel_test.cc b/quiche/quic/tools/connect_udp_tunnel_test.cc index 918ec19..38e7755 100644 --- a/quiche/quic/tools/connect_udp_tunnel_test.cc +++ b/quiche/quic/tools/connect_udp_tunnel_test.cc
@@ -56,7 +56,7 @@ void OnBodyAvailable() override {} - MOCK_METHOD(MessageStatus, SendHttp3Datagram, (absl::string_view data), + MOCK_METHOD(DatagramStatus, SendHttp3Datagram, (absl::string_view data), (override)); }; @@ -315,7 +315,7 @@ stream_, SendHttp3Datagram( quiche::ConnectUdpDatagramUdpPacketPayload(kData).Serialize())) - .WillOnce(Return(MESSAGE_STATUS_SUCCESS)); + .WillOnce(Return(DATAGRAM_STATUS_SUCCESS)); quiche::HttpHeaderBlock request_headers; request_headers[":method"] = "CONNECT";
diff --git a/quiche/quic/tools/quic_packet_printer_bin.cc b/quiche/quic/tools/quic_packet_printer_bin.cc index 9aad0aa..fd7cb15 100644 --- a/quiche/quic/tools/quic_packet_printer_bin.cc +++ b/quiche/quic/tools/quic_packet_printer_bin.cc
@@ -203,8 +203,8 @@ std::cerr << "OnBlockedFrame: " << frame; return true; } - bool OnMessageFrame(const QuicMessageFrame& frame) override { - std::cerr << "OnMessageFrame: " << frame; + bool OnDatagramFrame(const QuicDatagramFrame& frame) override { + std::cerr << "OnDatagramFrame: " << frame; return true; } bool OnHandshakeDoneFrame(const QuicHandshakeDoneFrame& frame) override {