BREAKING: Change Name LSAs to propagate cost which are applied to remote routes

This is a stopgap change to address a lack of functionality in the NDN testbed.
Current restrictions:
-Cost must be set from NFD readvertisement
-Cost is applied after routing calculations but before FIB insertion; lowest cost
nexthop will be chosen but may not be the optimal path given this cost.

Further work will be required to move the application of cost as part of routing
and to make this functionality more easily accessible.

Refs #5349

Change-Id: I914dc5c2d5d3cb6bfa13f5730df0eae66d115c60
diff --git a/src/lsa/adj-lsa.cpp b/src/lsa/adj-lsa.cpp
index f143499..9b58098 100644
--- a/src/lsa/adj-lsa.cpp
+++ b/src/lsa/adj-lsa.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2024,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -126,7 +126,7 @@
   }
 }
 
-std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
+std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
 AdjLsa::update(const std::shared_ptr<Lsa>& lsa)
 {
   auto alsa = std::static_pointer_cast<AdjLsa>(lsa);
@@ -135,9 +135,9 @@
     for (const auto& adjacent : alsa->getAdl()) {
       addAdjacent(adjacent);
     }
-    return {true, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
+    return {true, std::list<PrefixInfo>{}, std::list<PrefixInfo>{}};
   }
-  return {false, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
+  return {false, std::list<PrefixInfo>{}, std::list<PrefixInfo>{}};
 }
 
 } // namespace nlsr
diff --git a/src/lsa/adj-lsa.hpp b/src/lsa/adj-lsa.hpp
index 8c6354d..5fc3903 100644
--- a/src/lsa/adj-lsa.hpp
+++ b/src/lsa/adj-lsa.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2024,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -107,7 +107,7 @@
   void
   wireDecode(const ndn::Block& wire);
 
-  std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
+  std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
   update(const std::shared_ptr<Lsa>& lsa) override;
 
 private:
diff --git a/src/lsa/coordinate-lsa.cpp b/src/lsa/coordinate-lsa.cpp
index 11428f8..3008915 100644
--- a/src/lsa/coordinate-lsa.cpp
+++ b/src/lsa/coordinate-lsa.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2024,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -129,7 +129,7 @@
   }
 }
 
-std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
+std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
 CoordinateLsa::update(const std::shared_ptr<Lsa>& lsa)
 {
   auto clsa = std::static_pointer_cast<CoordinateLsa>(lsa);
@@ -139,9 +139,9 @@
     for (const auto& angle : clsa->getTheta()) {
       m_hyperbolicAngles.push_back(angle);
     }
-    return {true, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
+    return {true, std::list<PrefixInfo>{}, std::list<PrefixInfo>{}};
   }
-  return {false, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
+  return {false, std::list<PrefixInfo>{}, std::list<PrefixInfo>{}};
 }
 
 } // namespace nlsr
diff --git a/src/lsa/coordinate-lsa.hpp b/src/lsa/coordinate-lsa.hpp
index 3e7f0a1..60ef965 100644
--- a/src/lsa/coordinate-lsa.hpp
+++ b/src/lsa/coordinate-lsa.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2024,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -106,7 +106,7 @@
   void
   wireDecode(const ndn::Block& wire);
 
-  std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
+  std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
   update(const std::shared_ptr<Lsa>& lsa) override;
 
 private:
diff --git a/src/lsa/lsa.hpp b/src/lsa/lsa.hpp
index e482a92..a52a4f7 100644
--- a/src/lsa/lsa.hpp
+++ b/src/lsa/lsa.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2024,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -23,12 +23,14 @@
 #define NLSR_LSA_LSA_HPP
 
 #include "common.hpp"
+#include "name-prefix-list.hpp"
 #include "test-access-control.hpp"
 
 #include <ndn-cxx/util/scheduler.hpp>
 
 #include <list>
 
