blob: 778137773da59aaf2e5905fb152b1addbbae7f8c [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)
13 : Strategy(forwarder)
14{
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) {
39 this->rebuffPendingInterest(pitEntry);
40 }
41}
42
43} // namespace fw
44} // namespace nfd