Junxiao Shi | 2d9bdc8 | 2014-03-02 20:55:42 -0700 | [diff] [blame^] | 1 | /* -*- 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 | |
| 9 | namespace nfd { |
| 10 | namespace fw { |
| 11 | |
| 12 | NFD_LOG_INIT("ClientControlStrategy"); |
| 13 | |
| 14 | ClientControlStrategy::ClientControlStrategy(Forwarder& forwarder) |
| 15 | : BestRouteStrategy(forwarder) |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | ClientControlStrategy::~ClientControlStrategy() |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | void |
| 24 | ClientControlStrategy::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 |