Change MoQT control message size to be 16 bits.
PiperOrigin-RevId: 755220706
diff --git a/quiche/quic/moqt/moqt_framer.cc b/quiche/quic/moqt/moqt_framer.cc
index bf810f4..d2f57fc 100644
--- a/quiche/quic/moqt/moqt_framer.cc
+++ b/quiche/quic/moqt/moqt_framer.cc
@@ -160,17 +160,17 @@
QuicheBuffer SerializeControlMessage(MoqtMessageType type, Ts... data) {
uint64_t message_type = static_cast<uint64_t>(type);
size_t payload_size = quiche::ComputeLengthOnWire(data...);
- size_t buffer_size =
- payload_size + quiche::ComputeLengthOnWire(WireVarInt62(message_type),
- WireVarInt62(payload_size));
+ size_t buffer_size = sizeof(uint16_t) + payload_size +
+ quiche::ComputeLengthOnWire(WireVarInt62(message_type));
if (buffer_size == 0) {
return QuicheBuffer();
}
QuicheBuffer buffer(quiche::SimpleBufferAllocator::Get(), buffer_size);
quiche::QuicheDataWriter writer(buffer.size(), buffer.data());
- absl::Status status = SerializeIntoWriter(
- writer, WireVarInt62(message_type), WireVarInt62(payload_size), data...);
+ absl::Status status =
+ SerializeIntoWriter(writer, WireVarInt62(message_type),
+ quiche::WireUint16(payload_size), data...);
if (!status.ok() || writer.remaining() != 0) {
QUICHE_BUG(moqt_failed_serialization)
<< "Failed to serialize MoQT frame: " << status;
diff --git a/quiche/quic/moqt/moqt_framer_test.cc b/quiche/quic/moqt/moqt_framer_test.cc
index 21738c9..e772bc8 100644
--- a/quiche/quic/moqt/moqt_framer_test.cc
+++ b/quiche/quic/moqt/moqt_framer_test.cc
@@ -427,7 +427,7 @@
}
buffer = framer_.SerializeSubscribe(subscribe);
// Go to the filter type.
- const uint8_t* read = BufferAtOffset(buffer, 16);
+ const uint8_t* read = BufferAtOffset(buffer, 17);
EXPECT_EQ(static_cast<MoqtFilterType>(*read), expected_filter_type);
EXPECT_GT(buffer.size(), 0);
}
@@ -486,7 +486,7 @@
quiche::QuicheBuffer buffer;
buffer = framer_.SerializeSubscribeUpdate(subscribe_update);
EXPECT_GT(buffer.size(), 0);
- const uint8_t* end_group = BufferAtOffset(buffer, 5);
+ const uint8_t* end_group = BufferAtOffset(buffer, 6);
EXPECT_EQ(*end_group, 5);
}
@@ -501,7 +501,7 @@
quiche::QuicheBuffer buffer;
buffer = framer_.SerializeSubscribeUpdate(subscribe_update);
EXPECT_GT(buffer.size(), 0);
- const uint8_t* end_group = BufferAtOffset(buffer, 5);
+ const uint8_t* end_group = BufferAtOffset(buffer, 6);
EXPECT_EQ(*end_group, 5);
}
diff --git a/quiche/quic/moqt/moqt_parser.cc b/quiche/quic/moqt/moqt_parser.cc
index 66d52ba..5dd2508 100644
--- a/quiche/quic/moqt/moqt_parser.cc
+++ b/quiche/quic/moqt/moqt_parser.cc
@@ -179,7 +179,6 @@
auto on_return = absl::MakeCleanup([&] { processing_ = false; });
while (!no_more_data_) {
bool fin_read = false;
-
// Read the message type.
if (!message_type_.has_value()) {
message_type_ = ReadVarInt62FromStream(stream_, fin_read);
@@ -195,15 +194,23 @@
// Read the message length.
if (!message_size_.has_value()) {
- message_size_ = ReadVarInt62FromStream(stream_, fin_read);
- if (fin_read) {
+ if (stream_.ReadableBytes() < 2) {
+ return;
+ }
+ std::array<char, 2> size_bytes;
+ quiche::ReadStream::ReadResult result =
+ stream_.Read(absl::MakeSpan(size_bytes));
+ if (result.bytes_read != 2) {
+ ParseError(MoqtError::kInternalError,
+ "Stream returned incorrect ReadableBytes");
+ return;
+ }
+ if (result.fin) {
ParseError("FIN on control stream");
return;
}
- if (!message_size_.has_value()) {
- return;
- }
-
+ message_size_ = static_cast<uint16_t>(size_bytes[0]) << 8 |
+ static_cast<uint16_t>(size_bytes[1]);
if (*message_size_ > kMaxMessageHeaderSize) {
ParseError(MoqtError::kInternalError,
absl::StrCat("Cannot parse control messages more than ",
diff --git a/quiche/quic/moqt/moqt_parser.h b/quiche/quic/moqt/moqt_parser.h
index 2259f9d..1cb2fe3 100644
--- a/quiche/quic/moqt/moqt_parser.h
+++ b/quiche/quic/moqt/moqt_parser.h
@@ -159,7 +159,7 @@
bool parsing_error_ = false;
std::optional<uint64_t> message_type_;
- std::optional<uint64_t> message_size_;
+ std::optional<uint16_t> message_size_;
uint64_t max_auth_token_cache_size_ = 0;
uint64_t auth_token_cache_size_ = 0;
diff --git a/quiche/quic/moqt/moqt_parser_test.cc b/quiche/quic/moqt/moqt_parser_test.cc
index eb54620..7e4ba28 100644
--- a/quiche/quic/moqt/moqt_parser_test.cc
+++ b/quiche/quic/moqt/moqt_parser_test.cc
@@ -562,11 +562,11 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char setup[] = {
- 0x20, 0x0d, 0x02, 0x01, 0x02, // versions
- 0x03, // 3 params
- 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
- 0x02, 0x32, // max_request_id = 50
- 0x02, 0x32, // max_request_id = 50
+ 0x20, 0x00, 0x0d, 0x02, 0x01, 0x02, // versions
+ 0x03, // 3 params
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
+ 0x02, 0x32, // max_request_id = 50
+ 0x02, 0x32, // max_request_id = 50
};
stream.Receive(absl::string_view(setup, sizeof(setup)), false);
parser.ReadAndDispatchMessages();
@@ -580,7 +580,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char setup[] = {
- 0x21, 0x07,
+ 0x21, 0x00, 0x07,
0x01, // version = 1
0x01, // 1 param
0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
@@ -597,10 +597,10 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char setup[] = {
- 0x20, 0x0e, 0x02, 0x01, 0x02, // versions = 1, 2
- 0x02, // 2 params
- 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
- 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
+ 0x20, 0x00, 0x0e, 0x02, 0x01, 0x02, // versions = 1, 2
+ 0x02, // 2 params
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
};
stream.Receive(absl::string_view(setup, sizeof(setup)), false);
parser.ReadAndDispatchMessages();
@@ -614,9 +614,9 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kWebTrans, &stream, visitor_);
char setup[] = {
- 0x20, 0x09, 0x02, 0x01, 0x02, // versions = 1, 2
- 0x01, // 1 param
- 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
+ 0x20, 0x00, 0x09, 0x02, 0x01, 0x02, // versions = 1, 2
+ 0x01, // 1 param
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
};
stream.Receive(absl::string_view(setup, sizeof(setup)), false);
parser.ReadAndDispatchMessages();
@@ -630,8 +630,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char setup[] = {
- 0x20, 0x04, 0x02, 0x01, 0x02, // versions = 1, 2
- 0x00, // no param
+ 0x20, 0x00, 0x04, 0x02, 0x01, 0x02, // versions = 1, 2
+ 0x00, // no param
};
stream.Receive(absl::string_view(setup, sizeof(setup)), false);
parser.ReadAndDispatchMessages();
@@ -645,11 +645,11 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char setup[] = {
- 0x20, 0x0d, 0x02, 0x01, 0x02, // versions = 1, 2
- 0x03, // 4 params
- 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
- 0x02, 0x32, // max_subscribe_id = 50
- 0x02, 0x32, // max_subscribe_id = 50
+ 0x20, 0x00, 0x0d, 0x02, 0x01, 0x02, // versions = 1, 2
+ 0x03, // 4 params
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // path = "foo"
+ 0x02, 0x32, // max_subscribe_id = 50
+ 0x02, 0x32, // max_subscribe_id = 50
};
stream.Receive(absl::string_view(setup, sizeof(setup)), false);
parser.ReadAndDispatchMessages();
@@ -663,8 +663,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kWebTrans, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x1a, 0x01, 0x02, 0x01,
- 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, 0x00, 0x1a, 0x01, 0x02,
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
0x02, // filter_type = kLatestObject
@@ -681,8 +681,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x16, 0x01, 0x02, 0x01,
- 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, 0x00, 0x16, 0x01, 0x02,
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
0x02, // filter_type = kLatestObject
@@ -701,8 +701,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x16, 0x01, 0x02, 0x01,
- 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, 0x00, 0x16, 0x01, 0x02,
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
0x02, // filter_type = kLatestObject
@@ -721,8 +721,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x14, 0x01, 0x02, 0x01,
- 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, 0x00, 0x14, 0x01, 0x02,
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
0x02, // filter_type = kLatestObject
@@ -740,7 +740,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x18, 0x01, 0x02, 0x01, 0x03, 0x66, 0x6f,
+ 0x03, 0x00, 0x18, 0x01, 0x02, 0x01, 0x03, 0x66, 0x6f,
0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
@@ -759,8 +759,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x14, 0x01, 0x02, 0x01,
- 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, 0x00, 0x14, 0x01, 0x02,
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
0x02, // filter_type = kLatestObject
@@ -779,8 +779,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x14, 0x01, 0x02, 0x01,
- 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, 0x00, 0x14, 0x01, 0x02,
+ 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
0x02, // filter_type = kLatestObject
@@ -799,8 +799,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x16, 0x01, 0x02, 0x01, 0x03,
- 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, 0x00, 0x16, 0x01, 0x02, 0x01,
+ 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
0x02, // filter_type = kLatestObject
@@ -818,11 +818,11 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kWebTrans, &stream, visitor_);
char subscribe_ok[] = {
- 0x04, 0x11, 0x01, 0x03, // subscribe_id = 1, expires = 3
- 0x02, 0x01, // group_order = 2, content exists
- 0x0c, 0x14, // largest_group_id = 12, largest_object_id = 20,
- 0x02, // 2 parameters
- 0x02, 0x67, 0x10, // delivery_timeout = 10000
+ 0x04, 0x00, 0x11, 0x01, 0x03, // subscribe_id = 1, expires = 3
+ 0x02, 0x01, // group_order = 2, content exists
+ 0x0c, 0x14, // largest_group_id = 12, largest_object_id = 20,
+ 0x02, // 2 parameters
+ 0x02, 0x67, 0x10, // delivery_timeout = 10000
0x01, 0x05, 0x03, 0x00, 0x62, 0x61, 0x72, // authorization_token = "bar"
};
stream.Receive(absl::string_view(subscribe_ok, sizeof(subscribe_ok)), false);
@@ -837,7 +837,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kWebTrans, &stream, visitor_);
char subscribe_update[] = {
- 0x02, 0x0d, 0x02, 0x03, 0x01, 0x05, // start and end sequences
+ 0x02, 0x00, 0x0d, 0x02, 0x03, 0x01, 0x05, // start and end sequences
0xaa, // priority = 0xaa
0x01, // 1 parameter
0x01, 0x05, 0x03, 0x00, 0x62, 0x61, 0x72, // authorization_token = "bar"
@@ -855,7 +855,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kWebTrans, &stream, visitor_);
char announce[] = {
- 0x06, 0x14, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x06, 0x00, 0x14, 0x01, 0x03, 0x66, 0x6f,
+ 0x6f, // track_namespace = "foo"
0x02, // 2 params
0x01, 0x05, 0x03, 0x00, 0x62, 0x61, 0x72, // authorization = "bar"
0x01, 0x05, 0x03, 0x00, 0x62, 0x61, 0x72, // authorization = "bar"
@@ -869,7 +870,8 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kWebTrans, &stream, visitor_);
char announce[] = {
- 0x06, 0x10, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x06, 0x00, 0x10, 0x01, 0x03, 0x66, 0x6f,
+ 0x6f, // track_namespace = "foo"
0x02, // 2 params
0x01, 0x05, 0x03, 0x00, 0x62, 0x61, 0x72, // authorization_info = "bar"
0x02, 0x67, 0x10, // delivery_timeout = 10000
@@ -943,7 +945,7 @@
char big_message[2 * kMaxMessageHeaderSize];
quic::QuicDataWriter writer(sizeof(big_message), big_message);
writer.WriteVarInt62(static_cast<uint64_t>(MoqtMessageType::kServerSetup));
- writer.WriteVarInt62(8 + kMaxMessageHeaderSize);
+ writer.WriteUInt16(8 + kMaxMessageHeaderSize);
writer.WriteVarInt62(0x1); // version
writer.WriteVarInt62(0x1); // num_params
writer.WriteVarInt62(0xbeef); // unknown param
@@ -961,10 +963,10 @@
TEST_F(MoqtMessageSpecificTest, UnknownMessageType) {
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
- char message[6];
+ char message[7];
quic::QuicDataWriter writer(sizeof(message), message);
writer.WriteVarInt62(0xbeef); // unknown message type
- writer.WriteVarInt62(0x1); // length
+ writer.WriteUInt16(0x1); // length
writer.WriteVarInt62(0x1); // payload
stream.Receive(absl::string_view(message, writer.length()), false);
parser.ReadAndDispatchMessages();
@@ -976,7 +978,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x15, 0x01, 0x02, // id and alias
+ 0x03, 0x00, 0x15, 0x01, 0x02, // id and alias
0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20, group order descending
@@ -998,7 +1000,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x15, 0x01, 0x02, // id and alias
+ 0x03, 0x00, 0x15, 0x01, 0x02, // id and alias
0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x08, // priority = 0x20 ???
@@ -1016,7 +1018,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x17, 0x01, 0x02, // id and alias
+ 0x03, 0x00, 0x17, 0x01, 0x02, // id and alias
0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
@@ -1041,7 +1043,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x18, 0x01, 0x02, // id and alias
+ 0x03, 0x00, 0x18, 0x01, 0x02, // id and alias
0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
@@ -1067,7 +1069,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x18, 0x01, 0x02, // id and alias
+ 0x03, 0x00, 0x18, 0x01, 0x02, // id and alias
0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
@@ -1088,7 +1090,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe[] = {
- 0x03, 0x13, 0x01, 0x02, // id and alias
+ 0x03, 0x00, 0x13, 0x01, 0x02, // id and alias
0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, 0x02, // priority = 0x20 descending
@@ -1107,9 +1109,9 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe_update[] = {
- 0x02, 0x06, 0x02, 0x03, 0x01, 0x04, // start and end sequences
- 0x20, // priority
- 0x00, // No parameters
+ 0x02, 0x00, 0x06, 0x02, 0x03, 0x01, 0x04, // start and end sequences
+ 0x20, // priority
+ 0x00, // No parameters
};
stream.Receive(absl::string_view(subscribe_update, sizeof(subscribe_update)),
false);
@@ -1121,10 +1123,10 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char subscribe_update[] = {
- 0x02, 0x08, 0x02, 0x03, 0x01, 0x03, // start and end sequences
- 0x20, // priority
- 0x01, // 1 parameter
- 0x02, 0x20, // delivery_timeout = 32 ms
+ 0x02, 0x00, 0x08, 0x02, 0x03, 0x01, 0x03, // start and end sequences
+ 0x20, // priority
+ 0x01, // 1 parameter
+ 0x02, 0x20, // delivery_timeout = 32 ms
};
stream.Receive(absl::string_view(subscribe_update, sizeof(subscribe_update)),
false);
@@ -1137,9 +1139,9 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char object_ack[] = {
- 0x71, 0x84, 0x05, // type
- 0x01, 0x10, 0x20, // subscribe ID, group, object
- 0x40, 0x81, // -0x40 time delta
+ 0x71, 0x84, 0x00, 0x05, // type
+ 0x01, 0x10, 0x20, // subscribe ID, group, object
+ 0x40, 0x81, // -0x40 time delta
};
stream.Receive(absl::string_view(object_ack, sizeof(object_ack)), false);
parser.ReadAndDispatchMessages();
@@ -1319,15 +1321,15 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char announce_ok[] = {
- 0x07, 0x03, // type, length
- 0x01, 0x01, 'a', // 1 namespace element
+ 0x07, 0x00, 0x03, // type, length
+ 0x01, 0x01, 'a', // 1 namespace element
};
stream.Receive(absl::string_view(announce_ok, sizeof(announce_ok)), false);
parser.ReadAndDispatchMessages();
EXPECT_EQ(visitor_.messages_received_, 1);
EXPECT_EQ(visitor_.parsing_error_, std::nullopt);
- announce_ok[1] -= 2; // Remove one element.
- announce_ok[2] = 0x00;
+ announce_ok[2] -= 2; // Remove one element.
+ announce_ok[3] = 0x00;
stream.Receive(absl::string_view(announce_ok, sizeof(announce_ok) - 2),
false);
parser.ReadAndDispatchMessages();
@@ -1339,7 +1341,7 @@
webtransport::test::InMemoryStream stream(/*stream_id=*/0);
MoqtControlParser parser(kRawQuic, &stream, visitor_);
char announce_ok[70] = {
- 0x07, 0x40, 0x41, // type, length = 65
+ 0x07, 0x00, 0x41, // type, length = 65
0x20, // 32 namespace elements. This is the maximum.
};
for (size_t i = 4; i < sizeof(announce_ok); i = i + 2) {
diff --git a/quiche/quic/moqt/test_tools/moqt_test_message.h b/quiche/quic/moqt/test_tools/moqt_test_message.h
index 898bfd1..b0709ef 100644
--- a/quiche/quic/moqt/test_tools/moqt_test_message.h
+++ b/quiche/quic/moqt/test_tools/moqt_test_message.h
@@ -75,12 +75,12 @@
void DecreasePayloadLengthByOne() {
size_t length_offset =
0x1 << ((static_cast<uint8_t>(wire_image_[0]) & 0xc0) >> 6);
- wire_image_[length_offset]--;
+ wire_image_[length_offset + 1]--;
}
void IncreasePayloadLengthByOne() {
size_t length_offset =
0x1 << ((static_cast<uint8_t>(wire_image_[0]) & 0xc0) >> 6);
- wire_image_[length_offset]++;
+ wire_image_[length_offset + 1]++;
set_wire_image_size(wire_image_size_ + 1);
}
@@ -92,12 +92,10 @@
// Expands all the varints in the message, alternating between making them 2,
// 4, and 8 bytes long. Updates length fields accordingly.
- // Each character in |varints| corresponds to a byte in the original message.
+ // Each character in |varints| corresponds to a byte in the original message
+ // payload.
// If there is a 'v', it is a varint that should be expanded. If '-', skip
// to the next byte.
- // Always expand the message length field (if a control message) to 2 bytes,
- // so it's a known length that is large enough to be safe. The second byte
- // of |varints| does not matter.
void ExpandVarintsImpl(absl::string_view varints,
bool is_control_message = true) {
int next_varint_len = 2;
@@ -105,39 +103,29 @@
quic::QuicDataReader reader(
absl::string_view(wire_image_, wire_image_size_));
quic::QuicDataWriter writer(sizeof(new_wire_image), new_wire_image);
- size_t i = 0;
size_t length_field = 0;
if (is_control_message) {
- // the length will be a 16-bit varint.
- bool nonvarint_type = false;
- while (varints[i] == '-') {
- ++i;
- nonvarint_type = true;
- uint8_t byte;
- reader.ReadUInt8(&byte);
- writer.WriteUInt8(byte);
- }
- uint64_t value;
- if (!nonvarint_type) {
- ++i;
- reader.ReadVarInt62(&value);
+ uint8_t type_length = static_cast<uint8_t>(reader.PeekVarInt62Length());
+ uint64_t type;
+ reader.ReadVarInt62(&type);
+ if (type_length == 1) {
+ // Expand the message type.
+ type_length = next_varint_len;
writer.WriteVarInt62WithForcedLength(
- value, static_cast<quiche::QuicheVariableLengthIntegerLength>(
- next_varint_len));
- next_varint_len *= 2;
- if (next_varint_len == 16) {
- next_varint_len = 2;
- }
+ type, static_cast<quiche::QuicheVariableLengthIntegerLength>(
+ type_length));
+ next_varint_len = 4;
+ } else {
+ writer.WriteVarInt62(type);
}
- reader.ReadVarInt62(&value);
- ++i;
length_field = writer.length();
- // Write in current length as a 2B placeholder.
- writer.WriteVarInt62WithForcedLength(
- value, static_cast<quiche::QuicheVariableLengthIntegerLength>(2));
+ uint16_t size;
+ reader.ReadUInt16(&size);
+ writer.WriteUInt16(size);
}
+ size_t i = 0;
while (!reader.IsDoneReading()) {
- if (i >= varints.length() || varints[i++] == '-') {
+ if (i >= (varints.length()) || varints[i++] == '-') {
uint8_t byte;
reader.ReadUInt8(&byte);
writer.WriteUInt8(byte);
@@ -155,9 +143,10 @@
}
memcpy(wire_image_, new_wire_image, writer.length());
wire_image_size_ = writer.length();
- if (is_control_message) {
- wire_image_[length_field + 1] =
- static_cast<uint8_t>(writer.length() - length_field - 2);
+ if (is_control_message) { // First byte will be empty.
+ quic::QuicDataWriter length_writer(writer.length(),
+ &wire_image_[length_field]);
+ length_writer.WriteUInt16(writer.length() - length_field - 2);
}
}
@@ -378,8 +367,8 @@
if (webtrans) {
// Should not send PATH.
client_setup_.parameters.path = "";
- raw_packet_[1] = 0x06; // adjust payload length (-5)
- raw_packet_[5] = 0x01; // only one parameter
+ raw_packet_[2] = 0x06; // adjust payload length (-5)
+ raw_packet_[6] = 0x01; // only one parameter
SetWireImage(raw_packet_, sizeof(raw_packet_) - 5);
} else {
SetWireImage(raw_packet_, sizeof(raw_packet_));
@@ -409,9 +398,9 @@
void ExpandVarints() override {
if (!client_setup_.parameters.path.empty()) {
- ExpandVarintsImpl("vvvvvvvvvv---");
+ ExpandVarintsImpl("vvvvvvvv---");
} else {
- ExpandVarintsImpl("vvvvvvvv");
+ ExpandVarintsImpl("vvvvvv");
}
}
@@ -420,8 +409,8 @@
}
private:
- uint8_t raw_packet_[13] = {
- 0x20, 0x0b, // type
+ uint8_t raw_packet_[14] = {
+ 0x20, 0x00, 0x0b, // type
0x02, 0x01, 0x02, // versions
0x02, // 2 parameters
0x02, 0x32, // max_request_id = 50
@@ -450,17 +439,17 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvvvv"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vvvv"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(server_setup_);
}
private:
- uint8_t raw_packet_[6] = {
- 0x21, 0x04, // type
- 0x01, 0x01, // version, one parameter
- 0x02, 0x32, // max_request_id = 50
+ uint8_t raw_packet_[7] = {
+ 0x21, 0x00, 0x04, // type
+ 0x01, 0x01, // version, one parameter
+ 0x02, 0x32, // max_subscribe_id = 50
};
MoqtServerSetup server_setup_ = {
/*selected_version=*/static_cast<MoqtVersion>(1),
@@ -512,7 +501,7 @@
}
void ExpandVarints() override {
- ExpandVarintsImpl("vvvvvv---v------vvvvv--vv-----");
+ ExpandVarintsImpl("vvvv---v------vvvvv--vv-----");
}
MessageStructuredData structured_data() const override {
@@ -520,8 +509,8 @@
}
private:
- uint8_t raw_packet_[30] = {
- 0x03, 0x1c, 0x01, 0x02, // id and alias
+ uint8_t raw_packet_[31] = {
+ 0x03, 0x00, 0x1c, 0x01, 0x02, // id and alias
0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x20, // subscriber priority = 0x20
@@ -579,30 +568,30 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv--vvvv--v--"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv--vvvv--v--"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(subscribe_ok_);
}
void SetInvalidContentExists() {
- raw_packet_[5] = 0x02;
+ raw_packet_[6] = 0x02;
SetWireImage(raw_packet_, sizeof(raw_packet_));
}
void SetInvalidDeliveryOrder() {
- raw_packet_[4] = 0x10;
+ raw_packet_[5] = 0x10;
SetWireImage(raw_packet_, sizeof(raw_packet_));
}
private:
- uint8_t raw_packet_[15] = {
- 0x04, 0x0d, 0x01, 0x03, // subscribe_id = 1, expires = 3
- 0x02, 0x01, // group_order = 2, content exists
- 0x0c, 0x14, // largest_group_id = 12, largest_object_id = 20,
- 0x02, // 2 parameters
- 0x02, 0x67, 0x10, // delivery_timeout = 10000
- 0x04, 0x67, 0x10, // max_cache_duration = 10000
+ uint8_t raw_packet_[16] = {
+ 0x04, 0x00, 0x0d, 0x01, 0x03, // subscribe_id = 1, expires = 3
+ 0x02, 0x01, // group_order = 2, content exists
+ 0x0c, 0x14, // largest_group_id = 12, largest_object_id = 20,
+ 0x02, // 2 parameters
+ 0x02, 0x67, 0x10, // delivery_timeout = 10000
+ 0x04, 0x67, 0x10, // max_cache_duration = 10000
};
MoqtSubscribeOk subscribe_ok_ = {
@@ -642,15 +631,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvvv---v"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vvv---v"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(subscribe_error_);
}
private:
- uint8_t raw_packet_[9] = {
- 0x05, 0x07,
+ uint8_t raw_packet_[10] = {
+ 0x05, 0x00, 0x07,
0x02, // subscribe_id = 2
0x05, // error_code = 5
0x03, 0x62, 0x61, 0x72, // reason_phrase = "bar"
@@ -680,15 +669,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvv"); }
+ void ExpandVarints() override { ExpandVarintsImpl("v"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(unsubscribe_);
}
private:
- uint8_t raw_packet_[3] = {
- 0x0a, 0x01, 0x03, // subscribe_id = 3
+ uint8_t raw_packet_[4] = {
+ 0x0a, 0x00, 0x01, 0x03, // subscribe_id = 3
};
MoqtUnsubscribe unsubscribe_ = {
@@ -724,17 +713,17 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvvvv--"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vvvv--"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(subscribe_done_);
}
private:
- uint8_t raw_packet_[8] = {
- 0x0b, 0x06, 0x02, 0x02, // subscribe_id = 2, error_code = 2,
- 0x05, // stream_count = 5
- 0x02, 0x68, 0x69, // reason_phrase = "hi"
+ uint8_t raw_packet_[9] = {
+ 0x0b, 0x00, 0x06, 0x02, 0x02, // subscribe_id = 2, error_code = 2,
+ 0x05, // stream_count = 5
+ 0x02, 0x68, 0x69, // reason_phrase = "hi"
};
MoqtSubscribeDone subscribe_done_ = {
@@ -776,18 +765,18 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvvvv-vv--"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vvvv-vv--"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(subscribe_update_);
}
private:
- uint8_t raw_packet_[11] = {
- 0x02, 0x09, 0x02, 0x03, 0x01, 0x05, // start and end sequences
- 0xaa, // subscriber_priority
- 0x01, // 1 parameter
- 0x02, 0x67, 0x10, // delivery_timeout = 10000
+ uint8_t raw_packet_[12] = {
+ 0x02, 0x00, 0x09, 0x02, 0x03, 0x01, 0x05, // start and end sequences
+ 0xaa, // subscriber_priority
+ 0x01, // 1 parameter
+ 0x02, 0x67, 0x10, // delivery_timeout = 10000
};
MoqtSubscribeUpdate subscribe_update_ = {
@@ -819,15 +808,16 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---vvv-----"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---vvv-----"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(announce_);
}
private:
- uint8_t raw_packet_[15] = {
- 0x06, 0x0d, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ uint8_t raw_packet_[16] = {
+ 0x06, 0x00, 0x0d, 0x01, 0x03, 0x66, 0x6f,
+ 0x6f, // track_namespace = "foo"
0x01, // 1 parameter
0x01, 0x05, 0x03, 0x00, 0x62, 0x61, 0x72, // authorization_tag = "bar"
};
@@ -853,15 +843,16 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(announce_ok_);
}
private:
- uint8_t raw_packet_[7] = {
- 0x07, 0x05, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ uint8_t raw_packet_[8] = {
+ 0x07, 0x00, 0x05, 0x01,
+ 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
};
MoqtAnnounceOk announce_ok_ = {
@@ -892,17 +883,18 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---vv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---vv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(announce_error_);
}
private:
- uint8_t raw_packet_[12] = {
- 0x08, 0x0a, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
- 0x03, // error_code = 3
- 0x03, 0x62, 0x61, 0x72, // reason_phrase = "bar"
+ uint8_t raw_packet_[13] = {
+ 0x08, 0x00, 0x0a, 0x01,
+ 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, // error_code = 3
+ 0x03, 0x62, 0x61, 0x72, // reason_phrase = "bar"
};
MoqtAnnounceError announce_error_ = {
@@ -935,17 +927,18 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---vv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---vv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(announce_cancel_);
}
private:
- uint8_t raw_packet_[12] = {
- 0x0c, 0x0a, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
- 0x03, // error_code = 3
- 0x03, 0x62, 0x61, 0x72, // reason_phrase = "bar"
+ uint8_t raw_packet_[13] = {
+ 0x0c, 0x00, 0x0a, 0x01,
+ 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x03, // error_code = 3
+ 0x03, 0x62, 0x61, 0x72, // reason_phrase = "bar"
};
MoqtAnnounceCancel announce_cancel_ = {
@@ -974,15 +967,16 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---v----vvv-----"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---v----vvv-----"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(track_status_request_);
}
private:
- uint8_t raw_packet_[20] = {
- 0x0d, 0x12, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ uint8_t raw_packet_[21] = {
+ 0x0d, 0x00, 0x12, 0x01, 0x03, 0x66, 0x6f,
+ 0x6f, // track_namespace = "foo"
0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
0x01, // 1 parameter
0x01, 0x05, 0x03, 0x00, 0x62, 0x61, 0x72, // authorization_tag = "bar"
@@ -1009,15 +1003,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(unannounce_);
}
private:
- uint8_t raw_packet_[7] = {
- 0x09, 0x05, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace
+ uint8_t raw_packet_[8] = {
+ 0x09, 0x00, 0x05, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace
};
MoqtUnannounce unannounce_ = {
@@ -1056,20 +1050,21 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---v----vvvvv--v--"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---v----vvvvv--v--"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(track_status_);
}
private:
- uint8_t raw_packet_[22] = {
- 0x0e, 0x14, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
- 0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
- 0x00, 0x0c, 0x14, // status, last_group, last_object
- 0x02, // 2 parameters
- 0x02, 0x67, 0x10, // Delivery Timeout = 10000
- 0x04, 0x67, 0x10, // Max Cache Duration = 10000
+ uint8_t raw_packet_[23] = {
+ 0x0e, 0x00, 0x14, 0x01, 0x03,
+ 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x04, 0x61, 0x62, 0x63, 0x64, // track_name = "abcd"
+ 0x00, 0x0c, 0x14, // status, last_group, last_object
+ 0x02, // 2 parameters
+ 0x02, 0x67, 0x10, // Delivery Timeout = 10000
+ 0x04, 0x67, 0x10, // Max Cache Duration = 10000
};
MoqtTrackStatus track_status_ = {
@@ -1097,15 +1092,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("v---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(goaway_);
}
private:
- uint8_t raw_packet_[6] = {
- 0x10, 0x04, 0x03, 0x66, 0x6f, 0x6f,
+ uint8_t raw_packet_[7] = {
+ 0x10, 0x00, 0x04, 0x03, 0x66, 0x6f, 0x6f,
};
MoqtGoAway goaway_ = {
@@ -1132,16 +1127,16 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---vvv-----"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---vvv-----"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(subscribe_namespace_);
}
private:
- uint8_t raw_packet_[15] = {
- 0x11, 0x0d, 0x01, 0x03, 0x66, 0x6f, 0x6f, // namespace = "foo"
- 0x01, // 1 parameter
+ uint8_t raw_packet_[16] = {
+ 0x11, 0x00, 0x0d, 0x01, 0x03, 0x66, 0x6f, 0x6f, // namespace = "foo"
+ 0x01, // 1 parameter
0x01, 0x05, 0x03, 0x00, 0x62, 0x61, 0x72, // authorization_tag = "bar"
};
@@ -1166,15 +1161,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(subscribe_namespace_ok_);
}
private:
- uint8_t raw_packet_[7] = {
- 0x12, 0x05, 0x01, 0x03, 0x66, 0x6f, 0x6f, // namespace = "foo"
+ uint8_t raw_packet_[8] = {
+ 0x12, 0x00, 0x05, 0x01, 0x03, 0x66, 0x6f, 0x6f, // namespace = "foo"
};
MoqtSubscribeAnnouncesOk subscribe_namespace_ok_ = {
@@ -1205,17 +1200,18 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---vv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---vv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(subscribe_namespace_error_);
}
private:
- uint8_t raw_packet_[12] = {
- 0x13, 0x0a, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
- 0x01, // error_code = 1
- 0x03, 0x62, 0x61, 0x72, // reason_phrase = "bar"
+ uint8_t raw_packet_[13] = {
+ 0x13, 0x00, 0x0a, 0x01,
+ 0x03, 0x66, 0x6f, 0x6f, // track_namespace = "foo"
+ 0x01, // error_code = 1
+ 0x03, 0x62, 0x61, 0x72, // reason_phrase = "bar"
};
MoqtSubscribeAnnouncesError subscribe_namespace_error_ = {
@@ -1240,15 +1236,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(unsubscribe_namespace_);
}
private:
- uint8_t raw_packet_[7] = {
- 0x14, 0x05, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace
+ uint8_t raw_packet_[8] = {
+ 0x14, 0x00, 0x05, 0x01, 0x03, 0x66, 0x6f, 0x6f, // track_namespace
};
MoqtUnsubscribeAnnounces unsubscribe_namespace_ = {
@@ -1271,15 +1267,16 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvv"); }
+ void ExpandVarints() override { ExpandVarintsImpl("v"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(max_request_id_);
}
private:
- uint8_t raw_packet_[3] = {
+ uint8_t raw_packet_[4] = {
0x15,
+ 0x00,
0x01,
0x0b,
};
@@ -1349,7 +1346,7 @@
}
void ExpandVarints() override {
- ExpandVarintsImpl("vvv--vvv---v---vvvvvv-----");
+ ExpandVarintsImpl("v--vvv---v---vvvvvv-----");
}
MessageStructuredData structured_data() const override {
@@ -1362,19 +1359,19 @@
QUICHE_CHECK(!object.has_value() || *object < 64);
fetch_.end_group = group;
fetch_.end_object = object;
- raw_packet_[17] = group;
- raw_packet_[18] = object.has_value() ? (*object + 1) : 0;
+ raw_packet_[18] = group;
+ raw_packet_[19] = object.has_value() ? (*object + 1) : 0;
SetWireImage(raw_packet_, sizeof(raw_packet_));
}
void SetGroupOrder(uint8_t group_order) {
- raw_packet_[4] = static_cast<uint8_t>(group_order);
+ raw_packet_[5] = static_cast<uint8_t>(group_order);
SetWireImage(raw_packet_, sizeof(raw_packet_));
}
private:
- uint8_t raw_packet_[27] = {
- 0x16, 0x19,
+ uint8_t raw_packet_[28] = {
+ 0x16, 0x00, 0x19,
0x01, // fetch_id = 1
0x02, // priority = kHigh
0x01, // group_order = kAscending
@@ -1461,7 +1458,7 @@
}
void ExpandVarints() override {
- ExpandVarintsImpl("vvv--vvv---v---vvvvvv-----");
+ ExpandVarintsImpl("v--vvv---v---vvvvvv-----");
}
MessageStructuredData structured_data() const override {
@@ -1469,13 +1466,13 @@
}
void SetGroupOrder(uint8_t group_order) {
- raw_packet_[4] = static_cast<uint8_t>(group_order);
+ raw_packet_[5] = static_cast<uint8_t>(group_order);
SetWireImage(raw_packet_, sizeof(raw_packet_));
}
private:
- uint8_t raw_packet_[16] = {
- 0x16, 0x0e,
+ uint8_t raw_packet_[17] = {
+ 0x16, 0x00, 0x0e,
0x01, // fetch_id = 1
0x02, // priority = kHigh
0x01, // group_order = kAscending
@@ -1512,15 +1509,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvv"); }
+ void ExpandVarints() override { ExpandVarintsImpl("v"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(fetch_cancel_);
}
private:
- uint8_t raw_packet_[3] = {
- 0x17, 0x01,
+ uint8_t raw_packet_[4] = {
+ 0x17, 0x00, 0x01,
0x01, // subscribe_id = 1
};
@@ -1555,15 +1552,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvv-vvvvv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("v-vvvvv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(fetch_ok_);
}
private:
- uint8_t raw_packet_[10] = {
- 0x18, 0x08,
+ uint8_t raw_packet_[11] = {
+ 0x18, 0x00, 0x08,
0x01, // subscribe_id = 1
0x01, // group_order = kAscending
0x05, 0x04, // largest_object = 5, 4
@@ -1601,15 +1598,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvvv---"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vvv---"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(fetch_error_);
}
private:
- uint8_t raw_packet_[8] = {
- 0x19, 0x06,
+ uint8_t raw_packet_[9] = {
+ 0x19, 0x00, 0x06,
0x01, // subscribe_id = 1
0x01, // error_code = kUnauthorized
0x03, 0x62, 0x61, 0x72, // reason_phrase = "bar"
@@ -1636,15 +1633,15 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvv"); }
+ void ExpandVarints() override { ExpandVarintsImpl("v"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(requests_blocked_);
}
private:
- uint8_t raw_packet_[3] = {
- 0x1a, 0x01,
+ uint8_t raw_packet_[4] = {
+ 0x1a, 0x00, 0x01,
0x0b, // max_request_id = 11
};
@@ -1680,17 +1677,17 @@
return true;
}
- void ExpandVarints() override { ExpandVarintsImpl("vvvvvv"); }
+ void ExpandVarints() override { ExpandVarintsImpl("vvvv"); }
MessageStructuredData structured_data() const override {
return TestMessageBase::MessageStructuredData(object_ack_);
}
private:
- uint8_t raw_packet_[7] = {
- 0x71, 0x84, 0x04, // type
- 0x01, 0x10, 0x20, // subscribe ID, group, object
- 0x20, // 0x10 time delta
+ uint8_t raw_packet_[8] = {
+ 0x71, 0x84, 0x00, 0x04, // type
+ 0x01, 0x10, 0x20, // subscribe ID, group, object
+ 0x20, // 0x10 time delta
};
MoqtObjectAck object_ack_ = {