Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -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 "best-route-strategy.hpp" |
| 8 | |
| 9 | namespace nfd { |
| 10 | |
| 11 | BestRouteStrategy::BestRouteStrategy(Forwarder& fw) |
| 12 | : Strategy(fw) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | BestRouteStrategy::~BestRouteStrategy() |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | void |
| 21 | BestRouteStrategy::afterReceiveInterest(const Face& inFace, |
| 22 | const Interest& interest, |
| 23 | shared_ptr<fib::Entry> fibEntry, |
| 24 | shared_ptr<pit::Entry> pitEntry, |
| 25 | pit::InRecordCollection::iterator pitInRecord) |
| 26 | { |
| 27 | const fib::NextHopList& nexthops = fibEntry->getNextHops(); |
| 28 | if (nexthops.size() == 0) { |
| 29 | this->rebuffPendingInterest(pitEntry); |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | shared_ptr<Face> outFace = nexthops.begin()->getFace(); |
| 34 | this->sendInterest(pitEntry, outFace); |
| 35 | } |
| 36 | |
| 37 | } // namespace nfd |