gfe-relnote: Add QuicPacketCreator::SerializeCoalescedPacket function. Not used yet. Not protected.
PiperOrigin-RevId: 276529504
Change-Id: Id9ddd1c7af0b52e12e75c754295e10d23058ee62
diff --git a/quic/core/quic_coalesced_packet.cc b/quic/core/quic_coalesced_packet.cc
index 62eee42..6d7f872 100644
--- a/quic/core/quic_coalesced_packet.cc
+++ b/quic/core/quic_coalesced_packet.cc
@@ -58,20 +58,15 @@
}
}
- if (packet.encryption_level == ENCRYPTION_INITIAL) {
- for (const auto& frame : packet.nonretransmittable_frames) {
- if (frame.type == PADDING_FRAME) {
- QUIC_BUG << "ENCRYPTION_INITIAL packet should not contain padding "
- "frame if trying to send coalesced packet";
- return false;
- }
- }
- }
if (length_ + packet.encrypted_length > max_packet_length_) {
// Packet does not fit.
return false;
}
-
+ QUIC_DVLOG(1) << "Successfully coalesced packet: encryption_level: "
+ << EncryptionLevelToString(packet.encryption_level)
+ << ", encrypted_length: " << packet.encrypted_length
+ << ", current length: " << length_
+ << ", max_packet_length: " << max_packet_length_;
length_ += packet.encrypted_length;
if (packet.encryption_level == ENCRYPTION_INITIAL) {
// Save a copy of ENCRYPTION_INITIAL packet (excluding encrypted buffer, as
@@ -100,4 +95,23 @@
initial_packet_ = nullptr;
}
+bool QuicCoalescedPacket::CopyEncryptedBuffers(char* buffer,
+ size_t buffer_len,
+ size_t* length_copied) const {
+ *length_copied = 0;
+ for (const auto& packet : encrypted_buffers_) {
+ if (packet.empty()) {
+ continue;
+ }
+ if (packet.length() > buffer_len) {
+ return false;
+ }
+ memcpy(buffer, packet.data(), packet.length());
+ buffer += packet.length();
+ buffer_len -= packet.length();
+ *length_copied += packet.length();
+ }
+ return true;
+}
+
} // namespace quic