blob: 5bbf7f70c2cb21038e2ac3d4aa58a059e7e6698b [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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
QUICHE team5be974e2020-12-29 18:35:24 -05005#include "quic/test_tools/limited_mtu_test_writer.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -05006
7namespace quic {
8namespace test {
9
10LimitedMtuTestWriter::LimitedMtuTestWriter(QuicByteCount mtu) : mtu_(mtu) {}
11
12LimitedMtuTestWriter::~LimitedMtuTestWriter() = default;
13
14WriteResult LimitedMtuTestWriter::WritePacket(
15 const char* buffer,
16 size_t buf_len,
17 const QuicIpAddress& self_address,
18 const QuicSocketAddress& peer_address,
19 PerPacketOptions* options) {
20 if (buf_len > mtu_) {
21 // Drop the packet.
22 return WriteResult(WRITE_STATUS_OK, buf_len);
23 }
24
25 return QuicPacketWriterWrapper::WritePacket(buffer, buf_len, self_address,
26 peer_address, options);
27}
28
29} // namespace test
30} // namespace quic