blob: 7f5b248e67ffacc6456841220c510d796a741fd1 [file] [log] [blame]
Junxiao Shi727ed292014-02-19 23:26:45 -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 "broadcast-strategy.hpp"
8
9namespace nfd {
10namespace fw {
11
Junxiao Shif3c07812014-03-11 21:48:49 -070012const Name BroadcastStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/broadcast");
13
14BroadcastStrategy::BroadcastStrategy(Forwarder& forwarder, const Name& name)
15 : Strategy(forwarder, name)
Junxiao Shi727ed292014-02-19 23:26:45 -070016{
17}
18
19BroadcastStrategy::~BroadcastStrategy()
20{
21}
22
23void
24BroadcastStrategy::afterReceiveInterest(const Face& inFace,
25 const Interest& interest,
26 shared_ptr<fib::Entry> fibEntry,
27 shared_ptr<pit::Entry> pitEntry)
28{
29 const fib::NextHopList& nexthops = fibEntry->getNextHops();
30
Junxiao Shi727ed292014-02-19 23:26:45 -070031 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
32 shared_ptr<Face> outFace = it->getFace();
Junxiao Shi57f0f312014-03-16 11:52:20 -070033 if (pitEntry->canForwardTo(*outFace)) {
Junxiao Shi727ed292014-02-19 23:26:45 -070034 this->sendInterest(pitEntry, outFace);
Junxiao Shi727ed292014-02-19 23:26:45 -070035 }
36 }
37
Junxiao Shi57f0f312014-03-16 11:52:20 -070038 if (!pitEntry->hasUnexpiredOutRecords()) {
Junxiao Shi09498f02014-02-26 19:41:08 -070039 this->rejectPendingInterest(pitEntry);
Junxiao Shi727ed292014-02-19 23:26:45 -070040 }
41}
42
43} // namespace fw
44} // namespace nfd