blob: 8f87270cf92e4110bb34a431ec0ecb86f99c7de6 [file] [log] [blame]
Junxiao Shid3c792f2014-01-30 00:46:13 -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 "best-route-strategy.hpp"
8
9namespace nfd {
Junxiao Shi8c8d2182014-01-30 22:33:00 -070010namespace fw {
Junxiao Shid3c792f2014-01-30 00:46:13 -070011
Junxiao Shif3c07812014-03-11 21:48:49 -070012const Name BestRouteStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/best-route");
13
14BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder, const Name& name)
15 : Strategy(forwarder, name)
Junxiao Shid3c792f2014-01-30 00:46:13 -070016{
17}
18
19BestRouteStrategy::~BestRouteStrategy()
20{
21}
22
23void
24BestRouteStrategy::afterReceiveInterest(const Face& inFace,
25 const Interest& interest,
26 shared_ptr<fib::Entry> fibEntry,
Junxiao Shi8c8d2182014-01-30 22:33:00 -070027 shared_ptr<pit::Entry> pitEntry)
Junxiao Shid3c792f2014-01-30 00:46:13 -070028{
29 const fib::NextHopList& nexthops = fibEntry->getNextHops();
30 if (nexthops.size() == 0) {
Junxiao Shi09498f02014-02-26 19:41:08 -070031 this->rejectPendingInterest(pitEntry);
Junxiao Shid3c792f2014-01-30 00:46:13 -070032 return;
33 }
34
35 shared_ptr<Face> outFace = nexthops.begin()->getFace();
36 this->sendInterest(pitEntry, outFace);
37}
38
Junxiao Shi8c8d2182014-01-30 22:33:00 -070039} // namespace fw
Junxiao Shid3c792f2014-01-30 00:46:13 -070040} // namespace nfd