Junxiao Shi | 727ed29 | 2014-02-19 23:26:45 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 9 | namespace nfd { |
| 10 | namespace fw { |
| 11 | |
| 12 | BroadcastStrategy::BroadcastStrategy(Forwarder& forwarder) |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 13 | : Strategy(forwarder, "ndn:/localhost/nfd/strategy/broadcast") |
Junxiao Shi | 727ed29 | 2014-02-19 23:26:45 -0700 | [diff] [blame] | 14 | { |
| 15 | } |
| 16 | |
| 17 | BroadcastStrategy::~BroadcastStrategy() |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | void |
| 22 | BroadcastStrategy::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 Shi | 09498f0 | 2014-02-26 19:41:08 -0700 | [diff] [blame] | 39 | this->rejectPendingInterest(pitEntry); |
Junxiao Shi | 727ed29 | 2014-02-19 23:26:45 -0700 | [diff] [blame] | 40 | } |
| 41 | } |
| 42 | |
| 43 | } // namespace fw |
| 44 | } // namespace nfd |