void my_routing::show_fib_data(const ndn::ConstBufferPtr& buf) { size_t offset = 0; auto face_list = my_faceid::get_face_list(); while (offset < buf->size()) { bool isOk = false; ndn::Block block; std::tie(isOk, block) = ndn::Block::fromBuffer(buf, offset); if (!isOk) { std::cout << "ERROR: cannot decode FibEntry TLV" << std::endl; m_has_error = true; break; } offset += block.size(); ndn::nfd::FibEntry fibEntry(block); std::cout << " " << fibEntry.getPrefix() << " nexthops={"; bool isFirst = true; for (const ndn::nfd::NextHopRecord & nextHop : fibEntry.getNextHopRecords()) { if (isFirst) { isFirst = false; } else { std::cout << ", "; } std::cout << "faceid=" << nextHop.getFaceId() << " name=" << my_faceid::get_face_name(face_list, nextHop.getFaceId()) << " (cost=" << nextHop.getCost() << ")"; } std::cout << "}" << std::endl; } }
void my_routing::show_rib_data(const ndn::ConstBufferPtr& buf) { size_t offset = 0; auto face_list = my_faceid::get_face_list(); while (offset < buf->size()) { bool isOk = false; ndn::Block block; std::tie(isOk, block) = ndn::Block::fromBuffer(buf, offset); if (!isOk) { std::cout << "ERROR: cannot decode RibEntry TLV" << std::endl; m_has_error = true; break; } offset += block.size(); ndn::nfd::RibEntry ribEntry(block); std::cout << " " << ribEntry.getName().toUri() << " route={"; bool isFirst = true; for (const ndn::nfd::Route & nextRoute : ribEntry) { if (isFirst) { isFirst = false; } else { std::cout << ", "; } std::cout << "faceid=" << nextRoute.getFaceId() << " name=" << my_faceid::get_face_name(face_list, nextRoute.getFaceId()) << " (origin=" << nextRoute.getOrigin() << " cost=" << nextRoute.getCost(); if (!nextRoute.hasInfiniteExpirationPeriod()) { std::cout << " expires=" << ndn::time::duration_cast<ndn::time::seconds>(nextRoute.getExpirationPeriod()) .count() << "s"; } if (nextRoute.isChildInherit()) { std::cout << " ChildInherit"; } if (nextRoute.isRibCapture()) { std::cout << " RibCapture"; } std::cout << ")"; } std::cout << "}" << std::endl; } }
void my_routing::show_strategy_data(const ndn::ConstBufferPtr& buf) { size_t offset = 0; while (offset < buf->size()) { bool isOk = false; ndn::Block block; std::tie(isOk, block) = ndn::Block::fromBuffer(buf, offset); if (!isOk) { std::cerr << "ERROR: cannot decode StrategyChoice TLV" << std::endl; m_has_error = true; break; } offset += block.size(); ndn::nfd::StrategyChoice strategyChoice(block); std::cout << strategyChoice.getName() << " strategy=" << strategyChoice.getStrategy() << std::endl; } }
void my_routing::show_interfaces_data(const ndn::ConstBufferPtr& buf) { size_t offset = 0; while (offset < buf->size()) { bool isOk = false; ndn::Block block; std::tie(isOk, block) = ndn::Block::fromBuffer(buf, offset); if (!isOk) { std::cout << "ERROR: cannot decode FaceStatus TLV" << std::endl; m_has_error = true; break; } offset += block.size(); ndn::nfd::FaceStatus faceStatus(block); std::cout << "faceid=" << faceStatus.getFaceId() << " remote=" << faceStatus.getRemoteUri() << " local=" << faceStatus.getLocalUri(); if (faceStatus.hasExpirationPeriod()) { std::cout << " expires=" << ndn::time::duration_cast<ndn::time::seconds>(faceStatus.getExpirationPeriod()).count() << "s"; } std::cout << " " << faceStatus.getFaceScope() << " " << faceStatus.getFacePersistency() << " " << faceStatus.getLinkType(); std::cout << " counters={" << "in={" << faceStatus.getNInInterests() << "i " << faceStatus.getNInDatas() << "d " << faceStatus.getNInBytes() << "B}" << " out={" << faceStatus.getNOutInterests() << "i " << faceStatus.getNOutDatas() << "d " << faceStatus.getNOutBytes() << "B}" << "}"; std::cout << std::endl; } }
void Nlsrc::onFetchSuccess(const ndn::ConstBufferPtr& data, const std::function<void(const T&)>& recordLsa) { ndn::Block block; size_t offset = 0; while (offset < data->size()) { bool isOk = false; std::tie(isOk, block) = ndn::Block::fromBuffer(data, offset); if (!isOk) { std::cerr << "ERROR: cannot decode LSA TLV" << std::endl; break; } offset += block.size(); T lsa(block); recordLsa(lsa); } runNextStep(); }