blob: b37171fa0ac01064b834ac8c8642cc432932fe82 [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/*
3 * Copyright (c) 2014-2018, 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)
47 , afterReceiveInterest_count(0)
48 , beforeSatisfyInterest_count(0)
Teng Liang85a36632018-03-21 05:59:34 -070049 , afterContentStoreHit_count(0)
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000050 , afterReceiveNack_count(0)
51{
52 this->setInstanceName(name);
53}
54
55void
56DummyStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
57 const shared_ptr<pit::Entry>& pitEntry)
58{
59 ++afterReceiveInterest_count;
60
61 if (interestOutFace != nullptr) {
62 this->sendInterest(pitEntry, *interestOutFace, interest);
63 }
64 else {
65 this->rejectPendingInterest(pitEntry);
66 }
67}
68
69void
70DummyStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
71 const Face& inFace, const Data& data)
72{
73 ++beforeSatisfyInterest_count;
74}
75
76void
Teng Liang85a36632018-03-21 05:59:34 -070077DummyStrategy::afterContentStoreHit(const shared_ptr<pit::Entry>& pitEntry,
78 const Face& inFace, const Data& data)
79{
80 ++afterContentStoreHit_count;
81
82 this->sendData(pitEntry, data, inFace);
83}
84
85void
Junxiao Shi0e4a1f12016-12-24 02:39:01 +000086DummyStrategy::afterReceiveNack(const Face& inFace, const lp::Nack& nack,
87 const shared_ptr<pit::Entry>& pitEntry)
88{
89 ++afterReceiveNack_count;
90}
91
92} // namespace tests
93} // namespace nfd