table+fw: update ForwardingHint format

refs #5187

Change-Id: Ic8e32c83caeb60404f1b035a4f7e9841cc513f0b
diff --git a/core/common.hpp b/core/common.hpp
index a5a88eb..01f794c 100644
--- a/core/common.hpp
+++ b/core/common.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -69,6 +69,7 @@
 #include <ndn-cxx/util/optional.hpp>
 #include <ndn-cxx/util/scheduler.hpp>
 #include <ndn-cxx/util/signal.hpp>
+#include <ndn-cxx/util/span.hpp>
 #include <ndn-cxx/util/time.hpp>
 
 #include <boost/asio.hpp>
@@ -97,6 +98,7 @@
 
 using ndn::optional;
 using ndn::nullopt;
+using ndn::span;
 using ndn::to_string;
 
 using ndn::Block;
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index 8762e24..7212c52 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -297,7 +297,7 @@
 
   const fib::Entry* fibEntry = nullptr;
   for (const auto& delegation : fh) {
-    fibEntry = &fib.findLongestPrefixMatch(delegation.name);
+    fibEntry = &fib.findLongestPrefixMatch(delegation);
     if (fibEntry->hasNextHops()) {
       if (fibEntry->getPrefix().size() == 0) {
         // in consumer region, return the default route
@@ -305,7 +305,7 @@
       }
       else {
         // in default-free zone, use the first delegation that finds a FIB entry
-        NFD_LOG_TRACE("lookupFib delegation=" << delegation.name << " found=" << fibEntry->getPrefix());
+        NFD_LOG_TRACE("lookupFib delegation=" << delegation << " found=" << fibEntry->getPrefix());
       }
       return *fibEntry;
     }
diff --git a/daemon/table/network-region-table.cpp b/daemon/table/network-region-table.cpp
index 4ede386..5869d18 100644
--- a/daemon/table/network-region-table.cpp
+++ b/daemon/table/network-region-table.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -28,11 +28,11 @@
 namespace nfd {
 
 bool
-NetworkRegionTable::isInProducerRegion(const ndn::DelegationList& forwardingHint) const
+NetworkRegionTable::isInProducerRegion(span<const Name> forwardingHint) const
 {
   for (const Name& regionName : *this) {
     for (const auto& delegation : forwardingHint) {
-      if (delegation.name.isPrefixOf(regionName)) {
+      if (delegation.isPrefixOf(regionName)) {
         return true;
       }
     }
diff --git a/daemon/table/network-region-table.hpp b/daemon/table/network-region-table.hpp
index e531a45..96acf87 100644
--- a/daemon/table/network-region-table.hpp
+++ b/daemon/table/network-region-table.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -28,8 +28,6 @@
 
 #include "core/common.hpp"
 
-#include <ndn-cxx/delegation-list.hpp>
-
 namespace nfd {
 
 /** \brief stores a collection of producer region names
@@ -48,11 +46,11 @@
    *  \retval false the Interest has not reached a producer region
    *
    *  If any delegation name in the forwarding hint is a prefix of any region name,
-   *  the Interest has reached the producer region and should be forwarded according to ‎its Name;
+   *  the Interest has reached the producer region and should be forwarded according to its Name;
    *  otherwise, the Interest should be forwarded according to the forwarding hint.
    */
   bool
-  isInProducerRegion(const ndn::DelegationList& forwardingHint) const;
+  isInProducerRegion(span<const Name> forwardingHint) const;
 };
 
 } // namespace nfd
diff --git a/tests/daemon/fw/forwarding-hint.t.cpp b/tests/daemon/fw/forwarding-hint.t.cpp
index da63619..d330395 100644
--- a/tests/daemon/fw/forwarding-hint.t.cpp
+++ b/tests/daemon/fw/forwarding-hint.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -34,6 +34,14 @@
 
 using namespace nfd::tests;
 
+#define CHECK_FH_EQUAL(actual, ...) \
+  do { \
+    std::vector<Name> expected({__VA_ARGS__}); \
+    BOOST_CHECK_EQUAL_COLLECTIONS( \
+      (actual).getForwardingHint().begin(), (actual).getForwardingHint().end(), \
+      expected.begin(), expected.end()); \
+  } while (false)
+
 BOOST_AUTO_TEST_SUITE(Fw)
 BOOST_AUTO_TEST_SUITE(TestForwardingHint)
 
@@ -104,7 +112,7 @@
   consumerExpressInterest(int seq)
   {
     auto interest = makeInterest(Name("/net/ndnsim").appendNumber(seq));
-    interest->setForwardingHint({delTelia, delUcla});
+    interest->setForwardingHint({nameTelia, nameUcla});
     consumerA->getClientFace().expressInterest(*interest, nullptr, nullptr, nullptr);
   }
 
@@ -114,8 +122,8 @@
   shared_ptr<TopologyLink> linkAH, linkHT, linkTP, linkHC, linkCS, linkSQ;
   shared_ptr<TopologyAppLink> consumerA, producerP, producerQ;
 
-  ndn::Delegation delTelia = {10, "/telia/terabits"};
-  ndn::Delegation delUcla = {20, "/ucla/cs"};
+  Name nameTelia = "/telia/terabits";
+  Name nameUcla = "/ucla/cs";
 };
 
 BOOST_FIXTURE_TEST_SUITE(NdnsimTeliaUclaTopology, NdnsimTeliaUclaTopologyFixture)
@@ -128,12 +136,12 @@
   // A forwards Interest according to default route, no change to forwarding hint
   BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1);
   const Interest& interestAH = topo.getPcap(linkAH->getFace(nodeA)).sentInterests.at(0);
-  BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
+  CHECK_FH_EQUAL(interestAH, nameTelia, nameUcla);
 
   // H prefers T, no change to forwarding hint
   BOOST_CHECK_EQUAL(linkHT->getFace(nodeH).getCounters().nOutInterests, 1);
   const Interest& interestHT = topo.getPcap(linkHT->getFace(nodeH)).sentInterests.at(0);
-  BOOST_CHECK_EQUAL(interestHT.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
+  CHECK_FH_EQUAL(interestHT, nameTelia, nameUcla);
 
   // T forwards to P, forwarding hint stripped when Interest reaches producer region
   BOOST_CHECK_EQUAL(linkTP->getFace(nodeT).getCounters().nOutInterests, 1);
@@ -157,17 +165,17 @@
   // A forwards Interest according to default route, no change to forwarding hint
   BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1);
   const Interest& interestAH = topo.getPcap(linkAH->getFace(nodeA)).sentInterests.at(0);
-  BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
+  CHECK_FH_EQUAL(interestAH, nameTelia, nameUcla);
 
   // H forwards to C, no change to forwarding hint
   BOOST_CHECK_EQUAL(linkHC->getFace(nodeH).getCounters().nOutInterests, 1);
   const Interest& interestHC = topo.getPcap(linkHC->getFace(nodeH)).sentInterests.at(0);
-  BOOST_CHECK_EQUAL(interestHC.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
+  CHECK_FH_EQUAL(interestHC, nameTelia, nameUcla);
 
   // C forwards to S, no change to forwarding hint
   BOOST_CHECK_EQUAL(linkCS->getFace(nodeC).getCounters().nOutInterests, 1);
   const Interest& interestCS = topo.getPcap(linkCS->getFace(nodeC)).sentInterests.at(0);
-  BOOST_CHECK_EQUAL(interestCS.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
+  CHECK_FH_EQUAL(interestCS, nameTelia, nameUcla);
 
   // S forwards to Q, forwarding hint stripped when Interest reaches producer region
   BOOST_CHECK_EQUAL(linkSQ->getFace(nodeS).getCounters().nOutInterests, 1);
diff --git a/tests/daemon/table/network-region-table.t.cpp b/tests/daemon/table/network-region-table.t.cpp
index 6ba2678..431e3d3 100644
--- a/tests/daemon/table/network-region-table.t.cpp
+++ b/tests/daemon/table/network-region-table.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -36,7 +36,7 @@
 
 BOOST_AUTO_TEST_CASE(InProducerRegion)
 {
-  ndn::DelegationList fh{{10, "/telia/terabits"}, {20, "/ucla/cs"}};
+  const std::vector<Name> fh{"/telia/terabits", "/ucla/cs"};
 
   NetworkRegionTable nrt1;
   nrt1.insert("/verizon");
diff --git a/tests/daemon/table/pit-entry.t.cpp b/tests/daemon/table/pit-entry.t.cpp
index 00993ee..d5b71fc 100644
--- a/tests/daemon/table/pit-entry.t.cpp
+++ b/tests/daemon/table/pit-entry.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  Regents of the University of California,
+ * Copyright (c) 2014-2022,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -58,7 +58,7 @@
   BOOST_CHECK_EQUAL(entry.canMatch(*interest3), true);
 
   auto interest4 = makeInterest("/A");
-  interest4->setForwardingHint({{10, "/telia/terabits"}, {20, "/ucla/cs"}});
+  interest4->setForwardingHint({"/telia/terabits", "/ucla/cs"});
   BOOST_CHECK_EQUAL(entry.canMatch(*interest4), false); // expected failure until #3162
 
   auto interest5 = makeInterest("/A", true);