update ForwardingHint format

refs #5187

Change-Id: Ib42cfca32933b63da2683d129293f92186bbb637
diff --git a/src/clients/iterative-query-controller.cpp b/src/clients/iterative-query-controller.cpp
index ccb9451..e923e77 100644
--- a/src/clients/iterative-query-controller.cpp
+++ b/src/clients/iterative-query-controller.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -238,7 +238,7 @@
 
   // addLink
   if (m_lastLink.hasWire()) {
-    query.setDelegationListFromLink(Link(m_lastLink));
+    query.setForwardingHintFromLink(Link(m_lastLink));
   }
 
   switch (m_step) {
diff --git a/src/clients/query.cpp b/src/clients/query.cpp
index 9bc5c60..d008d3b 100644
--- a/src/clients/query.cpp
+++ b/src/clients/query.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -47,13 +47,7 @@
 
   m_zone = zone;
 
-  if (!interest.getForwardingHint().empty()) {
-    m_delegationList = interest.getForwardingHint();
-  }
-  else {
-    m_delegationList = DelegationList();
-  }
-
+  m_forwardingHint.assign(interest.getForwardingHint().begin(), interest.getForwardingHint().end());
 
   size_t len = zone.size();
   m_queryType = interest.getName().get(len);
@@ -75,17 +69,15 @@
   Interest interest(name);
   interest.setCanBePrefix(true);
   interest.setInterestLifetime(m_interestLifetime);
-  if (!m_delegationList.empty()) {
-    interest.setForwardingHint(m_delegationList);
-  }
+  interest.setForwardingHint(m_forwardingHint);
 
   return interest;
 }
 
 void
-Query::setDelegationListFromLink(const Link& link)
+Query::setForwardingHintFromLink(const Link& link)
 {
-  m_delegationList = link.getDelegationList();
+  m_forwardingHint.assign(link.getDelegationList().begin(), link.getDelegationList().end());
 }
 
 std::ostream&
diff --git a/src/clients/query.hpp b/src/clients/query.hpp
index bd7ff25..68f26ee 100644
--- a/src/clients/query.hpp
+++ b/src/clients/query.hpp
@@ -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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -60,7 +60,7 @@
   fromInterest(const Name& zone, const Interest& interest);
 
   void
-  setDelegationListFromLink(const Link& link);
+  setForwardingHintFromLink(const Link& link);
 
   bool
   operator==(const Query& other) const
@@ -170,21 +170,21 @@
   }
 
   /**
-   * @brief set link object
+   * @brief set ForwardingHint
    */
   void
-  setDelegationList(const DelegationList& delegations)
+  setForwardingHint(std::vector<Name> forwardingHint)
   {
-    m_delegationList = delegations;
+    m_forwardingHint = std::move(forwardingHint);
   }
 
   /**
-   * @brief get Link object
+   * @brief get ForwardingHint
    */
-  const DelegationList&
-  getDelegationList() const
+  span<const Name>
+  getForwardingHint() const
   {
-    return m_delegationList;
+    return m_forwardingHint;
   }
 
 private:
@@ -193,7 +193,7 @@
   Name m_rrLabel;
   name::Component m_rrType;
   time::milliseconds m_interestLifetime;
-  DelegationList m_delegationList;
+  std::vector<Name> m_forwardingHint;
 };
 
 std::ostream&
