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