// Copyright (c) 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef QUICHE_QUIC_TEST_TOOLS_SIMULATOR_PACKET_FILTER_H_ #define QUICHE_QUIC_TEST_TOOLS_SIMULATOR_PACKET_FILTER_H_ #include "quiche/quic/test_tools/simulator/port.h" namespace quic { namespace simulator { // Packet filter allows subclasses to filter out the packets that enter the // input port and exit the output port. Packets in the other direction are // always passed through. // // The filter wraps around the input endpoint, and exposes the resulting // filtered endpoint via the output() method. For example, if initially there // are two endpoints, A and B, connected via a symmetric link: // // QuicEndpoint endpoint_a; // QuicEndpoint endpoint_b; // // [...] // // SymmetricLink a_b_link(&endpoint_a, &endpoint_b, ...); // // and the goal is to filter the traffic from A to B, then the new invocation // would be as follows: // // PacketFilter filter(&simulator, "A-to-B packet filter", endpoint_a); // SymmetricLink a_b_link(&filter, &endpoint_b, ...); // // Note that the filter drops the packet instanteneously, without it ever // reaching the output wire. This means that in a direct endpoint-to-endpoint // scenario, whenever the packet is dropped, the link would become immediately // available for the next packet. class PacketFilter : public Endpoint, public ConstrainedPortInterface { … }; } // namespace simulator } // namespace quic #endif // QUICHE_QUIC_TEST_TOOLS_SIMULATOR_PACKET_FILTER_H_