xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/test_tools/bad_packet_writer.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2017 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_BAD_PACKET_WRITER_H_
6 #define QUICHE_QUIC_TEST_TOOLS_BAD_PACKET_WRITER_H_
7 
8 #include "quiche/quic/core/quic_packet_writer_wrapper.h"
9 
10 namespace quic {
11 
12 namespace test {
13 // This packet writer allows causing packet write error with specified error
14 // code when writing a particular packet.
15 class BadPacketWriter : public QuicPacketWriterWrapper {
16  public:
17   BadPacketWriter(size_t packet_causing_write_error, int error_code);
18 
19   ~BadPacketWriter() override;
20 
21   WriteResult WritePacket(const char* buffer, size_t buf_len,
22                           const QuicIpAddress& self_address,
23                           const QuicSocketAddress& peer_address,
24                           PerPacketOptions* options,
25                           const QuicPacketWriterParams& params) override;
26 
27  private:
28   size_t packet_causing_write_error_;
29   int error_code_;
30 };
31 
32 }  // namespace test
33 
34 }  // namespace quic
35 
36 #endif  // QUICHE_QUIC_TEST_TOOLS_BAD_PACKET_WRITER_H_
37