blob: 4cc4e5f87f6cfb799e4e0d41b92bd009723fccbc [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
12BroadcastStrategy::BroadcastStrategy(Forwarder& forwarder)
Junxiao Shibb5105f2014-03-03 12:06:45 -070013 : Strategy(forwarder, "ndn:/localhost/nfd/strategy/broadcast")
Junxiao Shi727ed292014-02-19 23:26:45 -070014{
15}
16
17BroadcastStrategy::~BroadcastStrategy()
18{
19}
20
21void
22BroadcastStrategy::afterReceiveInterest(const Face& inFace,
23 const Interest& interest,
24 shared_ptr<fib::Entry> fibEntry,
25 shared_ptr<pit::Entry> pitEntry)
26{
27 const fib::NextHopList& nexthops = fibEntry->getNextHops();
28
29 bool isPropagated = false;
30 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
31 shared_ptr<Face> outFace = it->getFace();
32 if (outFace->getId() != inFace.getId()) {
33 this->sendInterest(pitEntry, outFace);
34 isPropagated = true;
35 }
36 }
37
38 if (!isPropagated) {
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