prepare for using TLV in probe
Change-Id: I40dbf460909a20610b4e99be4701c58f80b1bc46
diff --git a/src/protocol-detail/info.cpp b/src/protocol-detail/info.cpp
index fb2cce5..51dc3f8 100644
--- a/src/protocol-detail/info.cpp
+++ b/src/protocol-detail/info.cpp
@@ -24,7 +24,7 @@
namespace ndncert {
Block
-INFO::encodeContentFromCAConfig(const CaConfig& caConfig, const security::v2::Certificate& certificate)
+INFO::encodeDataContent(const CaConfig& caConfig, const security::v2::Certificate& certificate)
{
auto content = makeEmptyBlock(tlv::Content);
content.push_back(makeNestedBlock(tlv_ca_prefix, caConfig.m_caPrefix));
diff --git a/src/protocol-detail/info.hpp b/src/protocol-detail/info.hpp
index 9c190f2..a21040e 100644
--- a/src/protocol-detail/info.hpp
+++ b/src/protocol-detail/info.hpp
@@ -29,9 +29,15 @@
class INFO {
public:
+ /**
+ * Encode CA configuration and its certificate into a TLV block as INFO Data packet content.
+ */
static Block
- encodeContentFromCAConfig(const CaConfig& caConfig, const security::v2::Certificate& certificate);
+ encodeDataContent(const CaConfig& caConfig, const security::v2::Certificate& certificate);
+ /**
+ * Decode CA configuration from the TLV block of INFO Data packet content.
+ */
static ClientCaItem
decodeClientConfigFromContent(const Block& block);
};
diff --git a/src/protocol-detail/new.hpp b/src/protocol-detail/new.hpp
index ae95a15..ee141d7 100644
--- a/src/protocol-detail/new.hpp
+++ b/src/protocol-detail/new.hpp
@@ -21,26 +21,35 @@
#ifndef NDNCERT_PROTOCOL_DETAIL_NEW_HPP
#define NDNCERT_PROTOCOL_DETAIL_NEW_HPP
+#include <ndn-cxx/security/v2/certificate.hpp>
+
#include "../certificate-request.hpp"
#include "ndn-cxx/encoding/block.hpp"
-#include <ndn-cxx/security/v2/certificate.hpp>
namespace ndn {
namespace ndncert {
class NEW {
public:
+ /**
+ * Encode Client's certificate request into a ApplicationParameters TLV for NEW Interest.
+ * For client side use.
+ */
static Block
encodeApplicationParameters(const std::string& ecdhPub, const security::v2::Certificate& certRequest,
- const shared_ptr<Data>& probeToken);
+ const shared_ptr<Data>& probeToken);
+ /**
+ * Encode CA's response of NEW Interest into a content TLV for NEW Data packet.
+ * For CA side use.
+ */
static Block
encodeDataContent(const std::string& ecdhKey, const std::string& salt,
- const CertificateRequest& request,
- const std::list<std::string>& challenges);
+ const CertificateRequest& request,
+ const std::list<std::string>& challenges);
};
} // namespace ndncert
} // namespace ndn
-#endif // NDNCERT_PROTOCOL_DETAIL_HPP
\ No newline at end of file
+#endif // NDNCERT_PROTOCOL_DETAIL_HPP
\ No newline at end of file
diff --git a/src/protocol-detail/probe.cpp b/src/protocol-detail/probe.cpp
index f8a561d..2a3a71e 100644
--- a/src/protocol-detail/probe.cpp
+++ b/src/protocol-detail/probe.cpp
@@ -19,10 +19,12 @@
*/
#include "probe.hpp"
-#include "boost/throw_exception.hpp"
-#include "../logging.hpp"
+
+#include <boost/throw_exception.hpp>
#include <ndn-cxx/encoding/tlv.hpp>
+#include "../logging.hpp"
+
namespace ndn {
namespace ndncert {
@@ -48,19 +50,18 @@
auto content = makeEmptyBlock(tlv::ApplicationParameters);
std::vector<std::string> fields = parseProbeComponents(ca.m_probe);
- std::vector<std::string> arguments = parseProbeComponents(probeInfo);;
+ std::vector<std::string> arguments = parseProbeComponents(probeInfo);
+ ;
if (arguments.size() != fields.size()) {
- BOOST_THROW_EXCEPTION(Error("Error in genProbeRequestJson: argument list does not match field list in the config file."));
+ BOOST_THROW_EXCEPTION(std::runtime_error("Error in genProbeRequestJson: argument list does not match field list in the config file."));
}
for (size_t i = 0; i < fields.size(); ++i) {
- content.push_back(
- makeStringBlock(tlv_parameter_key, fields.at(i))
- );
- content.push_back(
- makeStringBlock(tlv_parameter_value, arguments.at(i))
- );
+ content.push_back(
+ makeStringBlock(tlv_parameter_key, fields.at(i)));
+ content.push_back(
+ makeStringBlock(tlv_parameter_value, arguments.at(i)));
}
content.encode();
return content;
@@ -81,7 +82,7 @@
fields.push_back(m_probe.substr(last));
Block content = makeEmptyBlock(tlv::Content);
-
+
// TODO: Currently have no mechanism to utilize the given params to determine name
//for (size_t i = 0; i < fields.size(); ++i) {
// root.put(fields.at(i), parameterJson.get(fields.at(i), ""));
diff --git a/src/protocol-detail/probe.hpp b/src/protocol-detail/probe.hpp
index 6fbca8e..41b73c8 100644
--- a/src/protocol-detail/probe.hpp
+++ b/src/protocol-detail/probe.hpp
@@ -28,17 +28,6 @@
namespace ndncert {
class PROBE {
-
-public:
- /**
- * @brief Error that can be thrown from PROBE
- */
- class Error : public std::runtime_error
- {
- public:
- using std::runtime_error::runtime_error;
- };
-
public:
static std::vector<std::string>
parseProbeComponents(const std::string& probe);
@@ -53,4 +42,4 @@
} // namespace ndncert
} // namespace ndn
-#endif // NDNCERT_PROTOCOL_DETAIL_HPP
\ No newline at end of file
+#endif // NDNCERT_PROTOCOL_DETAIL_HPP
\ No newline at end of file