blob: eacd6047c67728e7b43f79adaf44a54ec567ab50 [file] [log] [blame]
Junxiao Shi2d9bdc82014-03-02 20:55:42 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "client-control-strategy.hpp"
8
9namespace nfd {
10namespace fw {
11
12NFD_LOG_INIT("ClientControlStrategy");
13
14ClientControlStrategy::ClientControlStrategy(Forwarder& forwarder)
15 : BestRouteStrategy(forwarder)
16{
17}
18
19ClientControlStrategy::~ClientControlStrategy()
20{
21}
22
23void
24ClientControlStrategy::afterReceiveInterest(const Face& inFace,
25 const Interest& interest,
26 shared_ptr<fib::Entry> fibEntry,
27 shared_ptr<pit::Entry> pitEntry)
28{
29 // Strategy needn't check whether LocalControlHeader-NextHopFaceId is enabled.
30 // LocalFace does this check.
31 if (!interest.getLocalControlHeader().hasNextHopFaceId()) {
32 this->BestRouteStrategy::afterReceiveInterest(inFace, interest, fibEntry, pitEntry);
33 return;
34 }
35
36 FaceId outFaceId = static_cast<FaceId>(interest.getNextHopFaceId());
37 shared_ptr<Face> outFace = this->getFace(outFaceId);
38 if (!static_cast<bool>(outFace)) {
39 // If outFace doesn't exist, it's better to reject the Interest
40 // than to use BestRouteStrategy.
41 NFD_LOG_WARN("Interest " << interest.getName() <<
42 " NextHopFaceId=" << outFaceId << " non-existent face");
43 this->rejectPendingInterest(pitEntry);
44 return;
45 }
46
47 this->sendInterest(pitEntry, outFace);
48}
49
50} // namespace fw
51} // namespace nfd