diff --git a/src/daemon/rrset-factory.cpp b/src/daemon/rrset-factory.cpp
index d0938a1..cded8e0 100644
--- a/src/daemon/rrset-factory.cpp
+++ b/src/daemon/rrset-factory.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -117,7 +117,7 @@
 RrsetFactory::generateNsRrset(const Name& label,
                               uint64_t version,
                               time::seconds ttl,
-                              const ndn::DelegationList& delegations)
+                              std::vector<Name> delegations)
 {
   if (!m_checked) {
     NDN_THROW(Error("You have to call checkZoneKey before call generate functions"));
@@ -131,7 +131,7 @@
   Rrset& rrset = rrsetAndName.first;
 
   Link link(name);
-  link.setDelegationList(delegations);
+  link.setDelegationList(std::move(delegations));
 
   setContentType(link, NDNS_LINK, ttl);
   sign(link);
diff --git a/src/daemon/rrset-factory.hpp b/src/daemon/rrset-factory.hpp
index bab99ca..bffb093 100644
--- a/src/daemon/rrset-factory.hpp
+++ b/src/daemon/rrset-factory.hpp
@@ -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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -57,7 +57,7 @@
   generateNsRrset(const Name& label,
                   uint64_t version,
                   time::seconds ttl,
-                  const ndn::DelegationList& delegations);
+                  std::vector<Name> delegations);
 
   Rrset
   generateTxtRrset(const Name& label,
diff --git a/src/mgmt/management-tool.cpp b/src/mgmt/management-tool.cpp
index 6d34997..02299c9 100644
--- a/src/mgmt/management-tool.cpp
+++ b/src/mgmt/management-tool.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -475,11 +475,8 @@
           }
           else {
             Link link(rrset.getData());
-            const DelegationList& ds = link.getDelegationList();
-            for (const auto& i: ds) {
-              std::string str = std::to_string(i.preference);
-                + "," + i.name.toUri() + ";";
-              os << str;
+            for (const auto& delegation : link.getDelegationList()) {
+              os << delegation << ";";
             }
           }
           os << std::endl;
diff --git a/src/validator/certificate-fetcher-ndns-cert.cpp b/src/validator/certificate-fetcher-ndns-cert.cpp
index a29afe0..cd4a0ce 100644
--- a/src/validator/certificate-fetcher-ndns-cert.cpp
+++ b/src/validator/certificate-fetcher-ndns-cert.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -85,8 +85,9 @@
 
   if (data.getContentType() == NDNS_LINK) {
     Link link(data.wireEncode());
-    if (!link.getDelegationList().empty()) {
-      interest.setForwardingHint(link.getDelegationList());
+    auto delList = link.getDelegationList();
+    if (!delList.empty()) {
+      interest.setForwardingHint({delList.begin(), delList.end()});
       NDNS_LOG_INFO(" [* -> *] sending interest with LINK:" << interestName);
     }
     else {
diff --git a/tests/unit/clients/iterative-query-controller.t.cpp b/tests/unit/clients/iterative-query-controller.t.cpp
index 6478156..f8bb7db 100644
--- a/tests/unit/clients/iterative-query-controller.t.cpp
+++ b/tests/unit/clients/iterative-query-controller.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -126,7 +126,9 @@
     if (i > 0) {
       BOOST_CHECK_EQUAL(!interestRx[i].getForwardingHint().empty(), true);
       if (!interestRx[i].getForwardingHint().empty()) {
-        BOOST_CHECK_EQUAL(interestRx[i].getForwardingHint(), m_links[i - 1].getDelegationList());
+        BOOST_CHECK_EQUAL_COLLECTIONS(
+          interestRx[i].getForwardingHint().begin(), interestRx[i].getForwardingHint().end(),
+          m_links[i - 1].getDelegationList().begin(), m_links[i - 1].getDelegationList().end());
       }
     }
   }
diff --git a/tests/unit/clients/query.t.cpp b/tests/unit/clients/query.t.cpp
index e4da482..944bcb0 100644
--- a/tests/unit/clients/query.t.cpp
+++ b/tests/unit/clients/query.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -48,16 +48,20 @@
 
   auto link = make_shared<Link>("/ndn/link/NDNS/test/NS");
   for (int i = 1; i <= 5; i++) {
-    link->addDelegation(i, std::string("/link/") + to_string(i));
+    link->addDelegation(std::string("/link/") + to_string(i));
   }
   // link has to be signed first, then wireDecode
   m_keyChain.sign(*link, security::signingByIdentity(certIdentity));
 
-  q.setDelegationListFromLink(*link);
-  BOOST_CHECK_EQUAL(q.getDelegationList(), link->getDelegationList());
+  q.setForwardingHintFromLink(*link);
+  BOOST_CHECK_EQUAL_COLLECTIONS(
+    q.getForwardingHint().begin(), q.getForwardingHint().end(),
+    link->getDelegationList().begin(), link->getDelegationList().end());
 
   Interest interest = q.toInterest();
-  BOOST_CHECK_EQUAL(interest.getForwardingHint(), link->getDelegationList());
+  BOOST_CHECK_EQUAL_COLLECTIONS(
+    interest.getForwardingHint().begin(), interest.getForwardingHint().end(),
+    link->getDelegationList().begin(), link->getDelegationList().end());
 
   ndns::Query q2(zone, qType);
   BOOST_CHECK_EQUAL(q2.fromInterest(zone, interest), true);
diff --git a/tests/unit/daemon/rrset-factory.t.cpp b/tests/unit/daemon/rrset-factory.t.cpp
index f97f433..5314dad 100644
--- a/tests/unit/daemon/rrset-factory.t.cpp
+++ b/tests/unit/daemon/rrset-factory.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -106,14 +106,13 @@
   RrsetFactory rf(TEST_DATABASE2, m_zoneName, m_keyChain, m_certName);
 
   // rf without checkZoneKey: throw.
-  ndn::DelegationList delegations;
+  std::vector<Name> delegations;
   BOOST_CHECK_THROW(rf.generateNsRrset(label, version, ttl, delegations),
                     ndns::RrsetFactory::Error);
   rf.checkZoneKey();
 
   for (int i = 1; i <= 4; i++) {
-    Name name("/delegation/" + std::to_string(i));
-    delegations.insert(i, name);
+    delegations.emplace_back("/delegation/" + std::to_string(i));
   }
 
   Rrset rrset = rf.generateNsRrset(label, version, ttl, delegations);
@@ -132,7 +131,9 @@
 
   BOOST_CHECK_EQUAL(link.getName(), linkName);
   BOOST_CHECK_EQUAL(link.getContentType(), NDNS_LINK);
-  BOOST_CHECK(link.getDelegationList() == delegations);
+  BOOST_CHECK_EQUAL_COLLECTIONS(
+    link.getDelegationList().begin(), link.getDelegationList().end(),
+    delegations.begin(), delegations.end());
 
   BOOST_CHECK(security::verifySignature(link, m_cert));
 }
diff --git a/tests/unit/database-test-data.cpp b/tests/unit/database-test-data.cpp
index d4808d6..3ec18ae 100644
--- a/tests/unit/database-test-data.cpp
+++ b/tests/unit/database-test-data.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -136,9 +136,7 @@
                   m_keyChain, m_certName);
   rf.onlyCheckZone();
   if (type == label::NS_RR_TYPE) {
-    DelegationList ds;
-    ds.insert(1, "xx");
-    rrset = rf.generateNsRrset(label, version.toVersion(), ttl, ds);
+    rrset = rf.generateNsRrset(label, version.toVersion(), ttl, {"/xx"});
     if (contentType != NDNS_AUTH) {
       // do not add AUTH packet to link
       m_links.push_back(Link(rrset.getData()));
diff --git a/tests/unit/mgmt/management-tool.t.cpp b/tests/unit/mgmt/management-tool.t.cpp
index 054a8cf..6a3d535 100644
--- a/tests/unit/mgmt/management-tool.t.cpp
+++ b/tests/unit/mgmt/management-tool.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -631,7 +631,7 @@
 
   RrsetFactory rf(TEST_DATABASE, zoneName, m_keyChain, DEFAULT_CERT);
   rf.checkZoneKey();
-  Rrset rrset1 = rf.generateNsRrset("/l1", 7654, ttl2, DelegationList());
+  Rrset rrset1 = rf.generateNsRrset("/l1", 7654, ttl2, {});
 
   BOOST_CHECK_NO_THROW(m_tool.addRrset(rrset1));
   Rrset rrset2 = findRrSet(zone, "/l1", label::NS_RR_TYPE);
@@ -661,7 +661,7 @@
 
   Name labelName("/l1/l2/l3");
 
-  Rrset rrset1 = rf.generateNsRrset(labelName, 7654, ttl, DelegationList());
+  Rrset rrset1 = rf.generateNsRrset(labelName, 7654, ttl, {});
 
   //add NS NDNS_AUTH and check user-defined ttl
   BOOST_CHECK_NO_THROW(m_tool.addMultiLevelLabelRrset(rrset1, rf, ttl));
@@ -682,12 +682,12 @@
   checkRrset("/l1/l2/l3", label::NS_RR_TYPE, ndns::NDNS_LINK);
 
   // insert a shorter NS, when there are longer NS or TXT
-  Rrset shorterNs = rf.generateNsRrset("/l1/l2", 7654, ttl, DelegationList());
+  Rrset shorterNs = rf.generateNsRrset("/l1/l2", 7654, ttl, {});
   BOOST_CHECK_THROW(m_tool.addMultiLevelLabelRrset(shorterNs, rf, ttl),
                     ndns::ManagementTool::Error);
 
   // insert a longer NS, when there is already a shorter NS
-  Rrset longerNs = rf.generateNsRrset("/l1/l2/l3/l4", 7654, ttl, DelegationList());
+  Rrset longerNs = rf.generateNsRrset("/l1/l2/l3/l4", 7654, ttl, {});
   BOOST_CHECK_THROW(m_tool.addMultiLevelLabelRrset(longerNs, rf, ttl),
                     ndns::ManagementTool::Error);
 
@@ -697,7 +697,7 @@
 
   // insert a smaller NS, when there is long TXT
   Rrset longTxt = rf.generateTxtRrset("/k1/k2/k3", 7654, ttl, std::vector<std::string>());
-  Rrset smallerNs = rf.generateNsRrset("/k1/k2", 7654, ttl, DelegationList());
+  Rrset smallerNs = rf.generateNsRrset("/k1/k2", 7654, ttl, {});
   BOOST_CHECK_NO_THROW(m_tool.addMultiLevelLabelRrset(longTxt, rf, ttl));
   BOOST_CHECK_THROW(m_tool.addMultiLevelLabelRrset(smallerNs, rf, ttl),
                     ndns::ManagementTool::Error);
diff --git a/tools/ndns-add-rr.cpp b/tools/ndns-add-rr.cpp
index 40ccdb2..0c25a8f 100644
--- a/tools/ndns-add-rr.cpp
+++ b/tools/ndns-add-rr.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.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -177,16 +177,13 @@
       ndns::Rrset rrset;
 
       if (type == ndns::label::NS_RR_TYPE) {
-        ndn::DelegationList delegations;
+        std::vector<Name> delegations;
         for (const auto& i : content) {
-          std::vector<string> data;
-          boost::split(data, i, boost::is_any_of(","));
-          uint64_t priority = boost::lexical_cast<uint64_t>(data[0]);
-          delegations.insert(priority, Name(data[1]));
+          delegations.emplace_back(i);
         }
 
         rrset = rrsetFactory.generateNsRrset(label,
-                                             version, ttl, delegations);
+                                             version, ttl, std::move(delegations));
       }
       else if (type == ndns::label::TXT_RR_TYPE) {
         rrset = rrsetFactory.generateTxtRrset(label,