refactor client module to requester
Change-Id: I2b9835af7f03942bfdb6a886c95cfb4b907e2068
diff --git a/src/protocol-detail/challenge.cpp b/src/protocol-detail/challenge.cpp
index 61a3519..85875fd 100644
--- a/src/protocol-detail/challenge.cpp
+++ b/src/protocol-detail/challenge.cpp
@@ -19,8 +19,6 @@
*/
#include "challenge.hpp"
-#include "../ndncert-common.hpp"
-#include "../request-state.hpp"
namespace ndn {
namespace ndncert {
diff --git a/src/protocol-detail/error.cpp b/src/protocol-detail/error.cpp
index b74180b..dabfa6a 100644
--- a/src/protocol-detail/error.cpp
+++ b/src/protocol-detail/error.cpp
@@ -37,16 +37,11 @@
ErrorTLV::decodefromDataContent(const Block& block)
{
block.parse();
+ if (block.find(tlv_error_code) == block.elements_end()) {
+ return std::make_tuple(ErrorCode::NO_ERROR, "");
+ }
ErrorCode error = static_cast<ErrorCode>(readNonNegativeInteger(block.get(tlv_error_code)));
- auto description = readString(block.get(tlv_error_info));
- return std::make_tuple(error, description);
-}
-
-bool
-ErrorTLV::isErrorContent(const Block& block)
-{
- block.parse();
- return block.find(tlv_error_code) != block.elements_end();
+ return std::make_tuple(error, readString(block.get(tlv_error_info)));
}
} // namespace ndncert
diff --git a/src/protocol-detail/error.hpp b/src/protocol-detail/error.hpp
index d39fe1a..8a2cda0 100644
--- a/src/protocol-detail/error.hpp
+++ b/src/protocol-detail/error.hpp
@@ -39,9 +39,6 @@
*/
static std::tuple<ErrorCode, std::string>
decodefromDataContent(const Block& block);
-
- static bool
- isErrorContent(const Block& block);
};
} // namespace ndncert
diff --git a/src/protocol-detail/info.cpp b/src/protocol-detail/info.cpp
index 06eba0e..7c0e449 100644
--- a/src/protocol-detail/info.cpp
+++ b/src/protocol-detail/info.cpp
@@ -24,7 +24,7 @@
namespace ndncert {
Block
-INFO::encodeDataContent(const CaConfigItem& caConfig, const security::v2::Certificate& certificate)
+INFO::encodeDataContent(const CaProfile& caConfig, const security::v2::Certificate& certificate)
{
auto content = makeEmptyBlock(tlv::Content);
content.push_back(makeNestedBlock(tlv_ca_prefix, caConfig.m_caPrefix));
@@ -48,10 +48,10 @@
return content;
}
-CaConfigItem
+CaProfile
INFO::decodeDataContent(const Block& block)
{
- CaConfigItem result;
+ CaProfile result;
block.parse();
for (auto const& item : block.elements()) {
switch (item.type()) {
diff --git a/src/protocol-detail/info.hpp b/src/protocol-detail/info.hpp
index 03f0d61..571d120 100644
--- a/src/protocol-detail/info.hpp
+++ b/src/protocol-detail/info.hpp
@@ -32,12 +32,12 @@
* Encode CA configuration and its certificate into a TLV block as INFO Data packet content.
*/
static Block
- encodeDataContent(const CaConfigItem& caConfig, const security::v2::Certificate& certificate);
+ encodeDataContent(const CaProfile& caConfig, const security::v2::Certificate& certificate);
/**
* Decode CA configuration from the TLV block of INFO Data packet content.
*/
- static CaConfigItem
+ static CaProfile
decodeDataContent(const Block& block);
};