blob: 19458e922f61f8eab7296c3612f5e15503ca41c3 [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 Shi8c8d2182014-01-30 22:33:00 -070012BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder)
Junxiao Shibb5105f2014-03-03 12:06:45 -070013 : Strategy(forwarder, "ndn:/localhost/nfd/strategy/best-route")
Junxiao Shid3c792f2014-01-30 00:46:13 -070014{
15}
16
17BestRouteStrategy::~BestRouteStrategy()
18{
19}
20
21void
22BestRouteStrategy::afterReceiveInterest(const Face& inFace,
23 const Interest& interest,
24 shared_ptr<fib::Entry> fibEntry,
Junxiao Shi8c8d2182014-01-30 22:33:00 -070025 shared_ptr<pit::Entry> pitEntry)
Junxiao Shid3c792f2014-01-30 00:46:13 -070026{
27 const fib::NextHopList& nexthops = fibEntry->getNextHops();
28 if (nexthops.size() == 0) {
Junxiao Shi09498f02014-02-26 19:41:08 -070029 this->rejectPendingInterest(pitEntry);
Junxiao Shid3c792f2014-01-30 00:46:13 -070030 return;
31 }
32
33 shared_ptr<Face> outFace = nexthops.begin()->getFace();
34 this->sendInterest(pitEntry, outFace);
35}
36
Junxiao Shi8c8d2182014-01-30 22:33:00 -070037} // namespace fw
Junxiao Shid3c792f2014-01-30 00:46:13 -070038} // namespace nfd