xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/test_tools/limited_mtu_test_writer.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef QUICHE_QUIC_TEST_TOOLS_LIMITED_MTU_TEST_WRITER_H_
6 #define QUICHE_QUIC_TEST_TOOLS_LIMITED_MTU_TEST_WRITER_H_
7 
8 #include "quiche/quic/core/quic_packet_writer_wrapper.h"
9 #include "quiche/quic/core/quic_packets.h"
10 
11 namespace quic {
12 namespace test {
13 
14 // Simulates a connection over a link with fixed MTU.  Drops packets which
15 // exceed the MTU and passes the rest of them as-is.
16 class LimitedMtuTestWriter : public QuicPacketWriterWrapper {
17  public:
18   explicit LimitedMtuTestWriter(QuicByteCount mtu);
19   LimitedMtuTestWriter(const LimitedMtuTestWriter&) = delete;
20   LimitedMtuTestWriter& operator=(const LimitedMtuTestWriter&) = delete;
21   ~LimitedMtuTestWriter() override;
22 
23   // Inherited from QuicPacketWriterWrapper.
24   WriteResult WritePacket(const char* buffer, size_t buf_len,
25                           const QuicIpAddress& self_address,
26                           const QuicSocketAddress& peer_address,
27                           PerPacketOptions* options,
28                           const QuicPacketWriterParams& params) override;
29 
30  private:
31   QuicByteCount mtu_;
32 };
33 
34 }  // namespace test
35 }  // namespace quic
36 
37 #endif  // QUICHE_QUIC_TEST_TOOLS_LIMITED_MTU_TEST_WRITER_H_
38