rib: move RibManager to mgmt
Refs: #4528
Change-Id: Idff4ce8fe28b48163794cd12f0d185f8ca4233e3
diff --git a/daemon/fw/self-learning-strategy.cpp b/daemon/fw/self-learning-strategy.cpp
index 42f0f22..92f9ae3 100644
--- a/daemon/fw/self-learning-strategy.cpp
+++ b/daemon/fw/self-learning-strategy.cpp
@@ -227,7 +227,7 @@
{
runOnRibIoService([pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data, pa] {
rib::Service::get().getRibManager().slAnnounce(pa, inFaceId, ROUTE_RENEW_LIFETIME,
- [] (rib::RibManager::SlAnnounceResult res) {
+ [] (RibManager::SlAnnounceResult res) {
NFD_LOG_DEBUG("Add route via PrefixAnnouncement with result=" << res);
});
});
@@ -239,7 +239,7 @@
// renew route with PA or ignore PA (if route has no PA)
runOnRibIoService([name, inFaceId, maxLifetime] {
rib::Service::get().getRibManager().slRenew(name, inFaceId, maxLifetime,
- [] (rib::RibManager::SlAnnounceResult res) {
+ [] (RibManager::SlAnnounceResult res) {
NFD_LOG_DEBUG("Renew route with result=" << res);
});
});
diff --git a/daemon/rib/rib-manager.cpp b/daemon/mgmt/rib-manager.cpp
similarity index 98%
rename from daemon/rib/rib-manager.cpp
rename to daemon/mgmt/rib-manager.cpp
index 4477ebc..0a73db2 100644
--- a/daemon/rib/rib-manager.cpp
+++ b/daemon/mgmt/rib-manager.cpp
@@ -36,7 +36,9 @@
#include <ndn-cxx/mgmt/nfd/rib-entry.hpp>
namespace nfd {
-namespace rib {
+
+using rib::RibUpdate;
+using rib::Route;
NFD_LOG_INIT(RibManager);
@@ -46,7 +48,7 @@
const Name RibManager::LOCALHOP_TOP_PREFIX = "/localhop/nfd";
-RibManager::RibManager(Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
+RibManager::RibManager(rib::Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
ndn::nfd::Controller& nfdController, Dispatcher& dispatcher,
ndn::util::Scheduler& scheduler)
: ManagerBase(dispatcher, MGMT_MODULE_NAME)
@@ -267,7 +269,7 @@
{
auto now = time::steady_clock::now();
for (const auto& kv : m_rib) {
- const RibEntry& entry = *kv.second;
+ const rib::RibEntry& entry = *kv.second;
ndn::nfd::RibEntry item;
item.setName(entry.getName());
for (const Route& route : entry.getRoutes()) {
@@ -414,7 +416,7 @@
void
RibManager::slFindAnn(const Name& name, const SlFindAnnCallback& cb) const
{
- shared_ptr<RibEntry> entry;
+ shared_ptr<rib::RibEntry> entry;
auto exactMatch = m_rib.find(name);
if (exactMatch != m_rib.end()) {
entry = exactMatch->second;
@@ -496,5 +498,4 @@
}
}
-} // namespace rib
} // namespace nfd
diff --git a/daemon/rib/rib-manager.hpp b/daemon/mgmt/rib-manager.hpp
similarity index 91%
rename from daemon/rib/rib-manager.hpp
rename to daemon/mgmt/rib-manager.hpp
index 503dc2f..876ed75 100644
--- a/daemon/rib/rib-manager.hpp
+++ b/daemon/mgmt/rib-manager.hpp
@@ -23,28 +23,26 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NFD_DAEMON_RIB_RIB_MANAGER_HPP
-#define NFD_DAEMON_RIB_RIB_MANAGER_HPP
-
-#include "fib-updater.hpp"
-#include "rib.hpp"
+#ifndef NFD_DAEMON_MGMT_RIB_MANAGER_HPP
+#define NFD_DAEMON_MGMT_RIB_MANAGER_HPP
#include "core/config-file.hpp"
#include "core/manager-base.hpp"
+#include "rib/rib.hpp"
-#include <ndn-cxx/security/validator-config.hpp>
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
#include <ndn-cxx/mgmt/nfd/face-monitor.hpp>
+#include <ndn-cxx/security/validator-config.hpp>
#include <ndn-cxx/util/scheduler.hpp>
namespace nfd {
-namespace rib {
/**
- * @brief Serve commands and datasets in NFD RIB management protocol.
+ * @brief Serve commands and datasets of NFD RIB management protocol.
+ * @sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt
*/
-class RibManager : public nfd::ManagerBase
+class RibManager : public ManagerBase
{
public:
class Error : public std::runtime_error
@@ -53,8 +51,9 @@
using std::runtime_error::runtime_error;
};
- RibManager(Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain, ndn::nfd::Controller& nfdController,
- Dispatcher& dispatcher, ndn::util::Scheduler& scheduler);
+ RibManager(rib::Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
+ ndn::nfd::Controller& nfdController, Dispatcher& dispatcher,
+ ndn::util::Scheduler& scheduler);
/**
* @brief Apply localhost_security configuration.
@@ -174,7 +173,7 @@
* \param done completion callback
*/
void
- beginAddRoute(const Name& name, Route route, optional<time::nanoseconds> expires,
+ beginAddRoute(const Name& name, rib::Route route, optional<time::nanoseconds> expires,
const std::function<void(RibUpdateResult)>& done);
/** \brief Start removing a route from RIB and FIB.
@@ -183,11 +182,12 @@
* \param done completion callback
*/
void
- beginRemoveRoute(const Name& name, const Route& route,
+ beginRemoveRoute(const Name& name, const rib::Route& route,
const std::function<void(RibUpdateResult)>& done);
void
- beginRibUpdate(const RibUpdate& update, const std::function<void(RibUpdateResult)>& done);
+ beginRibUpdate(const rib::RibUpdate& update,
+ const std::function<void(RibUpdateResult)>& done);
private: // management Dispatcher related
void
@@ -243,7 +243,7 @@
static const Name LOCALHOP_TOP_PREFIX;
private:
- Rib& m_rib;
+ rib::Rib& m_rib;
ndn::KeyChain& m_keyChain;
ndn::nfd::Controller& m_nfdController;
Dispatcher& m_dispatcher;
@@ -262,7 +262,6 @@
std::ostream&
operator<<(std::ostream& os, RibManager::SlAnnounceResult res);
-} // namespace rib
} // namespace nfd
-#endif // NFD_DAEMON_RIB_RIB_MANAGER_HPP
+#endif // NFD_DAEMON_MGMT_RIB_MANAGER_HPP
diff --git a/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp b/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp
index 2d508f8..7810619 100644
--- a/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp
+++ b/daemon/rib/readvertise/host-to-gateway-readvertise-policy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,7 +25,7 @@
#include "host-to-gateway-readvertise-policy.hpp"
#include "core/scope-prefix.hpp"
-#include "rib/rib-manager.hpp"
+#include "mgmt/rib-manager.hpp"
#include <ndn-cxx/security/pib/identity.hpp>
#include <ndn-cxx/security/signing-helpers.hpp>
diff --git a/daemon/rib/service.hpp b/daemon/rib/service.hpp
index 0d6a71a..fe9b110 100644
--- a/daemon/rib/service.hpp
+++ b/daemon/rib/service.hpp
@@ -26,9 +26,10 @@
#ifndef NFD_DAEMON_RIB_SERVICE_HPP
#define NFD_DAEMON_RIB_SERVICE_HPP
-#include "rib-manager.hpp"
-
#include "core/config-file.hpp"
+#include "mgmt/rib-manager.hpp"
+#include "rib/fib-updater.hpp"
+#include "rib/rib.hpp"
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/mgmt/dispatcher.hpp>