multicast-strategy.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "multicast-strategy.hpp"
27 #include "pit-algorithm.hpp"
28 
29 namespace nfd {
30 namespace fw {
31 
32 const Name MulticastStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/multicast/%FD%01");
33 NFD_REGISTER_STRATEGY(MulticastStrategy);
34 
35 MulticastStrategy::MulticastStrategy(Forwarder& forwarder, const Name& name)
36  : Strategy(forwarder, name)
37 {
38 }
39 
40 void
41 MulticastStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
42  const shared_ptr<pit::Entry>& pitEntry)
43 {
44  const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
45  const fib::NextHopList& nexthops = fibEntry.getNextHops();
46 
47  for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
48  Face& outFace = it->getFace();
49  if (canForwardToLegacy(*pitEntry, outFace)) {
50  this->sendInterest(pitEntry, outFace);
51  }
52  }
53 
54  if (!hasPendingOutRecords(*pitEntry)) {
55  this->rejectPendingInterest(pitEntry);
56  }
57 }
58 
59 } // namespace fw
60 } // namespace nfd
bool canForwardToLegacy(const pit::Entry &pitEntry, const Face &face)
decide whether Interest can be forwarded to face
#define NFD_REGISTER_STRATEGY(StrategyType)
registers a built-in strategy
main class of NFD
Definition: forwarder.hpp:52
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
represents a FIB entry
Definition: fib-entry.hpp:51
MulticastStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
std::vector< fib::NextHop > NextHopList
Definition: fib-entry.hpp:47
bool hasPendingOutRecords(const pit::Entry &pitEntry)
determine whether pitEntry has any pending out-records
represents a forwarding strategy
Definition: strategy.hpp:38
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, bool wantNewNonce=false)
send Interest to outFace
Definition: strategy.hpp:138
const NextHopList & getNextHops() const
Definition: fib-entry.hpp:64
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:151
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present
Definition: strategy.cpp:91