Avoid using deprecated ndn-cxx functions
Change-Id: I51e0abcb7454e31efbcc779a17d2c490802108ec
diff --git a/src/clients/response.cpp b/src/clients/response.cpp
index 5f223d3..3da172b 100644
--- a/src/clients/response.cpp
+++ b/src/clients/response.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -26,7 +26,7 @@
Response::Response()
: m_contentType(NDNS_BLOB)
, m_freshnessPeriod(DEFAULT_RR_FRESHNESS_PERIOD)
- , m_appContent(makeBinaryBlock(ndn::tlv::Content, reinterpret_cast<const uint8_t*>(0), 0))
+ , m_appContent(makeEmptyBlock(ndn::tlv::Content))
{
}
@@ -35,12 +35,12 @@
, m_queryType(queryType)
, m_contentType(NDNS_BLOB)
, m_freshnessPeriod(DEFAULT_RR_FRESHNESS_PERIOD)
- , m_appContent(makeBinaryBlock(ndn::tlv::Content, reinterpret_cast<const uint8_t*>(0), 0))
+ , m_appContent(makeEmptyBlock(ndn::tlv::Content))
{
}
template<encoding::Tag T>
-inline size_t
+size_t
Response::wireEncode(EncodingImpl<T>& block) const
{
if (m_contentType == NDNS_BLOB || m_contentType == NDNS_KEY) {
@@ -52,8 +52,7 @@
// Block*
size_t totalLength = 0;
- for (std::vector<Block>::const_reverse_iterator iter = m_rrs.rbegin();
- iter != m_rrs.rend(); ++iter) {
+ for (auto iter = m_rrs.rbegin(); iter != m_rrs.rend(); ++iter) {
totalLength += block.prependBlock(*iter);
}
@@ -176,7 +175,7 @@
bool
Response::removeRr(const Block& rr)
{
- for (std::vector<Block>::iterator iter = m_rrs.begin(); iter != m_rrs.end(); ++iter) {
+ for (auto iter = m_rrs.begin(); iter != m_rrs.end(); ++iter) {
if (*iter == rr) {
m_rrs.erase(iter);
return true;
@@ -207,14 +206,13 @@
getRrType() == other.getRrType() && getVersion() == other.getVersion() &&
getContentType() == other.getContentType());
- if (tmp == false)
- return tmp;
+ if (!tmp)
+ return false;
- if (m_contentType == NDNS_BLOB || m_contentType == NDNS_KEY) {
- return tmp && (getAppContent() == other.getAppContent());
- }
+ if (m_contentType == NDNS_BLOB || m_contentType == NDNS_KEY)
+ return getAppContent() == other.getAppContent();
else
- return tmp && getRrs() == other.getRrs();
+ return getRrs() == other.getRrs();
}
std::ostream&
@@ -229,15 +227,16 @@
<< " NdnsContentType=" << response.getContentType();
if (response.getContentType() == NDNS_BLOB
|| response.getContentType() == NDNS_KEY) {
- if (response.getAppContent().empty())
- os << " appContent=NULL";
- else
+ if (response.getAppContent().isValid())
os << " appContentSize=" << response.getAppContent().size();
+ else
+ os << " appContent=NULL";
}
else {
os << " rrs.size=" << response.getRrs().size();
}
return os;
}
+
} // namespace ndns
} // namespace ndn
diff --git a/src/mgmt/management-tool.cpp b/src/mgmt/management-tool.cpp
index 3832561..3119840 100644
--- a/src/mgmt/management-tool.cpp
+++ b/src/mgmt/management-tool.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -447,7 +447,7 @@
os << "; rrset=" << rrset.getLabel().toUri()
<< " type=" << rrset.getType().toUri()
<< " version=" << rrset.getVersion().toUri()
- << " signed-by=" << data.getSignature().getKeyLocator().getName().toUri()
+ << " signed-by=" << data.getKeyLocator()->getName().toUri()
<< std::endl;
}
@@ -494,7 +494,7 @@
os.width();
os << "; content-type=" << re.getContentType()
<< " version=" << rrset.getVersion().toUri()
- << " signed-by=" << data.getSignature().getKeyLocator().getName().toUri();
+ << " signed-by=" << data.getKeyLocator()->getName().toUri();
os << std::endl;
if (printRaw && (re.getContentType() == NDNS_BLOB
diff --git a/src/util/util.cpp b/src/util/util.cpp
index 7d350a5..8466733 100644
--- a/src/util/util.cpp
+++ b/src/util/util.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -64,8 +64,11 @@
bufferSource(block.wire(), block.size()) >> base64Encode() >> streamSink(os);
}
else {
- os << "Name: " << data.getName().toUri() << std::endl;
- os << "KeyLocator: " << data.getSignature().getKeyLocator().getName().toUri() << std::endl;
+ os << "Name: " << data.getName() << std::endl;
+ auto kl = data.getKeyLocator();
+ if (kl) {
+ os << "KeyLocator: " << kl->getName() << std::endl;
+ }
bufferSource(block.wire(), block.size()) >> base64Encode() >> streamSink(os);
os << std::endl;
}
diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
index ab60698..64a9a97 100644
--- a/tests/identity-management-fixture.cpp
+++ b/tests/identity-management-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -93,7 +93,7 @@
v2::AdditionalDescription description;
description.set("type", "sub-certificate");
- info.appendTypeSpecificTlv(description.wireEncode());
+ info.addCustomTlv(description.wireEncode());
m_keyChain.sign(request, signingByIdentity(issuer).setSignatureInfo(info));
m_keyChain.setDefaultCertificate(subIdentity.getDefaultKey(), request);
diff --git a/tests/unit/daemon/name-server.cpp b/tests/unit/daemon/name-server.cpp
index dae6685..76daa2f 100644
--- a/tests/unit/daemon/name-server.cpp
+++ b/tests/unit/daemon/name-server.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -285,7 +285,7 @@
m_keyChain.setDefaultCertificate(dsk, dskCert);
NDNS_LOG_TRACE("KeyChain: add cert: " << dskCert.getName() << ". KeyLocator: "
- << dskCert.getSignature().getKeyLocator().getName());
+ << dskCert.getKeyLocator()->getName());
Rrset rrset(&m_test);
Name label = dskCert.getName().getPrefix(-2).getSubName(m_test.getName().size() + 1);
@@ -324,7 +324,7 @@
bool hasDataBack = false;
// no data back, since the Update cannot pass verification
- face.onSendData.connectSingleShot([&] (const Data& data) {
+ face.onSendData.connectSingleShot([&] (const Data&) {
hasDataBack = true;
BOOST_FAIL("UNEXPECTED");
});
diff --git a/tools/ndns-update.cpp b/tools/ndns-update.cpp
index 2a454f8..91c3ea1 100644
--- a/tools/ndns-update.cpp
+++ b/tools/ndns-update.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California.
+ * Copyright (c) 2014-2020, Regents of the University of California.
*
* This file is part of NDNS (Named Data Networking Domain Name Service).
* See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -68,9 +68,7 @@
<< "start to update RR at Zone = " << this->m_zone
<< " new RR is: " << m_update->getName()
<<" =================== ");
-
- NDNS_LOG_INFO("new RR is signed by: "
- << m_update->getSignature().getKeyLocator().getName());
+ NDNS_LOG_INFO("new RR is signed by: " << m_update->getKeyLocator()->getName());
Interest interest = this->makeUpdateInterest();
NDNS_LOG_TRACE("[* <- *] send Update: " << m_update->getName().toUri());
@@ -89,7 +87,7 @@
private:
void
- onData(const Interest& interest, const Data& data)
+ onData(const Interest&, const Data& data)
{
NDNS_LOG_INFO("get response of Update");
int ret = -1;
@@ -106,9 +104,8 @@
NDNS_LOG_INFO("to verify the response");
m_validator->validate(data,
- bind(&NdnsUpdate::onDataValidated, this, _1),
- bind(&NdnsUpdate::onDataValidationFailed, this, _1, _2)
- );
+ bind(&NdnsUpdate::onDataValidated, this, _1),
+ bind(&NdnsUpdate::onDataValidationFailed, this, _1, _2));
}
std::tuple<int, std::string>
@@ -120,7 +117,7 @@
blk.parse();
Block block = blk.blockFromValue();
block.parse();
- Block::element_const_iterator val = block.elements_begin();
+ auto val = block.elements_begin();
for (; val != block.elements_end(); ++val) {
if (val->type() == ndns::tlv::UpdateReturnCode) { // the first must be return code
ret = readNonNegativeInteger(*val);
@@ -149,22 +146,22 @@
private:
void
- onTimeout(const ndn::Interest& interest)
+ onTimeout(const ndn::Interest&)
{
- NDNS_LOG_TRACE("Update timeouts");
+ NDNS_LOG_TRACE("Update timeout");
m_hasError = true;
this->stop();
}
void
- onDataValidated(const Data& data)
+ onDataValidated(const Data&)
{
NDNS_LOG_INFO("data pass verification");
this->stop();
}
void
- onDataValidationFailed(const Data& data, const security::v2::ValidationError& str)
+ onDataValidationFailed(const Data&, const security::v2::ValidationError&)
{
NDNS_LOG_INFO("data does not pass verification");
m_hasError = true;
@@ -172,7 +169,6 @@
}
public:
-
void
setInterestLifetime(const time::milliseconds& interestLifetime)
{