mgmt: loosened coupling between FibManager and InternalFace
Implemented InternalFace.setInterestFilter to loosen
coupling
refs: #1138
Change-Id: Ie58daed35bc3613398c8d3fc1de8b796e29907b8
diff --git a/daemon/mgmt/internal-face.cpp b/daemon/mgmt/internal-face.cpp
index b207dd2..0c3fe3b 100644
--- a/daemon/mgmt/internal-face.cpp
+++ b/daemon/mgmt/internal-face.cpp
@@ -5,12 +5,12 @@
*/
#include "internal-face.hpp"
-#include "fib-manager.hpp"
namespace nfd {
-InternalFace::InternalFace(FibManager& manager)
- : m_fibManager(manager)
+NFD_LOG_INIT("InternalFace");
+
+InternalFace::InternalFace()
{
}
@@ -18,11 +18,25 @@
void
InternalFace::sendInterest(const Interest& interest)
{
- const Name& interestName = interest.getName();
+ const Name& interestName(interest.getName());
+ NFD_LOG_DEBUG("received Interest: " << interestName);
- if (m_fibManager.getRequestPrefix().isPrefixOf(interestName))
+ size_t nComps = interestName.size();
+ for (size_t i = 0; i < nComps; i++)
{
- m_fibManager.onFibRequest(interest);
+ Name prefix(interestName.getPrefix(nComps - i));
+ std::map<Name, OnInterest>::const_iterator filter =
+ m_interestFilters.find(prefix);
+
+ if (filter != m_interestFilters.end())
+ {
+ NFD_LOG_DEBUG("found Interest filter for " << prefix);
+ filter->second(interestName, interest);
+ }
+ else
+ {
+ NFD_LOG_DEBUG("no Interest filter found for " << prefix);
+ }
}
//Drop Interest
}
@@ -37,7 +51,8 @@
InternalFace::setInterestFilter(const Name& filter,
OnInterest onInterest)
{
-
+ NFD_LOG_INFO("registering callback for " << filter);
+ m_interestFilters[filter] = onInterest;
}
void