blob: 9fbdff232c1090c357729966f1dc7ea35288381a [file] [log] [blame]
// Copyright (c) 2019 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 "net/third_party/quiche/src/quic/core/quic_packets.h"
namespace quic {
// QuicCoalescedPacket is used to buffer multiple packets which can be coalesced
// into the same UDP datagram.
class QUIC_EXPORT_PRIVATE QuicCoalescedPacket {
// Returns true if |packet| is successfully coalesced with existing packets.
// Returns false otherwise.
bool MaybeCoalescePacket(const SerializedPacket& packet,
const QuicSocketAddress& self_address,
const QuicSocketAddress& peer_address,
QuicBufferAllocator* allocator,
QuicPacketLength current_max_packet_length);
// Clears this coalesced packet.
void Clear();
QuicPacketLength length() const { return length_; }
QuicPacketLength max_packet_length() const { return max_packet_length_; }
// self/peer addresses are set when trying to coalesce the first packet.
// Packets with different self/peer addresses cannot be coalesced.
QuicSocketAddress self_address_;
QuicSocketAddress peer_address_;
// Length of this coalesced packet.
QuicPacketLength length_;
// Max packet length. Do not try to coalesce packet when max packet length
// changes (e.g., with MTU discovery).
QuicPacketLength max_packet_length_;
// Copies of packets' encrypted buffers according to different encryption
// levels.
// TODO(fayang): Test serialization when implementing
// QuicPacketCreator::SerializeCoalescedPacket.
std::string encrypted_buffers_[NUM_ENCRYPTION_LEVELS];
// A copy of ENCRYPTION_INITIAL packet if this coalesced packet contains one.
// Null otherwise. Please note, the encrypted_buffer field is not copied. The
// frames are copied to allow it be re-serialized when this coalesced packet
// gets sent.
std::unique_ptr<SerializedPacket> initial_packet_;
} // namespace quic