fw: ClientControlStrategy
refs #1214 Change-Id: Ia382acad6c8eeac85663fd664d1d34ba6f2ad478
This commit is contained in:
committed by
Alex Afanasyev
parent
bb5105f218
commit
2d9bdc8a5f
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (C) 2014 Named Data Networking Project
|
||||
* See COPYING for copyright and distribution information.
|
||||
*/
|
||||
|
||||
#include "client-control-strategy.hpp"
|
||||
|
||||
namespace nfd {
|
||||
namespace fw {
|
||||
|
||||
NFD_LOG_INIT("ClientControlStrategy");
|
||||
|
||||
ClientControlStrategy::ClientControlStrategy(Forwarder& forwarder)
|
||||
: BestRouteStrategy(forwarder)
|
||||
{
|
||||
}
|
||||
|
||||
ClientControlStrategy::~ClientControlStrategy()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ClientControlStrategy::afterReceiveInterest(const Face& inFace,
|
||||
const Interest& interest,
|
||||
shared_ptr<fib::Entry> fibEntry,
|
||||
shared_ptr<pit::Entry> pitEntry)
|
||||
{
|
||||
// Strategy needn't check whether LocalControlHeader-NextHopFaceId is enabled.
|
||||
// LocalFace does this check.
|
||||
if (!interest.getLocalControlHeader().hasNextHopFaceId()) {
|
||||
this->BestRouteStrategy::afterReceiveInterest(inFace, interest, fibEntry, pitEntry);
|
||||
return;
|
||||
}
|
||||
|
||||
FaceId outFaceId = static_cast<FaceId>(interest.getNextHopFaceId());
|
||||
shared_ptr<Face> outFace = this->getFace(outFaceId);
|
||||
if (!static_cast<bool>(outFace)) {
|
||||
// If outFace doesn't exist, it's better to reject the Interest
|
||||
// than to use BestRouteStrategy.
|
||||
NFD_LOG_WARN("Interest " << interest.getName() <<
|
||||
" NextHopFaceId=" << outFaceId << " non-existent face");
|
||||
this->rejectPendingInterest(pitEntry);
|
||||
return;
|
||||
}
|
||||
|
||||
this->sendInterest(pitEntry, outFace);
|
||||
}
|
||||
|
||||
} // namespace fw
|
||||
} // namespace nfd
|
||||
Reference in New Issue
Block a user