dissect+peek: avoid deprecated ndn-cxx functions

Change-Id: Ibd9f8ad30e315f537d1560db823372af3d58d713
This commit is contained in:
Davide Pesavento committed 2022-03-12 16:08:34 -05:00
1 parent 96412a18d8
commit 242d5063f7
9 files changed
+28 -21

No files matched your search

+1
View File
@@ -44,6 +44,7 @@
#include <iostream>
#include <limits>
#include <memory>
#include <optional>
#include <stdexcept>
#include <string>
#include <string_view>
+2 -2
View File
@@ -63,8 +63,8 @@ protected:
util::DummyClientFace face{m_io};
Options opt;
unique_ptr<DiscoverVersion> discover;
optional<Name> discoveredName;
optional<uint64_t> discoveredVersion;
std::optional<Name> discoveredName;
std::optional<uint64_t> discoveredVersion;
bool isDiscoveryFinished = false;
};
+3 -3
View File
@@ -86,7 +86,7 @@ public:
checkOutput(output_test_stream& output, const Data& data)
{
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));
}
@@ -94,7 +94,7 @@ public:
checkOutput(output_test_stream& output, const lp::Nack& nack)
{
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));
}
};
@@ -252,7 +252,7 @@ BOOST_AUTO_TEST_CASE(NoTimeout)
{
auto options = makeDefaultOptions();
options.interestLifetime = 1_s;
options.timeout = nullopt;
options.timeout = std::nullopt;
initialize(options);
BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
+2 -2
View File
@@ -27,7 +27,7 @@
#include <map>
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/name-component.hpp>
#include <ndn-cxx/util/string-helper.hpp>
namespace ndn::dissect {
@@ -168,7 +168,7 @@ Dissector::printBlock(const Block& block)
const auto& elements = block.elements();
if (elements.empty()) {
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 << "\n";
+1 -1
View File
@@ -105,7 +105,7 @@ public: // options
std::string interface;
std::string inputFile;
std::string pcapFilter{getDefaultPcapFilter()};
optional<std::regex> nameFilter;
std::optional<std::regex> nameFilter;
bool wantPromisc = true;
bool wantTimestamp = true;
bool wantVerbose = false;
+13 -8
View File
@@ -64,7 +64,9 @@ NdnPeek::createInterest() const
interest.setMustBeFresh(m_options.mustBeFresh);
interest.setForwardingHint(m_options.forwardingHint);
interest.setInterestLifetime(m_options.interestLifetime);
interest.setHopLimit(m_options.hopLimit);
if (m_options.hopLimit) {
interest.setHopLimit(*m_options.hopLimit);
}
if (m_options.applicationParameters) {
interest.setApplicationParameters(m_options.applicationParameters);
}
@@ -76,6 +78,12 @@ NdnPeek::createInterest() const
return interest;
}
static void
writeToCout(span<const uint8_t> bytes)
{
std::cout.write(reinterpret_cast<const char*>(bytes.data()), bytes.size());
}
void
NdnPeek::onData(const Data& data)
{
@@ -89,12 +97,10 @@ NdnPeek::onData(const Data& data)
}
if (m_options.wantPayloadOnly) {
const Block& block = data.getContent();
std::cout.write(reinterpret_cast<const char*>(block.value()), block.value_size());
writeToCout(data.getContent().value_bytes());
}
else {
const Block& block = data.wireEncode();
std::cout.write(reinterpret_cast<const char*>(block.wire()), block.size());
writeToCout(data.wireEncode());
}
}
@@ -104,7 +110,7 @@ NdnPeek::onNack(const lp::Nack& nack)
m_result = Result::NACK;
m_timeoutEvent.cancel();
lp::NackHeader header = nack.getHeader();
const auto& header = nack.getHeader();
if (m_options.isVerbose) {
std::cerr << "NACK: " << header.getReason() << "\nRTT: "
<< 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;
}
else {
const Block& block = header.wireEncode();
std::cout.write(reinterpret_cast<const char*>(block.wire()), block.size());
writeToCout(header.wireEncode());
}
}
+2 -2
View File
@@ -48,13 +48,13 @@ struct PeekOptions
bool mustBeFresh = false;
std::vector<Name> forwardingHint;
time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME;
optional<uint8_t> hopLimit;
std::optional<uint8_t> hopLimit;
shared_ptr<Buffer> applicationParameters;
// program behavior options
bool isVerbose = false;
bool wantPayloadOnly = false;
optional<time::milliseconds> timeout;
std::optional<time::milliseconds> timeout;
};
class NdnPeek : noncopyable
+1 -1
View File
@@ -49,7 +49,7 @@ struct PokeOptions
// program behavior options
bool isVerbose = false;
bool wantUnsolicited = false;
optional<time::milliseconds> timeout;
std::optional<time::milliseconds> timeout;
};
class NdnPoke : noncopyable
+3 -2
View File
@@ -27,8 +27,9 @@ def configure(conf):
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', '%s/pkgconfig' % conf.env.LIBDIR))
pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
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']
if conf.env.WITH_TESTS: