**breaking** route: consolidate routing tlv into route
refs: #5116
Plus some misc improvements
Change-Id: Id0902fec65160b4368b1b5066f460433aced98ed
diff --git a/src/publisher/dataset-interest-handler.cpp b/src/publisher/dataset-interest-handler.cpp
index a574622..24c6e1a 100644
--- a/src/publisher/dataset-interest-handler.cpp
+++ b/src/publisher/dataset-interest-handler.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
#include "dataset-interest-handler.hpp"
#include "nlsr.hpp"
@@ -40,8 +40,7 @@
const RoutingTable& rt)
: m_dispatcher(dispatcher)
, m_lsdb(lsdb)
- , m_routingTableEntries(rt.getRoutingTableEntry())
- , m_dryRoutingTableEntries(rt.getDryRoutingTableEntry())
+ , m_routingTable(rt)
{
setDispatcher(m_dispatcher);
}
@@ -93,51 +92,12 @@
context.end();
}
-
-std::vector<tlv::RoutingTable>
-DatasetInterestHandler::getTlvRTEntries()
-{
- std::vector<tlv::RoutingTable> rtable;
- for (const auto& rte : m_routingTableEntries) {
- tlv::RoutingTable tlvRoutingTable;
- std::shared_ptr<tlv::Destination> tlvDes = tlv::makeDes(rte);
- tlvRoutingTable.setDestination(*tlvDes);
- for (const auto& nh : rte.getNexthopList().getNextHops()) {
- tlv::NextHop tlvNexthop;
- tlvNexthop.setUri(nh.getConnectingFaceUri());
- tlvNexthop.setCost(nh.getRouteCost());
- tlvRoutingTable.addNexthops(tlvNexthop);
- }
- rtable.push_back(tlvRoutingTable);
- }
- if (!m_dryRoutingTableEntries.empty()) {
- for (const auto& dryRte : m_dryRoutingTableEntries) {
- tlv::RoutingTable tlvRoutingTable;
- std::shared_ptr<tlv::Destination> tlvDes = tlv::makeDes(dryRte);
- tlvRoutingTable.setDestination(*tlvDes);
- for (const auto& nh : dryRte.getNexthopList().getNextHops()) {
- tlv::NextHop tlvNexthop;
- tlvNexthop.setUri(nh.getConnectingFaceUri());
- tlvNexthop.setCost(nh.getRouteCost());
- tlvRoutingTable.addNexthops(tlvNexthop);
- }
- rtable.push_back(tlvRoutingTable);
- }
- }
- return rtable;
-}
-
void
DatasetInterestHandler::publishRtStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
- NLSR_LOG_DEBUG("Received interest: " << interest);
- tlv::RoutingTableStatus rtStatus;
- for (const tlv::RoutingTable& rt : getTlvRTEntries()) {
- rtStatus.addRoutingTable(rt);
- }
- const ndn::Block& wire = rtStatus.wireEncode();
- context.append(wire);
+ NLSR_LOG_DEBUG("Received interest: " << interest);
+ context.append(m_routingTable.wireEncode());
context.end();
}
diff --git a/src/publisher/dataset-interest-handler.hpp b/src/publisher/dataset-interest-handler.hpp
index 28a6c4c..b39ac25 100644
--- a/src/publisher/dataset-interest-handler.hpp
+++ b/src/publisher/dataset-interest-handler.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2020, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
/*! \file dataset-interest-handler.hpp
@@ -37,9 +37,6 @@
#include "lsdb.hpp"
#include "logger.hpp"
-#include "tlv/routing-table-status.hpp"
-#include "tlv/routing-table-entry.hpp"
-
#include <ndn-cxx/mgmt/dispatcher.hpp>
#include <ndn-cxx/face.hpp>
#include <boost/noncopyable.hpp>
@@ -79,11 +76,6 @@
void
setDispatcher(ndn::mgmt::Dispatcher& dispatcher);
- /*! \brief generate a TLV-format of routing table entry
- */
- std::vector<tlv::RoutingTable>
- getTlvRTEntries();
-
/*! \brief provide routing-table dataset
*/
void
@@ -111,9 +103,7 @@
private:
ndn::mgmt::Dispatcher& m_dispatcher;
const Lsdb& m_lsdb;
-
- const std::list<RoutingTableEntry>& m_routingTableEntries;
- const std::list<RoutingTableEntry>& m_dryRoutingTableEntries;
+ const RoutingTable& m_routingTable;
};
} // namespace nlsr