src: decouple classes from Nlsr object
refs: #1952, #2803, #3960, #4288
Change-Id: Ibe3ac3820f11e8107ee4b13e510d53c27467a6cb
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index a38d33b..1da774b 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -38,7 +38,7 @@
Fib::Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList,
ConfParameter& conf, ndn::security::v2::KeyChain& keyChain)
: m_scheduler(scheduler)
- , m_refreshTime(0)
+ , m_refreshTime(2 * conf.getLsaRefreshTime())
, m_controller(face, keyChain)
, m_adjacencyList(adjacencyList)
, m_confParameter(conf)
diff --git a/src/route/map.hpp b/src/route/map.hpp
index 01801be..b4aa396 100644
--- a/src/route/map.hpp
+++ b/src/route/map.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -54,8 +54,6 @@
} // namespace detail
-class Nlsr;
-
class Map
{
public:
diff --git a/src/route/name-prefix-table.cpp b/src/route/name-prefix-table.cpp
index 1c05c2c..65e935c 100644
--- a/src/route/name-prefix-table.cpp
+++ b/src/route/name-prefix-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -33,9 +33,10 @@
INIT_LOGGER(route.NamePrefixTable);
-NamePrefixTable::NamePrefixTable(Nlsr& nlsr,
+NamePrefixTable::NamePrefixTable(Fib& fib, RoutingTable& routingTable,
std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal)
- : m_nlsr(nlsr)
+ : m_fib(fib)
+ , m_routingTable(routingTable)
{
m_afterRoutingChangeConnection = afterRoutingChangeSignal->connect(
[this] (const std::list<RoutingTableEntry>& entries) {
@@ -70,8 +71,7 @@
// There isn't currently a routing table entry in the pool for this name
if (rtpeItr == m_rtpool.end()) {
// See if there is a routing table entry available we could use
- RoutingTableEntry* routeEntryPtr = m_nlsr.getRoutingTable()
- .findRoutingTableEntry(destRouter);
+ RoutingTableEntry* routeEntryPtr = m_routingTable.findRoutingTableEntry(destRouter);
// We have to create a new routing table entry
if (routeEntryPtr == nullptr) {
@@ -102,7 +102,7 @@
// If this entry has next hops, we need to inform the FIB
if (npte->getNexthopList().size() > 0) {
NLSR_LOG_TRACE("Updating FIB with next hops for " << npte->getNamePrefix());
- m_nlsr.getFib().update(name, npte->getNexthopList());
+ m_fib.update(name, npte->getNexthopList());
}
// The routing table may recalculate and add a routing table entry
// with no next hops to replace an existing routing table entry. In
@@ -112,7 +112,7 @@
// calculation may add next hops.
else {
NLSR_LOG_TRACE(npte->getNamePrefix() << " has no next hops; removing from FIB");
- m_nlsr.getFib().remove(name);
+ m_fib.remove(name);
}
}
else {
@@ -124,11 +124,11 @@
if ((*nameItr)->getNexthopList().size() > 0) {
NLSR_LOG_TRACE("Updating FIB with next hops for " << (**nameItr));
- m_nlsr.getFib().update(name, (*nameItr)->getNexthopList());
+ m_fib.update(name, (*nameItr)->getNexthopList());
}
else {
NLSR_LOG_TRACE(npte->getNamePrefix() << " has no next hops; removing from FIB");
- m_nlsr.getFib().remove(name);
+ m_fib.remove(name);
}
}
// Add the reference to this NPT to the RTPE.
@@ -189,13 +189,13 @@
NLSR_LOG_TRACE(**nameItr << " has no routing table entries;"
<< " removing from table and FIB");
m_table.erase(nameItr);
- m_nlsr.getFib().remove(name);
+ m_fib.remove(name);
}
else {
NLSR_LOG_TRACE(**nameItr << " has other routing table entries;"
<< " updating FIB with next hops");
(*nameItr)->generateNhlfromRteList();
- m_nlsr.getFib().update(name, (*nameItr)->getNexthopList());
+ m_fib.update(name, (*nameItr)->getNexthopList());
}
}
else {
diff --git a/src/route/name-prefix-table.hpp b/src/route/name-prefix-table.hpp
index aa55c9e..8349453 100644
--- a/src/route/name-prefix-table.hpp
+++ b/src/route/name-prefix-table.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -26,12 +26,12 @@
#include "routing-table-pool-entry.hpp"
#include "signals.hpp"
#include "test-access-control.hpp"
+#include "route/fib.hpp"
#include <list>
#include <unordered_map>
namespace nlsr {
-class Nlsr;
class NamePrefixTable
{
@@ -41,7 +41,8 @@
using NptEntryList = std::list<std::shared_ptr<NamePrefixTableEntry>>;
using const_iterator = NptEntryList::const_iterator;
- NamePrefixTable(Nlsr& nlsr, std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal);
+ NamePrefixTable(Fib& fib, RoutingTable& routingTable,
+ std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal);
~NamePrefixTable();
@@ -124,7 +125,8 @@
NptEntryList m_table;
private:
- Nlsr& m_nlsr;
+ Fib& m_fib;
+ RoutingTable& m_routingTable;
ndn::util::signal::Connection m_afterRoutingChangeConnection;
};
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index 492c39b..68a7ca2 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -22,7 +22,6 @@
#include "routing-table-calculator.hpp"
#include "lsdb.hpp"
#include "map.hpp"
-#include "lsa.hpp"
#include "nexthop.hpp"
#include "nlsr.hpp"
#include "logger.hpp"
@@ -57,21 +56,17 @@
}
void
-RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map& pMap)
+RoutingTableCalculator::makeAdjMatrix(const std::list<AdjLsa>& adjLsaList, Map& pMap)
{
- std::list<AdjLsa> adjLsdb = pnlsr.getLsdb().getAdjLsdb();
// For each LSA represented in the map
- for (std::list<AdjLsa>::iterator it = adjLsdb.begin(); it != adjLsdb.end() ; it++) {
+ for (const auto& adjLsa : adjLsaList) {
+ ndn::optional<int32_t> row = pMap.getMappingNoByRouterName(adjLsa.getOrigRouter());
-
- ndn::optional<int32_t> row = pMap.getMappingNoByRouterName((*it).getOrigRouter());
-
- std::list<Adjacent> adl = (*it).getAdl().getAdjList();
+ std::list<Adjacent> adl = adjLsa.getAdl().getAdjList();
// For each adjacency represented in the LSA
- for (std::list<Adjacent>::iterator itAdl = adl.begin(); itAdl != adl.end() ; itAdl++) {
-
- ndn::optional<int32_t> col = pMap.getMappingNoByRouterName((*itAdl).getName());
- double cost = (*itAdl).getLinkCost();
+ for (const auto& adjacent : adl) {
+ ndn::optional<int32_t> col = pMap.getMappingNoByRouterName(adjacent.getName());
+ double cost = adjacent.getLinkCost();
if (row && col && *row < static_cast<int32_t>(m_nRouters)
&& *col < static_cast<int32_t>(m_nRouters))
@@ -224,24 +219,25 @@
}
void
-LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
- RoutingTable& rt, Nlsr& pnlsr)
+LinkStateRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt,
+ ConfParameter& confParam,
+ const std::list<AdjLsa>& adjLsaList)
{
NLSR_LOG_DEBUG("LinkStateRoutingTableCalculator::calculatePath Called");
allocateAdjMatrix();
initMatrix();
- makeAdjMatrix(pnlsr, pMap);
+ makeAdjMatrix(adjLsaList, pMap);
writeAdjMatrixLog(pMap);
ndn::optional<int32_t> sourceRouter =
- pMap.getMappingNoByRouterName(pnlsr.getConfParameter().getRouterPrefix());
+ pMap.getMappingNoByRouterName(confParam.getRouterPrefix());
allocateParent(); // These two matrices are used in Dijkstra's algorithm.
allocateDistance(); //
// We only bother to do the calculation if we have a router by that name.
- if (sourceRouter && pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1) {
+ if (sourceRouter && confParam.getMaxFacesPerPrefix() == 1) {
// In the single path case we can simply run Dijkstra's algorithm.
doDijkstraPathCalculation(*sourceRouter);
// Inform the routing table of the new next hops.
- addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, *sourceRouter);
+ addAllLsNextHopsToRoutingTable(confParam.getAdjacencyList(), rt, pMap, *sourceRouter);
}
else {
// Multi Path
@@ -257,7 +253,7 @@
// Do Dijkstra's algorithm using the current neighbor as your start.
doDijkstraPathCalculation(*sourceRouter);
// Update the routing table with the calculations.
- addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, *sourceRouter);
+ addAllLsNextHopsToRoutingTable(confParam.getAdjacencyList(), rt, pMap, *sourceRouter);
}
freeLinks();
freeLinksCosts();
@@ -318,8 +314,9 @@
}
void
-LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
- Map& pMap, uint32_t sourceRouter)
+LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(AdjacencyList& adjacencies,
+ RoutingTable& rt, Map& pMap,
+ uint32_t sourceRouter)
{
NLSR_LOG_DEBUG("LinkStateRoutingTableCalculator::addAllNextHopsToRoutingTable Called");
@@ -341,7 +338,7 @@
ndn::optional<ndn::Name> nextHopRouterName= pMap.getRouterNameByMappingNo(nextHopRouter);
if (nextHopRouterName) {
std::string nextHopFace =
- pnlsr.getAdjacencyList().getAdjacent(*nextHopRouterName).getFaceUri().toString();
+ adjacencies.getAdjacent(*nextHopRouterName).getFaceUri().toString();
// Add next hop to routing table
NextHop nh(nextHopFace, routeCost);
rt.addNextHop(*(pMap.getRouterNameByMappingNo(i)), nh);
diff --git a/src/route/routing-table-calculator.hpp b/src/route/routing-table-calculator.hpp
index 0812aad..dd1e658 100644
--- a/src/route/routing-table-calculator.hpp
+++ b/src/route/routing-table-calculator.hpp
@@ -23,6 +23,8 @@
#define NLSR_ROUTING_TABLE_CALCULATOR_HPP
#include "common.hpp"
+#include "lsa.hpp"
+#include "conf-parameter.hpp"
#include <list>
#include <iostream>
@@ -34,7 +36,6 @@
class Map;
class RoutingTable;
-class Nlsr;
class RoutingTableCalculator
{
@@ -56,12 +57,11 @@
initMatrix();
/*! \brief Constructs an adj. matrix to calculate with.
- \param pnlsr The NLSR object that contains the LSAs that we need to iterate
- over.
+ \param adjLsaList The Adjacency Lsa list.
\param pMap The map to populate with the adj. data.
*/
void
- makeAdjMatrix(Nlsr& pnlsr, Map& pMap);
+ makeAdjMatrix(const std::list<AdjLsa>& adjLsaList, Map& pMap);
void
writeAdjMatrixLog(const Map& map) const;
@@ -137,7 +137,8 @@
}
void
- calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);
+ calculatePath(Map& pMap, RoutingTable& rt, ConfParameter& confParam,
+ const std::list<AdjLsa>& adjLsaList);
private:
/*! \brief Performs a Dijkstra's calculation over the adjacency matrix.
@@ -168,7 +169,7 @@
isNotExplored(int* Q, int u, int start, int element);
void
- addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
+ addAllLsNextHopsToRoutingTable(AdjacencyList& adjacencies, RoutingTable& rt,
Map& pMap, uint32_t sourceRouter);
/*! \brief Determines a destination's next hop.
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 48ef422..4e2fa86 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -35,39 +35,44 @@
INIT_LOGGER(route.RoutingTable);
-RoutingTable::RoutingTable(ndn::Scheduler& scheduler)
+RoutingTable::RoutingTable(ndn::Scheduler& scheduler, Fib& fib, Lsdb& lsdb,
+ NamePrefixTable& namePrefixTable, ConfParameter& confParam)
: afterRoutingChange{std::make_unique<AfterRoutingChange>()}
, m_scheduler(scheduler)
+ , m_fib(fib)
+ , m_lsdb(lsdb)
+ , m_namePrefixTable(namePrefixTable)
, m_NO_NEXT_HOP{-12345}
- , m_routingCalcInterval{static_cast<uint32_t>(ROUTING_CALC_INTERVAL_DEFAULT)}
+ , m_routingCalcInterval{confParam.getRoutingCalcInterval()}
+ , m_isRoutingTableCalculating(false)
+ , m_isRouteCalculationScheduled(false)
+ , m_confParam(confParam)
{
}
void
-RoutingTable::calculate(Nlsr& pnlsr)
+RoutingTable::calculate()
{
- pnlsr.getLsdb().writeCorLsdbLog();
- pnlsr.getLsdb().writeNameLsdbLog();
- pnlsr.getLsdb().writeAdjLsdbLog();
- pnlsr.getNamePrefixTable().writeLog();
- if (pnlsr.getIsRoutingTableCalculating() == false) {
- //setting routing table calculation
- pnlsr.setIsRoutingTableCalculating(true);
+ m_lsdb.writeCorLsdbLog();
+ m_lsdb.writeNameLsdbLog();
+ m_lsdb.writeAdjLsdbLog();
+ m_namePrefixTable.writeLog();
+ if (m_isRoutingTableCalculating == false) {
+ // setting routing table calculation
+ m_isRoutingTableCalculating = true;
- bool isHrEnabled = pnlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF;
+ bool isHrEnabled = m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF;
- if ((!isHrEnabled
- &&
- pnlsr.getLsdb()
- .doesLsaExist(ndn::Name{pnlsr.getConfParameter().getRouterPrefix()}
+ if ((!isHrEnabled &&
+ m_lsdb
+ .doesLsaExist(ndn::Name{m_confParam.getRouterPrefix()}
.append(std::to_string(Lsa::Type::ADJACENCY)), Lsa::Type::ADJACENCY))
||
- (isHrEnabled
- &&
- pnlsr.getLsdb()
- .doesLsaExist(ndn::Name{pnlsr.getConfParameter().getRouterPrefix()}
+ (isHrEnabled &&
+ m_lsdb
+ .doesLsaExist(ndn::Name{m_confParam.getRouterPrefix()}
.append(std::to_string(Lsa::Type::COORDINATE)), Lsa::Type::COORDINATE))) {
- if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
+ if (m_lsdb.getIsBuildAdjLsaSheduled() != 1) {
NLSR_LOG_TRACE("Clearing old routing table");
clearRoutingTable();
// for dry run options
@@ -76,24 +81,24 @@
NLSR_LOG_DEBUG("Calculating routing table");
// calculate Link State routing
- if ((pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF)
- || (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN)) {
- calculateLsRoutingTable(pnlsr);
+ if ((m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF)
+ || (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN)) {
+ calculateLsRoutingTable();
}
- // calculate hyperbolic
- if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
- calculateHypRoutingTable(pnlsr, false);
+ // calculate hyperbolic routing
+ if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
+ calculateHypRoutingTable(false);
}
- //calculate dry hyperbolic routing
- if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
- calculateHypRoutingTable(pnlsr, true);
+ // calculate dry hyperbolic routing
+ if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
+ calculateHypRoutingTable(true);
}
// Inform the NPT that updates have been made
NLSR_LOG_DEBUG("Calling Update NPT With new Route");
(*afterRoutingChange)(m_rTable);
- writeLog(pnlsr.getConfParameter().getHyperbolicState());
- pnlsr.getNamePrefixTable().writeLog();
- pnlsr.getFib().writeLog();
+ writeLog();
+ m_namePrefixTable.writeLog();
+ m_fib.writeLog();
}
else {
NLSR_LOG_DEBUG("Adjacency building is scheduled, so"
@@ -108,61 +113,60 @@
// need to update NPT here
NLSR_LOG_DEBUG("Calling Update NPT With new Route");
(*afterRoutingChange)(m_rTable);
- writeLog(pnlsr.getConfParameter().getHyperbolicState());
- pnlsr.getNamePrefixTable().writeLog();
- pnlsr.getFib().writeLog();
- //debugging purpose end
+ writeLog();
+ m_namePrefixTable.writeLog();
+ m_fib.writeLog();
+ // debugging purpose end
}
- pnlsr.setIsRouteCalculationScheduled(false); //clear scheduled flag
- pnlsr.setIsRoutingTableCalculating(false); //unsetting routing table calculation
+ m_isRouteCalculationScheduled = false; // clear scheduled flag
+ m_isRoutingTableCalculating = false; // unsetting routing table calculation
}
else {
- scheduleRoutingTableCalculation(pnlsr);
+ scheduleRoutingTableCalculation();
}
}
void
-RoutingTable::calculateLsRoutingTable(Nlsr& nlsr)
+RoutingTable::calculateLsRoutingTable()
{
NLSR_LOG_DEBUG("RoutingTable::calculateLsRoutingTable Called");
Map map;
- map.createFromAdjLsdb(nlsr.getLsdb().getAdjLsdb().begin(), nlsr.getLsdb().getAdjLsdb().end());
+ map.createFromAdjLsdb(m_lsdb.getAdjLsdb().begin(), m_lsdb.getAdjLsdb().end());
map.writeLog();
size_t nRouters = map.getMapSize();
LinkStateRoutingTableCalculator calculator(nRouters);
- calculator.calculatePath(map, *this, nlsr);
+ calculator.calculatePath(map, *this, m_confParam, m_lsdb.getAdjLsdb());
}
void
-RoutingTable::calculateHypRoutingTable(Nlsr& nlsr, bool isDryRun)
+RoutingTable::calculateHypRoutingTable(bool isDryRun)
{
Map map;
- map.createFromCoordinateLsdb(nlsr.getLsdb().getCoordinateLsdb().begin(),
- nlsr.getLsdb().getCoordinateLsdb().end());
+ map.createFromCoordinateLsdb(m_lsdb.getCoordinateLsdb().begin(),
+ m_lsdb.getCoordinateLsdb().end());
map.writeLog();
size_t nRouters = map.getMapSize();
- HyperbolicRoutingCalculator calculator(nRouters, isDryRun,
- nlsr.getConfParameter().getRouterPrefix());
+ HyperbolicRoutingCalculator calculator(nRouters, isDryRun, m_confParam.getRouterPrefix());
- calculator.calculatePath(map, *this, nlsr.getLsdb(), nlsr.getAdjacencyList());
+ calculator.calculatePath(map, *this, m_lsdb, m_confParam.getAdjacencyList());
}
void
-RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
+RoutingTable::scheduleRoutingTableCalculation()
{
- if (pnlsr.getIsRouteCalculationScheduled() != true) {
+ if (m_isRouteCalculationScheduled != true) {
NLSR_LOG_DEBUG("Scheduling routing table calculation in " << m_routingCalcInterval);
m_scheduler.scheduleEvent(m_routingCalcInterval,
- std::bind(&RoutingTable::calculate, this, std::ref(pnlsr)));
+ std::bind(&RoutingTable::calculate, this));
- pnlsr.setIsRouteCalculationScheduled(true);
+ m_isRouteCalculationScheduled = true;
}
}
@@ -202,23 +206,21 @@
}
void
-RoutingTable::writeLog(int hyperbolicState)
+RoutingTable::writeLog()
{
NLSR_LOG_DEBUG("---------------Routing Table------------------");
- for (std::list<RoutingTableEntry>::iterator it = m_rTable.begin() ;
- it != m_rTable.end(); ++it) {
- NLSR_LOG_DEBUG("Destination: " << (*it).getDestination());
+ for (const auto& rte : m_rTable) {
+ NLSR_LOG_DEBUG("Destination: " << rte.getDestination());
NLSR_LOG_DEBUG("Nexthops: ");
- (*it).getNexthopList().writeLog();
+ rte.getNexthopList().writeLog();
}
- if (hyperbolicState == HYPERBOLIC_STATE_DRY_RUN) {
+ if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
NLSR_LOG_DEBUG("--------Hyperbolic Routing Table(Dry)---------");
- for (std::list<RoutingTableEntry>::iterator it = m_dryTable.begin() ;
- it != m_dryTable.end(); ++it) {
- NLSR_LOG_DEBUG("Destination: " << (*it).getDestination());
+ for (const auto& rte : m_dryTable) {
+ NLSR_LOG_DEBUG("Destination: " << rte.getDestination());
NLSR_LOG_DEBUG("Nexthops: ");
- (*it).getNexthopList().writeLog();
+ rte.getNexthopList().writeLog();
}
}
}
diff --git a/src/route/routing-table.hpp b/src/route/routing-table.hpp
index 5572aed..f43ad11 100644
--- a/src/route/routing-table.hpp
+++ b/src/route/routing-table.hpp
@@ -25,6 +25,8 @@
#include "conf-parameter.hpp"
#include "routing-table-entry.hpp"
#include "signals.hpp"
+#include "lsdb.hpp"
+#include "route/fib.hpp"
#include <iostream>
#include <utility>
@@ -34,22 +36,21 @@
namespace nlsr {
-class Nlsr;
class NextHop;
class RoutingTable : boost::noncopyable
{
public:
explicit
- RoutingTable(ndn::Scheduler& scheduler);
+ RoutingTable(ndn::Scheduler& scheduler, Fib& fib, Lsdb& lsdb,
+ NamePrefixTable& namePrefixTable, ConfParameter& confParam);
/*! \brief Calculates a list of next hops for each router in the network.
- * \param nlsr The NLSR object that contains the LSAs needed for adj. info.
*
* Calculates the list of next hops to every other router in the network.
*/
void
- calculate(Nlsr& nlsr);
+ calculate();
/*! \brief Adds a next hop to a routing table entry.
* \param destRouter The destination router whose RTE we want to modify.
@@ -70,10 +71,9 @@
/*! \brief Schedules a calculation event in the event scheduler only
* if one isn't already scheduled.
- * \param pnlsr The NLSR whose scheduling status is needed.
*/
void
- scheduleRoutingTableCalculation(Nlsr& pnlsr);
+ scheduleRoutingTableCalculation();
int
getNoNextHop()
@@ -114,11 +114,11 @@
private:
/*! \brief Calculates a link-state routing table. */
void
- calculateLsRoutingTable(Nlsr& pnlsr);
+ calculateLsRoutingTable();
/*! \brief Calculates a HR routing table. */
void
- calculateHypRoutingTable(Nlsr& pnlsr, bool isDryRun);
+ calculateHypRoutingTable(bool isDryRun);
void
clearRoutingTable();
@@ -127,7 +127,7 @@
clearDryRoutingTable();
void
- writeLog(int hyperbolicState);
+ writeLog();
public:
std::unique_ptr<AfterRoutingChange> afterRoutingChange;
@@ -137,12 +137,20 @@
private:
ndn::Scheduler& m_scheduler;
+ Fib& m_fib;
+ Lsdb& m_lsdb;
+ NamePrefixTable& m_namePrefixTable;
const int m_NO_NEXT_HOP;
std::list<RoutingTableEntry> m_dryTable;
ndn::time::seconds m_routingCalcInterval;
+
+ bool m_isRoutingTableCalculating;
+ bool m_isRouteCalculationScheduled;
+
+ ConfParameter& m_confParam;
};
} // namespace nlsr