Updating the build framework
diff --git a/src/ndns-tlv.h b/src/ndns-tlv.h
deleted file mode 100644
index d8535a5..0000000
--- a/src/ndns-tlv.h
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-namespace ndn {
-namespace tlv {
-namespace ndns {
- enum {
- Type = 2000,
- Fressness = 2001,
- ContentBlob = 2002,
- NumberOfRRData = 2003,
- RRData = 2004
- };//enum
-}//namespace ndns
-}//namespace tlv
-}//namespace ndn
diff --git a/src/ndns-tlv.hpp b/src/ndns-tlv.hpp
new file mode 100644
index 0000000..5343a96
--- /dev/null
+++ b/src/ndns-tlv.hpp
@@ -0,0 +1,34 @@
+/* -*- 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/>.
+ */
+
+namespace ndn {
+namespace ndns {
+namespace tlv {
+
+enum {
+ Type = 2000,
+ Fressness = 2001,
+ ContentBlob = 2002,
+ NumberOfRRData = 2003,
+ RRData = 2004
+};
+
+} // namespace tlv
+} // namespace ndns
+} // namespace ndn
diff --git a/src/query.cpp b/src/query.cpp
index 861d1c8..756de40 100644
--- a/src/query.cpp
+++ b/src/query.cpp
@@ -1,53 +1,63 @@
-/*
- * query.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: shock
+ * 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.h"
+#include "query.hpp"
namespace ndn {
+namespace ndns {
Query::Query()
-: m_interestLifetime(time::milliseconds(4000))
+ : m_interestLifetime(time::milliseconds(4000))
{
- // TODO Auto-generated constructor stub
-
}
Query::~Query() {
- // TODO Auto-generated destructor stub
}
void
Query::fromWire(const Name &name, const Interest &interest)
{
- Name interestName;
- interestName = interest.getName();
+ Name interestName;
+ interestName = interest.getName();
- int qtflag = -1;
- size_t len = interestName.size();
- for (size_t i=0; i<len; i++)
+ int qtflag = -1;
+ size_t len = interestName.size();
+ for (size_t i=0; i<len; i++)
{
- string comp = interestName.get(i).toEscapedString();
- if (comp == ndn::toString(QueryType::DNS) || comp == ndn::toString(QueryType::DNS_R))
- {
- qtflag = i;
- break;
- }
+ std::string comp = interestName.get(i).toUri();
+ if (comp == toString(QUERY_DNS) || comp == toString(QUERY_DNS_R))
+ {
+ qtflag = i;
+ break;
+ }
}//for
- if (qtflag == -1)
+ if (qtflag == -1)
{
- cerr<<"There is no QueryType in the Interest Name: "<<interestName<<endl;
- return;
+ std::cerr << "There is no QueryType in the Interest Name: " << interestName << std::endl;
+ return;
}
- this->m_queryType = ndn::toQueryType(interestName.get(qtflag).toEscapedString());
- this->m_rrType = ndn::toRRType(interestName.get(len-1).toEscapedString());
- this->m_authorityZone = interestName.getPrefix(qtflag); //the DNS/DNS-R is not included
- this->m_interestLifetime = interest.getInterestLifetime();
+ this->m_queryType = toQueryType(interestName.get(qtflag).toUri());
+ this->m_rrType = toRRType(interestName.get(len-1).toUri());
+ this->m_authorityZone = interestName.getPrefix(qtflag); //the DNS/DNS-R is not included
+ this->m_interestLifetime = interest.getInterestLifetime();
}
@@ -55,8 +65,8 @@
size_t
Query::wireEncode(EncodingImpl<T>& block) const
{
- size_t totalLength = 0;
- totalLength += 0;
+ size_t totalLength = 0;
+ totalLength += 0;
size_t totalLength = prependByteArrayBlock(block, tlv::Bytes,
@@ -71,15 +81,16 @@
Interest
Query::toWire() const
{
- Name name = this->m_authorityZone;
- name.append(ndn::toString(this->m_queryType));
- name.append(this->m_rrLabel);
- name.append(ndn::toString(this->m_rrType));
- Selectors selector;
- //selector.setMustBeFresh(true);
+ Name name = this->m_authorityZone;
+ name.append(toString(this->m_queryType));
+ name.append(this->m_rrLabel);
+ name.append(toString(this->m_rrType));
+ Selectors selector;
+ //selector.setMustBeFresh(true);
- Interest interest = Interest(name, selector, -1, this->m_interestLifetime);
- return interest;
+ Interest interest = Interest(name, selector, -1, this->m_interestLifetime);
+ return interest;
}
-} /* namespace ndn */
+} // namespace ndns
+} // namespace ndn
diff --git a/src/query.h b/src/query.h
deleted file mode 100644
index 001efa0..0000000
--- a/src/query.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * query.h
- *
- * Created on: 18 Jul, 2014
- * Author: shock
- */
-
-#ifndef QUERY_H_
-#define QUERY_H_
-
-#include <ndn-cxx/name.hpp>
-#include <rr.h>
-
-using namespace std;
-
-namespace ndn {
-
-
-enum class QueryType
-{
- DNS,
- DNS_R,
-};
-
-static const string
-toString(QueryType qType) const
-{
- string label;
- switch (qType)
- {
- case QueryType::DNS:
- label = "DNS";
- break;
- case QueryType::DNS_R:
- label = "DNS-R";
- break;
- default:
- label = "Default";
- break;
- }
- return label;
-
-}
-
-static const QueryType
-toQueryType(string str)
-{
- QueryType atype;
- switch (str)
- {
- case "DNS":
- atype = QueryType::DNS;
- break;
- case "DNS-R":
- atype = QueryType::DNS_R;
- break;
- defalut:
- atype = QueryType::DNS;
- break;
- }
- return atype;
-}
-
-
-
-
-class Query {
-public:
- Query();
-
- virtual ~Query();
-
-
-
- const Name& getAuthorityZone() const {
- return m_authorityZone;
- }
-
- void setAuthorityZone(const Name& authorityZone) {
- m_authorityZone = authorityZone;
- }
-
- time::milliseconds getInterestLifetime() const {
- return m_interestLifetime;
- }
-
- void setInterestLifetime(time::milliseconds interestLifetime) {
- m_interestLifetime = interestLifetime;
- }
-
- enum QueryType getQueryType() const {
- return m_queryType;
- }
-
- void setQueryType(enum QueryType queryType) {
- m_queryType = queryType;
- }
-
- const Name& getRrLabel() const {
- return m_rrLabel;
- }
-
- void setRrLabel(const Name& rrLabel) {
- m_rrLabel = rrLabel;
- }
-
- const RRType& getRrType() const {
- return m_rrType;
- }
-
- void setRrType(const RRType& rrType) {
- m_rrType = rrType;
- }
-
-private:
-template<bool T>
-size_t
-wireEncode(EncodingImpl<T> & block) const;
-
-public:
-
-const Block&
-wireEncode() const;
-
-void
-wireDecode(const Block& wire);
-
-
-Interest
-toWire() const;
-
-void
-fromWire(const Name &name, const Interest& interest);
-
-
-
-
-
-public:
- Name m_authorityZone;
- enum QueryType m_queryType;
- time::milliseconds m_interestLifetime;
- Name m_rrLabel;
- enum RRType m_rrType;
-
- mutable Block m_wire;
- //bool hasWire;
-};
-
-} /* namespace ndn */
-
-#endif /* QUERY_H_ */
diff --git a/src/query.hpp b/src/query.hpp
new file mode 100644
index 0000000..48ef464
--- /dev/null
+++ b/src/query.hpp
@@ -0,0 +1,152 @@
+/* -*- 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_QUERY_HPP
+#define NDNS_QUERY_HPP
+
+#include "rr.hpp"
+
+#include <ndn-cxx/name.hpp>
+
+namespace ndn {
+namespace ndns {
+
+class Query
+{
+public:
+
+ enum QueryType {
+ QUERY_DNS,
+ QUERY_DNS_R
+ };
+
+ Query();
+
+ virtual ~Query();
+
+ const Name& getAuthorityZone() const {
+ return m_authorityZone;
+ }
+
+ void setAuthorityZone(const Name& authorityZone) {
+ m_authorityZone = authorityZone;
+ }
+
+ time::milliseconds getInterestLifetime() const {
+ return m_interestLifetime;
+ }
+
+ void setInterestLifetime(time::milliseconds interestLifetime) {
+ m_interestLifetime = interestLifetime;
+ }
+
+ enum QueryType getQueryType() const {
+ return m_queryType;
+ }
+
+ void setQueryType(enum QueryType queryType) {
+ m_queryType = queryType;
+ }
+
+ const Name& getRrLabel() const {
+ return m_rrLabel;
+ }
+
+ void setRrLabel(const Name& rrLabel) {
+ m_rrLabel = rrLabel;
+ }
+
+ const RRType& getRrType() const {
+ return m_rrType;
+ }
+
+ void setRrType(const RRType& rrType) {
+ m_rrType = rrType;
+ }
+
+ static std::string
+ toString(QueryType qType)
+ {
+ std::string label;
+ switch (qType)
+ {
+ case QUERY_DNS:
+ label = "DNS";
+ break;
+ case QUERY_DNS_R:
+ label = "DNS-R";
+ break;
+ default:
+ label = "Default";
+ break;
+ }
+ return label;
+
+ }
+
+ static const QueryType
+ toQueryType(const std::string& str)
+ {
+ QueryType atype;
+ if (str == "DNS") {
+ atype = QUERY_DNS;
+ }
+ else if (str == "DNS-R") {
+ atype = QUERY_DNS_R;
+ }
+ else {
+ atype = QUERY_DNS;
+ }
+ return atype;
+ }
+
+private:
+ template<bool T>
+ size_t
+ wireEncode(EncodingImpl<T> & block) const;
+
+public:
+
+ const Block&
+ wireEncode() const;
+
+ void
+ wireDecode(const Block& wire);
+
+
+ Interest
+ toWire() const;
+
+ void
+ fromWire(const Name &name, const Interest& interest);
+
+public:
+ Name m_authorityZone;
+ enum QueryType m_queryType;
+ time::milliseconds m_interestLifetime;
+ Name m_rrLabel;
+ enum RRType m_rrType;
+
+ mutable Block m_wire;
+};
+
+} // namespace ndns
+} // namespace ndn
+
+#endif // NDNS_QUERY_HPP
diff --git a/src/resolver.cpp b/src/resolver.cpp
index 39da63d..fb9dd13 100644
--- a/src/resolver.cpp
+++ b/src/resolver.cpp
@@ -1,26 +1,45 @@
-/*
- * resolver.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: shock
+ * 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 "resolver.h"
+#include "resolver.hpp"
namespace ndn {
+namespace ndns {
-Resolver::Resolver() {
- // TODO Auto-generated constructor stub
+Resolver::Resolver()
+{
}
-Resolver::~Resolver() {
- // TODO Auto-generated destructor stub
+Resolver::~Resolver()
+{
}
-const RR Resolver::iterativelyResolve(const string domain, const string name){
- return "ex";
+
+const RR Resolver::iterativelyResolve(const std::string& domain, const std::string& name)
+{
+ return "ex";
}
-const RR Resolver::recusivelyResolve(const string domain, const string name){
- return "ex";
+
+const RR Resolver::recusivelyResolve(const std::string& domain, const std::string& name)
+{
+ return "ex";
}
-} /* namespace ndn */
+
+} // namespace ndns
+} // namespace ndn
diff --git a/src/resolver.h b/src/resolver.h
deleted file mode 100644
index 1dcdd6d..0000000
--- a/src/resolver.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * resolver.h
- *
- * Created on: 18 Jul, 2014
- * Author: shock
- */
-
-#ifndef RESOLVER_H_
-#define RESOLVER_H_
-
-#include <string>
-#include "rr.h"
-
-
-using namespace std;
-
-namespace ndn {
-
-class Resolver {
-public:
- Resolver();
- virtual ~Resolver();
-
-
- const RR iterativelyResolve(const string domain, const string name);
- const RR recusivelyResolve(const string domain, const string name);
-
-};
-
-} /* namespace ndn */
-
-#endif /* RESOLVER_H_ */
diff --git a/src/resolver.hpp b/src/resolver.hpp
new file mode 100644
index 0000000..d690c43
--- /dev/null
+++ b/src/resolver.hpp
@@ -0,0 +1,42 @@
+/* -*- 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_RESOLVER_HPP
+#define NDNS_RESOLVER_HPP
+
+#include "rr.hpp"
+
+namespace ndn {
+namespace ndns {
+
+class Resolver {
+public:
+ Resolver();
+ virtual ~Resolver();
+
+
+ const RR iterativelyResolve(const std::string& domain, const std::string& name);
+ const RR recusivelyResolve(const std::string& domain, const std::string& name);
+
+};
+
+} // namespace ndns
+} // namespace ndn
+
+#endif // NDNS_RESOLVER_HPP
diff --git a/src/response.cpp b/src/response.cpp
index a4c7746..f0c5b17 100644
--- a/src/response.cpp
+++ b/src/response.cpp
@@ -1,121 +1,128 @@
-/*
- * response.cpp
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, Regents of the University of California.
*
- * Created on: 19 Jul, 2014
- * Author: shock
+ * 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 "response.h"
-
+#include "response.hpp"
namespace ndn {
+namespace ndns {
-Response::Response() {
- // TODO Auto-generated constructor stub
-
+Response::Response()
+{
}
-Response::~Response() {
- // TODO Auto-generated destructor stub
+Response::~Response()
+{
}
-
Data
Response::toWire() const
{
- Name name = this->m_queryName;
- name.append(this->m_serial);
+ Name name = this->m_queryName;
+ name.append(this->m_serial);
- Data data(name);
+ Data data(name);
- data.setFreshnessPeriod(this->m_freshness);
+ data.setFreshnessPeriod(this->m_freshness);
- string content = "";
+ string content = "";
- size_t totalLen = 0;
- Block block = Block();
- block.push_back
- (nonNegativeIntegerBlock
- (tlv::ndns::Type, static_cast<unsigned long>(this->m_responseType))
- );
+ size_t totalLen = 0;
+ Block block = Block();
+ block.push_back
+ (nonNegativeIntegerBlock
+ (tlv::ndns::Type, static_cast<unsigned long>(this->m_responseType))
+ );
- block.push_back
- (nonNegativeIntegerBlock
- (tlv::ndns::Fressness, this->m_freshness.count())
- );
+ block.push_back
+ (nonNegativeIntegerBlock
+ (tlv::ndns::Fressness, this->m_freshness.count())
+ );
- Block block2 = Block(tlv::ndns::ContentBlob);
- block2.push_back
- (nonNegativeIntegerBlock
- (tlv::ndns::NumberOfRRData, this->m_numberOfRR)
- );
+ Block block2 = Block(tlv::ndns::ContentBlob);
+ block2.push_back
+ (nonNegativeIntegerBlock
+ (tlv::ndns::NumberOfRRData, this->m_numberOfRR)
+ );
- for (int i=0; i<this->m_numberOfRR; i++)
- {
- RR rr = m_rrs[i];
- block2.push_back(rr.toWire());
- }
+ for (int i=0; i<this->m_numberOfRR; i++)
+ {
+ RR rr = m_rrs[i];
+ block2.push_back(rr.toWire());
+ }
- block.push_back(block2);
+ block.push_back(block2);
- return data;
+ return data;
}
void
Response::fromWire(const Interest &interest, const Data &data)
{
- Name dataName;
- dataName = data.getName();
+ Name dataName;
+ dataName = data.getName();
- int qtflag = -1;
- size_t len = dataName.size();
- for (size_t i=0; i<len; i++)
+ int qtflag = -1;
+ size_t len = dataName.size();
+ for (size_t i=0; i<len; i++)
{
- string comp = dataName.get(i).toEscapedString();
- if (comp == ndn::toString(QueryType::DNS) || comp == ndn::toString(QueryType::DNS_R))
- {
- qtflag = i;
- break;
- }
+ string comp = dataName.get(i).toEscapedString();
+ if (comp == ndn::toString(QueryType::DNS) || comp == ndn::toString(QueryType::DNS_R))
+ {
+ qtflag = i;
+ break;
+ }
}//for
- if (qtflag == -1)
+ if (qtflag == -1)
{
- cerr<<"There is no QueryType in the Interest Name: "<<dataName<<endl;
- return;
+ cerr<<"There is no QueryType in the Interest Name: "<<dataName<<endl;
+ return;
}
- this->m_queryName = dataName.getPrefix(-1);
+ this->m_queryName = dataName.getPrefix(-1);
- string last = dataName.get(len-1).toEscapedString();
- if (ndn::toRRType(last) == RRType::UNKNOWN)
+ string last = dataName.get(len-1).toEscapedString();
+ if (ndn::toRRType(last) == RRType::UNKNOWN)
{
- this->m_serial = "";
+ this->m_serial = "";
} else
{
- this->m_serial = last;
+ this->m_serial = last;
}
- Block block = data.getContent();
- this->m_numberOfRR = readNonNegativeInteger(block.get(tlv::ndns::NumberOfRRData));
+ Block block = data.getContent();
+ this->m_numberOfRR = readNonNegativeInteger(block.get(tlv::ndns::NumberOfRRData));
- Block block2 = block.get(tlv::ndns::ContentBlob);
- for (int i=0; i<this->m_numberOfRR; i++)
+ Block block2 = block.get(tlv::ndns::ContentBlob);
+ for (int i=0; i<this->m_numberOfRR; i++)
{
- Block block3 = block2.get(tlv::ndns::RRData);
- RR rr;
- rr.fromWire(block3);
- m_rrs.push_back(rr);
+ Block block3 = block2.get(tlv::ndns::RRData);
+ RR rr;
+ rr.fromWire(block3);
+ m_rrs.push_back(rr);
}
}
-} /* namespace ndn */
-
-
-
-
+} // namespace ndns
+} // namespace ndn
diff --git a/src/response.h b/src/response.h
deleted file mode 100644
index 52e11c6..0000000
--- a/src/response.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * response.h
- *
- * Created on: 19 Jul, 2014
- * Author: shock
- */
-
-#ifndef RESPONSE_H_
-#define RESPONSE_H_
-
-#include <boost/asio.hpp> // /opt/local/include
-#include <boost/bind.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/noncopyable.hpp>
-
-#include <ndn-cxx/face.hpp> // /usr/local/include
-#include <ndn-cxx/name.hpp>
-#include <ndn-cxx/data.hpp>
-
-#include <ndn-cxx/encoding/block-helpers.hpp>
-#include <ndn-cxx/encoding/block.hpp>
-#include <ndn-cxx/encoding/tlv-ndnd.hpp>
-
-#include<vector>
-
-#include "ndns-tlv.h"
-
-using namespace std;
-
-namespace ndn {
-
-
-
-enum class ResponseType
-{
- NDNS_Resp,
- NDNS_Nack,
- NDNS_Auth
-};
-
-
-static const string
-toString(ResponseType responseType) const
-{
- string label;
- switch (responseType)
- {
- case ResponseType::NDNS_Resp:
- label = "NDNS Resp";
- break;
- case ResponseType::NDNS_Nack:
- label = "NDNS Nack";
- break;
- case ResponseType::NDNS_Auth:
- label = "NDNS Auth";
- break;
- default:
- label = "Default";
- break;
- }
- return label;
-}
-
-class Response {
-public:
- Response();
- virtual ~Response();
-
-Data
-toWire() const;
-
-void
-fromWire(const Interest &interest, const Data &data);
-
-private:
- Name m_queryName;
- string m_serial;
- ResponseType m_responseType;
-
- time::milliseconds m_freshness;
-
- unsigned int m_numberOfRR;
- vector<RR> m_rrs;
-
-};
-
-} /* namespace ndn */
-
-#endif /* RESPONSE_H_ */
diff --git a/src/response.hpp b/src/response.hpp
new file mode 100644
index 0000000..95a4cda
--- /dev/null
+++ b/src/response.hpp
@@ -0,0 +1,99 @@
+/* -*- 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_RESPONSE_HPP
+#define NDNS_RESPONSE_HPP
+
+#include <boost/asio.hpp>
+#include <boost/bind.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/noncopyable.hpp>
+
+#include <ndn-cxx/face.hpp> // /usr/local/include
+#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/data.hpp>
+
+#include <ndn-cxx/encoding/block-helpers.hpp>
+#include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/encoding/tlv-ndnd.hpp>
+
+#include <vector>
+
+#include "ndns-tlv.hpp"
+
+namespace ndn {
+namespace ndns {
+
+enum ResponseType
+ {
+ NDNS_Resp,
+ NDNS_Nack,
+ NDNS_Auth
+ };
+
+
+static std::string
+toString(ResponseType responseType) const
+{
+ string label;
+ switch (responseType)
+ {
+ case ResponseType::NDNS_Resp:
+ label = "NDNS Resp";
+ break;
+ case ResponseType::NDNS_Nack:
+ label = "NDNS Nack";
+ break;
+ case ResponseType::NDNS_Auth:
+ label = "NDNS Auth";
+ break;
+ default:
+ label = "Default";
+ break;
+ }
+ return label;
+}
+
+class Response {
+public:
+ Response();
+ virtual ~Response();
+
+ Data
+ toWire() const;
+
+ void
+ fromWire(const Interest &interest, const Data &data);
+
+private:
+ Name m_queryName;
+ std::string m_serial;
+ ResponseType m_responseType;
+
+ time::milliseconds m_freshness;
+
+ unsigned int m_numberOfRR;
+ vector<RR> m_rrs;
+
+};
+
+} // namespace ndns
+} // namespace ndn
+
+#endif // NDNS_RESPONSE_HPP
diff --git a/src/rr.cpp b/src/rr.cpp
index 0b9d6d8..4f55e21 100644
--- a/src/rr.cpp
+++ b/src/rr.cpp
@@ -1,79 +1,89 @@
-/*
- * RR.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: shock
+ * 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 "RR.h"
+#include "rr.hpp"
namespace ndn {
+namespace ndns {
RR::RR()
-: id (0Lu)
-, m_rrData("ex.com")
+ : m_id(0Lu)
+ , m_rrData("ex.com")
{
- // TODO Auto-generated constructor stub
-
}
-RR::~RR() {
- // TODO Auto-generated destructor stub
+RR::~RR()
+{
}
template<bool T>
size_t
RR::wireEncode(EncodingImpl<T> & block) const
{
- size_t totalLength = 0;
- string msg = this->getRrdata();
- totalLength += prependByteArrayBlock(block,
- tlv::ndns::RRData,
- reinterpret_cast<const uint8_t*>(msg.c_str()),
- msg.size()
- );
+ size_t totalLength = 0;
+ const std::string& msg = this->getRrdata();
+ totalLength += prependByteArrayBlock(block,
+ tlv::ndns::RRData,
+ reinterpret_cast<const uint8_t*>(msg.c_str()),
+ msg.size()
+ );
- return totalLength;
+ return totalLength;
}
const Block&
RR::wireEncode() const
{
- if (m_wire.hasWire())
- return m_wire;
- EncodingEstimator estimator;
- size_t estimatedSize = wireEncode(estimator);
- EncodingBuffer buffer(estimatedSize, 0);
- wireEncode(buffer);
- m_wire = buffer.block();
- return m_wire;
+ if (m_wire.hasWire())
+ return m_wire;
+ EncodingEstimator estimator;
+ size_t estimatedSize = wireEncode(estimator);
+ EncodingBuffer buffer(estimatedSize, 0);
+ wireEncode(buffer);
+ m_wire = buffer.block();
+ return m_wire;
}
void
RR::wireDecode(const Block& wire)
{
- if (!wire.hasWire()) {
- throw Tlv::Error("The supplied block does not contain wire format");
- }
+ if (!wire.hasWire()) {
+ throw Tlv::Error("The supplied block does not contain wire format");
+ }
- if (wire.type() != tlv::ndns::RRData)
- throw Tlv::Error("Unexpected TLV type when decoding Content");
+ if (wire.type() != tlv::ndns::RRData)
+ throw Tlv::Error("Unexpected TLV type when decoding Content");
- m_wire = wire;
- m_wire.parse();
+ m_wire = wire;
+ m_wire.parse();
- Block::element_const_iterator it = m_wire.elements_begin();
+ Block::element_const_iterator it = m_wire.elements_begin();
- if (it != m_wire.elements_end() && it->type() == tlv::ndns::RRData)
- {
- m_rrData = string(reinterpret_cast<const char*>(it->value()), it->value_size());
- it ++;
- } else {
- throw Tlv::Error("not the RRData Type");
- }
+ if (it != m_wire.elements_end() && it->type() == tlv::ndns::RRData)
+ {
+ m_rrData = std::string(reinterpret_cast<const char*>(it->value()), it->value_size());
+ it ++;
+ } else {
+ throw Tlv::Error("not the RRData Type");
+ }
}
-
-
-} /* namespace ndn */
+} // namespace ndns
+} // namespace ndn
diff --git a/src/rr.h b/src/rr.h
deleted file mode 100644
index d6de294..0000000
--- a/src/rr.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * RR.h
- *
- * Created on: 18 Jul, 2014
- * Author: shock
- */
-
-#ifndef RR_H_
-#define RR_H_
-
-#include <string>
-
-
-#include "ndns-tlv.h"
-#include <ndn-cxx/encoding/block.hpp>
-#include <ndn-cxx/interest.hpp>
-
-
-using namespace std;
-
-namespace ndn {
-
-enum RRType
-{
- NS,
- TXT,
- UNKNOWN
-};
-
-
-
-
-class RR {
-public:
- RR();
- virtual ~RR();
-
- const string& getRrdata() const {
- return m_rrData;
- }
-
- void setRrdata(const string& rrdata) {
- this->m_rrData = rrdata;
- }
-
-
-
-private:
-template<bool T>
-size_t
-wireEncode(EncodingImpl<T> & block) const;
-
-public:
-
-const Block&
-wireEncode() const;
-
-void
-wireDecode(const Block& wire);
-
-
-Interest
-toWire() const;
-
-
-private:
- unsigned long id;
- string m_rrData;
-
- mutable Block m_wire;
-};
-
-} /* namespace ndn */
-
-#endif /* RR_H_ */
diff --git a/src/rr.hpp b/src/rr.hpp
new file mode 100644
index 0000000..95001e9
--- /dev/null
+++ b/src/rr.hpp
@@ -0,0 +1,82 @@
+/* -*- 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_RR_HPP
+#define NDNS_RR_HPP
+
+#include "ndns-tlv.hpp"
+
+#include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/interest.hpp>
+
+namespace ndn {
+namespace ndns {
+
+enum RRType
+ {
+ NS,
+ TXT,
+ UNKNOWN
+ };
+
+class RR {
+public:
+ RR();
+ virtual ~RR();
+
+ const std::string&
+ getRrdata() const
+ {
+ return m_rrData;
+ }
+
+ void setRrdata(const std::string& rrdata)
+ {
+ this->m_rrData = rrdata;
+ }
+
+private:
+ template<bool T>
+ size_t
+ wireEncode(EncodingImpl<T> & block) const;
+
+public:
+
+ const Block&
+ wireEncode() const;
+
+ void
+ wireDecode(const Block& wire);
+
+
+ Interest
+ toWire() const;
+
+
+private:
+ uint32_t m_id;
+ std::string m_rrData;
+
+ mutable Block m_wire;
+};
+
+} // namespace ndns
+} // namespace ndn
+
+#endif // NDNS_RR_HPP
diff --git a/src/zone.cpp b/src/zone.cpp
index 9483941..f5a33ba 100644
--- a/src/zone.cpp
+++ b/src/zone.cpp
@@ -1,25 +1,36 @@
-/*
- * zone.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: shock
+ * 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 "zone.h"
+#include "zone.hpp"
namespace ndn {
+namespace ndns {
Zone::Zone() {
- // TODO Auto-generated constructor stub
-
}
Zone::~Zone() {
- // TODO Auto-generated destructor stub
}
-const RR Zone::hasName(string key) {
- return "example.key";
+const RR Zone::hasName(const std::string& key) {
+ return "example.key";
}
-} /* namespace ndn */
+} // namespace ndns
+} // namespace ndn
diff --git a/src/zone.h b/src/zone.h
deleted file mode 100644
index bdc2581..0000000
--- a/src/zone.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * zone.h
- *
- * Created on: 18 Jul, 2014
- * Author: shock
- */
-
-#ifndef ZONE_H_
-#define ZONE_H_
-
-#include <string>
-#include "rr.h"
-
-
-using namespace std;
-
-namespace ndn {
-
-class Zone {
-public:
- Zone();
- virtual ~Zone();
-
- const RR hasName(string key);
-
-};
-
-} /* namespace ndn */
-
-#endif /* ZONE_H_ */
diff --git a/src/zone.hpp b/src/zone.hpp
new file mode 100644
index 0000000..a54c9a8
--- /dev/null
+++ b/src/zone.hpp
@@ -0,0 +1,40 @@
+/* -*- 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_ZONE_HPP
+#define NDNS_ZONE_HPP
+
+#include "rr.hpp"
+
+namespace ndn {
+namespace ndns {
+
+class Zone {
+public:
+ Zone();
+ virtual ~Zone();
+
+ const RR hasName(const std::string& key);
+
+};
+
+} // namespace ndns
+} // namespace ndn
+
+#endif // NDNS_ZONE_HPP