rib: Implement RIB as trie
refs: #1271
Change-Id: Idbd6d4d67f8a88b474ea0b20280c79e367bc98e5
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index a84d7f6..b89b619 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -1,12 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014 Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis
+ * Copyright (c) 2014, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
@@ -21,7 +21,7 @@
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
#include "rib-manager.hpp"
#include "core/global-io.hpp"
@@ -216,28 +216,27 @@
return;
}
- RibEntry ribEntry;
- ribEntry.name = parameters.getName();
- ribEntry.faceId = parameters.getFaceId();
- ribEntry.origin = parameters.getOrigin();
- ribEntry.cost = parameters.getCost();
- ribEntry.flags = parameters.getFlags();
- ribEntry.expires = time::steady_clock::now() + parameters.getExpirationPeriod();
+ FaceEntry faceEntry;
+ faceEntry.faceId = parameters.getFaceId();
+ faceEntry.origin = parameters.getOrigin();
+ faceEntry.cost = parameters.getCost();
+ faceEntry.flags = parameters.getFlags();
+ faceEntry.expires = time::steady_clock::now() + parameters.getExpirationPeriod();
- NFD_LOG_TRACE("register prefix: " << ribEntry);
+ NFD_LOG_TRACE("register prefix: " << faceEntry);
- // For right now, just pass the options to fib as it is,
- // without processing flags. Later options will be first added to
- // Rib tree, then nrd will generate fib updates based on flags and then
- // will add next hops one by one..
- m_managedRib.insert(ribEntry);
+ /// \todo For right now, just pass the options to fib as is
+ /// without processing flags. Later, options will first be added to
+ /// Rib tree, nrd will generate fib updates based on flags, and
+ /// will then add next hops one by one.
+ m_managedRib.insert(parameters.getName(), faceEntry);
m_nfdController.start<ndn::nfd::FibAddNextHopCommand>(
ControlParameters()
- .setName(ribEntry.name)
- .setFaceId(ribEntry.faceId)
- .setCost(ribEntry.cost),
- bind(&RibManager::onRegSuccess, this, request, parameters, ribEntry),
- bind(&RibManager::onCommandError, this, _1, _2, request, ribEntry));
+ .setName(parameters.getName())
+ .setFaceId(faceEntry.faceId)
+ .setCost(faceEntry.cost),
+ bind(&RibManager::onRegSuccess, this, request, parameters, faceEntry),
+ bind(&RibManager::onCommandError, this, _1, _2, request, faceEntry));
}
void
@@ -253,19 +252,18 @@
return;
}
- RibEntry ribEntry;
- ribEntry.name = parameters.getName();
- ribEntry.faceId = parameters.getFaceId();
- ribEntry.origin = parameters.getOrigin();
+ FaceEntry faceEntry;
+ faceEntry.faceId = parameters.getFaceId();
+ faceEntry.origin = parameters.getOrigin();
- NFD_LOG_TRACE("unregister prefix: " << ribEntry);
+ NFD_LOG_TRACE("unregister prefix: " << faceEntry);
m_nfdController.start<ndn::nfd::FibRemoveNextHopCommand>(
ControlParameters()
- .setName(ribEntry.name)
- .setFaceId(ribEntry.faceId),
- bind(&RibManager::onUnRegSuccess, this, request, parameters, ribEntry),
- bind(&RibManager::onCommandError, this, _1, _2, request, ribEntry));
+ .setName(parameters.getName())
+ .setFaceId(faceEntry.faceId),
+ bind(&RibManager::onUnRegSuccess, this, request, parameters, faceEntry),
+ bind(&RibManager::onCommandError, this, _1, _2, request, faceEntry));
}
void
@@ -316,7 +314,7 @@
void
RibManager::onCommandError(uint32_t code, const std::string& error,
const shared_ptr<const Interest>& request,
- const RibEntry& ribEntry)
+ const FaceEntry& faceEntry)
{
NFD_LOG_ERROR("NFD returned an error: " << error << " (code: " << code << ")");
@@ -336,13 +334,13 @@
}
sendResponse(request->getName(), response);
- m_managedRib.erase(ribEntry);
+ m_managedRib.erase(request->getName(), faceEntry);
}
void
RibManager::onRegSuccess(const shared_ptr<const Interest>& request,
const ControlParameters& parameters,
- const RibEntry& ribEntry)
+ const FaceEntry& faceEntry)
{
ControlResponse response;
@@ -350,7 +348,7 @@
response.setText("Success");
response.setBody(parameters.wireEncode());
- NFD_LOG_TRACE("onRegSuccess: registered " << ribEntry);
+ NFD_LOG_TRACE("onRegSuccess: registered " << faceEntry);
sendResponse(request->getName(), response);
}
@@ -359,7 +357,7 @@
void
RibManager::onUnRegSuccess(const shared_ptr<const Interest>& request,
const ControlParameters& parameters,
- const RibEntry& ribEntry)
+ const FaceEntry& faceEntry)
{
ControlResponse response;
@@ -367,10 +365,10 @@
response.setText("Success");
response.setBody(parameters.wireEncode());
- NFD_LOG_TRACE("onUnRegSuccess: unregistered " << ribEntry);
+ NFD_LOG_TRACE("onUnRegSuccess: unregistered " << faceEntry);
sendResponse(request->getName(), response);
- m_managedRib.erase(ribEntry);
+ m_managedRib.erase(request->getName(), faceEntry);
}
void