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