rib: Insert RIB command prefixes into RIB
refs: #2312
Change-Id: I9452f60d4c2162ad265603d3d5d44f083452ec58
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index 44214a3..ae64820 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -106,7 +106,7 @@
ControlParameters()
.setName(commandPrefix)
.setFaceId(0),
- bind(&RibManager::onNrdCommandPrefixAddNextHopSuccess, this, cref(commandPrefix)),
+ bind(&RibManager::onNrdCommandPrefixAddNextHopSuccess, this, cref(commandPrefix), _1),
bind(&RibManager::onNrdCommandPrefixAddNextHopError, this, cref(commandPrefix), _2));
m_face.setInterestFilter(commandPrefix, onRequest);
@@ -529,9 +529,22 @@
}
void
-RibManager::onNrdCommandPrefixAddNextHopSuccess(const Name& prefix)
+RibManager::onNrdCommandPrefixAddNextHopSuccess(const Name& prefix,
+ const ndn::nfd::ControlParameters& result)
{
NFD_LOG_DEBUG("Successfully registered " + prefix.toUri() + " with NFD");
+
+ // Routes must be inserted into the RIB so route flags can be applied
+ Route route;
+ route.faceId = result.getFaceId();
+ route.origin = ndn::nfd::ROUTE_ORIGIN_APP;
+ route.expires = time::steady_clock::TimePoint::max();
+ route.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT;
+
+ m_managedRib.insert(prefix, route);
+
+ m_registeredFaces.insert(route.faceId);
+ m_managedRib.clearFibUpdates();
}
void
diff --git a/rib/rib-manager.hpp b/rib/rib-manager.hpp
index efaf760..3819d5a 100644
--- a/rib/rib-manager.hpp
+++ b/rib/rib-manager.hpp
@@ -142,9 +142,12 @@
const ControlParameters& parameters,
const Route& route);
+PUBLIC_WITH_TESTS_ELSE_PRIVATE:
void
- onNrdCommandPrefixAddNextHopSuccess(const Name& prefix);
+ onNrdCommandPrefixAddNextHopSuccess(const Name& prefix,
+ const ndn::nfd::ControlParameters& result);
+private:
void
onNrdCommandPrefixAddNextHopError(const Name& name, const std::string& msg);
@@ -272,8 +275,11 @@
const SignedVerbDispatchTable m_signedVerbDispatch;
static const Name COMMAND_PREFIX; // /localhost/nrd
+
+PUBLIC_WITH_TESTS_ELSE_PRIVATE:
static const Name REMOTE_COMMAND_PREFIX; // /localhop/nrd
+private:
// number of components in an invalid, but not malformed, unsigned command.
// (/localhost/nrd + verb + options) = 4
static const size_t COMMAND_UNSIGNED_NCOMPS;