QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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 | #include "net/third_party/quiche/src/quic/test_tools/limited_mtu_test_writer.h" |
| 6 | |
| 7 | namespace quic { |
| 8 | namespace test { |
| 9 | |
| 10 | LimitedMtuTestWriter::LimitedMtuTestWriter(QuicByteCount mtu) : mtu_(mtu) {} |
| 11 | |
| 12 | LimitedMtuTestWriter::~LimitedMtuTestWriter() = default; |
| 13 | |
| 14 | WriteResult 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 |