BOOST_AUTO_TEST_CASE_TEMPLATE(CombineReasons, Combination, NackReasonCombinations) { Combination combination; shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first; fibEntry->addNextHop(face3, 10); fibEntry->addNextHop(face4, 20); fibEntry->addNextHop(face5, 30); shared_ptr<Interest> interest1 = makeInterest("/F6sEwB24I", 282); shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first; pitEntry->insertOrUpdateInRecord(face1, *interest1); pitEntry->insertOrUpdateOutRecord(face3, *interest1); pitEntry->insertOrUpdateOutRecord(face4, *interest1); lp::Nack nack3 = makeNack("/F6sEwB24I", 282, combination.getX()); pitEntry->getOutRecord(*face3)->setIncomingNack(nack3); strategy.afterReceiveNack(*face3, nack3, fibEntry, pitEntry); BOOST_CHECK_EQUAL(strategy.sendNackHistory.size(), 0); lp::Nack nack4 = makeNack("/F6sEwB24I", 282, combination.getY()); pitEntry->getOutRecord(*face4)->setIncomingNack(nack4); strategy.afterReceiveNack(*face4, nack4, fibEntry, pitEntry); BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 1); BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry); BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].outFaceId, face1->getId()); BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), combination.getExpectedResult()); }
inline lp::Nack makeNack(const Name& name, uint32_t nonce, lp::NackReason reason) { Interest interest(name); interest.setNonce(nonce); return makeNack(interest, reason); }
shared_ptr<ndn::Data> NdnDataManager::operator[]( shared_ptr<const ndn::Interest> interest ) { Name subname = interest->getName(); auto it = subname.end()-1; while( ( it->isVersion() || it->isSegment() || it->isSegmentOffset() || it->isTimestamp() || it->isSequenceNumber() ) && ( it-- ) != subname.begin() ); subname = subname.getPrefix( it - subname.begin() + 1 ); if( m_producers.find( subname ) != m_producers.end() ) { // find data producer auto producer = m_producers[subname]; // if access level is 0, no access needs to be provided if( interest->getAuthTag().getAccessLevel() == 0 ) { Coordinator:: producerSatisfiedRequest( interest->getName().getPrefix( 2 ), interest->getName() ); return producer->makeData( interest ); } // generate data packet shared_ptr<Data> data = producer->makeData( interest ); // check that the interest's access rights // satisfy the data's requirements if( m_auth_manager->getTagAccess( interest->getAuthTag() ) < data->getAccessLevel() ) { Coordinator:: producerDeniedRequest( interest->getName().getPrefix( 2 ), interest->getName(), "Insufficient Auth" ); return makeNack( *data ); } // check that the data satisfies interest if( interest->matchesData( *data ) ) { Coordinator:: producerSatisfiedRequest( interest->getName().getPrefix(2), interest->getName() ); return data; } } Coordinator::producerOther( interest->getName().getPrefix( 2 ), "No data matching " + interest->getName().toUri() ); return NULL; };
BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopNackToNonLocal, T, Tests, StrategyScopeControlFixture<typename T::Strategy>) { fib::Entry* fibEntry = this->fib.insert("/localhop/A").first; fibEntry->addNextHop(*this->localFace4, 10); fibEntry->addNextHop(*this->nonLocalFace2, 20); shared_ptr<Interest> interest = makeInterest("/localhop/A/1", 1377); shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, *interest); lp::Nack nack = makeNack("/localhop/A/1", 1377, lp::NackReason::NO_ROUTE); pitEntry->insertOrUpdateOutRecord(*this->localFace4, *interest)->setIncomingNack(nack); this->waitForStrategyAction( [&] { this->strategy.afterReceiveNack(*this->localFace4, nack, pitEntry); }, T::canProcessNack()); BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); if (T::canProcessNack()) { BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); } }