示例#1
0
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;
    }
}
示例#2
0
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;
    }
}
示例#3
0
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;
    }
}
示例#4
0
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;
    }
}
示例#5
0
文件: nlsrc.cpp 项目: named-data/NLSR
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();
}