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) override; 25 26 private: 27 size_t packet_causing_write_error_; 28 int error_code_; 29 }; 30 31 } // namespace test 32 33 } // namespace quic 34 35 #endif // QUICHE_QUIC_TEST_TOOLS_BAD_PACKET_WRITER_H_ 36