clients: Change iterative-query-controller to use Link
Change-Id: I3b4fe73a467fb38c4fcde87481d1f84ec19c16c0
diff --git a/src/clients/iterative-query-controller.cpp b/src/clients/iterative-query-controller.cpp
index 3c25505..6bd99bd 100644
--- a/src/clients/iterative-query-controller.cpp
+++ b/src/clients/iterative-query-controller.cpp
@@ -93,6 +93,14 @@
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();
+ }
+ }
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;
@@ -190,6 +198,12 @@
query.setZone(m_dstLabel.getPrefix(m_nFinishedComps));
query.setInterestLifetime(m_interestLifetime);
+
+ // addLink
+ if (m_lastLink.hasWire()) {
+ query.setLink(m_lastLink);
+ }
+
switch (m_step) {
case QUERY_STEP_QUERY_NS:
query.setQueryType(label::NDNS_ITERATIVE_QUERY);
@@ -214,7 +228,6 @@
throw std::runtime_error("call makeLatestInterest() unexpected: " + oss.str());
}
-
Interest interest = query.toInterest();
return interest;
}
diff --git a/src/clients/iterative-query-controller.hpp b/src/clients/iterative-query-controller.hpp
index dba1635..8fc2a34 100644
--- a/src/clients/iterative-query-controller.hpp
+++ b/src/clients/iterative-query-controller.hpp
@@ -32,6 +32,7 @@
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/link.hpp>
namespace ndn {
namespace ndns {
@@ -145,6 +146,9 @@
* used when query the KSK (key signing key), e.g., /net/ndnsim/ksk-1
*/
size_t m_nTryComps;
+
+private:
+ Block m_lastLink;
};
std::ostream&
diff --git a/src/clients/query.cpp b/src/clients/query.cpp
index 4e7621b..9853672 100644
--- a/src/clients/query.cpp
+++ b/src/clients/query.cpp
@@ -47,6 +47,13 @@
m_zone = zone;
+ if (interest.hasLink()) {
+ m_link = interest.getLink().wireEncode();
+ } else {
+ m_link = Block();
+ }
+
+
size_t len = zone.size();
m_queryType = interest.getName().get(len);
@@ -64,7 +71,14 @@
.append(this->m_rrLabel)
.append(this->m_rrType);
- return Interest(name, m_interestLifetime);
+ Interest interest;
+ interest.setName(name);
+ interest.setInterestLifetime(m_interestLifetime);
+ if (m_link.hasWire()) {
+ interest.setLink(m_link);
+ }
+
+ return interest;
}
std::ostream&
diff --git a/src/clients/query.hpp b/src/clients/query.hpp
index bf76684..d96d58c 100644
--- a/src/clients/query.hpp
+++ b/src/clients/query.hpp
@@ -24,6 +24,7 @@
#include "ndns-enum.hpp"
#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/link.hpp>
namespace ndn {
namespace ndns {
@@ -165,12 +166,31 @@
m_rrType = rrType;
}
+ /**
+ * @brief set link object
+ */
+ void
+ setLink(const Block& link)
+ {
+ m_link = link;
+ }
+
+ /**
+ * @brief get Link object
+ */
+ const Block&
+ getLink() const
+ {
+ return m_link;
+ }
+
private:
Name m_zone;
name::Component m_queryType;
Name m_rrLabel;
name::Component m_rrType;
time::milliseconds m_interestLifetime;
+ Block m_link;
};
std::ostream&