rib: Rename FaceEntry to Route
refs: #2159
Change-Id: Ia324a47816cac514dacc4a69a29fd30d08932e5b
diff --git a/rib/rib-entry.cpp b/rib/rib-entry.cpp
index 3e24275..4ded689 100644
--- a/rib/rib-entry.cpp
+++ b/rib/rib-entry.cpp
@@ -34,25 +34,25 @@
namespace nfd {
namespace rib {
-RibEntry::FaceList::iterator
-RibEntry::findFace(const FaceEntry& face)
+RibEntry::RouteList::iterator
+RibEntry::findRoute(const Route& route)
{
- return std::find_if(begin(), end(), bind(&compareFaceIdAndOrigin, _1, face));
+ return std::find_if(begin(), end(), bind(&compareFaceIdAndOrigin, _1, route));
}
bool
-RibEntry::insertFace(const FaceEntry& entry)
+RibEntry::insertRoute(const Route& route)
{
- iterator it = findFace(entry);
+ iterator it = findRoute(route);
if (it == end())
{
- if (entry.flags & ndn::nfd::ROUTE_FLAG_CAPTURE)
+ if (route.flags & ndn::nfd::ROUTE_FLAG_CAPTURE)
{
- m_nFacesWithCaptureSet++;
+ m_nRoutesWithCaptureSet++;
}
- m_faces.push_back(entry);
+ m_routes.push_back(route);
return true;
}
else
@@ -62,27 +62,26 @@
}
void
-RibEntry::eraseFace(const FaceEntry& face)
+RibEntry::eraseRoute(const Route& route)
{
- RibEntry::iterator it = std::find_if(begin(), end(), bind(&compareFaceIdAndOrigin, _1, face));
- eraseFace(it);
+ RibEntry::iterator it = findRoute(route);
+ eraseRoute(it);
}
bool
-RibEntry::hasFace(const FaceEntry& face)
+RibEntry::hasRoute(const Route& route)
{
- RibEntry::const_iterator it = std::find_if(cbegin(), cend(),
- bind(&compareFaceIdAndOrigin, _1, face));
+ RibEntry::const_iterator it = findRoute(route);
- return it != cend();
+ return it != end();
}
bool
RibEntry::hasFaceId(const uint64_t faceId) const
{
- RibEntry::const_iterator it = std::find_if(cbegin(), cend(), bind(&compareFaceId, _1, faceId));
+ RibEntry::const_iterator it = std::find_if(begin(), end(), bind(&compareFaceId, _1, faceId));
- return it != cend();
+ return it != end();
}
void
@@ -101,64 +100,64 @@
m_children.remove(child);
}
-RibEntry::FaceList::iterator
-RibEntry::eraseFace(FaceList::iterator face)
+RibEntry::RouteList::iterator
+RibEntry::eraseRoute(RouteList::iterator route)
{
- if (face != m_faces.end())
+ if (route != m_routes.end())
{
- if (face->flags & ndn::nfd::ROUTE_FLAG_CAPTURE)
+ if (route->flags & ndn::nfd::ROUTE_FLAG_CAPTURE)
{
- m_nFacesWithCaptureSet--;
+ m_nRoutesWithCaptureSet--;
}
//cancel any scheduled event
- NFD_LOG_TRACE("Cancelling expiration eventId: " << face->getExpirationEvent());
- scheduler::cancel(face->getExpirationEvent());
+ NFD_LOG_TRACE("Cancelling expiration eventId: " << route->getExpirationEvent());
+ scheduler::cancel(route->getExpirationEvent());
- return m_faces.erase(face);
+ return m_routes.erase(route);
}
- return m_faces.end();
+ return m_routes.end();
}
void
-RibEntry::addInheritedFace(const FaceEntry& face)
+RibEntry::addInheritedRoute(const Route& route)
{
- m_inheritedFaces.push_back(face);
+ m_inheritedRoutes.push_back(route);
}
void
-RibEntry::removeInheritedFace(const FaceEntry& face)
+RibEntry::removeInheritedRoute(const Route& route)
{
- FaceList::iterator it = findInheritedFace(face);
- m_inheritedFaces.erase(it);
+ RouteList::iterator it = findInheritedRoute(route);
+ m_inheritedRoutes.erase(it);
}
-RibEntry::FaceList::iterator
-RibEntry::findInheritedFace(const FaceEntry& face)
+RibEntry::RouteList::iterator
+RibEntry::findInheritedRoute(const Route& route)
{
- return std::find_if(m_inheritedFaces.begin(), m_inheritedFaces.end(),
- bind(&compareFaceId, _1, face.faceId));
+ return std::find_if(m_inheritedRoutes.begin(), m_inheritedRoutes.end(),
+ bind(&compareFaceId, _1, route.faceId));
}
bool
-RibEntry::hasInheritedFace(const FaceEntry& face)
+RibEntry::hasInheritedRoute(const Route& route)
{
- FaceList::const_iterator it = findInheritedFace(face);
+ RouteList::const_iterator it = findInheritedRoute(route);
- return (it != m_inheritedFaces.end());
+ return (it != m_inheritedRoutes.end());
}
bool
RibEntry::hasCapture() const
{
- return m_nFacesWithCaptureSet > 0;
+ return m_nRoutesWithCaptureSet > 0;
}
bool
RibEntry::hasChildInheritOnFaceId(uint64_t faceId) const
{
- for (RibEntry::const_iterator it = m_faces.begin(); it != m_faces.end(); ++it)
+ for (RibEntry::const_iterator it = m_routes.begin(); it != m_routes.end(); ++it)
{
if (it->faceId == faceId && (it->flags & ndn::nfd::ROUTE_FLAG_CHILD_INHERIT))
{
@@ -169,66 +168,67 @@
return false;
}
-shared_ptr<FaceEntry>
-RibEntry::getFaceWithLowestCostByFaceId(uint64_t faceId)
+shared_ptr<Route>
+RibEntry::getRouteWithLowestCostByFaceId(uint64_t faceId)
{
- shared_ptr<FaceEntry> face;
+ shared_ptr<Route> candidate;
- for (FaceList::iterator it = begin(); it != end(); ++it)
+ for (const Route& route : m_routes)
{
// Correct face ID
- if (it->faceId == faceId)
+ if (route.faceId == faceId)
{
- // If this is the first face with this ID found
- if (!static_cast<bool>(face))
+ // If this is the first route with this Face ID found
+ if (candidate == nullptr)
{
- face = make_shared<FaceEntry>(*it);
+ candidate = make_shared<Route>(route);
}
- else if (it->cost < face->cost) // Found a face with a lower cost
+ else if (route.cost < candidate->cost) // Found a route with a lower cost
{
- face = make_shared<FaceEntry>(*it);
+ candidate = make_shared<Route>(route);
}
}
}
- return face;
+ return candidate;
}
-shared_ptr<FaceEntry>
-RibEntry::getFaceWithLowestCostAndChildInheritByFaceId(uint64_t faceId)
+shared_ptr<Route>
+RibEntry::getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId)
{
- shared_ptr<FaceEntry> face;
+ shared_ptr<Route> candidate;
- for (FaceList::iterator it = begin(); it != end(); ++it)
+ for (const Route& route : m_routes)
{
// Correct face ID and Child Inherit flag set
- if (it->faceId == faceId && it->flags & ndn::nfd::ROUTE_FLAG_CHILD_INHERIT)
+ if (route.faceId == faceId &&
+ (route.flags & ndn::nfd::ROUTE_FLAG_CHILD_INHERIT) == ndn::nfd::ROUTE_FLAG_CHILD_INHERIT)
{
- // If this is the first face with this ID found
- if (!static_cast<bool>(face))
+ // If this is the first route with this Face ID found
+ if (candidate == nullptr)
{
- face = make_shared<FaceEntry>(*it);
+ candidate = make_shared<Route>(route);
}
- else if (it->cost < face->cost) // Found a face with a lower cost
+ else if (route.cost < candidate->cost) // Found a route with a lower cost
{
- face = make_shared<FaceEntry>(*it);
+ candidate = make_shared<Route>(route);
}
}
}
- return face;
+ return candidate;
}
std::ostream&
-operator<<(std::ostream& os, const FaceEntry& entry)
+operator<<(std::ostream& os, const Route& route)
{
- os << "FaceEntry("
- << "faceid: " << entry.faceId
- << ", origin: " << entry.origin
- << ", cost: " << entry.cost
- << ", flags: " << entry.flags;
- if (entry.expires != time::steady_clock::TimePoint::max()) {
- os << ", expires in: " << (entry.expires - time::steady_clock::now());
+ os << "Route("
+ << "faceid: " << route.faceId
+ << ", origin: " << route.origin
+ << ", cost: " << route.cost
+ << ", flags: " << route.flags;
+ if (route.expires != time::steady_clock::TimePoint::max()) {
+ os << ", expires in: " << (route.expires - time::steady_clock::now());
}
else {
os << ", never expires";
@@ -244,9 +244,9 @@
os << "RibEntry {\n";
os << "\tName: " << entry.getName() << "\n";
- for (RibEntry::FaceList::const_iterator faceIt = entry.cbegin(); faceIt != entry.cend(); ++faceIt)
+ for (const Route& route : entry)
{
- os << "\t" << (*faceIt) << "\n";
+ os << "\t" << route << "\n";
}
os << "}";
diff --git a/rib/rib-entry.hpp b/rib/rib-entry.hpp
index b17085a..4cfecc1 100644
--- a/rib/rib-entry.hpp
+++ b/rib/rib-entry.hpp
@@ -26,23 +26,22 @@
#ifndef NFD_RIB_RIB_ENTRY_HPP
#define NFD_RIB_RIB_ENTRY_HPP
-#include "face-entry.hpp"
+#include "route.hpp"
namespace nfd {
namespace rib {
-/** \class RibEntry
- * \brief represents a namespace
+/** \brief represents a RIB entry, which contains one or more Routes with the same prefix
*/
class RibEntry : public enable_shared_from_this<RibEntry>
{
public:
- typedef std::list<FaceEntry> FaceList;
- typedef FaceList::iterator iterator;
- typedef FaceList::const_iterator const_iterator;
+ typedef std::list<Route> RouteList;
+ typedef RouteList::iterator iterator;
+ typedef RouteList::const_iterator const_iterator;
RibEntry()
- : m_nFacesWithCaptureSet(0)
+ : m_nRoutesWithCaptureSet(0)
{
}
@@ -64,99 +63,99 @@
void
removeChild(shared_ptr<RibEntry> child);
- std::list<shared_ptr<RibEntry> >&
+ std::list<shared_ptr<RibEntry>>&
getChildren();
bool
hasChildren() const;
- /** \brief inserts a new face into the entry's face list
- * If another entry already exists with the same faceId and origin,
- * the new face is not inserted.
- * \return{ true if the face is inserted, false otherwise }
+ /** \brief inserts a new route into the entry's route list
+ * If another route already exists with the same faceId and origin,
+ * the new route is not inserted.
+ * \return{ true if the route is inserted, false otherwise }
*/
bool
- insertFace(const FaceEntry& face);
+ insertRoute(const Route& route);
- /** \brief erases a FaceEntry with the same faceId and origin
+ /** \brief erases a Route with the same faceId and origin
*/
void
- eraseFace(const FaceEntry& face);
+ eraseRoute(const Route& route);
- /** \brief erases a FaceEntry with the passed iterator
+ /** \brief erases a Route with the passed iterator
* \return{ an iterator to the element that followed the erased iterator }
*/
iterator
- eraseFace(FaceList::iterator face);
+ eraseRoute(RouteList::iterator route);
bool
hasFaceId(const uint64_t faceId) const;
- FaceList&
- getFaces();
+ RouteList&
+ getRoutes();
iterator
- findFace(const FaceEntry& face);
+ findRoute(const Route& route);
bool
- hasFace(const FaceEntry& face);
+ hasRoute(const Route& route);
void
- addInheritedFace(const FaceEntry& face);
+ addInheritedRoute(const Route& route);
void
- removeInheritedFace(const FaceEntry& face);
+ removeInheritedRoute(const Route& route);
- /** \brief Returns the faces this namespace has inherited.
- * The inherited faces returned represent inherited entries this namespace has in the FIB.
- * \return{ faces inherited by this namespace }
+ /** \brief Returns the routes this namespace has inherited.
+ * The inherited routes returned represent inherited routes this namespace has in the FIB.
+ * \return{ routes inherited by this namespace }
*/
- FaceList&
- getInheritedFaces();
+ RouteList&
+ getInheritedRoutes();
- /** \brief Finds an inherited face with a matching face ID.
- * \return{ An iterator to the matching face if one is found;
+ /** \brief Finds an inherited route with a matching face ID.
+ * \return{ An iterator to the matching route if one is found;
* otherwise, an iterator to the end of the entry's
- * inherited face list }
+ * inherited route list }
*/
- FaceList::iterator
- findInheritedFace(const FaceEntry& face);
+ RouteList::iterator
+ findInheritedRoute(const Route& route);
- /** \brief Determines if the entry has an inherited face with a matching face ID.
- * \return{ True, if a matching inherited face is found; otherwise, false. }
+ /** \brief Determines if the entry has an inherited route with a matching face ID.
+ * \return{ True, if a matching inherited route is found; otherwise, false. }
*/
bool
- hasInheritedFace(const FaceEntry& face);
+ hasInheritedRoute(const Route& route);
bool
hasCapture() const;
- /** \brief Determines if the entry has an inherited face with the passed
+ /** \brief Determines if the entry has an inherited route with the passed
* face ID and its child inherit flag set.
- * \return{ True, if a matching inherited face is found; otherwise, false. }
+ * \return{ True, if a matching inherited route is found; otherwise, false. }
*/
bool
hasChildInheritOnFaceId(uint64_t faceId) const;
- /** \brief Returns the face with the lowest cost that has the passed face ID.
- * \return{ The face with with the lowest cost that has the passed face ID}
+ /** \brief Returns the route with the lowest cost that has the passed face ID.
+ * \return{ The route with the lowest cost that has the passed face ID}
*/
- shared_ptr<FaceEntry>
- getFaceWithLowestCostByFaceId(uint64_t faceId);
+ shared_ptr<Route>
+ getRouteWithLowestCostByFaceId(uint64_t faceId);
- /** \brief Returns the face with the lowest cost that has the passed face ID
+ /** \brief Returns the route with the lowest cost that has the passed face ID
* and its child inherit flag set.
- * \return{ The face with with the lowest cost that has the passed face ID
+ * \return{ The route with the lowest cost that has the passed face ID
* and its child inherit flag set }
*/
- shared_ptr<FaceEntry>
- getFaceWithLowestCostAndChildInheritByFaceId(uint64_t faceId);
+ shared_ptr<Route>
+ getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId);
const_iterator
- cbegin() const;
+ begin() const;
const_iterator
- cend() const;
+ end() const;
iterator
begin();
@@ -170,18 +169,18 @@
private:
Name m_name;
- std::list<shared_ptr<RibEntry> > m_children;
+ std::list<shared_ptr<RibEntry>> m_children;
shared_ptr<RibEntry> m_parent;
- FaceList m_faces;
- FaceList m_inheritedFaces;
+ RouteList m_routes;
+ RouteList m_inheritedRoutes;
- /** \brief The number of faces on this namespace with the capture flag set.
+ /** \brief The number of routes on this namespace with the capture flag set.
*
- * This count is used to check if the namespace will block inherited faces.
+ * This count is used to check if the namespace will block inherited routes.
* If the number is greater than zero, a route on the namespace has it's capture
- * flag set which means the namespace should not inherit any faces.
+ * flag set which means the namespace should not inherit any routes.
*/
- uint64_t m_nFacesWithCaptureSet;
+ uint64_t m_nRoutesWithCaptureSet;
};
inline void
@@ -208,46 +207,46 @@
return m_parent;
}
-inline std::list<shared_ptr<RibEntry> >&
+inline std::list<shared_ptr<RibEntry>>&
RibEntry::getChildren()
{
return m_children;
}
-inline RibEntry::FaceList&
-RibEntry::getFaces()
+inline RibEntry::RouteList&
+RibEntry::getRoutes()
{
- return m_faces;
+ return m_routes;
}
-inline RibEntry::FaceList&
-RibEntry::getInheritedFaces()
+inline RibEntry::RouteList&
+RibEntry::getInheritedRoutes()
{
- return m_inheritedFaces;
+ return m_inheritedRoutes;
}
inline RibEntry::const_iterator
-RibEntry::cbegin() const
+RibEntry::begin() const
{
- return m_faces.begin();
+ return m_routes.begin();
}
inline RibEntry::const_iterator
-RibEntry::cend() const
+RibEntry::end() const
{
- return m_faces.end();
+ return m_routes.end();
}
inline RibEntry::iterator
RibEntry::begin()
{
- return m_faces.begin();
+ return m_routes.begin();
}
inline RibEntry::iterator
RibEntry::end()
{
- return m_faces.end();
+ return m_routes.end();
}
std::ostream&
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index 809b301..44214a3 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -286,35 +286,35 @@
parameters.setFaceId(request->getIncomingFaceId());
}
- FaceEntry faceEntry;
- faceEntry.faceId = parameters.getFaceId();
- faceEntry.origin = parameters.getOrigin();
- faceEntry.cost = parameters.getCost();
- faceEntry.flags = parameters.getFlags();
+ Route route;
+ route.faceId = parameters.getFaceId();
+ route.origin = parameters.getOrigin();
+ route.cost = parameters.getCost();
+ route.flags = parameters.getFlags();
if (parameters.hasExpirationPeriod() &&
parameters.getExpirationPeriod() != time::milliseconds::max())
{
- faceEntry.expires = time::steady_clock::now() + parameters.getExpirationPeriod();
+ route.expires = time::steady_clock::now() + parameters.getExpirationPeriod();
// Schedule a new event, the old one will be cancelled during rib insertion.
scheduler::EventId eventId = scheduler::schedule(parameters.getExpirationPeriod(),
bind(&RibManager::expireEntry, this, shared_ptr<Interest>(), parameters));
- NFD_LOG_TRACE("Scheduled unregistration at: " << faceEntry.expires <<
+ NFD_LOG_TRACE("Scheduled unregistration at: " << route.expires <<
" with EventId: " << eventId);
//set the NewEventId of this entry
- faceEntry.setExpirationEvent(eventId);
+ route.setExpirationEvent(eventId);
}
else
{
- faceEntry.expires = time::steady_clock::TimePoint::max();
+ route.expires = time::steady_clock::TimePoint::max();
}
- NFD_LOG_TRACE("register prefix: " << faceEntry);
+ NFD_LOG_TRACE("register prefix: " << route);
- m_managedRib.insert(parameters.getName(), faceEntry);
- m_registeredFaces.insert(faceEntry.faceId);
+ m_managedRib.insert(parameters.getName(), route);
+ m_registeredFaces.insert(route.faceId);
sendUpdatesToFib(request, parameters);
}
@@ -322,13 +322,13 @@
void
RibManager::expireEntry(const shared_ptr<const Interest>& request, ControlParameters& params)
{
- FaceEntry face;
- face.faceId = params.getFaceId();
- face.origin = params.getOrigin();
- face.cost = params.getCost();
- face.flags = params.getFlags();
+ Route route;
+ route.faceId = params.getFaceId();
+ route.origin = params.getOrigin();
+ route.cost = params.getCost();
+ route.flags = params.getFlags();
- NFD_LOG_DEBUG(face << " for " << params.getName() << " has expired");
+ NFD_LOG_DEBUG(route << " for " << params.getName() << " has expired");
unregisterEntry(request, params);
}
@@ -361,13 +361,13 @@
parameters.setFaceId(request->getIncomingFaceId());
}
- FaceEntry faceEntry;
- faceEntry.faceId = parameters.getFaceId();
- faceEntry.origin = parameters.getOrigin();
+ Route route;
+ route.faceId = parameters.getFaceId();
+ route.origin = parameters.getOrigin();
- NFD_LOG_TRACE("unregister prefix: " << faceEntry);
+ NFD_LOG_TRACE("unregister prefix: " << route);
- m_managedRib.erase(parameters.getName(), faceEntry);
+ m_managedRib.erase(parameters.getName(), route);
sendUpdatesToFib(request, parameters);
}
@@ -421,7 +421,7 @@
void
RibManager::onCommandError(uint32_t code, const std::string& error,
const shared_ptr<const Interest>& request,
- const FaceEntry& faceEntry)
+ const Route& route)
{
NFD_LOG_ERROR("NFD returned an error: " << error << " (code: " << code << ")");
@@ -447,7 +447,7 @@
void
RibManager::onRegSuccess(const shared_ptr<const Interest>& request,
const ControlParameters& parameters,
- const FaceEntry& faceEntry)
+ const Route& route)
{
ControlResponse response;
@@ -455,7 +455,7 @@
response.setText("Success");
response.setBody(parameters.wireEncode());
- NFD_LOG_TRACE("onRegSuccess: registered " << faceEntry);
+ NFD_LOG_TRACE("onRegSuccess: registered " << route);
if (static_cast<bool>(request))
sendResponse(request->getName(), response);
@@ -465,7 +465,7 @@
void
RibManager::onUnRegSuccess(const shared_ptr<const Interest>& request,
const ControlParameters& parameters,
- const FaceEntry& faceEntry)
+ const Route& route)
{
ControlResponse response;
@@ -473,7 +473,7 @@
response.setText("Success");
response.setBody(parameters.wireEncode());
- NFD_LOG_TRACE("onUnRegSuccess: unregistered " << faceEntry);
+ NFD_LOG_TRACE("onUnRegSuccess: unregistered " << route);
if (static_cast<bool>(request))
sendResponse(request->getName(), response);
@@ -717,15 +717,15 @@
if (update->action == FibUpdate::ADD_NEXTHOP)
{
- FaceEntry faceEntry;
- faceEntry.faceId = update->faceId;
- faceEntry.cost = update->cost;
+ Route route;
+ route.faceId = update->faceId;
+ route.cost = update->cost;
m_nfdController.start<ndn::nfd::FibAddNextHopCommand>(
ControlParameters()
.setName(update->name)
- .setFaceId(faceEntry.faceId)
- .setCost(faceEntry.cost),
+ .setFaceId(route.faceId)
+ .setCost(route.cost),
bind(&RibManager::onAddNextHopSuccess, this, request,
parameters,
currentTransactionId,
@@ -735,13 +735,13 @@
}
else if (update->action == FibUpdate::REMOVE_NEXTHOP)
{
- FaceEntry faceEntry;
- faceEntry.faceId = update->faceId;
+ Route route;
+ route.faceId = update->faceId;
m_nfdController.start<ndn::nfd::FibRemoveNextHopCommand>(
ControlParameters()
.setName(update->name)
- .setFaceId(faceEntry.faceId),
+ .setFaceId(route.faceId),
bind(&RibManager::onRemoveNextHopSuccess, this, request,
parameters,
currentTransactionId,
diff --git a/rib/rib-manager.hpp b/rib/rib-manager.hpp
index e3750b1..efaf760 100644
--- a/rib/rib-manager.hpp
+++ b/rib/rib-manager.hpp
@@ -130,17 +130,17 @@
void
onCommandError(uint32_t code, const std::string& error,
const shared_ptr<const Interest>& request,
- const FaceEntry& faceEntry);
+ const Route& route);
void
onRegSuccess(const shared_ptr<const Interest>& request,
const ControlParameters& parameters,
- const FaceEntry& faceEntry);
+ const Route& route);
void
onUnRegSuccess(const shared_ptr<const Interest>& request,
const ControlParameters& parameters,
- const FaceEntry& faceEntry);
+ const Route& route);
void
onNrdCommandPrefixAddNextHopSuccess(const Name& prefix);
diff --git a/rib/rib-status-publisher.cpp b/rib/rib-status-publisher.cpp
index 76a164c..0b8ede4 100644
--- a/rib/rib-status-publisher.cpp
+++ b/rib/rib-status-publisher.cpp
@@ -61,24 +61,21 @@
size_t ribEntryLength = 0;
ndn::nfd::RibEntry tlvEntry;
- const RibEntry::FaceList& faces = entry.getFaces();
- for (RibEntry::FaceList::const_iterator faceIt = faces.begin();
- faceIt != faces.end(); ++faceIt)
+ for (const Route& route : entry)
{
- const FaceEntry& face = *faceIt;
+ ndn::nfd::Route routeEle;
+ routeEle.setFaceId(route.faceId)
+ .setOrigin(route.origin)
+ .setCost(route.cost)
+ .setFlags(route.flags);
- ndn::nfd::Route route;
- route
- .setFaceId(face.faceId)
- .setOrigin(face.origin)
- .setCost(face.cost)
- .setFlags(face.flags);
- if (face.expires < time::steady_clock::TimePoint::max()) {
- route.setExpirationPeriod(time::duration_cast<time::milliseconds>
- (face.expires - time::steady_clock::now()));
+ if (route.expires < time::steady_clock::TimePoint::max()) {
+ routeEle.setExpirationPeriod(time::duration_cast<time::milliseconds>(
+ route.expires - time::steady_clock::now()));
}
- tlvEntry.addRoute(route);
+
+ tlvEntry.addRoute(routeEle);
}
tlvEntry.setName(prefix);
diff --git a/rib/rib.cpp b/rib/rib.cpp
index 02df45e..0110b19 100644
--- a/rib/rib.cpp
+++ b/rib/rib.cpp
@@ -33,9 +33,9 @@
namespace rib {
static inline bool
-sortFace(const FaceEntry& entry1, const FaceEntry& entry2)
+sortRoutes(const Route& lhs, const Route& rhs)
{
- return entry1.faceId < entry2.faceId;
+ return lhs.faceId < rhs.faceId;
}
static inline bool
@@ -73,29 +73,29 @@
return m_rib.find(prefix);
}
-FaceEntry*
-Rib::find(const Name& prefix, const FaceEntry& face) const
+Route*
+Rib::find(const Name& prefix, const Route& route) const
{
RibTable::const_iterator ribIt = m_rib.find(prefix);
// Name prefix exists
if (ribIt != m_rib.end())
{
- shared_ptr<RibEntry> entry(ribIt->second);
+ shared_ptr<RibEntry> entry = ribIt->second;
- RibEntry::iterator faceIt = std::find_if(entry->begin(), entry->end(),
- bind(&compareFaceIdAndOrigin, _1, face));
+ RibEntry::iterator routeIt = entry->findRoute(route);
- if (faceIt != entry->end())
+ if (routeIt != entry->end())
{
- return &((*faceIt));
+ return &((*routeIt));
}
}
- return 0;
+
+ return nullptr;
}
void
-Rib::insert(const Name& prefix, const FaceEntry& face)
+Rib::insert(const Name& prefix, const Route& route)
{
RibTable::iterator ribIt = m_rib.find(prefix);
@@ -104,49 +104,47 @@
{
shared_ptr<RibEntry> entry(ribIt->second);
- RibEntry::iterator faceIt = std::find_if(entry->getFaces().begin(),
- entry->getFaces().end(),
- bind(&compareFaceIdAndOrigin, _1, face));
+ RibEntry::iterator routeIt = entry->findRoute(route);
- if (faceIt == entry->end())
+ if (routeIt == entry->end())
{
- // Will the new face change the namespace's capture flag?
- bool captureWasTurnedOn = (entry->hasCapture() == false && isCaptureFlagSet(face.flags));
+ // Will the new route change the namespace's capture flag?
+ bool captureWasTurnedOn = (entry->hasCapture() == false && isCaptureFlagSet(route.flags));
- // New face
- entry->insertFace(face);
+ // New route
+ entry->insertRoute(route);
m_nItems++;
// Register with face lookup table
- m_faceMap[face.faceId].push_back(entry);
+ m_faceMap[route.faceId].push_back(entry);
- createFibUpdatesForNewFaceEntry(*entry, face, captureWasTurnedOn);
+ createFibUpdatesForNewRoute(*entry, route, captureWasTurnedOn);
}
- else // Entry exists, update fields
+ else // Route exists, update fields
{
// First cancel old scheduled event, if any, then set the EventId to new one
- if (static_cast<bool>(faceIt->getExpirationEvent()))
+ if (static_cast<bool>(routeIt->getExpirationEvent()))
{
NFD_LOG_TRACE("Cancelling expiration event for " << entry->getName() << " "
- << *faceIt);
- scheduler::cancel(faceIt->getExpirationEvent());
+ << *routeIt);
+ scheduler::cancel(routeIt->getExpirationEvent());
}
// No checks are required here as the iterator needs to be updated in all cases.
- faceIt->setExpirationEvent(face.getExpirationEvent());
+ routeIt->setExpirationEvent(route.getExpirationEvent());
// Save flags for update processing
- uint64_t previousFlags = faceIt->flags;
+ uint64_t previousFlags = routeIt->flags;
- // If the entry's cost didn't change and child inherit is not set,
+ // If the route's cost didn't change and child inherit is not set,
// no need to traverse subtree.
- uint64_t previousCost = faceIt->cost;
+ uint64_t previousCost = routeIt->cost;
- faceIt->flags = face.flags;
- faceIt->cost = face.cost;
- faceIt->expires = face.expires;
+ routeIt->flags = route.flags;
+ routeIt->cost = route.cost;
+ routeIt->expires = route.expires;
- createFibUpdatesForUpdatedEntry(*entry, face, previousFlags, previousCost);
+ createFibUpdatesForUpdatedRoute(*entry, route, previousFlags, previousCost);
}
}
else // New name prefix
@@ -157,7 +155,7 @@
m_nItems++;
entry->setName(prefix);
- entry->insertFace(face);
+ entry->insertRoute(route);
// Find prefix's parent
shared_ptr<RibEntry> parent = findParent(prefix);
@@ -185,9 +183,9 @@
}
// Register with face lookup table
- m_faceMap[face.faceId].push_back(entry);
+ m_faceMap[route.faceId].push_back(entry);
- createFibUpdatesForNewRibEntry(*entry, face);
+ createFibUpdatesForNewRibEntry(*entry, route);
// do something after inserting an entry
afterInsertEntry(prefix);
@@ -195,7 +193,7 @@
}
void
-Rib::erase(const Name& prefix, const FaceEntry& face)
+Rib::erase(const Name& prefix, const Route& route)
{
RibTable::iterator ribIt = m_rib.find(prefix);
@@ -206,42 +204,42 @@
const bool hadCapture = entry->hasCapture();
- // Need to copy face to do FIB updates with correct cost and flags since nfdc does not
+ // Need to copy route to do FIB updates with correct cost and flags since nfdc does not
// pass flags or cost
- RibEntry::iterator faceIt = entry->findFace(face);
+ RibEntry::iterator routeIt = entry->findRoute(route);
- if (faceIt != entry->end())
+ if (routeIt != entry->end())
{
- FaceEntry faceToErase = *faceIt;
- faceToErase.flags = faceIt->flags;
- faceToErase.cost = faceIt->cost;
+ Route routeToErase = *routeIt;
+ routeToErase.flags = routeIt->flags;
+ routeToErase.cost = routeIt->cost;
- entry->eraseFace(faceIt);
+ entry->eraseRoute(routeIt);
m_nItems--;
const bool captureWasTurnedOff = (hadCapture && !entry->hasCapture());
- createFibUpdatesForErasedFaceEntry(*entry, faceToErase, captureWasTurnedOff);
+ createFibUpdatesForErasedRoute(*entry, routeToErase, captureWasTurnedOff);
// If this RibEntry no longer has this faceId, unregister from face lookup table
- if (!entry->hasFaceId(face.faceId))
+ if (!entry->hasFaceId(route.faceId))
{
- m_faceMap[face.faceId].remove(entry);
+ m_faceMap[route.faceId].remove(entry);
}
else
{
// The RibEntry still has the face ID; need to update FIB
- // with lowest cost for the same face instead of removing the face from the FIB
- shared_ptr<FaceEntry> lowCostFace = entry->getFaceWithLowestCostByFaceId(face.faceId);
+ // with lowest cost for the same route instead of removing the route from the FIB
+ shared_ptr<Route> lowCostRoute = entry->getRouteWithLowestCostByFaceId(route.faceId);
- BOOST_ASSERT(static_cast<bool>(lowCostFace));
+ BOOST_ASSERT(static_cast<bool>(lowCostRoute));
- createFibUpdatesForNewFaceEntry(*entry, *lowCostFace, false);
+ createFibUpdatesForNewRoute(*entry, *lowCostRoute, false);
}
- // If a RibEntry's facelist is empty, remove it from the tree
- if (entry->getFaces().size() == 0)
+ // If a RibEntry's route list is empty, remove it from the tree
+ if (entry->getRoutes().size() == 0)
{
eraseEntry(ribIt);
}
@@ -263,41 +261,34 @@
RibEntryList& ribEntries = lookupIt->second;
// For each RIB entry that has faceId, remove the face from the entry
- for (RibEntryList::iterator entryIt = ribEntries.begin(); entryIt != ribEntries.end(); ++entryIt)
+ for (shared_ptr<RibEntry>& entry : ribEntries)
{
- shared_ptr<RibEntry> entry = *entryIt;
-
const bool hadCapture = entry->hasCapture();
- // Find the faces in the entry
- for (RibEntry::iterator faceIt = entry->begin(); faceIt != entry->end(); ++faceIt)
+ // Find the routes in the entry
+ for (RibEntry::iterator routeIt = entry->begin(); routeIt != entry->end(); ++routeIt)
{
- if (faceIt->faceId == faceId)
+ if (routeIt->faceId == faceId)
{
- FaceEntry copy = *faceIt;
+ Route copy = *routeIt;
- faceIt = entry->eraseFace(faceIt);
+ routeIt = entry->eraseRoute(routeIt);
m_nItems--;
const bool captureWasTurnedOff = (hadCapture && !entry->hasCapture());
- createFibUpdatesForErasedFaceEntry(*entry, copy, captureWasTurnedOff);
+ createFibUpdatesForErasedRoute(*entry, copy, captureWasTurnedOff);
}
}
- // If a RibEntry's facelist is empty, remove it from the tree
- if (entry->getFaces().size() == 0)
+ // If a RibEntry's route list is empty, remove it from the tree
+ if (entry->getRoutes().size() == 0)
{
eraseEntry(m_rib.find(entry->getName()));
}
}
// Face no longer exists, remove from face lookup table
- FaceLookupTable::iterator entryToDelete = m_faceMap.find(faceId);
-
- if (entryToDelete != m_faceMap.end())
- {
- m_faceMap.erase(entryToDelete);
- }
+ m_faceMap.erase(lookupIt);
}
shared_ptr<RibEntry>
@@ -399,8 +390,7 @@
void
Rib::insertFibUpdate(shared_ptr<FibUpdate> update)
{
- // If an update with the same name and face already exists,
- // replace it
+ // If an update with the same name and Face ID already exists, replace it
FibUpdateList::iterator it = std::find_if(m_fibUpdateList.begin(), m_fibUpdateList.end(),
bind(&compareFibUpdates, _1, update));
@@ -419,108 +409,107 @@
}
void
-Rib::createFibUpdatesForNewRibEntry(RibEntry& entry, const FaceEntry& face)
+Rib::createFibUpdatesForNewRibEntry(RibEntry& entry, const Route& route)
{
// Create FIB update for new entry
- insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), face.faceId, face.cost));
+ insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), route.faceId, route.cost));
// No flags are set
- if (!isAnyFlagSet(face.flags))
+ if (!isAnyFlagSet(route.flags))
{
- // Add ancestor faces to self
- addInheritedFacesToEntry(entry, getAncestorFaces(entry));
+ // Add ancestor routes to self
+ addInheritedRoutesToEntry(entry, getAncestorRoutes(entry));
}
- else if (areBothFlagsSet(face.flags))
+ else if (areBothFlagsSet(route.flags))
{
- // Add face to children
- FaceSet facesToAdd;
- facesToAdd.insert(face);
+ // Add route to children
+ RouteSet routesToAdd;
+ routesToAdd.insert(route);
- // Remove faces blocked by capture and add self to children
- modifyChildrensInheritedFaces(entry, facesToAdd, getAncestorFaces(entry));
+ // Remove routes blocked by capture and add self to children
+ modifyChildrensInheritedRoutes(entry, routesToAdd, getAncestorRoutes(entry));
}
- else if (isChildInheritFlagSet(face.flags))
+ else if (isChildInheritFlagSet(route.flags))
{
- FaceSet ancestorFaces = getAncestorFaces(entry);
+ RouteSet ancestorRoutes = getAncestorRoutes(entry);
- // Add ancestor faces to self
- addInheritedFacesToEntry(entry, ancestorFaces);
+ // Add ancestor routes to self
+ addInheritedRoutesToEntry(entry, ancestorRoutes);
- // If there is an ancestor face which is the same as the new face, replace it
- // with the new face
- FaceSet::iterator it = ancestorFaces.find(face);
+ // If there is an ancestor route with the same Face ID as the new route, replace it
+ // with the new route
+ RouteSet::iterator it = ancestorRoutes.find(route);
- // There is a face that needs to be overwritten, erase and then replace
- if (it != ancestorFaces.end())
+ // There is a route that needs to be overwritten, erase and then replace
+ if (it != ancestorRoutes.end())
{
- ancestorFaces.erase(it);
+ ancestorRoutes.erase(it);
}
- // Add new face to ancestor list so it can be added to children
- ancestorFaces.insert(face);
+ // Add new route to ancestor list so it can be added to children
+ ancestorRoutes.insert(route);
- // Add ancestor faces to children
- modifyChildrensInheritedFaces(entry, ancestorFaces, FaceSet());
+ // Add ancestor routes to children
+ modifyChildrensInheritedRoutes(entry, ancestorRoutes, RouteSet());
}
- else if (isCaptureFlagSet(face.flags))
+ else if (isCaptureFlagSet(route.flags))
{
- // Remove faces blocked by capture
- modifyChildrensInheritedFaces(entry, FaceSet(), getAncestorFaces(entry));
+ // Remove routes blocked by capture
+ modifyChildrensInheritedRoutes(entry, RouteSet(), getAncestorRoutes(entry));
}
}
void
-Rib::createFibUpdatesForNewFaceEntry(RibEntry& entry, const FaceEntry& face,
- bool captureWasTurnedOn)
+Rib::createFibUpdatesForNewRoute(RibEntry& entry, const Route& route, bool captureWasTurnedOn)
{
- // Only update if the new face has a lower cost than a previously installed face
- shared_ptr<FaceEntry> prevFace = entry.getFaceWithLowestCostAndChildInheritByFaceId(face.faceId);
+ // Only update if the new route has a lower cost than a previously installed route
+ shared_ptr<Route> prevRoute = entry.getRouteWithLowestCostAndChildInheritByFaceId(route.faceId);
- FaceSet facesToAdd;
- if (isChildInheritFlagSet(face.flags))
+ RouteSet routesToAdd;
+ if (isChildInheritFlagSet(route.flags))
{
- // Add to children if this new face doesn't override a previous lower cost, or
- // add to children if this new is lower cost than a previous face.
- // Less than equal, since entry may find this face
- if (!static_cast<bool>(prevFace) || face.cost <= prevFace->cost)
+ // Add to children if this new route doesn't override a previous lower cost, or
+ // add to children if this new route is lower cost than a previous route.
+ // Less than equal, since entry may find this route
+ if (prevRoute == nullptr || route.cost <= prevRoute->cost)
{
// Add self to children
- facesToAdd.insert(face);
+ routesToAdd.insert(route);
}
}
- FaceSet facesToRemove;
+ RouteSet routesToRemove;
if (captureWasTurnedOn)
{
// Capture flag on
- facesToRemove = getAncestorFaces(entry);
+ routesToRemove = getAncestorRoutes(entry);
- // Remove ancestor faces from self
- removeInheritedFacesFromEntry(entry, facesToRemove);
+ // Remove ancestor routes from self
+ removeInheritedRoutesFromEntry(entry, routesToRemove);
}
- modifyChildrensInheritedFaces(entry, facesToAdd, facesToRemove);
+ modifyChildrensInheritedRoutes(entry, routesToAdd, routesToRemove);
- // If another face with same faceId and lower cost, don't update.
+ // If another route with same faceId and lower cost, don't update.
// Must be done last so that add updates replace removal updates
// Create FIB update for new entry
- if (face.cost <= entry.getFaceWithLowestCostByFaceId(face.faceId)->cost)
+ if (route.cost <= entry.getRouteWithLowestCostByFaceId(route.faceId)->cost)
{
- insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), face.faceId, face.cost));
+ insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), route.faceId, route.cost));
}
}
void
-Rib::createFibUpdatesForUpdatedEntry(RibEntry& entry, const FaceEntry& face,
+Rib::createFibUpdatesForUpdatedRoute(RibEntry& entry, const Route& route,
const uint64_t previousFlags, const uint64_t previousCost)
{
- const bool costDidChange = (face.cost != previousCost);
+ const bool costDidChange = (route.cost != previousCost);
- // Look for an installed face with the lowest cost and child inherit set
- shared_ptr<FaceEntry> prevFace = entry.getFaceWithLowestCostAndChildInheritByFaceId(face.faceId);
+ // Look for the installed route with the lowest cost and child inherit set
+ shared_ptr<Route> prevRoute = entry.getRouteWithLowestCostAndChildInheritByFaceId(route.faceId);
// No flags changed and cost didn't change, no change in FIB
- if (face.flags == previousFlags && !costDidChange)
+ if (route.flags == previousFlags && !costDidChange)
{
return;
}
@@ -528,32 +517,32 @@
// Cost changed so create update for the entry itself
if (costDidChange)
{
- // Create update if this face's cost is lower than other faces
- if (face.cost <= entry.getFaceWithLowestCostByFaceId(face.faceId)->cost)
+ // Create update if this route's cost is lower than other routes
+ if (route.cost <= entry.getRouteWithLowestCostByFaceId(route.faceId)->cost)
{
// Create FIB update for the updated entry
- insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), face.faceId, face.cost));
+ insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), route.faceId, route.cost));
}
- else if (previousCost < entry.getFaceWithLowestCostByFaceId(face.faceId)->cost)
+ else if (previousCost < entry.getRouteWithLowestCostByFaceId(route.faceId)->cost)
{
- // Create update if this face used to be the lowest face but is no longer
- // the lowest cost face.
- insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), prevFace->faceId,
- prevFace->cost));
+ // Create update if this route used to be the lowest cost route but is no longer
+ // the lowest cost route.
+ insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), prevRoute->faceId,
+ prevRoute->cost));
}
- // If another face with same faceId and lower cost and ChildInherit exists,
+ // If another route with same faceId and lower cost and ChildInherit exists,
// don't update children.
- if (!static_cast<bool>(prevFace) || face.cost <= prevFace->cost)
+ if (prevRoute == nullptr || route.cost <= prevRoute->cost)
{
// If no flags changed but child inheritance is set, need to update children
// with new cost
- if ((face.flags == previousFlags) && isChildInheritFlagSet(face.flags))
+ if ((route.flags == previousFlags) && isChildInheritFlagSet(route.flags))
{
// Add self to children
- FaceSet facesToAdd;
- facesToAdd.insert(face);
- modifyChildrensInheritedFaces(entry, facesToAdd, FaceSet());
+ RouteSet routesToAdd;
+ routesToAdd.insert(route);
+ modifyChildrensInheritedRoutes(entry, routesToAdd, RouteSet());
return;
}
@@ -561,140 +550,140 @@
}
// Child inherit was turned on
- if (!isChildInheritFlagSet(previousFlags) && isChildInheritFlagSet(face.flags))
+ if (!isChildInheritFlagSet(previousFlags) && isChildInheritFlagSet(route.flags))
{
- // If another face with same faceId and lower cost and ChildInherit exists,
+ // If another route with same faceId and lower cost and ChildInherit exists,
// don't update children.
- if (!static_cast<bool>(prevFace) || face.cost <= prevFace->cost)
+ if (prevRoute == nullptr || route.cost <= prevRoute->cost)
{
// Add self to children
- FaceSet facesToAdd;
- facesToAdd.insert(face);
- modifyChildrensInheritedFaces(entry, facesToAdd, FaceSet());
+ RouteSet routesToAdd;
+ routesToAdd.insert(route);
+ modifyChildrensInheritedRoutes(entry, routesToAdd, RouteSet());
}
} // Child inherit was turned off
- else if (isChildInheritFlagSet(previousFlags) && !isChildInheritFlagSet(face.flags))
+ else if (isChildInheritFlagSet(previousFlags) && !isChildInheritFlagSet(route.flags))
{
// Remove self from children
- FaceSet facesToRemove;
- facesToRemove.insert(face);
+ RouteSet routesToRemove;
+ routesToRemove.insert(route);
- FaceSet facesToAdd;
- // If another face with same faceId and ChildInherit exists, update children with this face.
- if (static_cast<bool>(prevFace))
+ RouteSet routesToAdd;
+ // If another route with same faceId and ChildInherit exists, update children with this route.
+ if (prevRoute != nullptr)
{
- facesToAdd.insert(*prevFace);
+ routesToAdd.insert(*prevRoute);
}
else
{
// Look for an ancestor that was blocked previously
- const FaceSet ancestorFaces = getAncestorFaces(entry);
- FaceSet::iterator it = ancestorFaces.find(face);
+ const RouteSet ancestorRoutes = getAncestorRoutes(entry);
+ RouteSet::iterator it = ancestorRoutes.find(route);
// If an ancestor is found, add it to children
- if (it != ancestorFaces.end())
+ if (it != ancestorRoutes.end())
{
- facesToAdd.insert(*it);
+ routesToAdd.insert(*it);
}
}
- modifyChildrensInheritedFaces(entry, facesToAdd, facesToRemove);
+ modifyChildrensInheritedRoutes(entry, routesToAdd, routesToRemove);
}
// Capture was turned on
- if (!isCaptureFlagSet(previousFlags) && isCaptureFlagSet(face.flags))
+ if (!isCaptureFlagSet(previousFlags) && isCaptureFlagSet(route.flags))
{
- FaceSet ancestorFaces = getAncestorFaces(entry);
+ RouteSet ancestorRoutes = getAncestorRoutes(entry);
- // Remove ancestor faces from self
- removeInheritedFacesFromEntry(entry, ancestorFaces);
+ // Remove ancestor routes from self
+ removeInheritedRoutesFromEntry(entry, ancestorRoutes);
- // Remove ancestor faces from children
- modifyChildrensInheritedFaces(entry, FaceSet(), ancestorFaces);
+ // Remove ancestor routes from children
+ modifyChildrensInheritedRoutes(entry, RouteSet(), ancestorRoutes);
} // Capture was turned off
- else if (isCaptureFlagSet(previousFlags) && !isCaptureFlagSet(face.flags))
+ else if (isCaptureFlagSet(previousFlags) && !isCaptureFlagSet(route.flags))
{
- FaceSet ancestorFaces = getAncestorFaces(entry);
+ RouteSet ancestorRoutes = getAncestorRoutes(entry);
- // Add ancestor faces to self
- addInheritedFacesToEntry(entry, ancestorFaces);
+ // Add ancestor routes to self
+ addInheritedRoutesToEntry(entry, ancestorRoutes);
- // Add ancestor faces to children
- modifyChildrensInheritedFaces(entry, ancestorFaces, FaceSet());
+ // Add ancestor routes to children
+ modifyChildrensInheritedRoutes(entry, ancestorRoutes, RouteSet());
}
}
void
-Rib::createFibUpdatesForErasedFaceEntry(RibEntry& entry, const FaceEntry& face,
- const bool captureWasTurnedOff)
+Rib::createFibUpdatesForErasedRoute(RibEntry& entry, const Route& route,
+ const bool captureWasTurnedOff)
{
- insertFibUpdate(FibUpdate::createRemoveUpdate(entry.getName(), face.faceId));
+ insertFibUpdate(FibUpdate::createRemoveUpdate(entry.getName(), route.faceId));
- if (areBothFlagsSet(face.flags))
+ if (areBothFlagsSet(route.flags))
{
// Remove self from children
- FaceSet facesToRemove;
- facesToRemove.insert(face);
+ RouteSet routesToRemove;
+ routesToRemove.insert(route);
// If capture is turned off for the route, need to add ancestors
// to self and children
- FaceSet facesToAdd;
+ RouteSet routesToAdd;
if (captureWasTurnedOff)
{
- // Look for an ancestors that were blocked previously
- facesToAdd = getAncestorFaces(entry);
+ // Look for ancestors that were blocked previously
+ routesToAdd = getAncestorRoutes(entry);
- // Add ancestor faces to self
- addInheritedFacesToEntry(entry, facesToAdd);
+ // Add ancestor routes to self
+ addInheritedRoutesToEntry(entry, routesToAdd);
}
- modifyChildrensInheritedFaces(entry, facesToAdd, facesToRemove);
+ modifyChildrensInheritedRoutes(entry, routesToAdd, routesToRemove);
}
- else if (isChildInheritFlagSet(face.flags))
+ else if (isChildInheritFlagSet(route.flags))
{
// If not blocked by capture, add inherited routes to children
- FaceSet facesToAdd;
+ RouteSet routesToAdd;
if (!entry.hasCapture())
{
- facesToAdd = getAncestorFaces(entry);
+ routesToAdd = getAncestorRoutes(entry);
}
- FaceSet facesToRemove;
- facesToRemove.insert(face);
+ RouteSet routesToRemove;
+ routesToRemove.insert(route);
- // Add ancestor faces to children
- modifyChildrensInheritedFaces(entry, facesToAdd, facesToRemove);
+ // Add ancestor routes to children
+ modifyChildrensInheritedRoutes(entry, routesToAdd, routesToRemove);
}
- else if (isCaptureFlagSet(face.flags))
+ else if (isCaptureFlagSet(route.flags))
{
// If capture is turned off for the route, need to add ancestors
// to self and children
- FaceSet facesToAdd;
+ RouteSet routesToAdd;
if (captureWasTurnedOff)
{
// Look for an ancestors that were blocked previously
- facesToAdd = getAncestorFaces(entry);
+ routesToAdd = getAncestorRoutes(entry);
- // Add ancestor faces to self
- addInheritedFacesToEntry(entry, facesToAdd);
+ // Add ancestor routes to self
+ addInheritedRoutesToEntry(entry, routesToAdd);
}
- modifyChildrensInheritedFaces(entry, facesToAdd, FaceSet());
+ modifyChildrensInheritedRoutes(entry, routesToAdd, RouteSet());
}
- // Need to check if the removed face was blocking an inherited route
- FaceSet ancestorFaces = getAncestorFaces(entry);
+ // Need to check if the removed route was blocking an inherited route
+ RouteSet ancestorRoutes = getAncestorRoutes(entry);
if (!entry.hasCapture())
{
- // If there is an ancestor face which is the same as the erased face, add that face
+ // If there is an ancestor route with the same Face ID as the erased route, add that route
// to the current entry
- FaceSet::iterator it = ancestorFaces.find(face);
+ RouteSet::iterator it = ancestorRoutes.find(route);
- if (it != ancestorFaces.end())
+ if (it != ancestorRoutes.end())
{
- entry.addInheritedFace(*it);
+ entry.addInheritedRoute(*it);
insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), it->faceId, it->cost));
}
}
@@ -703,28 +692,28 @@
void
Rib::createFibUpdatesForErasedRibEntry(RibEntry& entry)
{
- for (RibEntry::FaceList::iterator it = entry.getInheritedFaces().begin();
- it != entry.getInheritedFaces().end(); ++it)
+ for (RibEntry::RouteList::iterator it = entry.getInheritedRoutes().begin();
+ it != entry.getInheritedRoutes().end(); ++it)
{
insertFibUpdate(FibUpdate::createRemoveUpdate(entry.getName(), it->faceId));
}
}
-Rib::FaceSet
-Rib::getAncestorFaces(const RibEntry& entry) const
+Rib::RouteSet
+Rib::getAncestorRoutes(const RibEntry& entry) const
{
- FaceSet ancestorFaces(&sortFace);
+ RouteSet ancestorRoutes(&sortRoutes);
shared_ptr<RibEntry> parent = entry.getParent();
while (static_cast<bool>(parent))
{
- for (RibEntry::iterator it = parent->getFaces().begin();
- it != parent->getFaces().end(); ++it)
+ for (RibEntry::iterator it = parent->getRoutes().begin();
+ it != parent->getRoutes().end(); ++it)
{
if (isChildInheritFlagSet(it->flags))
{
- ancestorFaces.insert(*it);
+ ancestorRoutes.insert(*it);
}
}
@@ -736,52 +725,51 @@
parent = parent->getParent();
}
- return ancestorFaces;
+ return ancestorRoutes;
}
void
-Rib::addInheritedFacesToEntry(RibEntry& entry, const Rib::FaceSet& facesToAdd)
+Rib::addInheritedRoutesToEntry(RibEntry& entry, const Rib::RouteSet& routesToAdd)
{
- for (FaceSet::const_iterator it = facesToAdd.begin(); it != facesToAdd.end(); ++it)
+ for (RouteSet::const_iterator it = routesToAdd.begin(); it != routesToAdd.end(); ++it)
{
- // Don't add an ancestor faceId if the namespace has an entry for that faceId
+ // Don't add an ancestor route if the namespace has a route with that Face ID
if (!entry.hasFaceId(it->faceId))
{
- entry.addInheritedFace(*it);
+ entry.addInheritedRoute(*it);
insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), it->faceId, it->cost));
}
}
}
void
-Rib::removeInheritedFacesFromEntry(RibEntry& entry, const Rib::FaceSet& facesToRemove)
+Rib::removeInheritedRoutesFromEntry(RibEntry& entry, const Rib::RouteSet& routesToRemove)
{
- for (FaceSet::const_iterator it = facesToRemove.begin(); it != facesToRemove.end(); ++it)
+ for (RouteSet::const_iterator it = routesToRemove.begin(); it != routesToRemove.end(); ++it)
{
- // Only remove if the face has been inherited
- if (entry.hasInheritedFace(*it))
+ // Only remove if the route has been inherited
+ if (entry.hasInheritedRoute(*it))
{
- entry.removeInheritedFace(*it);
+ entry.removeInheritedRoute(*it);
insertFibUpdate(FibUpdate::createRemoveUpdate(entry.getName(), it->faceId));
}
}
}
void
-Rib::modifyChildrensInheritedFaces(RibEntry& entry, const Rib::FaceSet& facesToAdd,
- const Rib::FaceSet& facesToRemove)
+Rib::modifyChildrensInheritedRoutes(RibEntry& entry, const Rib::RouteSet& routesToAdd,
+ const Rib::RouteSet& routesToRemove)
{
RibEntryList children = entry.getChildren();
for (RibEntryList::iterator child = children.begin(); child != children.end(); ++child)
{
- traverseSubTree(*(*child), facesToAdd, facesToRemove);
+ traverseSubTree(*(*child), routesToAdd, routesToRemove);
}
}
void
-Rib::traverseSubTree(RibEntry& entry, Rib::FaceSet facesToAdd,
- Rib::FaceSet facesToRemove)
+Rib::traverseSubTree(RibEntry& entry, Rib::RouteSet routesToAdd, Rib::RouteSet routesToRemove)
{
// If a route on the namespace has the capture flag set, ignore self and children
if (entry.hasCapture())
@@ -789,51 +777,50 @@
return;
}
- // Remove inherited faces from current namespace
- for (Rib::FaceSet::const_iterator removeIt = facesToRemove.begin();
- removeIt != facesToRemove.end(); )
+ // Remove inherited routes from current namespace
+ for (Rib::RouteSet::const_iterator removeIt = routesToRemove.begin();
+ removeIt != routesToRemove.end(); )
{
- // If a route on the namespace has the same face and child inheritance set, ignore this face
+ // If a route on the namespace has the same face and child inheritance set, ignore this route
if (entry.hasChildInheritOnFaceId(removeIt->faceId))
{
- facesToRemove.erase(removeIt++);
+ routesToRemove.erase(removeIt++);
continue;
}
- // Only remove face if it removes an existing inherited route
- if (entry.hasInheritedFace(*removeIt))
+ // Only remove route if it removes an existing inherited route
+ if (entry.hasInheritedRoute(*removeIt))
{
- entry.removeInheritedFace(*removeIt);
+ entry.removeInheritedRoute(*removeIt);
insertFibUpdate(FibUpdate::createRemoveUpdate(entry.getName(), removeIt->faceId));
}
++removeIt;
}
- // Add inherited faces to current namespace
- for (Rib::FaceSet::const_iterator addIt = facesToAdd.begin();
- addIt != facesToAdd.end(); )
+ // Add inherited routes to current namespace
+ for (Rib::RouteSet::const_iterator addIt = routesToAdd.begin(); addIt != routesToAdd.end(); )
{
- // If a route on the namespace has the same face and child inherit set, ignore this face
+ // If a route on the namespace has the same face and child inherit set, ignore this route
if (entry.hasChildInheritOnFaceId(addIt->faceId))
{
- facesToAdd.erase(addIt++);
+ routesToAdd.erase(addIt++);
continue;
}
- // Only add face if it does not override an existing route
+ // Only add route if it does not override an existing route
if (!entry.hasFaceId(addIt->faceId))
{
- RibEntry::FaceList::iterator faceIt = entry.findInheritedFace(*addIt);
+ RibEntry::RouteList::iterator routeIt = entry.findInheritedRoute(*addIt);
- // If the entry already has the inherited face, just update the face
- if (faceIt != entry.getInheritedFaces().end())
+ // If the entry already has the inherited route, just update the route
+ if (routeIt != entry.getInheritedRoutes().end())
{
- faceIt->cost = addIt->cost;
+ routeIt->cost = addIt->cost;
}
- else // Otherwise, this is a newly inherited face
+ else // Otherwise, this is a newly inherited route
{
- entry.addInheritedFace(*addIt);
+ entry.addInheritedRoute(*addIt);
}
insertFibUpdate(FibUpdate::createAddUpdate(entry.getName(), addIt->faceId, addIt->cost));
@@ -844,10 +831,10 @@
Rib::RibEntryList children = entry.getChildren();
- // Apply face operations to current namespace's children
+ // Apply route operations to current namespace's children
for (Rib::RibEntryList::iterator child = children.begin(); child != children.end(); ++child)
{
- traverseSubTree(*(*child), facesToAdd, facesToRemove);
+ traverseSubTree(*(*child), routesToAdd, routesToRemove);
}
}
diff --git a/rib/rib.hpp b/rib/rib.hpp
index 2568b1a..698ce17 100644
--- a/rib/rib.hpp
+++ b/rib/rib.hpp
@@ -40,27 +40,27 @@
class Rib : noncopyable
{
public:
- typedef std::list<shared_ptr<RibEntry> > RibEntryList;
- typedef std::map<Name, shared_ptr<RibEntry> > RibTable;
+ typedef std::list<shared_ptr<RibEntry>> RibEntryList;
+ typedef std::map<Name, shared_ptr<RibEntry>> RibTable;
typedef RibTable::const_iterator const_iterator;
- typedef std::map<uint64_t, std::list<shared_ptr<RibEntry> > > FaceLookupTable;
- typedef bool (*FaceComparePredicate)(const FaceEntry&, const FaceEntry&);
- typedef std::set<FaceEntry, FaceComparePredicate> FaceSet;
- typedef std::list<shared_ptr<const FibUpdate> > FibUpdateList;
+ typedef std::map<uint64_t, std::list<shared_ptr<RibEntry>>> FaceLookupTable;
+ typedef bool (*RouteComparePredicate)(const Route&, const Route&);
+ typedef std::set<Route, RouteComparePredicate> RouteSet;
+ typedef std::list<shared_ptr<const FibUpdate>> FibUpdateList;
Rib();
const_iterator
find(const Name& prefix) const;
- FaceEntry*
- find(const Name& prefix, const FaceEntry& face) const;
+ Route*
+ find(const Name& prefix, const Route& route) const;
void
- insert(const Name& prefix, const FaceEntry& face);
+ insert(const Name& prefix, const Route& route);
void
- erase(const Name& prefix, const FaceEntry& face);
+ erase(const Name& prefix, const Route& route);
void
erase(const uint64_t faceId);
@@ -83,10 +83,10 @@
/** \brief finds namespaces under the passed prefix
* \return{ a list of entries which are under the passed prefix }
*/
- std::list<shared_ptr<RibEntry> >
+ std::list<shared_ptr<RibEntry>>
findDescendants(const Name& prefix) const;
- const std::list<shared_ptr<const FibUpdate> >&
+ const std::list<shared_ptr<const FibUpdate>>&
getFibUpdates() const;
void
@@ -100,42 +100,42 @@
insertFibUpdate(shared_ptr<FibUpdate> update);
void
- createFibUpdatesForNewRibEntry(RibEntry& entry, const FaceEntry& face);
+ createFibUpdatesForNewRibEntry(RibEntry& entry, const Route& route);
void
- createFibUpdatesForNewFaceEntry(RibEntry& entry, const FaceEntry& face,
- const bool captureWasTurnedOn);
+ createFibUpdatesForNewRoute(RibEntry& entry, const Route& route,
+ const bool captureWasTurnedOn);
void
- createFibUpdatesForUpdatedEntry(RibEntry& entry, const FaceEntry& face,
+ createFibUpdatesForUpdatedRoute(RibEntry& entry, const Route& route,
const uint64_t previousFlags, const uint64_t previousCost);
void
- createFibUpdatesForErasedFaceEntry(RibEntry& entry, const FaceEntry& face,
- const bool captureWasTurnedOff);
+ createFibUpdatesForErasedRoute(RibEntry& entry, const Route& route,
+ const bool captureWasTurnedOff);
void
createFibUpdatesForErasedRibEntry(RibEntry& entry);
- FaceSet
- getAncestorFaces(const RibEntry& entry) const;
+ RouteSet
+ getAncestorRoutes(const RibEntry& entry) const;
void
- modifyChildrensInheritedFaces(RibEntry& entry, const Rib::FaceSet& facesToAdd,
- const Rib::FaceSet& facesToRemove);
+ modifyChildrensInheritedRoutes(RibEntry& entry, const Rib::RouteSet& routesToAdd,
+ const Rib::RouteSet& routesToRemove);
void
- traverseSubTree(RibEntry& entry, Rib::FaceSet facesToAdd,
- Rib::FaceSet facesToRemove);
+ traverseSubTree(RibEntry& entry, Rib::RouteSet routesToAdd,
+ Rib::RouteSet routesToRemove);
- /** \brief Adds passed faces to the entry's inherited faces list
+ /** \brief Adds passed routes to the entry's inherited routes list
*/
void
- addInheritedFacesToEntry(RibEntry& entry, const Rib::FaceSet& facesToAdd);
+ addInheritedRoutesToEntry(RibEntry& entry, const Rib::RouteSet& routesToAdd);
- /** \brief Removes passed faces from the entry's inherited faces list
+ /** \brief Removes passed routes from the entry's inherited routes list
*/
void
- removeInheritedFacesFromEntry(RibEntry& entry, const Rib::FaceSet& facesToRemove);
+ removeInheritedRoutesFromEntry(RibEntry& entry, const Rib::RouteSet& routesToRemove);
public:
ndn::util::signal::Signal<Rib, Name> afterInsertEntry;
diff --git a/rib/face-entry.hpp b/rib/route.hpp
similarity index 80%
rename from rib/face-entry.hpp
rename to rib/route.hpp
index a6d468d..68769ef 100644
--- a/rib/face-entry.hpp
+++ b/rib/route.hpp
@@ -23,8 +23,8 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NFD_RIB_FACE_ENTRY_HPP
-#define NFD_RIB_FACE_ENTRY_HPP
+#ifndef NFD_RIB_ROUTE_HPP
+#define NFD_RIB_ROUTE_HPP
#include "common.hpp"
#include "core/scheduler.hpp"
@@ -32,13 +32,12 @@
namespace nfd {
namespace rib {
-/** \class FaceEntry
- * \brief represents a route for a name prefix
+/** \brief represents a route for a name prefix
*/
-class FaceEntry
+class Route
{
public:
- FaceEntry()
+ Route()
: faceId(0)
, origin(0)
, flags(0)
@@ -73,22 +72,22 @@
};
inline bool
-compareFaceIdAndOrigin(const FaceEntry& entry1, const FaceEntry& entry2)
+compareFaceIdAndOrigin(const Route& lhs, const Route& rhs)
{
- return (entry1.faceId == entry2.faceId && entry1.origin == entry2.origin);
+ return (lhs.faceId == rhs.faceId && lhs.origin == rhs.origin);
}
inline bool
-compareFaceId(const FaceEntry& entry, const uint64_t faceId)
+compareFaceId(const Route& route, const uint64_t faceId)
{
- return (entry.faceId == faceId);
+ return (route.faceId == faceId);
}
// Method definition in rib-entry.cpp
std::ostream&
-operator<<(std::ostream& os, const FaceEntry& entry);
+operator<<(std::ostream& os, const Route& route);
} // namespace rib
} // namespace nfd
-#endif // NFD_RIB_RIB_ENTRY_HPP
+#endif // NFD_RIB_ROUTE_HPP