summaryrefslogtreecommitdiff
path: root/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-17 17:24:03 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-06-22 07:51:41 +0000
commit774f54339e5db91f785733232d3950366db65d07 (patch)
tree068e1b47bd1af94d77094ed12b604a6b83d9c22a /chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc
parentf7eaed5286974984ba5f9e3189d8f49d03e99f81 (diff)
downloadqtwebengine-chromium-774f54339e5db91f785733232d3950366db65d07.tar.gz
BASELINE: Update Chromium to 102.0.5005.57
Change-Id: I885f714bb40ee724c28f94ca6bd8dbdb39915158 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc')
-rw-r--r--chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc83
1 files changed, 0 insertions, 83 deletions
diff --git a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc b/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc
deleted file mode 100644
index 3a8ee583fbd..00000000000
--- a/chromium/net/third_party/quiche/src/quic/test_tools/simulator/switch.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) 2012 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.
-
-#include <cinttypes>
-#include <utility>
-
-#include "absl/strings/str_cat.h"
-#include "quic/test_tools/simulator/switch.h"
-
-namespace quic {
-namespace simulator {
-
-Switch::Switch(Simulator* simulator,
- std::string name,
- SwitchPortNumber port_count,
- QuicByteCount queue_capacity) {
- for (size_t port_number = 1; port_number <= port_count; port_number++) {
- ports_.emplace_back(simulator,
- absl::StrCat(name, " (port ", port_number, ")"), this,
- port_number, queue_capacity);
- }
-}
-
-Switch::~Switch() {}
-
-Switch::Port::Port(Simulator* simulator,
- std::string name,
- Switch* parent,
- SwitchPortNumber port_number,
- QuicByteCount queue_capacity)
- : Endpoint(simulator, name),
- parent_(parent),
- port_number_(port_number),
- connected_(false),
- queue_(simulator, absl::StrCat(name, " (queue)"), queue_capacity) {}
-
-void Switch::Port::AcceptPacket(std::unique_ptr<Packet> packet) {
- parent_->DispatchPacket(port_number_, std::move(packet));
-}
-
-void Switch::Port::EnqueuePacket(std::unique_ptr<Packet> packet) {
- queue_.AcceptPacket(std::move(packet));
-}
-
-UnconstrainedPortInterface* Switch::Port::GetRxPort() {
- return this;
-}
-
-void Switch::Port::SetTxPort(ConstrainedPortInterface* port) {
- queue_.set_tx_port(port);
- connected_ = true;
-}
-
-void Switch::Port::Act() {}
-
-void Switch::DispatchPacket(SwitchPortNumber port_number,
- std::unique_ptr<Packet> packet) {
- Port* source_port = &ports_[port_number - 1];
- const auto source_mapping_it = switching_table_.find(packet->source);
- if (source_mapping_it == switching_table_.end()) {
- switching_table_.insert(std::make_pair(packet->source, source_port));
- }
-
- const auto destination_mapping_it =
- switching_table_.find(packet->destination);
- if (destination_mapping_it != switching_table_.end()) {
- destination_mapping_it->second->EnqueuePacket(std::move(packet));
- return;
- }
-
- // If no mapping is available yet, broadcast the packet to all ports
- // different from the source.
- for (Port& egress_port : ports_) {
- if (!egress_port.connected()) {
- continue;
- }
- egress_port.EnqueuePacket(std::make_unique<Packet>(*packet));
- }
-}
-
-} // namespace simulator
-} // namespace quic