Replace ndnsType with NdnsContentType
Change-Id: I74afe92d31e78d80404816113063d7f996d666c5
diff --git a/src/clients/iterative-query-controller.cpp b/src/clients/iterative-query-controller.cpp
index 6bd99bd..899a35c 100644
--- a/src/clients/iterative-query-controller.cpp
+++ b/src/clients/iterative-query-controller.cpp
@@ -63,20 +63,16 @@
void
IterativeQueryController::onData(const ndn::Interest& interest, const Data& data)
{
- NdnsType ndnsType = NDNS_RAW;
- const Block* block = data.getMetaInfo().findAppMetaInfo(ndns::tlv::NdnsType);
- if (block != nullptr) {
- ndnsType = static_cast<NdnsType>(readNonNegativeInteger(*block));
- }
+ NdnsContentType contentType = NdnsContentType(data.getContentType());
- NDNS_LOG_TRACE("[* -> *] get a " << ndnsType
+ NDNS_LOG_TRACE("[* -> *] get a " << contentType
<< " Response: " << data.getName());
if (m_validator == nullptr) {
- this->onDataValidated(make_shared<Data>(data), ndnsType);
+ this->onDataValidated(make_shared<Data>(data), contentType);
}
else {
m_validator->validate(data,
- bind(&IterativeQueryController::onDataValidated, this, _1, ndnsType),
+ bind(&IterativeQueryController::onDataValidated, this, _1, contentType),
[this] (const shared_ptr<const Data>& data, const std::string& str) {
NDNS_LOG_WARN("data: " << data->getName() << " fails verification");
this->abort();
@@ -85,22 +81,22 @@
}
}
void
-IterativeQueryController::onDataValidated(const shared_ptr<const Data>& data, NdnsType ndnsType)
+IterativeQueryController::onDataValidated(const shared_ptr<const Data>& data, NdnsContentType contentType)
{
switch (m_step) {
case QUERY_STEP_QUERY_NS:
- if (ndnsType == NDNS_NACK) {
+ if (contentType == NDNS_NACK) {
m_step = QUERY_STEP_QUERY_RR;
}
- else if (ndnsType == NDNS_RESP) {
- if (m_rrType == label::NS_RR_TYPE) {
- Link link(data->wireEncode());
- if (link.getDelegations().empty()) {
- m_lastLink = Block();
- } else {
- m_lastLink = data->wireEncode();
- }
+ else if (contentType == NDNS_LINK) {
+ Link link(data->wireEncode());
+ if (link.getDelegations().empty()) {
+ m_lastLink = Block();
+ } else {
+ m_lastLink = data->wireEncode();
}
+
+ // for NS query, if already received, just return, instead of more queries until NACK
if (m_nFinishedComps + m_nTryComps == m_dstLabel.size() && m_rrType == label::NS_RR_TYPE) {
// NS_RR_TYPE is different, since its record is stored at higher level
m_step = QUERY_STEP_ANSWER_STUB;
@@ -110,13 +106,17 @@
m_nTryComps = 1;
}
}
- else if (ndnsType == NDNS_AUTH) {
+ else if (contentType == NDNS_AUTH) {
m_nTryComps += 1;
}
- else if (ndnsType == NDNS_RAW) {
+ else if (contentType == NDNS_BLOB) {
std::ostringstream oss;
oss << *this;
- NDNS_LOG_WARN("get unexpected Response: NDNS_RAW for QUERY_NS: " << oss.str());
+ NDNS_LOG_WARN("get unexpected Response: NDNS_BLOB for QUERY_NS: " << oss.str());
+ } else {
+ std::ostringstream oss;
+ oss << *this;
+ NDNS_LOG_WARN("get unexpected Response for QUERY_NS: " << oss.str());
}
//
if (m_nFinishedComps + m_nTryComps > m_dstLabel.size()) {
diff --git a/src/clients/iterative-query-controller.hpp b/src/clients/iterative-query-controller.hpp
index 8fc2a34..7f975da 100644
--- a/src/clients/iterative-query-controller.hpp
+++ b/src/clients/iterative-query-controller.hpp
@@ -78,7 +78,7 @@
onData(const ndn::Interest& interest, const Data& data);
void
- onDataValidated(const shared_ptr<const Data>& data, NdnsType ndnsType);
+ onDataValidated(const shared_ptr<const Data>& data, NdnsContentType contentType);
/**
* @brief change the Controller state according to timeout. For current,
diff --git a/src/clients/response.cpp b/src/clients/response.cpp
index fc14346..0bbc9de 100644
--- a/src/clients/response.cpp
+++ b/src/clients/response.cpp
@@ -24,7 +24,7 @@
namespace ndns {
Response::Response()
- : m_ndnsType(NDNS_RAW)
+ : m_contentType(NDNS_BLOB)
, m_freshnessPeriod(DEFAULT_RR_FRESHNESS_PERIOD)
, m_appContent(makeBinaryBlock(ndn::tlv::Content, reinterpret_cast<const uint8_t*>(0), 0))
{
@@ -33,7 +33,7 @@
Response::Response(const Name& zone, const name::Component& queryType)
: m_zone(zone)
, m_queryType(queryType)
- , m_ndnsType(NDNS_RAW)
+ , m_contentType(NDNS_BLOB)
, m_freshnessPeriod(DEFAULT_RR_FRESHNESS_PERIOD)
, m_appContent(makeBinaryBlock(ndn::tlv::Content, reinterpret_cast<const uint8_t*>(0), 0))
{
@@ -43,7 +43,7 @@
inline size_t
Response::wireEncode(EncodingImpl<T>& block) const
{
- if (m_ndnsType == NDNS_RAW) {
+ if (m_contentType == NDNS_BLOB) {
// Raw application content
return block.prependBlock(m_appContent);
}
@@ -66,7 +66,7 @@
const Block
Response::wireEncode() const
{
- if (m_ndnsType == NDNS_RAW) {
+ if (m_contentType == NDNS_BLOB) {
return m_appContent;
}
@@ -80,7 +80,7 @@
void
Response::wireDecode(const Block& wire)
{
- if (m_ndnsType == NDNS_RAW) {
+ if (m_contentType == NDNS_BLOB) {
m_appContent = wire;
return;
}
@@ -111,9 +111,7 @@
MetaInfo info = data.getMetaInfo();
m_freshnessPeriod = time::duration_cast<time::seconds>(info.getFreshnessPeriod());
- const Block* block = info.findAppMetaInfo(tlv::NdnsType);
- if (block != 0)
- m_ndnsType = static_cast<NdnsType>(readNonNegativeInteger(*block));
+ m_contentType = NdnsContentType(data.getContentType());
wireDecode(data.getContent());
return true;
@@ -139,17 +137,14 @@
shared_ptr<Data> data = make_shared<Data>(name);
- MetaInfo info;
- info.setFreshnessPeriod(m_freshnessPeriod);
-
- if (m_ndnsType != NDNS_RAW) {
- info.addAppMetaInfo(makeNonNegativeIntegerBlock(ndns::tlv::NdnsType, m_ndnsType));
+ if (m_contentType != NDNS_BLOB) {
data->setContent(this->wireEncode());
}
else {
data->setContent(m_appContent);
}
- data->setMetaInfo(info);
+ data->setFreshnessPeriod(m_freshnessPeriod);
+ data->setContentType(m_contentType);
return data;
}
@@ -198,12 +193,12 @@
bool tmp = (getZone() == other.getZone() &&
getQueryType() == other.getQueryType() && getRrLabel() == other.getRrLabel() &&
getRrType() == other.getRrType() && getVersion() == other.getVersion() &&
- getNdnsType() == other.getNdnsType());
+ getContentType() == other.getContentType());
if (tmp == false)
return tmp;
- if (m_ndnsType == NDNS_RAW) {
+ if (m_contentType == NDNS_BLOB) {
return tmp && (getAppContent() == other.getAppContent());
}
else
@@ -219,8 +214,8 @@
<< " rrType=" << response.getRrType()
<< " version=" << response.getVersion()
<< " freshnessPeriod=" << response.getFreshnessPeriod()
- << " ndnsType=" << response.getNdnsType();
- if (response.getNdnsType() == NDNS_RAW) {
+ << " NdnsContentType=" << response.getContentType();
+ if (response.getContentType() == NDNS_BLOB) {
if (response.getAppContent().empty())
os << " appContent=NULL";
else
diff --git a/src/clients/response.hpp b/src/clients/response.hpp
index c6a2779..9f2138f 100644
--- a/src/clients/response.hpp
+++ b/src/clients/response.hpp
@@ -177,15 +177,15 @@
}
void
- setNdnsType(NdnsType ndnsType)
+ setContentType(NdnsContentType contentType)
{
- m_ndnsType = ndnsType;
+ m_contentType = contentType;
}
- NdnsType
- getNdnsType() const
+ NdnsContentType
+ getContentType() const
{
- return m_ndnsType;
+ return m_contentType;
}
const Block&
@@ -228,7 +228,7 @@
name::Component m_rrType;
name::Component m_version;
- NdnsType m_ndnsType;
+ NdnsContentType m_contentType;
time::seconds m_freshnessPeriod;
/**
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;
diff --git a/src/mgmt/management-tool.cpp b/src/mgmt/management-tool.cpp
index dc3f971..0ddf57b 100644
--- a/src/mgmt/management-tool.cpp
+++ b/src/mgmt/management-tool.cpp
@@ -345,11 +345,11 @@
Data data(rrset.getData());
Response re;
re.fromData(zoneName, data);
- int iteration = re.getNdnsType() == NDNS_RAW || re.getNdnsType() == NDNS_AUTH ?
+ int iteration = re.getContentType() == NDNS_BLOB || re.getContentType() == NDNS_AUTH ?
1 : re.getRrs().size();
const std::vector<Block> &rrs = re.getRrs();
- if (re.getNdnsType() != NDNS_RAW) {
+ if (re.getContentType() != NDNS_BLOB) {
os << "; rrset=" << rrset.getLabel().toUri()
<< " type=" << rrset.getType().toUri()
<< " version=" << rrset.getVersion().toUri()
@@ -368,7 +368,7 @@
os.width(typeWidth + 2);
os << rrset.getType().toUri();
- if (re.getNdnsType() != NDNS_RAW) {
+ if (re.getContentType() != NDNS_BLOB) {
using namespace CryptoPP;
if (rrset.getType() == label::TXT_RR_TYPE) {
os.write(reinterpret_cast<const char*>(rrs[i].value()), rrs[i].value_size());
@@ -376,7 +376,7 @@
}
else if (rrset.getType() == label::NS_RR_TYPE) {
BOOST_ASSERT(iteration == 1);
- if (re.getNdnsType() == NDNS_AUTH) {
+ if (re.getContentType() == NDNS_AUTH) {
const std::string authStr = "NDNS-Auth";
os << authStr;
} else {
@@ -397,14 +397,14 @@
}
}
- if (re.getNdnsType() == NDNS_RAW) {
+ if (re.getContentType() == NDNS_BLOB) {
os.width();
- os << "; content-type=" << re.getNdnsType()
+ os << "; content-type=" << re.getContentType()
<< " version=" << rrset.getVersion().toUri()
<< " signed-by=" << data.getSignature().getKeyLocator().getName().toUri();
os << std::endl;
- if (printRaw && re.getNdnsType() == NDNS_RAW) {
+ if (printRaw && re.getContentType() == NDNS_BLOB) {
util::IndentedStream istream(os, "; ");
if (re.getRrType() == label::CERT_RR_TYPE) {
diff --git a/src/ndns-enum.cpp b/src/ndns-enum.cpp
index 45504fb..383eb95 100644
--- a/src/ndns-enum.cpp
+++ b/src/ndns-enum.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2016, 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.
@@ -23,20 +23,26 @@
namespace ndns {
std::ostream&
-operator<<(std::ostream& os, const NdnsType ndnsType)
+operator<<(std::ostream& os, const NdnsContentType ndnsType)
{
switch (ndnsType) {
- case NDNS_RESP:
- os << "NDNS-Resp";
+ case NDNS_BLOB:
+ os << "BLOB";
+ break;
+ case NDNS_LINK:
+ os << "LINK";
break;
case NDNS_NACK:
- os << "NDNS-Nack";
+ os << "NACK";
+ break;
+ case NDNS_KEY:
+ os << "KEY";
break;
case NDNS_AUTH:
os << "NDNS-Auth";
break;
- case NDNS_RAW:
- os << "NDNS-Raw";
+ case NDNS_RESP:
+ os << "NDNS-Resp";
break;
default:
os << "UNKNOWN";
diff --git a/src/ndns-enum.hpp b/src/ndns-enum.hpp
index 39e77b0..89ad87d 100644
--- a/src/ndns-enum.hpp
+++ b/src/ndns-enum.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2016, 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.
@@ -21,24 +21,26 @@
#define NDNS_NDNS_ENUM_HPP
#include <ostream>
+#include <ndn-cxx/encoding/tlv.hpp>
namespace ndn {
namespace ndns {
/**
- * @brief NdnsType defined in Response.NdnsMetaInfo.NdnsType
+ * @brief contentType of response
*/
-enum NdnsType {
- NDNS_RAW = 0, ///< this is not a real type, just mean that MetaInfo does not contain NdnsType
- NDNS_RESP = 1, ///< response type means there are requested RR
- NDNS_NACK = 2, ///< no requested RR
- NDNS_AUTH = 3, ///< only has RR for detailed (longer) label
-
- NDNS_UNKNOWN = 255
+enum NdnsContentType {
+ NDNS_BLOB = ndn::tlv::ContentType_Blob,
+ NDNS_LINK = ndn::tlv::ContentType_Link,
+ NDNS_KEY = ndn::tlv::ContentType_Key,
+ NDNS_NACK = ndn::tlv::ContentType_Nack,
+ NDNS_AUTH = 1086, ///< only has RR for detailed (longer) label
+ NDNS_RESP = 1087, ///< response type means there are requested RR
+ NDNS_UNKNOWN = 1088, ///< this is not a real type, just mean that contentType is unknown
};
std::ostream&
-operator<<(std::ostream& os, const NdnsType ndnsType);
+operator<<(std::ostream& os, const NdnsContentType contentType);
/**
* @brief define Return code of Update's Response
diff --git a/src/ndns-tlv.hpp b/src/ndns-tlv.hpp
index 3f8399d..27235a3 100644
--- a/src/ndns-tlv.hpp
+++ b/src/ndns-tlv.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2016, 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.
@@ -30,7 +30,6 @@
* @brief the field defined in NDNS packet format
*/
enum {
- NdnsType = 180, ///< Detailed Types are defined in NdnsType in ndns-enum.hpp
Rr = 190,
RrData = 191,
diff --git a/src/util/util.cpp b/src/util/util.cpp
index 1b14896..31f3549 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, Regents of the University of California.
+ * Copyright (c) 2014-2016, 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.
@@ -23,8 +23,8 @@
namespace ndn {
namespace ndns {
-NdnsType
-toNdnsType(const std::string& str)
+NdnsContentType
+toNdnsContentType(const std::string& str)
{
if (str == "resp")
return NDNS_RESP;
@@ -32,8 +32,10 @@
return NDNS_NACK;
else if (str == "auth")
return NDNS_AUTH;
- else if (str == "raw")
- return NDNS_RAW;
+ else if (str == "blob")
+ return NDNS_BLOB;
+ else if (str == "link")
+ return NDNS_LINK;
else
return NDNS_UNKNOWN;
}
diff --git a/src/util/util.hpp b/src/util/util.hpp
index 7acf496..24aa179 100644
--- a/src/util/util.hpp
+++ b/src/util/util.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014, Regents of the University of California.
+ * Copyright (c) 2014-2016, 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,8 +26,8 @@
namespace ndn {
namespace ndns {
-NdnsType
-toNdnsType(const std::string& str);
+NdnsContentType
+toNdnsContentType(const std::string& str);
/**
* @brief print the data in a flexible way
diff --git a/tests/unit/clients/iterative-query-controller.cpp b/tests/unit/clients/iterative-query-controller.cpp
index 308683e..453e743 100644
--- a/tests/unit/clients/iterative-query-controller.cpp
+++ b/tests/unit/clients/iterative-query-controller.cpp
@@ -76,8 +76,6 @@
BOOST_AUTO_TEST_SUITE(IterativeQueryController)
-BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(Basic, 3)
-
BOOST_FIXTURE_TEST_CASE(Basic, QueryControllerFixture)
{
using std::string;
diff --git a/tests/unit/clients/response.cpp b/tests/unit/clients/response.cpp
index c575c85..5c41f7d 100644
--- a/tests/unit/clients/response.cpp
+++ b/tests/unit/clients/response.cpp
@@ -36,12 +36,12 @@
ndns::Response r(zone, qType);
r.setRrLabel(Name("/ndnsim/www"));
r.setRrType(label::CERT_RR_TYPE);
- r.setNdnsType(NDNS_RAW);
+ r.setContentType(NDNS_BLOB);
r.setFreshnessPeriod(time::seconds(4000));
BOOST_CHECK_EQUAL(r.getFreshnessPeriod(), time::seconds(4000));
BOOST_CHECK_EQUAL(r.getRrType(), label::CERT_RR_TYPE);
- BOOST_CHECK_EQUAL(r.getNdnsType(), NDNS_RAW);
+ BOOST_CHECK_EQUAL(r.getContentType(), NDNS_BLOB);
BOOST_CHECK_EQUAL(r.getZone(), zone);
BOOST_CHECK_EQUAL(r.getQueryType(), qType);
@@ -59,7 +59,7 @@
ndns::Response r4(zone, qType);
r4.setRrLabel(Name("/ndnsim/www"));
r4.setRrType(label::TXT_RR_TYPE);
- r4.setNdnsType(NDNS_RESP);
+ r4.setContentType(NDNS_RESP);
std::string str = "Just try it";
Block s = makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size());
diff --git a/tests/unit/daemon/name-server.cpp b/tests/unit/daemon/name-server.cpp
index 64d0429..4b6af12 100644
--- a/tests/unit/daemon/name-server.cpp
+++ b/tests/unit/daemon/name-server.cpp
@@ -75,7 +75,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
- BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RESP);
+ BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_LINK);
});
face.receive(q.toInterest());
@@ -103,13 +103,13 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
- BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_NACK);
+ BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_NACK);
});
face.receive(q.toInterest());
run();
- // will ask for the existing record (will have type NDNS_RAW, as it is certificate)
+ // will ask for the existing record (will have type NDNS_BLOB, as it is certificate)
face.onSendData.connectSingleShot([&] (const Data& data) {
++nDataBack;
NDNS_LOG_TRACE("get Data back");
@@ -117,7 +117,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
- BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RAW);
+ BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_BLOB);
});
q.setRrLabel("dsk-1");
@@ -135,7 +135,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
- BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RAW);
+ BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_BLOB);
});
run();
@@ -149,7 +149,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
- BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_NACK);
+ BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_NACK);
});
run();
@@ -163,7 +163,7 @@
re.setQueryType(label::NDNS_ITERATIVE_QUERY);
re.setRrLabel(Name("net"));
re.setRrType(label::NS_RR_TYPE);
- re.setNdnsType(NDNS_RESP);
+ re.setContentType(NDNS_RESP);
std::string str = "ns1.ndnsim.net";
re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
@@ -190,7 +190,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
- BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RESP); // by default NDNS_RAW is enough
+ BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_RESP); // by default NDNS_BLOB is enough
BOOST_CHECK_GT(resp.getRrs().size(), 0);
Block block = resp.getRrs()[0];
block.parse();
@@ -215,7 +215,7 @@
re.setQueryType(label::NDNS_ITERATIVE_QUERY);
re.setRrLabel(Name("net-XYZ")); // insert new records
re.setRrType(label::NS_RR_TYPE);
- re.setNdnsType(NDNS_RESP);
+ re.setContentType(NDNS_RESP);
std::string str = "ns1.ndnsim.net";
re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
@@ -242,7 +242,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
- BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RESP); // by default NDNS_RAW is enough
+ BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_RESP); // by default NDNS_BLOB is enough
BOOST_CHECK_GT(resp.getRrs().size(), 0);
Block block = resp.getRrs()[0];
block.parse();
@@ -291,7 +291,7 @@
re.setQueryType(label::NDNS_ITERATIVE_QUERY);
re.setRrLabel(Name("ndnsim-XYZ")); // insert new records
re.setRrType(label::NS_RR_TYPE);
- re.setNdnsType(NDNS_RESP);
+ re.setContentType(NDNS_RESP);
std::string str = "ns1.ndnsim.net";
re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
@@ -393,7 +393,7 @@
re.setQueryType(label::NDNS_ITERATIVE_QUERY);
re.setRrLabel(Name("ndnsim-XYZ")); // insert new records
re.setRrType(label::NS_RR_TYPE);
- re.setNdnsType(NDNS_RESP);
+ re.setContentType(NDNS_RESP);
std::string str = "ns1.ndnsim.net";
re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
@@ -429,7 +429,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
- BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RESP); // by default NDNS_RAW is enough
+ BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_RESP); // by default NDNS_BLOB is enough
BOOST_CHECK_GT(resp.getRrs().size(), 0);
Block block = resp.getRrs()[0];
block.parse();
diff --git a/tests/unit/database-test-data.cpp b/tests/unit/database-test-data.cpp
index 6edcd1c..4b1de42 100644
--- a/tests/unit/database-test-data.cpp
+++ b/tests/unit/database-test-data.cpp
@@ -78,17 +78,20 @@
const time::seconds ttl(3000 + 100 * certificateIndex);
const name::Component version = name::Component::fromVersion(100 + 1000 * certificateIndex);
name::Component qType(label::NDNS_ITERATIVE_QUERY);
- NdnsType ndnsType = NDNS_RESP;
+ NdnsContentType contentType = NDNS_RESP;
if (type == label::CERT_RR_TYPE) {
- ndnsType = NDNS_RAW;
+ contentType = NDNS_BLOB;
qType = label::NDNS_CERT_QUERY;
+ } else if (type == label::NS_RR_TYPE) {
+ contentType = NDNS_LINK;
+ } else if (type == label::TXT_RR_TYPE) {
+ contentType = NDNS_RESP;
}
std::ostringstream os;
os << "a fake content: " << (++certificateIndex) << "th";
- addRrset(zone, label, type, ttl, version, qType, ndnsType, os.str());
+ addRrset(zone, label, type, ttl, version, qType, contentType, os.str());
};
-
addQueryRrset("/dsk-1", m_root, label::CERT_RR_TYPE);
addQueryRrset("/net/ksk-2", m_root, label::CERT_RR_TYPE);
addQueryRrset("/dsk-3", m_net, label::CERT_RR_TYPE);
@@ -114,7 +117,7 @@
void
DbTestData::addRrset(Zone& zone, const Name& label, const name::Component& type,
const time::seconds& ttl, const name::Component& version,
- const name::Component& qType, NdnsType ndnsType, const std::string& msg)
+ const name::Component& qType, NdnsContentType contentType, const std::string& msg)
{
Rrset rrset;
RrsetFactory rf(TEST_DATABASE.string(), zone.getName(),
@@ -123,7 +126,7 @@
if (type == label::NS_RR_TYPE) {
ndn::Link::DelegationSet ds = {std::pair<uint32_t, Name>(1,"/xx")};
rrset = rf.generateNsRrset(label, type, version.toVersion(), ttl, ds);
- if (ndnsType != NDNS_AUTH) {
+ if (contentType != NDNS_AUTH) {
// do not add AUTH packet to link
m_links.push_back(Link(rrset.getData()));
}
diff --git a/tests/unit/database-test-data.hpp b/tests/unit/database-test-data.hpp
index 26e092f..82410fe 100644
--- a/tests/unit/database-test-data.hpp
+++ b/tests/unit/database-test-data.hpp
@@ -46,7 +46,7 @@
void
addRrset(Zone& zone, const Name& label, const name::Component& type,
const time::seconds& ttl, const name::Component& version,
- const name::Component& qType, NdnsType ndnsType, const std::string& msg);
+ const name::Component& qType, NdnsContentType contentType, const std::string& msg);
public:
class PreviousStateCleaner
{
diff --git a/tools/ndns-dig.cpp b/tools/ndns-dig.cpp
index f7f9af0..0497315 100644
--- a/tools/ndns-dig.cpp
+++ b/tools/ndns-dig.cpp
@@ -105,7 +105,7 @@
Name name = Name().append(response.getZone()).append(response.getRrLabel());
if (name == m_dstLabel && m_rrType == response.getRrType()) {
NDNS_LOG_INFO("This is the final response returned by zone=" << response.getZone()
- << " and NdnsType=" << response.getNdnsType()
+ << " and NdnsType=" << response.getContentType()
<< ". It contains " << response.getRrs().size() << " RR(s)");
std::string msg;
diff --git a/tools/ndns-update.cpp b/tools/ndns-update.cpp
index 9dbbb2c..0652677 100644
--- a/tools/ndns-update.cpp
+++ b/tools/ndns-update.cpp
@@ -209,7 +209,7 @@
int ttl = 4;
Name rrLabel;
string rrType = "TXT";
- string ndnsTypeStr = "resp";
+ string contentTypeStr = "resp";
Name certName;
std::vector<string> contents;
string contentFile;
@@ -226,8 +226,8 @@
config.add_options()
("ttl,T", po::value<int>(&ttl), "TTL of query. default: 4 sec")
("rrtype,t", po::value<string>(&rrType), "set request RR Type. default: TXT")
- ("ndnsType,n", po::value<string>(&ndnsTypeStr), "Set the ndnsType of the resource record. "
- "Potential values are [resp|nack|auth|raw]. Default: resp")
+ ("contentType,n", po::value<string>(&contentTypeStr), "Set the contentType of the resource record. "
+ "Potential values are [blob|link|nack|auth|resp]. Default: resp")
("cert,c", po::value<Name>(&certName), "set the name of certificate to sign the update")
("content,o", po::value<std::vector<string>>(&contents)->multitoken(),
"set the content of the RR")
@@ -251,7 +251,7 @@
config_file_options.add(config).add(hidden);
po::options_description visible("Usage: ndns-update zone rrLabel [-t rrType] [-T TTL] "
- "[-n NdnsType] [-c cert] "
+ "[-n NdnsContentType] [-c cert] "
"[-f contentFile]|[-o content]\n"
"Allowed options");
@@ -313,10 +313,10 @@
}
}
- NdnsType ndnsType = toNdnsType(ndnsTypeStr);
+ NdnsContentType contentType = toNdnsContentType(contentTypeStr);
- if (ndnsType == ndns::NDNS_UNKNOWN) {
- std::cerr << "unknown NdnsType: " << ndnsTypeStr << std::endl;
+ if (contentType == ndns::NDNS_UNKNOWN) {
+ std::cerr << "unknown NdnsContentType: " << contentTypeStr << std::endl;
return 1;
}
@@ -328,7 +328,7 @@
re.setQueryType(qType);
re.setRrType(name::Component(rrType));
- re.setNdnsType(ndnsType);
+ re.setContentType(contentType);
for (const auto& content : contents) {
re.addRr(makeBinaryBlock(ndns::tlv::RrData, content.c_str(), content.size()));