dissect+peek: avoid deprecated ndn-cxx functions
Change-Id: Ibd9f8ad30e315f537d1560db823372af3d58d713
diff --git a/tools/peek/ndnpeek/ndnpeek.cpp b/tools/peek/ndnpeek/ndnpeek.cpp
index d58b92e..3fb540f 100644
--- a/tools/peek/ndnpeek/ndnpeek.cpp
+++ b/tools/peek/ndnpeek/ndnpeek.cpp
@@ -64,7 +64,9 @@
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 @@
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 @@
}
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 @@
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 @@
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());
}
}