blob: 439efd114c5323389ae5646376a7e4e2ae8d99d3 [file] [log] [blame]
Junxiao Shi0e4a1f12016-12-24 02:39:01 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Teng Liang63086442018-02-25 20:39:42 -07002/*
Davide Pesavento0498ce82021-06-14 02:02:21 -04003 * Copyright (c) 2014-2021, Regents of the University of California,
Junxiao Shi0e4a1f12016-12-24 02:39:01 +00004 * 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
28namespace nfd {
29namespace tests {
30
31NFD_REGISTER_STRATEGY(DummyStrategy);
32
33void
34DummyStrategy::registerAs(const Name& strategyName)
35{
36 registerAsImpl<DummyStrategy>(strategyName);
37}
38
39Name
40DummyStrategy::getStrategyName(uint64_t version)
41{
42 return Name("/dummy-strategy").appendVersion(version);
43}
44
45DummyStrategy::DummyStrategy(Forwarder& forwarder, const Name& name)
46 : Strategy(forwarder)
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000047{
48 this->setInstanceName(name);
49}
50
51void
Davide Pesavento0498ce82021-06-14 02:02:21 -040052DummyStrategy::afterReceiveInterest(const Interest& interest, const FaceEndpoint&,
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000053 const shared_ptr<pit::Entry>& pitEntry)
54{
55 ++afterReceiveInterest_count;
56
57 if (interestOutFace != nullptr) {
Davide Pesavento0498ce82021-06-14 02:02:21 -040058 this->sendInterest(interest, *interestOutFace, pitEntry);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000059 }
60 else {
61 this->rejectPendingInterest(pitEntry);
62 }
63}
64
65void
Davide Pesavento0498ce82021-06-14 02:02:21 -040066DummyStrategy::afterContentStoreHit(const Data& data, const FaceEndpoint& ingress,
67 const shared_ptr<pit::Entry>& pitEntry)
Teng Liang85a36632018-03-21 05:59:34 -070068{
69 ++afterContentStoreHit_count;
70
Davide Pesavento0498ce82021-06-14 02:02:21 -040071 Strategy::afterContentStoreHit(data, ingress, pitEntry);
Teng Liang43bb2312018-03-26 04:16:42 -070072}
73
74void
Davide Pesavento0498ce82021-06-14 02:02:21 -040075DummyStrategy::beforeSatisfyInterest(const Data& data, const FaceEndpoint& ingress,
76 const shared_ptr<pit::Entry>& pitEntry)
77{
78 ++beforeSatisfyInterest_count;
79
80 Strategy::beforeSatisfyInterest(data, ingress, pitEntry);
81}
82
83void
84DummyStrategy::afterReceiveData(const Data& data, const FaceEndpoint& ingress,
85 const shared_ptr<pit::Entry>& pitEntry)
Teng Liang43bb2312018-03-26 04:16:42 -070086{
87 ++afterReceiveData_count;
88
Davide Pesavento0498ce82021-06-14 02:02:21 -040089 Strategy::afterReceiveData(data, ingress, pitEntry);
Teng Liang85a36632018-03-21 05:59:34 -070090}
91
92void
Davide Pesavento0498ce82021-06-14 02:02:21 -040093DummyStrategy::afterReceiveNack(const lp::Nack& nack, const FaceEndpoint& ingress,
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000094 const shared_ptr<pit::Entry>& pitEntry)
95{
96 ++afterReceiveNack_count;
Ju Pan2feb4592019-09-16 20:56:38 +000097
Davide Pesavento0498ce82021-06-14 02:02:21 -040098 Strategy::afterReceiveNack(nack, ingress, pitEntry);
Ju Pan2feb4592019-09-16 20:56:38 +000099}
100
101void
102DummyStrategy::afterNewNextHop(const fib::NextHop& nextHop, const shared_ptr<pit::Entry>& pitEntry)
103{
104 afterNewNextHopCalls.push_back(pitEntry->getName());
105
106 Strategy::afterNewNextHop(nextHop, pitEntry);
Junxiao Shi0e4a1f12016-12-24 02:39:01 +0000107}
108
109} // namespace tests
110} // namespace nfd