Avoid deprecated ndn-cxx functions
Change-Id: I5d9ac045740267db783ff724c938b659b49c40ee
This commit is contained in:
1 parent
ed0017bd07
commit
5998428e9c
7 files changed
+33
-37
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2020, Regents of the University of California,
|
||||
* Copyright (c) 2016-2022, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -75,8 +75,8 @@ BOOST_AUTO_TEST_CASE(InOrderData)
|
||||
output.flush();
|
||||
|
||||
auto data = makeData(Name(name).appendVersion(1).appendSegment(i));
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(testStrings[i].data()),
|
||||
testStrings[i].size());
|
||||
data->setContent(make_span(reinterpret_cast<const uint8_t*>(testStrings[i].data()),
|
||||
testStrings[i].size()));
|
||||
|
||||
cons.m_bufferedData[i] = data;
|
||||
cons.writeInOrderData();
|
||||
@@ -109,8 +109,8 @@ BOOST_AUTO_TEST_CASE(OutOfOrderData)
|
||||
|
||||
for (size_t i = 0; i < testStrings.size(); ++i) {
|
||||
auto data = makeData(Name(name).appendVersion(1).appendSegment(i));
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(testStrings[i].data()),
|
||||
testStrings[i].size());
|
||||
data->setContent(make_span(reinterpret_cast<const uint8_t*>(testStrings[i].data()),
|
||||
testStrings[i].size()));
|
||||
|
||||
dataStore.push_back(data);
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2020, University of Memphis,
|
||||
* Copyright (c) 2014-2022, University of Memphis,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
* This file is part of ndn-tools (Named Data Networking Essential Tools).
|
||||
@@ -87,9 +87,9 @@ protected:
|
||||
ethernet::Address host;
|
||||
|
||||
// Ethernet header
|
||||
buffer.prependByteArray(reinterpret_cast<const uint8_t*>(ðertype), ethernet::TYPE_LEN);
|
||||
buffer.prependByteArray(host.data(), host.size());
|
||||
buffer.prependByteArray(host.data(), host.size());
|
||||
buffer.prependBytes({reinterpret_cast<const uint8_t*>(ðertype), ethernet::TYPE_LEN});
|
||||
buffer.prependBytes(host);
|
||||
buffer.prependBytes(host);
|
||||
|
||||
// pcap header
|
||||
pcap_pkthdr pkthdr{};
|
||||
@@ -97,28 +97,28 @@ protected:
|
||||
|
||||
{
|
||||
StdCoutRedirector redirect(output);
|
||||
dump.printPacket(&pkthdr, buffer.buf());
|
||||
dump.printPacket(&pkthdr, buffer.data());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
receiveIp4(EncodingBuffer& buffer, const ip* ipHeader)
|
||||
{
|
||||
buffer.prependByteArray(reinterpret_cast<const uint8_t*>(ipHeader), sizeof(ip));
|
||||
buffer.prependBytes({reinterpret_cast<const uint8_t*>(ipHeader), sizeof(ip)});
|
||||
receiveEthernet(buffer, s_ethertypeIp4);
|
||||
}
|
||||
|
||||
void
|
||||
receiveIp6(EncodingBuffer& buffer, const ip6_hdr* ip6Header)
|
||||
{
|
||||
buffer.prependByteArray(reinterpret_cast<const uint8_t*>(ip6Header), sizeof(ip6_hdr));
|
||||
buffer.prependBytes({reinterpret_cast<const uint8_t*>(ip6Header), sizeof(ip6_hdr)});
|
||||
receiveEthernet(buffer, s_ethertypeIp6);
|
||||
}
|
||||
|
||||
void
|
||||
receiveTcp4(EncodingBuffer& buffer, const tcphdr* tcpHeader)
|
||||
{
|
||||
buffer.prependByteArray(reinterpret_cast<const uint8_t*>(tcpHeader), sizeof(tcphdr));
|
||||
buffer.prependBytes({reinterpret_cast<const uint8_t*>(tcpHeader), sizeof(tcphdr)});
|
||||
|
||||
ip ipHeader{};
|
||||
ipHeader.ip_v = 4;
|
||||
@@ -133,7 +133,7 @@ protected:
|
||||
void
|
||||
receiveUdp4(EncodingBuffer& buffer, const udphdr* udpHeader)
|
||||
{
|
||||
buffer.prependByteArray(reinterpret_cast<const uint8_t*>(udpHeader), sizeof(udphdr));
|
||||
buffer.prependBytes({reinterpret_cast<const uint8_t*>(udpHeader), sizeof(udphdr)});
|
||||
|
||||
ip ipHeader{};
|
||||
ipHeader.ip_v = 4;
|
||||
@@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE(IncompleteNdnPacket)
|
||||
0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
EncodingBuffer buffer;
|
||||
buffer.prependByteArray(interest, 4);
|
||||
buffer.prependBytes(make_span(interest).first(4));
|
||||
|
||||
this->receiveEthernet(buffer);
|
||||
BOOST_CHECK(output.is_equal("0.000000 Ethernet, NDN truncated packet, length 4\n"));
|
||||
@@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(MalformedIpv4Header)
|
||||
uint8_t theAnswer = 42;
|
||||
|
||||
EncodingBuffer pkt1;
|
||||
pkt1.prependByte(theAnswer);
|
||||
pkt1.prependBytes({theAnswer});
|
||||
this->receiveEthernet(pkt1, s_ethertypeIp4);
|
||||
BOOST_CHECK(output.is_equal("IP truncated header, length 1\n"));
|
||||
|
||||
@@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(MalformedIpv6Header)
|
||||
uint8_t theAnswer = 42;
|
||||
|
||||
EncodingBuffer pkt1;
|
||||
pkt1.prependByte(theAnswer);
|
||||
pkt1.prependBytes({theAnswer});
|
||||
this->receiveEthernet(pkt1, s_ethertypeIp6);
|
||||
BOOST_CHECK(output.is_equal("IP6 truncated header, length 1\n"));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2020, Regents of the University of California.
|
||||
* Copyright (c) 2014-2022, Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-tools (Named Data Networking Essential Tools).
|
||||
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
|
||||
@@ -54,7 +54,7 @@ KeyChainFixture::makeCert(const Key& key, const std::string& issuer, const Key&
|
||||
cert.setFreshnessPeriod(1_h);
|
||||
|
||||
// set content
|
||||
cert.setContent(key.getPublicKey().data(), key.getPublicKey().size());
|
||||
cert.setContent(key.getPublicKey());
|
||||
|
||||
// set signature info
|
||||
ndn::SignatureInfo info;
|
||||
|
||||
@@ -143,8 +143,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Default, OutputCheck, OutputChecks)
|
||||
initialize(options);
|
||||
|
||||
auto data = makeData(options.name);
|
||||
const std::string payload = "NdnPeekTest";
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(payload.data()), payload.size());
|
||||
data->setContent({'n', 'd', 'n', 'p', 'e', 'e', 'k'});
|
||||
|
||||
{
|
||||
CoutRedirector redir(output);
|
||||
@@ -177,8 +176,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NonDefault, OutputCheck, OutputChecks)
|
||||
|
||||
auto data = makeData(Name(options.name).append("suffix"));
|
||||
data->setFreshnessPeriod(1_s);
|
||||
const std::string payload = "NdnPeekTest";
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(payload.data()), payload.size());
|
||||
data->setContent({'n', 'd', 'n', 'p', 'e', 'e', 'k'});
|
||||
|
||||
{
|
||||
CoutRedirector redir(output);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2021, Regents of the University of California,
|
||||
* Copyright (c) 2016-2022, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -41,7 +41,7 @@ Producer::Producer(const Name& prefix, Face& face, KeyChain& keyChain, std::istr
|
||||
, m_keyChain(keyChain)
|
||||
, m_options(opts)
|
||||
{
|
||||
if (prefix.size() > 0 && prefix[-1].isVersion()) {
|
||||
if (!prefix.empty() && prefix[-1].isVersion()) {
|
||||
m_prefix = prefix.getPrefix(-1);
|
||||
m_versionedPrefix = prefix;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ Producer::processDiscoveryInterest(const Interest& interest)
|
||||
void
|
||||
Producer::processSegmentInterest(const Interest& interest)
|
||||
{
|
||||
BOOST_ASSERT(m_store.size() > 0);
|
||||
BOOST_ASSERT(!m_store.empty());
|
||||
|
||||
if (m_options.isVerbose)
|
||||
std::cerr << "Interest: " << interest << "\n";
|
||||
@@ -164,7 +164,7 @@ Producer::populateStore(std::istream& is)
|
||||
if (nCharsRead > 0) {
|
||||
auto data = make_shared<Data>(Name(m_versionedPrefix).appendSegment(m_store.size()));
|
||||
data->setFreshnessPeriod(m_options.freshnessPeriod);
|
||||
data->setContent(buffer.data(), static_cast<size_t>(nCharsRead));
|
||||
data->setContent(make_span(buffer).first(nCharsRead));
|
||||
m_store.push_back(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,8 +207,7 @@ NdnDump::printPacket(const pcap_pkthdr* pkthdr, const uint8_t* payload) const
|
||||
shouldPrint = printPpp(out, payload, pkthdr->len);
|
||||
break;
|
||||
default:
|
||||
BOOST_ASSERT(false);
|
||||
return;
|
||||
NDN_CXX_UNREACHABLE;
|
||||
}
|
||||
|
||||
if (shouldPrint) {
|
||||
@@ -220,9 +219,9 @@ NdnDump::printPacket(const pcap_pkthdr* pkthdr, const uint8_t* payload) const
|
||||
}
|
||||
|
||||
void
|
||||
NdnDump::printTimestamp(std::ostream& os, const timeval& tv) const
|
||||
NdnDump::printTimestamp(std::ostream& os, const timeval& tv)
|
||||
{
|
||||
/// \todo Add more timestamp formats (time since previous packet, time since first packet, ...)
|
||||
// TODO: Add more timestamp formats (time since previous packet, time since first packet, ...)
|
||||
os << tv.tv_sec
|
||||
<< "."
|
||||
<< std::setfill('0') << std::setw(6) << tv.tv_usec
|
||||
@@ -520,7 +519,7 @@ NdnDump::printNdn(OutputFormatter& out, const uint8_t* pkt, size_t len) const
|
||||
|
||||
bool isOk = false;
|
||||
Block block;
|
||||
std::tie(isOk, block) = Block::fromBuffer(pkt, len);
|
||||
std::tie(isOk, block) = Block::fromBuffer({pkt, len});
|
||||
if (!isOk) {
|
||||
// if packet is incomplete, we will not be able to process it
|
||||
out << "NDN truncated packet, length " << len;
|
||||
@@ -549,8 +548,7 @@ NdnDump::printNdn(OutputFormatter& out, const uint8_t* pkt, size_t len) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isOk = false;
|
||||
std::tie(isOk, netPacket) = Block::fromBuffer(&*begin, std::distance(begin, end));
|
||||
std::tie(isOk, netPacket) = Block::fromBuffer({begin, end});
|
||||
if (!isOk) {
|
||||
// if network packet is fragmented, we will not be able to process it
|
||||
out << " fragment";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2011-2019, Regents of the University of California.
|
||||
* Copyright (c) 2011-2022, Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-tools (Named Data Networking Essential Tools).
|
||||
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
|
||||
@@ -66,8 +66,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
printTimestamp(std::ostream& os, const timeval& tv) const;
|
||||
static void
|
||||
printTimestamp(std::ostream& os, const timeval& tv);
|
||||
|
||||
bool
|
||||
dispatchByEtherType(OutputFormatter& out, const uint8_t* pkt, size_t len, uint16_t etherType) const;
|
||||
|
||||
Reference in new issue
Block a user