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 { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 10 | namespace fw { |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 11 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 12 | BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder) |
| 13 | : Strategy(forwarder) |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 14 | { |
| 15 | } |
| 16 | |
| 17 | BestRouteStrategy::~BestRouteStrategy() |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | void |
| 22 | BestRouteStrategy::afterReceiveInterest(const Face& inFace, |
| 23 | const Interest& interest, |
| 24 | shared_ptr<fib::Entry> fibEntry, |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 25 | shared_ptr<pit::Entry> pitEntry) |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 26 | { |
| 27 | const fib::NextHopList& nexthops = fibEntry->getNextHops(); |
| 28 | if (nexthops.size() == 0) { |
Junxiao Shi | 09498f0 | 2014-02-26 19:41:08 -0700 | [diff] [blame] | 29 | this->rejectPendingInterest(pitEntry); |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 30 | return; |
| 31 | } |
| 32 | |
| 33 | shared_ptr<Face> outFace = nexthops.begin()->getFace(); |
| 34 | this->sendInterest(pitEntry, outFace); |
| 35 | } |
| 36 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 37 | } // namespace fw |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 38 | } // namespace nfd |