Replace ndnsType with NdnsContentType
Change-Id: I74afe92d31e78d80404816113063d7f996d666c5
diff --git a/src/daemon/name-server.cpp b/src/daemon/name-server.cpp
index ab3356c..70288ec 100644
--- a/src/daemon/name-server.cpp
+++ b/src/daemon/name-server.cpp
@@ -103,14 +103,11 @@
}
else {
// no record, construct NACK
- Block block = makeNonNegativeIntegerBlock(tlv::NdnsType, NDNS_NACK);
- MetaInfo info;
- info.addAppMetaInfo(block);
- info.setFreshnessPeriod(this->getContentFreshness());
Name name = interest.getName();
name.appendVersion();
shared_ptr<Data> answer = make_shared<Data>(name);
- answer->setMetaInfo(info);
+ answer->setFreshnessPeriod(this->getContentFreshness());
+ answer->setContentType(NDNS_NACK);
m_keyChain.sign(*answer, m_certName);
NDNS_LOG_TRACE("answer query with NDNS-NACK: " << answer->getName());
@@ -168,14 +165,11 @@
rrset.setLabel(re.rrLabel);
rrset.setType(re.rrType);
- Block ndnsType = makeNonNegativeIntegerBlock(::ndn::ndns::tlv::NdnsType, NDNS_RESP);
- MetaInfo info;
- info.addAppMetaInfo(ndnsType);
- info.setFreshnessPeriod(this->getContentFreshness());
Name name = interest->getName();
name.appendVersion();
shared_ptr<Data> answer = make_shared<Data>(name);
- answer->setMetaInfo(info);
+ answer->setFreshnessPeriod(this->getContentFreshness());
+ answer->setContentType(NDNS_RESP);
Block blk(ndn::ndns::tlv::RrData);
try {
diff --git a/src/daemon/rrset-factory.cpp b/src/daemon/rrset-factory.cpp
index b1bbf90..a75c650 100644
--- a/src/daemon/rrset-factory.cpp
+++ b/src/daemon/rrset-factory.cpp
@@ -153,7 +153,7 @@
link.addDelegation(i.first, i.second);
}
- setMetaInfo(link);
+ setContentType(link, NDNS_LINK, ttl);
sign(link);
rrset.setData(link.wireEncode());
@@ -188,7 +188,7 @@
Data data(name);
data.setContent(wireEncode(rrs));
- setMetaInfo(data);
+ setContentType(data, NDNS_RESP, ttl);
sign(data);
rrset.setData(data.wireEncode());
@@ -216,7 +216,7 @@
Data data(name);
data.setContent(cert.wireEncode());
- setMetaInfo(data);
+ setContentType(data, NDNS_BLOB, ttl);
sign(data);
rrset.setData(data.wireEncode());
@@ -231,12 +231,11 @@
}
void
-RrsetFactory::setMetaInfo(Data& data)
+RrsetFactory::setContentType(Data& data, NdnsContentType contentType,
+ const time::seconds& ttl)
{
- MetaInfo metaInfo = data.getMetaInfo();
- metaInfo.addAppMetaInfo(makeNonNegativeIntegerBlock(ndns::tlv::NdnsType,
- NDNS_RESP));
- data.setMetaInfo(metaInfo);
+ data.setContentType(contentType);
+ data.setFreshnessPeriod(ttl);
}
template<encoding::Tag TAG>
@@ -273,7 +272,7 @@
std::vector<std::string> txts;
wire.parse();
- for (const auto& e: wire.elements()) {
+ for (const auto& e : wire.elements()) {
txts.push_back(std::string(reinterpret_cast<const char*>(e.value()),
e.value_size()));
}
diff --git a/src/daemon/rrset-factory.hpp b/src/daemon/rrset-factory.hpp
index 732f0a7..8318bb8 100644
--- a/src/daemon/rrset-factory.hpp
+++ b/src/daemon/rrset-factory.hpp
@@ -24,6 +24,7 @@
#include "rrset.hpp"
#include "logger.hpp"
#include "daemon/db-mgr.hpp"
+#include "ndns-enum.hpp"
#include <ndn-cxx/link.hpp>
#include <ndn-cxx/security/key-chain.hpp>
@@ -106,8 +107,8 @@
void
sign(Data& data);
- void
- setMetaInfo(Data& data);
+ void setContentType(Data& data, NdnsContentType contentType,
+ const time::seconds& ttl);
private:
KeyChain& m_keyChain;