blob: 3e8c2bfb823ebfeb087c9feae5258a5d4ac4185d [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
31 bool isPropagated = false;
32 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
33 shared_ptr<Face> outFace = it->getFace();
34 if (outFace->getId() != inFace.getId()) {
35 this->sendInterest(pitEntry, outFace);
36 isPropagated = true;
37 }
38 }
39
40 if (!isPropagated) {
Junxiao Shi09498f02014-02-26 19:41:08 -070041 this->rejectPendingInterest(pitEntry);
Junxiao Shi727ed292014-02-19 23:26:45 -070042 }
43}
44
45} // namespace fw
46} // namespace nfd