all: Fixing compatibility with NFD 0.5 and ndn-cxx 0.5
Change-Id: I3d23acf29f4858049d1040a3e421e1c7151b3aba
diff --git a/examples/ndn-load-balancer/random-load-balancer-strategy.cpp b/examples/ndn-load-balancer/random-load-balancer-strategy.cpp
index 6083dd3..4b1585f 100644
--- a/examples/ndn-load-balancer/random-load-balancer-strategy.cpp
+++ b/examples/ndn-load-balancer/random-load-balancer-strategy.cpp
@@ -49,34 +49,35 @@
}
static bool
-canForwardToNextHop(shared_ptr<pit::Entry> pitEntry, const fib::NextHop& nexthop)
+canForwardToNextHop(const Face& inFace, shared_ptr<pit::Entry> pitEntry, const fib::NextHop& nexthop)
{
- return pitEntry->canForwardTo(*nexthop.getFace());
+ return !wouldViolateScope(inFace, pitEntry->getInterest(), nexthop.getFace()) &&
+ canForwardToLegacy(*pitEntry, nexthop.getFace());
}
static bool
-hasFaceForForwarding(const fib::NextHopList& nexthops, shared_ptr<pit::Entry>& pitEntry)
+hasFaceForForwarding(const Face& inFace, const fib::NextHopList& nexthops, const shared_ptr<pit::Entry>& pitEntry)
{
- return std::find_if(nexthops.begin(), nexthops.end(), bind(&canForwardToNextHop, pitEntry, _1))
+ return std::find_if(nexthops.begin(), nexthops.end(), bind(&canForwardToNextHop, cref(inFace), pitEntry, _1))
!= nexthops.end();
}
void
RandomLoadBalancerStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
- shared_ptr<fib::Entry> fibEntry,
- shared_ptr<pit::Entry> pitEntry)
+ const shared_ptr<pit::Entry>& pitEntry)
{
NFD_LOG_TRACE("afterReceiveInterest");
- if (pitEntry->hasUnexpiredOutRecords()) {
+ if (hasPendingOutRecords(*pitEntry)) {
// not a new Interest, don't forward
return;
}
- const fib::NextHopList& nexthops = fibEntry->getNextHops();
+ const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
+ const fib::NextHopList& nexthops = fibEntry.getNextHops();
// Ensure there is at least 1 Face is available for forwarding
- if (!hasFaceForForwarding(nexthops, pitEntry)) {
+ if (!hasFaceForForwarding(inFace, nexthops, pitEntry)) {
this->rejectPendingInterest(pitEntry);
return;
}
@@ -91,7 +92,7 @@
for (selected = nexthops.begin(); selected != nexthops.end() && currentIndex != randomIndex;
++selected, ++currentIndex) {
}
- } while (!canForwardToNextHop(pitEntry, *selected));
+ } while (!canForwardToNextHop(inFace, pitEntry, *selected));
this->sendInterest(pitEntry, selected->getFace());
}
diff --git a/examples/ndn-load-balancer/random-load-balancer-strategy.hpp b/examples/ndn-load-balancer/random-load-balancer-strategy.hpp
index 2d45831..997bb56 100644
--- a/examples/ndn-load-balancer/random-load-balancer-strategy.hpp
+++ b/examples/ndn-load-balancer/random-load-balancer-strategy.hpp
@@ -29,6 +29,7 @@
#include <boost/random/mersenne_twister.hpp>
#include "face/face.hpp"
#include "fw/strategy.hpp"
+#include "fw/algorithm.hpp"
namespace nfd {
namespace fw {
@@ -37,11 +38,11 @@
public:
RandomLoadBalancerStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
- virtual ~RandomLoadBalancerStrategy();
+ virtual ~RandomLoadBalancerStrategy() override;
virtual void
afterReceiveInterest(const Face& inFace, const Interest& interest,
- shared_ptr<fib::Entry> fibEntry, shared_ptr<pit::Entry> pitEntry);
+ const shared_ptr<pit::Entry>& pitEntry) override;
public:
static const Name STRATEGY_NAME;
diff --git a/examples/ndn-triangle-calculate-routes.cpp b/examples/ndn-triangle-calculate-routes.cpp
index 614238e..b3860dc 100644
--- a/examples/ndn-triangle-calculate-routes.cpp
+++ b/examples/ndn-triangle-calculate-routes.cpp
@@ -82,9 +82,9 @@
bool isFirst = true;
for (auto& nextHop : entry.getNextHops()) {
- cout << *nextHop.getFace();
- auto face = nextHop.getFace();
- auto linkService = dynamic_cast<ndn::NetDeviceLinkService*>(face->getLinkService());
+ cout << nextHop.getFace();
+ auto& face = nextHop.getFace();
+ auto linkService = dynamic_cast<ndn::NetDeviceLinkService*>(face.getLinkService());
if (linkService == nullptr) {
continue;
}