dissect+peek: avoid deprecated ndn-cxx functions
Change-Id: Ibd9f8ad30e315f537d1560db823372af3d58d713
This commit is contained in:
1 parent
96412a18d8
commit
242d5063f7
9 files changed
+28
-21
No files matched your search
@@ -44,6 +44,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ protected:
|
|||||||
util::DummyClientFace face{m_io};
|
util::DummyClientFace face{m_io};
|
||||||
Options opt;
|
Options opt;
|
||||||
unique_ptr<DiscoverVersion> discover;
|
unique_ptr<DiscoverVersion> discover;
|
||||||
optional<Name> discoveredName;
|
std::optional<Name> discoveredName;
|
||||||
optional<uint64_t> discoveredVersion;
|
std::optional<uint64_t> discoveredVersion;
|
||||||
bool isDiscoveryFinished = false;
|
bool isDiscoveryFinished = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
checkOutput(output_test_stream& output, const Data& data)
|
checkOutput(output_test_stream& output, const Data& data)
|
||||||
{
|
{
|
||||||
const Block& block = data.wireEncode();
|
const Block& block = data.wireEncode();
|
||||||
std::string expected(reinterpret_cast<const char*>(block.wire()), block.size());
|
std::string expected(reinterpret_cast<const char*>(block.data()), block.size());
|
||||||
BOOST_CHECK(output.is_equal(expected));
|
BOOST_CHECK(output.is_equal(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ public:
|
|||||||
checkOutput(output_test_stream& output, const lp::Nack& nack)
|
checkOutput(output_test_stream& output, const lp::Nack& nack)
|
||||||
{
|
{
|
||||||
const Block& block = nack.getHeader().wireEncode();
|
const Block& block = nack.getHeader().wireEncode();
|
||||||
std::string expected(reinterpret_cast<const char*>(block.wire()), block.size());
|
std::string expected(reinterpret_cast<const char*>(block.data()), block.size());
|
||||||
BOOST_CHECK(output.is_equal(expected));
|
BOOST_CHECK(output.is_equal(expected));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(NoTimeout)
|
|||||||
{
|
{
|
||||||
auto options = makeDefaultOptions();
|
auto options = makeDefaultOptions();
|
||||||
options.interestLifetime = 1_s;
|
options.interestLifetime = 1_s;
|
||||||
options.timeout = nullopt;
|
options.timeout = std::nullopt;
|
||||||
initialize(options);
|
initialize(options);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
|
BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <ndn-cxx/encoding/tlv.hpp>
|
#include <ndn-cxx/encoding/tlv.hpp>
|
||||||
#include <ndn-cxx/name-component.hpp>
|
#include <ndn-cxx/util/string-helper.hpp>
|
||||||
|
|
||||||
namespace ndn::dissect {
|
namespace ndn::dissect {
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ Dissector::printBlock(const Block& block)
|
|||||||
const auto& elements = block.elements();
|
const auto& elements = block.elements();
|
||||||
if (elements.empty()) {
|
if (elements.empty()) {
|
||||||
m_out << " [[";
|
m_out << " [[";
|
||||||
name::Component(block.value(), block.value_size()).toUri(m_out);
|
escape(m_out, reinterpret_cast<const char*>(block.value()), block.value_size());
|
||||||
m_out << "]]";
|
m_out << "]]";
|
||||||
}
|
}
|
||||||
m_out << "\n";
|
m_out << "\n";
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public: // options
|
|||||||
std::string interface;
|
std::string interface;
|
||||||
std::string inputFile;
|
std::string inputFile;
|
||||||
std::string pcapFilter{getDefaultPcapFilter()};
|
std::string pcapFilter{getDefaultPcapFilter()};
|
||||||
optional<std::regex> nameFilter;
|
std::optional<std::regex> nameFilter;
|
||||||
bool wantPromisc = true;
|
bool wantPromisc = true;
|
||||||
bool wantTimestamp = true;
|
bool wantTimestamp = true;
|
||||||
bool wantVerbose = false;
|
bool wantVerbose = false;
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ NdnPeek::createInterest() const
|
|||||||
interest.setMustBeFresh(m_options.mustBeFresh);
|
interest.setMustBeFresh(m_options.mustBeFresh);
|
||||||
interest.setForwardingHint(m_options.forwardingHint);
|
interest.setForwardingHint(m_options.forwardingHint);
|
||||||
interest.setInterestLifetime(m_options.interestLifetime);
|
interest.setInterestLifetime(m_options.interestLifetime);
|
||||||
interest.setHopLimit(m_options.hopLimit);
|
if (m_options.hopLimit) {
|
||||||
|
interest.setHopLimit(*m_options.hopLimit);
|
||||||
|
}
|
||||||
if (m_options.applicationParameters) {
|
if (m_options.applicationParameters) {
|
||||||
interest.setApplicationParameters(m_options.applicationParameters);
|
interest.setApplicationParameters(m_options.applicationParameters);
|
||||||
}
|
}
|
||||||
@@ -76,6 +78,12 @@ NdnPeek::createInterest() const
|
|||||||
return interest;
|
return interest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
writeToCout(span<const uint8_t> bytes)
|
||||||
|
{
|
||||||
|
std::cout.write(reinterpret_cast<const char*>(bytes.data()), bytes.size());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NdnPeek::onData(const Data& data)
|
NdnPeek::onData(const Data& data)
|
||||||
{
|
{
|
||||||
@@ -89,12 +97,10 @@ NdnPeek::onData(const Data& data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_options.wantPayloadOnly) {
|
if (m_options.wantPayloadOnly) {
|
||||||
const Block& block = data.getContent();
|
writeToCout(data.getContent().value_bytes());
|
||||||
std::cout.write(reinterpret_cast<const char*>(block.value()), block.value_size());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const Block& block = data.wireEncode();
|
writeToCout(data.wireEncode());
|
||||||
std::cout.write(reinterpret_cast<const char*>(block.wire()), block.size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +110,7 @@ NdnPeek::onNack(const lp::Nack& nack)
|
|||||||
m_result = Result::NACK;
|
m_result = Result::NACK;
|
||||||
m_timeoutEvent.cancel();
|
m_timeoutEvent.cancel();
|
||||||
|
|
||||||
lp::NackHeader header = nack.getHeader();
|
const auto& header = nack.getHeader();
|
||||||
if (m_options.isVerbose) {
|
if (m_options.isVerbose) {
|
||||||
std::cerr << "NACK: " << header.getReason() << "\nRTT: "
|
std::cerr << "NACK: " << header.getReason() << "\nRTT: "
|
||||||
<< time::duration_cast<time::milliseconds>(time::steady_clock::now() - m_sendTime).count()
|
<< time::duration_cast<time::milliseconds>(time::steady_clock::now() - m_sendTime).count()
|
||||||
@@ -115,8 +121,7 @@ NdnPeek::onNack(const lp::Nack& nack)
|
|||||||
std::cout << header.getReason() << std::endl;
|
std::cout << header.getReason() << std::endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const Block& block = header.wireEncode();
|
writeToCout(header.wireEncode());
|
||||||
std::cout.write(reinterpret_cast<const char*>(block.wire()), block.size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ struct PeekOptions
|
|||||||
bool mustBeFresh = false;
|
bool mustBeFresh = false;
|
||||||
std::vector<Name> forwardingHint;
|
std::vector<Name> forwardingHint;
|
||||||
time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME;
|
time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME;
|
||||||
optional<uint8_t> hopLimit;
|
std::optional<uint8_t> hopLimit;
|
||||||
shared_ptr<Buffer> applicationParameters;
|
shared_ptr<Buffer> applicationParameters;
|
||||||
|
|
||||||
// program behavior options
|
// program behavior options
|
||||||
bool isVerbose = false;
|
bool isVerbose = false;
|
||||||
bool wantPayloadOnly = false;
|
bool wantPayloadOnly = false;
|
||||||
optional<time::milliseconds> timeout;
|
std::optional<time::milliseconds> timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NdnPeek : noncopyable
|
class NdnPeek : noncopyable
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ struct PokeOptions
|
|||||||
// program behavior options
|
// program behavior options
|
||||||
bool isVerbose = false;
|
bool isVerbose = false;
|
||||||
bool wantUnsolicited = false;
|
bool wantUnsolicited = false;
|
||||||
optional<time::milliseconds> timeout;
|
std::optional<time::milliseconds> timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NdnPoke : noncopyable
|
class NdnPoke : noncopyable
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ def configure(conf):
|
|||||||
|
|
||||||
conf.env.WITH_TESTS = conf.options.with_tests
|
conf.env.WITH_TESTS = conf.options.with_tests
|
||||||
|
|
||||||
conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX',
|
pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
|
||||||
pkg_config_path=os.environ.get('PKG_CONFIG_PATH', '%s/pkgconfig' % conf.env.LIBDIR))
|
conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.0', '--cflags', '--libs'],
|
||||||
|
uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
|
||||||
|
|
||||||
boost_libs = ['system', 'program_options', 'filesystem']
|
boost_libs = ['system', 'program_options', 'filesystem']
|
||||||
if conf.env.WITH_TESTS:
|
if conf.env.WITH_TESTS:
|
||||||
|
|||||||
Reference in new issue
Block a user