+
 namespace nlsr {
 
 /**
@@ -112,7 +114,7 @@
     m_expiringEventId = eid;
   }
 
-  virtual std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
+  virtual std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
   update(const std::shared_ptr<Lsa>& lsa) = 0;
 
   virtual const ndn::Block&
diff --git a/src/lsa/name-lsa.cpp b/src/lsa/name-lsa.cpp
index 7867b68..2efe86e 100644
--- a/src/lsa/name-lsa.cpp
+++ b/src/lsa/name-lsa.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2024,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -29,7 +29,7 @@
                  const NamePrefixList& npl)
   : Lsa(originRouter, seqNo, timepoint)
 {
-  for (const auto& name : npl.getNames()) {
+  for (const auto& name : npl.getPrefixInfo()) {
     addName(name);
   }
 }
@@ -45,7 +45,7 @@
 {
   size_t totalLength = 0;
 
-  auto names = m_npl.getNames();
+  auto names = m_npl.getPrefixInfo();
 
   for (auto it = names.rbegin();  it != names.rend(); ++it) {
     totalLength += it->wireEncode(block);
@@ -102,8 +102,9 @@
 
   NamePrefixList npl;
   for (; val != m_wire.elements_end(); ++val) {
-    if (val->type() == ndn::tlv::Name) {
-      npl.insert(ndn::Name(*val));
+    if (val->type() == nlsr::tlv::PrefixInfo) {
+      //TODO: Implement this structure as a type instead and add decoding
+      npl.insert(PrefixInfo(*val));
     }
     else {
       NDN_THROW(Error("Name", val->type()));
@@ -117,12 +118,14 @@
 {
   os << "      Names:\n";
   int i = 0;
-  for (const auto& name : m_npl.getNames()) {
-    os << "        Name " << i++ << ": " << name << "\n";
+  for (const auto& name : m_npl.getPrefixInfo()) {
+    os << "        Name " << i << ": " << name.getName()
+       << " | Cost: " << name.getCost() << "\n";
+    i++;
   }
 }
 
-std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
+std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
 NameLsa::update(const std::shared_ptr<Lsa>& lsa)
 {
   auto nlsa = std::static_pointer_cast<NameLsa>(lsa);
@@ -130,25 +133,31 @@
 
   // Obtain the set difference of the current and the incoming
   // name prefix sets, and add those.
+
   std::list<ndn::Name> newNames = nlsa->getNpl().getNames();
   std::list<ndn::Name> oldNames = m_npl.getNames();
-  std::list<ndn::Name> namesToAdd;
+  std::list<ndn::Name> nameRefToAdd;
+  std::list<PrefixInfo> namesToAdd;
+
   std::set_difference(newNames.begin(), newNames.end(), oldNames.begin(), oldNames.end(),
-                      std::inserter(namesToAdd, namesToAdd.begin()));
-  for (const auto& name : namesToAdd) {
-    addName(name);
+                      std::inserter(nameRefToAdd, nameRefToAdd.begin()));
+  for (const auto& name : nameRefToAdd) {
+    namesToAdd.push_back(nlsa->getNpl().getPrefixInfoForName(name));
+    addName(nlsa->getNpl().getPrefixInfoForName(name));
     updated = true;
   }
 
   // Also remove any names that are no longer being advertised.
-  std::list<ndn::Name> namesToRemove;
+  std::list<ndn::Name> nameRefToRemove;
+  std::list<PrefixInfo> namesToRemove;
   std::set_difference(oldNames.begin(), oldNames.end(), newNames.begin(), newNames.end(),
-                      std::inserter(namesToRemove, namesToRemove.begin()));
-  for (const auto& name : namesToRemove) {
-    removeName(name);
+                      std::inserter(nameRefToRemove, nameRefToRemove.begin()));
+  for (const auto& name : nameRefToRemove) {
+    namesToRemove.push_back(m_npl.getPrefixInfoForName(name));
+    removeName(m_npl.getPrefixInfoForName(name));
+
     updated = true;
   }
-
   return {updated, namesToAdd, namesToRemove};
 }
 
diff --git a/src/lsa/name-lsa.hpp b/src/lsa/name-lsa.hpp
index 625bbb7..27f46b1 100644
--- a/src/lsa/name-lsa.hpp
+++ b/src/lsa/name-lsa.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2024,  The University of Memphis,
+ * Copyright (c) 2014-2025,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -76,17 +76,17 @@
   }
 
   void
-  addName(const ndn::Name& name)
+  addName(const PrefixInfo& name)
   {
     m_wire.reset();
     m_npl.insert(name);
   }
 
   void
-  removeName(const ndn::Name& name)
+  removeName(const PrefixInfo& name)
   {
     m_wire.reset();
-    m_npl.erase(name);
+    m_npl.erase(name.getName());
   }
 
   template<ndn::encoding::Tag TAG>
@@ -99,7 +99,7 @@
   void
   wireDecode(const ndn::Block& wire);
 
-  std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
+  std::tuple<bool, std::list<PrefixInfo>, std::list<PrefixInfo>>
   update(const std::shared_ptr<Lsa>& lsa) override;
 
 private: