Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Teng Liang | 6308644 | 2018-02-25 20:39:42 -0700 | [diff] [blame] | 2 | /* |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, Regents of the University of California, |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
| 26 | #include "dummy-strategy.hpp" |
| 27 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 28 | namespace nfd::tests { |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 29 | |
| 30 | NFD_REGISTER_STRATEGY(DummyStrategy); |
| 31 | |
| 32 | void |
| 33 | DummyStrategy::registerAs(const Name& strategyName) |
| 34 | { |
| 35 | registerAsImpl<DummyStrategy>(strategyName); |
| 36 | } |
| 37 | |
| 38 | Name |
| 39 | DummyStrategy::getStrategyName(uint64_t version) |
| 40 | { |
| 41 | return Name("/dummy-strategy").appendVersion(version); |
| 42 | } |
| 43 | |
| 44 | DummyStrategy::DummyStrategy(Forwarder& forwarder, const Name& name) |
| 45 | : Strategy(forwarder) |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 46 | { |
| 47 | this->setInstanceName(name); |
| 48 | } |
| 49 | |
| 50 | void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 51 | DummyStrategy::afterReceiveInterest(const Interest& interest, const FaceEndpoint&, |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 52 | const shared_ptr<pit::Entry>& pitEntry) |
| 53 | { |
| 54 | ++afterReceiveInterest_count; |
| 55 | |
| 56 | if (interestOutFace != nullptr) { |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 57 | this->sendInterest(interest, *interestOutFace, pitEntry); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 58 | } |
| 59 | else { |
| 60 | this->rejectPendingInterest(pitEntry); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 65 | DummyStrategy::afterContentStoreHit(const Data& data, const FaceEndpoint& ingress, |
| 66 | const shared_ptr<pit::Entry>& pitEntry) |
Teng Liang | 85a3663 | 2018-03-21 05:59:34 -0700 | [diff] [blame] | 67 | { |
| 68 | ++afterContentStoreHit_count; |
| 69 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 70 | Strategy::afterContentStoreHit(data, ingress, pitEntry); |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 74 | DummyStrategy::beforeSatisfyInterest(const Data& data, const FaceEndpoint& ingress, |
| 75 | const shared_ptr<pit::Entry>& pitEntry) |
| 76 | { |
| 77 | ++beforeSatisfyInterest_count; |
| 78 | |
| 79 | Strategy::beforeSatisfyInterest(data, ingress, pitEntry); |
| 80 | } |
| 81 | |
| 82 | void |
| 83 | DummyStrategy::afterReceiveData(const Data& data, const FaceEndpoint& ingress, |
| 84 | const shared_ptr<pit::Entry>& pitEntry) |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 85 | { |
| 86 | ++afterReceiveData_count; |
| 87 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 88 | Strategy::afterReceiveData(data, ingress, pitEntry); |
Teng Liang | 85a3663 | 2018-03-21 05:59:34 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 92 | DummyStrategy::afterReceiveNack(const lp::Nack& nack, const FaceEndpoint& ingress, |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 93 | const shared_ptr<pit::Entry>& pitEntry) |
| 94 | { |
| 95 | ++afterReceiveNack_count; |
Ju Pan | 2feb459 | 2019-09-16 20:56:38 +0000 | [diff] [blame] | 96 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 97 | Strategy::afterReceiveNack(nack, ingress, pitEntry); |
Ju Pan | 2feb459 | 2019-09-16 20:56:38 +0000 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | void |
| 101 | DummyStrategy::afterNewNextHop(const fib::NextHop& nextHop, const shared_ptr<pit::Entry>& pitEntry) |
| 102 | { |
| 103 | afterNewNextHopCalls.push_back(pitEntry->getName()); |
| 104 | |
| 105 | Strategy::afterNewNextHop(nextHop, pitEntry); |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 106 | } |
| 107 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 108 | } // namespace nfd::tests |