support for NS, TXT, NDNCERT, FH
diff --git a/tools/caching-resolver-daemon.cpp b/tools/caching-resolver-daemon.cpp
index 9ef40fa..453099e 100644
--- a/tools/caching-resolver-daemon.cpp
+++ b/tools/caching-resolver-daemon.cpp
@@ -1,33 +1,144 @@
-/*
- * NameServer.cpp
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, Regents of the University of California.
*
- * Created on: 18 Jul, 2014
- * Author: Xiaoke JIANG
+ * 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 "app/name-caching-resolver.hpp"
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+#include "boost/program_options.hpp"
+#include "boost/filesystem.hpp"
+
+using namespace ndn;
+using namespace ndn::ndns;
+using namespace std;
+
int main(int argc, char * argv[])
{
- //char *programName, char *prefix, char *nameZone
+ string route="/";
+ int lifetime=2;
+ string hint = "";
+ try{
- if (argc != 2)
+ 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()
+ ("lifetime,t", po::value<std::string>(), "set the lifetime of Interest. default: 2")
+ ("hint,H", po::value<std::string>(&hint), "enable the forwarding Hint of Root Zone, which is disable by default")
+ ;
+
+
+ po::options_description hidden("Hidden Options");
+ hidden.add_options()
+ ("prefix,p", po::value<string>(&route), "routable prefix of the server. default: /")
+ ;
+
+ po::positional_options_description postion;
+ postion.add("prefix", 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"))
+ {
+ cout<<"E.g: caching-resolver-daemon /routable/prefix/announced"<<endl;
+ cout<<visible<<endl;
+ return 0;
+ }
+
+ cout<<"routablePrefix="<<route<<" lifetime="<<lifetime<<endl;
+ }
+ catch(const std::exception& ex)
{
- return 0;
+ cout << "Parameter Error: " << ex.what() << endl;
+ return 0;
+ }
+ catch(...)
+ {
+ cout << "Parameter Unknown error" << endl;
+ return 0;
}
- ndn::ndns::NameCachingResolver server(argv[0], argv[1]);
- server.run();
- cout<<"the server ends with hasError="<<server.hasError()<<endl;
- if (server.hasError()){
- return 0;
+
+ if (hint != "")
+ {
+ ndn::ndns::NameCachingResolver<IterativeQueryWithFowardingHint> server(argv[0], route.c_str());
+ server.setEnableForwardingHint(1);
+ server.setRootZoneFowardingHint(Name(hint));
+
+ time::milliseconds t(1000*lifetime);
+ server.setInterestLifetime(t);
+
+ server.run();
+
+ cout<<"the server ends with hasError="<<server.hasError()<<endl;
+
+ if (server.hasError()){
+ return 0;
+ } else {
+ return 1;
+ }
+
} else {
- return 1;
+ ndn::ndns::NameCachingResolver<IterativeQuery> server(argv[0], route.c_str());
+
+ time::milliseconds t(1000*lifetime);
+ server.setInterestLifetime(t);
+
+ server.run();
+
+ cout<<"the server ends with hasError="<<server.hasError()<<endl;
+
+ if (server.hasError()){
+ return 0;
+ } else {
+ return 1;
+ }
+
}
}
diff --git a/tools/dig.cpp b/tools/dig.cpp
index 104aac9..ef6bbf1 100644
--- a/tools/dig.cpp
+++ b/tools/dig.cpp
@@ -1,12 +1,22 @@
-/*
- * NameServer.cpp
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, Regents of the University of California.
*
- * Created on: 18 Jul, 2014
- * Author: Xiaoke JIANG
+ * 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 "app/name-dig.hpp"
#include "boost/program_options.hpp"
#include "boost/filesystem.hpp"
@@ -15,21 +25,6 @@
using namespace ndn::ndns;
using namespace std;
-void
-usage()
-{
- cout<<"\n Usage: \n"
- << "dig /name/to/be/resolved [options]\n"
- <<"\t[-t seconds] - set the maximal waiting time. default: 10\n"
- <<"\t[-p prefix] - set the routable prefix of caching resolver. default: / \n"
- <<"\t[-n number] - set the maximal tried time. default: 2\n"
- <<"\t[-r rr_type] - set the RR type. default: TXT\n"
- <<"\t[-h] - set the help message\n"
-
- <<"\ne.g.: dig /net/ndnsim/www -p /localhost -t 5 -n 2 -r TXT\n"
- ;
-
-}
int main(int argc, char * argv[])
{
@@ -47,19 +42,6 @@
namespace po = boost::program_options;
po::variables_map vm;
- /*
- po::options_description desc("Generic Options");
- desc.add_options()
- ("help,h", "print help message")
- ("name", po::value<string>(&dstLabel)->required()->composing(), "name to be resolved")
- ("resolver", po::value<string>(&resolver)->composing(), "routable prefix of resolver")
- ("waiting,w", po::value<int>(&waitingSeconds), "set waiting seconds for every Interest. default: 10")
- ("rrtype", po::value<std::string>(), "set request RR Type. default: TXT")
- ("try", po::value<int>(&tryMax), "set maximal Interest Tried Number. default: 2")
- //("positional,p", po::value< vector<string> >(), "positional optionals")
- ;
-
- */
po::options_description generic("Generic Options");
generic.add_options()
@@ -70,14 +52,14 @@
po::options_description config("Configuration");
config.add_options()
("waiting,w", po::value<int>(&waitingSeconds), "set waiting seconds for every Interest. default: 10")
- ("rrtype,t", po::value<std::string>(), "set request RR Type. default: TXT")
+ ("rrtype,t", po::value<std::string>(&rrType), "set request RR Type. default: TXT")
("trynum,n", po::value<int>(&tryMax), "set maximal Interest Tried Number. default: 2")
;
po::options_description hidden("Hidden Options");
hidden.add_options()
- ("name", po::value<string>(&dstLabel)->required(), "name to be resolved")
+ ("name", po::value<string>(&dstLabel), "name to be resolved")
("resolver", po::value<string>(&resolver), "routable prefix of resolver")
;
@@ -105,19 +87,22 @@
if (vm.count("help"))
{
+ cout<<"E.g: dig /name/to/be/resolved /routable/prefix/of/resolver"<<endl;
cout<<visible<<endl;
return 0;
}
- cout<<"waiting="<<waitingSeconds<<"s RRType="<<rrType<<" tryMax="<<tryMax<<endl;
+ cout<<"name="<<dstLabel<<" resolver="<<resolver<<" waiting="<<waitingSeconds<<"s RRType="<<rrType<<" tryMax="<<tryMax<<endl;
}
catch(const std::exception& ex)
{
cout << "Parameter Error: " << ex.what() << endl;
+ return 0;
}
catch(...)
{
cout << "Parameter Unknown error" << endl;
+ return 0;
}
@@ -139,10 +124,12 @@
cout<<"Error: "<<dig.getErr()<<endl;
} else
{
+ Name re = dig.getResponse().getQueryName();
if (dig.getRrs().size() == 0)
{
cout<<"Dig found no record(s) for Name "
<<dig.getDstLabel().toUri()<<std::endl;
+ cout<<"Final Response Name: "<<re.toUri()<<std::endl;
}
else {
cout<<"Success to the dig "<<dig.getDstLabel().toUri()<<" by Resolver "
@@ -155,7 +142,7 @@
cout<<" "<<*iter<<"\n";
iter ++;
}
-
+ cout<<"Final Response Name: "<<re.toUri()<<std::endl;
}
}
diff --git a/tools/name-server-daemon.cpp b/tools/name-server-daemon.cpp
index 3cce77c..9268bac 100644
--- a/tools/name-server-daemon.cpp
+++ b/tools/name-server-daemon.cpp
@@ -1,24 +1,111 @@
-/*
- * NameServer.cpp
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, Regents of the University of California.
*
- * Created on: 18 Jul, 2014
- * Author: Xiaoke JIANG
+ * 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 "app/name-server.hpp"
+#include "boost/program_options.hpp"
+#include "boost/filesystem.hpp"
int main(int argc, char * argv[])
{
- //char *programName, char *prefix, char *nameZone
+ string route = "/";
+ string zoneName = "/";
+ string dbfile="src/db/ndns-local.db";
+ string hint = "/";
- if (argc != 3)
+ 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()
+ ("dbfile,f", po::value<std::string>(&dbfile), "set database file. default: src/db/ndns-local.db")
+ ("hint,H", po::value<std::string>(&hint), "set Forwarding Hint, which is disable by default")
+ ;
+
+
+ po::options_description hidden("Hidden Options");
+ hidden.add_options()
+ ("prefix,p", po::value<string>(&route), "routable prefix of the server")
+ ("zone,z", po::value<string>(&zoneName), "name of the zone")
+ ;
+
+ po::positional_options_description postion;
+ postion.add("prefix", 1);
+ postion.add("zone", 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"))
+ {
+ cout<<"E.g: name-server-daemon /name/of/zone /routable/prefix/announced"<<endl;
+ cout<<visible<<endl;
+ return 0;
+ }
+
+ cout<<"zone="<<zoneName<<" routablePrefix="<<route<<" dbfile="<<dbfile<<endl;
+ }
+ catch(const std::exception& ex)
{
- return 0;
+ cout << "Parameter Error: " << ex.what() << endl;
+ return 0;
+ }
+ catch(...)
+ {
+ cout << "Parameter Unknown error" << endl;
+ return 0;
}
- ndn::ndns::NameServer server(argv[0], argv[1], argv[2]);
+
+
+ ndn::ndns::NameServer server(argv[0], route.c_str(), zoneName.c_str(), dbfile);
+
+ if (hint != "/") {
+ server.setEnableForwardingHint(1);
+ server.setForwardingHint(Name(hint));
+ }
+
+
server.run();
cout<<"the server ends with hasError="<<server.hasError()<<endl;