fw: deprecate ClientControlStrategy
It becomes unnecessary because NextHopFaceId is honored universally.
refs #3783
Change-Id: I4c0c48f10ae58aa2603998f195f43d54e81bfcf2
diff --git a/daemon/fw/client-control-strategy.cpp b/daemon/fw/client-control-strategy.cpp
index 0b1c5f5..37460f9 100644
--- a/daemon/fw/client-control-strategy.cpp
+++ b/daemon/fw/client-control-strategy.cpp
@@ -25,15 +25,13 @@
#include "client-control-strategy.hpp"
#include "core/logger.hpp"
-#include <ndn-cxx/lp/tags.hpp>
namespace nfd {
namespace fw {
NFD_LOG_INIT("ClientControlStrategy");
-const Name
-ClientControlStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/client-control/%FD%01");
+const Name ClientControlStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/client-control/%FD%02");
NFD_REGISTER_STRATEGY(ClientControlStrategy);
ClientControlStrategy::ClientControlStrategy(Forwarder& forwarder, const Name& name)
@@ -45,24 +43,13 @@
ClientControlStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
const shared_ptr<pit::Entry>& pitEntry)
{
- shared_ptr<lp::NextHopFaceIdTag> tag = interest.getTag<lp::NextHopFaceIdTag>();
- if (tag == nullptr) {
- this->BestRouteStrategy::afterReceiveInterest(inFace, interest, pitEntry);
- return;
+ if (m_isFirstUse) {
+ NFD_LOG_WARN("NextHopFaceId field is honored universally and "
+ "it's unnecessary to set client-control strategy.");
+ m_isFirstUse = false;
}
- FaceId outFaceId = static_cast<FaceId>(*tag);
- Face* outFace = this->getFace(outFaceId);
- if (outFace == nullptr) {
- // If outFace doesn't exist, it's better to reject the Interest
- // than to use BestRouteStrategy.
- NFD_LOG_WARN("Interest " << interest.getName() <<
- " NextHopFaceId=" << outFaceId << " non-existent face");
- this->rejectPendingInterest(pitEntry);
- return;
- }
-
- this->sendInterest(pitEntry, *outFace);
+ this->BestRouteStrategy::afterReceiveInterest(inFace, interest, pitEntry);
}
} // namespace fw
diff --git a/daemon/fw/client-control-strategy.hpp b/daemon/fw/client-control-strategy.hpp
index 68b4441..13ffd81 100644
--- a/daemon/fw/client-control-strategy.hpp
+++ b/daemon/fw/client-control-strategy.hpp
@@ -31,11 +31,8 @@
namespace nfd {
namespace fw {
-/** \brief a forwarding strategy controlled by client application
- *
- * The consumer may specify the nexthop for an Interest in NDNLPv2 NextHopFaceId field.
- * If NextHopFaceId field is omitted, the Interest is forwarded to
- * the FIB nexthop with lowest routing cost.
+/** \brief identical to BestRouteStrategy v1, for backwards compatibility
+ * \deprecated NextHopFaceId field is honored universally and it's unnecessary to set this strategy
*/
class ClientControlStrategy : public BestRouteStrategy
{
@@ -49,6 +46,9 @@
public:
static const Name STRATEGY_NAME;
+
+private:
+ bool m_isFirstUse = true;
};
} // namespace fw
diff --git a/tests/daemon/fw/client-control-strategy.t.cpp b/tests/daemon/fw/client-control-strategy.t.cpp
deleted file mode 100644
index 517d2aa..0000000
--- a/tests/daemon/fw/client-control-strategy.t.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "fw/client-control-strategy.hpp"
-#include "strategy-tester.hpp"
-#include "tests/daemon/face/dummy-face.hpp"
-#include <ndn-cxx/lp/tags.hpp>
-
-#include "tests/test-common.hpp"
-
-namespace nfd {
-namespace fw {
-namespace tests {
-
-using namespace nfd::tests;
-
-BOOST_AUTO_TEST_SUITE(Fw)
-BOOST_FIXTURE_TEST_SUITE(TestClientControlStrategy, BaseFixture)
-
-BOOST_AUTO_TEST_CASE(Forward3)
-{
- Forwarder forwarder;
- typedef StrategyTester<fw::ClientControlStrategy> ClientControlStrategyTester;
- ClientControlStrategyTester strategy(forwarder);
-
- auto face1 = make_shared<DummyFace>();
- auto face2 = make_shared<DummyFace>();
- auto face3 = make_shared<DummyFace>();
- auto face4 = make_shared<DummyFace>("dummy://", "dummy://", ndn::nfd::FACE_SCOPE_LOCAL);
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- forwarder.addFace(face3);
- forwarder.addFace(face4);
-
- Fib& fib = forwarder.getFib();
- fib::Entry& fibEntry = *fib.insert(Name()).first;
- fibEntry.addNextHop(*face2, 0);
-
- Pit& pit = forwarder.getPit();
-
- // Interest with valid NextHopFaceId
- shared_ptr<Interest> interest1 = makeInterest("ndn:/0z8r6yDDe");
- interest1->setTag(make_shared<lp::NextHopFaceIdTag>(face1->getId()));
- shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
- pitEntry1->insertOrUpdateInRecord(*face4, *interest1);
-
- strategy.sendInterestHistory.clear();
- strategy.afterReceiveInterest(*face4, *interest1, pitEntry1);
- BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
- BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face1->getId());
-
- // Interest without NextHopFaceId
- shared_ptr<Interest> interest2 = makeInterest("ndn:/y6JQADGVz");
- shared_ptr<pit::Entry> pitEntry2 = pit.insert(*interest2).first;
- pitEntry2->insertOrUpdateInRecord(*face4, *interest2);
-
- strategy.sendInterestHistory.clear();
- strategy.afterReceiveInterest(*face4, *interest2, pitEntry2);
- BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
- BOOST_CHECK_EQUAL(strategy.sendInterestHistory[0].outFaceId, face2->getId());
-
- // Interest with invalid NextHopFaceId
- shared_ptr<Interest> interest3 = makeInterest("ndn:/0z8r6yDDe");
- interest3->setTag(make_shared<lp::NextHopFaceIdTag>(face3->getId()));
- shared_ptr<pit::Entry> pitEntry3 = pit.insert(*interest3).first;
- pitEntry3->insertOrUpdateInRecord(*face4, *interest3);
-
- face3->close(); // face3 is closed and its FaceId becomes invalid
- strategy.sendInterestHistory.clear();
- strategy.rejectPendingInterestHistory.clear();
- strategy.afterReceiveInterest(*face4, *interest3, pitEntry3);
- BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 0);
- BOOST_REQUIRE_EQUAL(strategy.rejectPendingInterestHistory.size(), 1);
-}
-
-BOOST_AUTO_TEST_SUITE_END() // TestClientControlStrategy
-BOOST_AUTO_TEST_SUITE_END() // Fw
-
-} // namespace tests
-} // namespace fw
-} // namespace nfd