diff --git a/src/clients/iterative-query-controller.cpp b/src/clients/iterative-query-controller.cpp
new file mode 100644
index 0000000..1d7af26
--- /dev/null
+++ b/src/clients/iterative-query-controller.cpp
@@ -0,0 +1,243 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, 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.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "iterative-query-controller.hpp"
+#include "logger.hpp"
+#include <iostream>
+
+namespace ndn {
+namespace ndns {
+NDNS_LOG_INIT("IterQueryCtr")
+
+IterativeQueryController::IterativeQueryController(const Name& dstLabel,
+                                                   const name::Component& rrType,
+                                                   const time::milliseconds& interestLifetime,
+                                                   const QuerySucceedCallback& onSucceed,
+                                                   const QueryFailCallback& onFail,
+                                                   Face& face)
+  : QueryController(dstLabel, rrType, interestLifetime, onSucceed, onFail, face)
+  , m_step(QUERY_STEP_QUERY_NS)
+  , m_nFinishedComps(0)
+  , m_nTryComps(1)
+{
+  if (m_dstLabel.size() == 1) // the first one is to Query RR directly
+    m_step = QUERY_STEP_QUERY_RR;
+}
+
+void
+IterativeQueryController::onTimeout(const Interest& interest)
+{
+  NDNS_LOG_INFO("[* !! *] timeout happens: " << interest.getName());
+  NDNS_LOG_TRACE(*this);
+  this->abort();
+}
+
+void
+IterativeQueryController::abort()
+{
+  NDNS_LOG_DEBUG("abort iterative query");
+  if (m_onFail != nullptr)
+    m_onFail(0, "abort");
+  else
+    NDNS_LOG_TRACE("m_onFail is 0");
+
+}
+
+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));
+  }
+
+  NDNS_LOG_TRACE("[* -> *] get a " << ndnsType
+                 << " Response: " << data.getName());
+
+  switch (m_step) {
+  case QUERY_STEP_QUERY_NS:
+    if (ndnsType == NDNS_NACK) {
+      if (m_nFinishedComps + m_nTryComps == m_dstLabel.size() && m_rrType != label::NS_RR_TYPE)
+        m_step = QUERY_STEP_QUERY_RR;
+      else
+        m_step = QUERY_STEP_ANSWER_STUB;
+    }
+    else if (ndnsType == NDNS_RESP) {
+      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;
+      }
+      else {
+        m_nFinishedComps += m_nTryComps;
+        m_nTryComps = 1;
+      }
+    }
+    else if (ndnsType == NDNS_AUTH) {
+      m_nTryComps += 1;
+    }
+    else if (ndnsType == NDNS_RAW) {
+      std::ostringstream oss;
+      oss << *this;
+      NDNS_LOG_WARN("get unexpected Response: NDNS_RAW for QUERY_NS: " << oss.str());
+    }
+    //
+    if (m_nFinishedComps + m_nTryComps > m_dstLabel.size()) {
+      if (m_rrType == label::NS_RR_TYPE) {
+        m_step = QUERY_STEP_ANSWER_STUB;
+      }
+      else
+        m_step = QUERY_STEP_QUERY_RR;
+    }
+    break;
+  case QUERY_STEP_QUERY_RR:
+    m_step = QUERY_STEP_ANSWER_STUB;
+    break;
+  default:
+    NDNS_LOG_WARN("get unexpected Response at State " << *this);
+    // throw std::runtime_error("call makeLatestInterest() unexpected: " << *this);
+    // do not throw except since it may be duplicated Data
+    m_step = QUERY_STEP_ABORT;
+    break;
+  }
+
+  if (!hasEnded())
+    this->express(this->makeLatestInterest()); // express new Expres
+  else if (m_step == QUERY_STEP_ANSWER_STUB) {
+    NDNS_LOG_TRACE("query ends: " << *this);
+    Response re = this->parseFinalResponse(data);
+    if (m_onSucceed != nullptr)
+      m_onSucceed(data, re);
+    else
+      NDNS_LOG_TRACE("succeed callback is nullptr");
+  }
+  else if (m_step == QUERY_STEP_ABORT)
+    this->abort();
+}
+
+bool
+IterativeQueryController::hasEnded()
+{
+  return (m_step != QUERY_STEP_QUERY_NS && m_step != QUERY_STEP_QUERY_RR);
+}
+
+void
+IterativeQueryController::start()
+{
+  Interest interest = this->makeLatestInterest();
+  express(interest);
+}
+
+
+void
+IterativeQueryController::express(const Interest& interest)
+{
+  NDNS_LOG_DEBUG("[* <- *] send a Query: " << interest.getName());
+  m_face.expressInterest(interest,
+                         bind(&IterativeQueryController::onData, this, _1, _2),
+                         bind(&IterativeQueryController::onTimeout, this, _1)
+                         );
+}
+
+
+const Response
+IterativeQueryController::parseFinalResponse(const Data& data)
+{
+  Response re;
+  Name zone = m_dstLabel.getPrefix(m_nFinishedComps);
+  re.fromData("", zone, data);
+  return re;
+}
+
+const Interest
+IterativeQueryController::makeLatestInterest()
+{
+  // NDNS_LOG_TRACE("get latest Interest");
+  Query query;
+  //const Name& dstLabel = m_query.getRrLabel();
+
+  query.setZone(m_dstLabel.getPrefix(m_nFinishedComps));
+  query.setInterestLifetime(m_interestLifetime);
+  switch (m_step) {
+  case QUERY_STEP_QUERY_NS:
+    query.setQueryType(label::NDNS_ITERATIVE_QUERY);
+    query.setRrLabel(m_dstLabel.getSubName(m_nFinishedComps, m_nTryComps));
+    query.setRrType(label::NS_RR_TYPE);
+    break;
+  case QUERY_STEP_QUERY_RR:
+    if (m_rrType == label::CERT_RR_TYPE) {
+      // this only works for dsk, and ksk needs different mechanism
+      query.setQueryType(label::NDNS_CERT_QUERY);
+    }
+    else {
+      query.setQueryType(label::NDNS_ITERATIVE_QUERY);
+    }
+    query.setRrLabel(m_dstLabel.getSubName(m_nFinishedComps));
+    query.setRrType(m_rrType);
+    break;
+  default:
+    std::ostringstream oss;
+    oss << *this;
+    NDNS_LOG_WARN("unexpected state: " << oss.str());
+    throw std::runtime_error("call makeLatestInterest() unexpected: " + oss.str());
+  }
+
+
+  Interest interest = query.toInterest();
+  return interest;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const IterativeQueryController::QueryStep step)
+{
+  switch (step) {
+  case IterativeQueryController::QUERY_STEP_QUERY_NS:
+    os << "QueryNS";
+    break;
+  case IterativeQueryController::QUERY_STEP_QUERY_RR:
+    os << "QueryRR";
+    break;
+  case IterativeQueryController::QUERY_STEP_ANSWER_STUB:
+    os << "AnswerStub";
+    break;
+  case IterativeQueryController::QUERY_STEP_ABORT:
+    os << "Abort";
+    break;
+  default:
+    os << "UNKNOW";
+    break;
+  }
+  return os;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const IterativeQueryController& ctr)
+{
+  os << "InterativeQueryController: dstLabel=" << ctr.getDstLabel()
+     << " rrType=" << ctr.getRrType()
+     << " currentStep="  << ctr.getStep()
+     << " nFinishedComps=" << ctr.getNFinishedComps()
+     << " nTryComp=" << ctr.getNTryComps()
+    ;
+
+  return os;
+}
+
+} // namespace ndns
+} // namespace ndn
diff --git a/src/clients/iterative-query-controller.hpp b/src/clients/iterative-query-controller.hpp
new file mode 100644
index 0000000..c97cc66
--- /dev/null
+++ b/src/clients/iterative-query-controller.hpp
@@ -0,0 +1,154 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, 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.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NDNS_CLIENTS_ITERATIVE_QUERY_CONTROLLER_HPP
+#define NDNS_CLIENTS_ITERATIVE_QUERY_CONTROLLER_HPP
+
+#include "ndns-enum.hpp"
+#include "query.hpp"
+#include "response.hpp"
+#include "query-controller.hpp"
+#include "config.hpp"
+#include "common.hpp"
+
+#include <ndn-cxx/common.hpp>
+#include <ndn-cxx/data.hpp>
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/name.hpp>
+
+namespace ndn {
+namespace ndns {
+
+/**
+ * @brief controller which iteratively query a target label
+ */
+class IterativeQueryController : public QueryController
+{
+public:
+  /**
+   * @brief indicates a step in an iterative query process.
+   * Iterative Query contains multiple steps which are listed here
+   */
+  enum QueryStep {
+    QUERY_STEP_QUERY_NS = 1, ///< to query the naming server, before querying NS & waiting for Data
+    QUERY_STEP_QUERY_RR, ///< to query RR, before querying RR & waiting for it Data
+    QUERY_STEP_ANSWER_STUB, ///< to answer to stub resolver, after getting final Response,
+                            ///< or NACK or timeout
+    QUERY_STEP_ABORT, ///< to abort the resolver process, if unexpected behavior happens
+    QUERY_STEP_UNKNOWN = 255
+  };
+
+public:
+  explicit
+  IterativeQueryController(const Name& dstLabel, const name::Component& rrType,
+                           const time::milliseconds& interestLifetime,
+                           const QuerySucceedCallback& onSucceed, const QueryFailCallback& onFail,
+                           Face& face);
+
+  virtual void
+  start();
+
+  /**
+   * @brief return false if the current status is not QUEYR_STEP_QUERY_NS
+   * or QUERY_STEP_QUERY_RR
+   */
+  virtual bool
+  hasEnded();
+
+NDNS_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
+  void
+  onData(const ndn::Interest& interest, const Data& data);
+
+  /**
+   * @brief change the Controller state according to timeout. For current,
+   * abort the query when timeout
+   */
+  void
+  onTimeout(const Interest& interest);
+
+  void
+  abort();
+
+  /**
+   * @brief get the Interest according to current Controller state.
+   * Only be valid on State QueryNS & QueryRR, or throw exception
+   */
+  const Interest
+  makeLatestInterest();
+
+  const Response
+  parseFinalResponse(const Data& data);
+
+  void
+  express(const Interest& interest);
+
+  void
+  setNFinishedComps(size_t finished)
+  {
+    m_nFinishedComps = finished;
+  }
+
+public:
+  QueryStep
+  getStep() const
+  {
+    return m_step;
+  }
+
+  size_t
+  getNFinishedComps() const
+  {
+    return m_nFinishedComps;
+  }
+
+  size_t
+  getNTryComps() const
+  {
+    return m_nTryComps;
+  }
+
+protected:
+  /**
+   * @brief current query step
+   */
+  QueryStep m_step;
+
+  /*
+   * the number of label that has been resolved successfully
+   * This also define the next AuthZone prefix
+   * AuthZone = m_query.getRrLabel().getPrefix(m_nFinishedComps)
+   */
+  size_t m_nFinishedComps;
+
+  /*
+   * used when query the KSK (key signing key), e.g., /net/ndnsim/ksk-1
+   */
+  size_t m_nTryComps;
+};
+
+std::ostream&
+operator<<(std::ostream& os, const IterativeQueryController& iq);
+
+std::ostream&
+operator<<(std::ostream& os, const IterativeQueryController::QueryStep step);
+
+} // namespace ndns
+} // namespace ndn
+
+#endif // NDNS_CLIENTS_ITERATIVE_QUERY_HPP
diff --git a/src/clients/query-controller.cpp b/src/clients/query-controller.cpp
new file mode 100644
index 0000000..9cd3559
--- /dev/null
+++ b/src/clients/query-controller.cpp
@@ -0,0 +1,50 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, 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.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "query-controller.hpp"
+#include "logger.hpp"
+#include <iostream>
+
+namespace ndn {
+namespace ndns {
+
+QueryController::QueryController(const Name& dstLabel, const name::Component& rrType,
+                                 const time::milliseconds& interestLifetime,
+                                 const QuerySucceedCallback& onSucceed, const QueryFailCallback& onFail,
+                                 Face& face)
+  : m_dstLabel(dstLabel)
+  , m_rrType(rrType)
+  , m_interestLifetime(interestLifetime)
+  , m_onSucceed(onSucceed)
+  , m_onFail(onFail)
+  , m_face(face)
+{
+}
+
+std::ostream&
+operator<<(std::ostream& os, const QueryController& ctr)
+{
+  os << "QueryController: dstLabel=" << ctr.getDstLabel()
+     << " rrType=" << ctr.getRrType()
+    ;
+
+  return os;
+}
+} // namespace ndns
+} // namespace ndn
diff --git a/src/clients/query-controller.hpp b/src/clients/query-controller.hpp
new file mode 100644
index 0000000..778d563
--- /dev/null
+++ b/src/clients/query-controller.hpp
@@ -0,0 +1,111 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, 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.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NDNS_CLIENTS_QUERY_CONTROLLER_HPP
+#define NDNS_CLIENTS_QUERY_CONTROLLER_HPP
+
+#include "query.hpp"
+#include "response.hpp"
+
+#include <ndn-cxx/data.hpp>
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/face.hpp>
+
+
+namespace ndn {
+namespace ndns {
+
+/**
+ * @brief callback function when succeeding getting the final Response
+ * @param[in] Data the Data packet which contains the Response, client should verify the packet
+ * @param[in] Response the Final Response converted from Data
+ */
+typedef function<void(const Data&, const Response&)> QuerySucceedCallback;
+
+/**
+ * @brief callback function when failing to get the final Response
+ */
+typedef function<void(uint32_t errCode, const std::string& errMsg)> QueryFailCallback;
+
+/**
+ * @brief a Query Controller interface
+ *
+ */
+class QueryController : noncopyable
+{
+public:
+  QueryController(const Name& dstLabel, const name::Component& rrType,
+                  const time::milliseconds& interestLifetime,
+                  const QuerySucceedCallback& onSucceed, const QueryFailCallback& onFail,
+                  Face& face);
+
+  /**
+   * @brief start query process.
+   */
+  virtual void
+  start() = 0;
+
+  /**
+   * @brief should keep sending query, or has ended yet,
+   */
+  virtual bool
+  hasEnded() = 0;
+
+public:
+  ////////////////
+  // getter
+
+  const Name&
+  getDstLabel() const
+  {
+    return m_dstLabel;
+  }
+
+  const time::milliseconds&
+  getInterestLifetime() const
+  {
+    return m_interestLifetime;
+  }
+
+  const name::Component&
+  getRrType() const
+  {
+    return m_rrType;
+  }
+
+protected:
+  const Name m_dstLabel;
+  const name::Component m_rrType;
+  const time::milliseconds m_interestLifetime;
+
+  const QuerySucceedCallback m_onSucceed;
+  const QueryFailCallback m_onFail;
+
+  Face& m_face;
+
+};
+
+std::ostream&
+operator<<(std::ostream& os, const QueryController& ctr);
+
+} // namespace ndns
+} // namespace ndn
+
+#endif // NDNS_CLIENTS_QUERY_CONTROLLER_HPP
diff --git a/tests/unit/clients/iterative-query-controller.cpp b/tests/unit/clients/iterative-query-controller.cpp
new file mode 100644
index 0000000..0346419
--- /dev/null
+++ b/tests/unit/clients/iterative-query-controller.cpp
@@ -0,0 +1,113 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, 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.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "clients/iterative-query-controller.hpp"
+#include "daemon/name-server.hpp"
+#include "logger.hpp"
+#include "../database-test-data.hpp"
+#include "../../boost-test.hpp"
+
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
+#include <boost/asio.hpp>
+
+namespace ndn {
+namespace ndns {
+namespace tests {
+NDNS_LOG_INIT("IterativeQueryControllerTest");
+
+class QueryControllerFixture : public DbTestData
+{
+public:
+  QueryControllerFixture()
+    : producerFace(ndn::util::makeDummyClientFace(io, { false, true }))
+    , consumerFace(ndn::util::makeDummyClientFace(io, { false, true }))
+    , validator(*producerFace)
+    , top(m_root.getName(), m_certName, *producerFace, m_session, m_keyChain, validator)
+    , net(m_net.getName(), m_certName, *producerFace, m_session, m_keyChain, validator)
+    , ndnsim(m_ndnsim.getName(), m_certName, *producerFace, m_session, m_keyChain, validator)
+  {
+    run();
+    producerFace->onInterest += [&] (const Interest& interest) { consumerFace->receive(interest); };
+    consumerFace->onInterest += [&] (const Interest& interest) { producerFace->receive(interest); };
+    producerFace->onData += [&] (const Data& data) { consumerFace->receive(data); };
+    consumerFace->onData += [&] (const Data& data) { producerFace->receive(data); };
+  }
+
+  void
+  run()
+  {
+    io.poll();
+    io.reset();
+  }
+
+public:
+  boost::asio::io_service io;
+  shared_ptr<ndn::util::DummyClientFace> producerFace;
+  shared_ptr<ndn::util::DummyClientFace> consumerFace;
+
+  Name hint;
+  Validator validator;
+  ndns::NameServer top;
+  ndns::NameServer net;
+  ndns::NameServer ndnsim;
+};
+
+
+BOOST_AUTO_TEST_SUITE(IterativeQueryController)
+
+BOOST_FIXTURE_TEST_CASE(Basic, QueryControllerFixture)
+{
+  using std::string;
+  using ndns::NameServer;
+
+  string hint;
+  Name name = m_ndnsim.getName();
+  Name dstLabel(name.append("www"));
+  name::Component rrType("TXT");
+  time::milliseconds lifetime(4000);
+
+  bool hasDataBack = false;
+  auto ctr = make_shared<ndns::IterativeQueryController>(
+    dstLabel, rrType, lifetime,
+    [&hasDataBack] (const Data&, const Response&) {
+      hasDataBack = true;
+      BOOST_CHECK(true);
+    },
+    [&hasDataBack] (uint32_t errCode, const std::string& errMsg) {
+      BOOST_CHECK(false);
+    },
+    *consumerFace);
+
+  // IterativeQueryController is a whole process
+  // the tester should not send Interest one by one
+  // instead of starting it and letting it handle Interest/Data automatically
+  ctr->setNFinishedComps(1);
+
+  ctr->start();
+
+  run();
+  BOOST_CHECK_EQUAL(hasDataBack, true);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace ndns
+} // namespace ndn
diff --git a/tools/ndns-dig.cpp b/tools/ndns-dig.cpp
new file mode 100644
index 0000000..06d7397
--- /dev/null
+++ b/tools/ndns-dig.cpp
@@ -0,0 +1,219 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, 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.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ndns-label.hpp"
+#include "logger.hpp"
+#include "clients/response.hpp"
+#include "clients/query.hpp"
+#include "clients/iterative-query-controller.hpp"
+#include "validator.hpp"
+
+#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/face.hpp>
+#include <boost/program_options.hpp>
+#include <boost/asio.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/noncopyable.hpp>
+
+#include <memory>
+#include <string>
+
+
+namespace ndn {
+namespace ndns {
+NDNS_LOG_INIT("NdnsDig");
+
+class NdnsDig
+{
+public:
+  NdnsDig(const Name& hint, const Name& dstLabel,
+          const name::Component& rrType)
+    : m_dstLabel(dstLabel)
+    , m_rrType(rrType)
+    , m_hint(hint)
+    , m_interestLifetime(DEFAULT_INTEREST_LIFETIME)
+    , m_validator(m_face)
+    , m_ctr(new IterativeQueryController(m_dstLabel, m_rrType, m_interestLifetime,
+                                         bind(&NdnsDig::onSucceed, this, _1, _2),
+                                         bind(&NdnsDig::onFail, this, _1, _2),
+                                         m_face))
+    , m_hasError(false)
+  {
+  }
+
+  void
+  run()
+  {
+    NDNS_LOG_INFO(" =================================== "
+                  << "start to dig label = " << this->m_dstLabel
+                  << " for type = " << this->m_rrType
+                  << " =================================== ");
+
+    try {
+      m_ctr->start(); // non-block, may throw exception
+      m_face.processEvents();
+    }
+    catch (std::exception& e) {
+      NDNS_LOG_FATAL("Error: Face fails to process events: " << e.what());
+      m_hasError = true;
+    }
+  }
+
+  void
+  stop()
+  {
+    m_face.getIoService().stop();
+    NDNS_LOG_TRACE("application stops.");
+  }
+
+private:
+  void
+  onSucceed(const Data& data, const Response& response)
+  {
+    NDNS_LOG_INFO("Dig get following final Response (need verification):");
+    NDNS_LOG_INFO(response);
+    NDNS_LOG_TRACE("to verify the response");
+    m_validator.validate(data,
+                         bind(&NdnsDig::onDataValidated, this, _1),
+                         bind(&NdnsDig::onDataValidationFailed, this, _1, _2)
+                         );
+  }
+
+  void
+  onFail(uint32_t errCode, const std::string& errMsg)
+  {
+    NDNS_LOG_INFO("fail to get response: errCode=" << errCode << " msg=" << errMsg);
+    m_hasError = true;
+    this->stop();
+  }
+
+  void
+  onDataValidated(const shared_ptr<const Data>& data)
+  {
+    NDNS_LOG_INFO("final data pass verification");
+    this->stop();
+  }
+
+  void
+  onDataValidationFailed(const shared_ptr<const Data>& data, const std::string& str)
+  {
+    NDNS_LOG_INFO("final data does not pass verification");
+    m_hasError = true;
+    this->stop();
+  }
+
+public:
+  void
+  setInterestLifetime(const time::milliseconds& lifetime)
+  {
+    m_interestLifetime = lifetime;
+  }
+
+  const bool
+  hasError() const
+  {
+    return m_hasError;
+  }
+
+private:
+  Name m_dstLabel;
+  name::Component m_rrType;
+
+  Name m_hint;
+  Name m_certName;
+  time::milliseconds m_interestLifetime;
+
+  Face m_face;
+
+  Validator m_validator;
+  std::unique_ptr<QueryController> m_ctr;
+
+  bool m_hasError;
+};
+
+} // namespace ndns
+} // namespace ndn
+
+
+int
+main(int argc, char* argv[])
+{
+  ndn::ndns::log::init();
+  using std::string;
+  using namespace ndn;
+
+  Name dstLabel;
+  int ttl = 4;
+  string rrType = "TXT";
+
+  try {
+    namespace po = boost::program_options;
+    po::variables_map vm;
+
+    po::options_description generic("Generic Options");
+    generic.add_options()("help,h", "print help message");
+
+    po::options_description config("Configuration");
+    config.add_options()
+      ("timeout,T", po::value<int>(&ttl), "waiting seconds of query. default: 10 sec")
+      ("rrtype,t", po::value<std::string>(&rrType), "set request RR Type. default: TXT")
+      ;
+
+    po::options_description hidden("Hidden Options");
+    hidden.add_options()
+      ("name", po::value<Name>(&dstLabel), "name to be resolved")
+      ;
+    po::positional_options_description postion;
+    postion.add("name", 1);
+
+    po::options_description cmdline_options;
+    cmdline_options.add(generic).add(config).add(hidden);
+
+    po::options_description config_file_options;
+    config_file_options.add(config).add(hidden);
+
+    po::options_description visible("Allowed options");
+    visible.add(generic).add(config);
+
+    po::parsed_options parsed =
+      po::command_line_parser(argc, argv).options(cmdline_options).positional(postion).run();
+
+    po::store(parsed, vm);
+    po::notify(vm);
+
+    if (vm.count("help")) {
+      std::cout << "Usage: dig /name/to/be/resolved [-t rrType] [-T ttl]" << std::endl;
+      std::cout << visible << std::endl;
+      return 0;
+    }
+  }
+  catch (const std::exception& ex) {
+    std::cerr << "Parameter Error: " << ex.what() << std::endl;
+    return 0;
+  }
+
+  ndn::ndns::NdnsDig dig("", dstLabel, ndn::name::Component(rrType));
+  dig.setInterestLifetime(ndn::time::milliseconds(ttl * 1000));
+
+  dig.run();
+  if (dig.hasError())
+    return 1;
+  else
+    return 0;
+}
