fix all unit tests
Change-Id: I81ddefe248a563f0dda79b6bb27897599b84ce59
diff --git a/src/protocol-detail/info.cpp b/src/protocol-detail/info.cpp
index da8b969..06eba0e 100644
--- a/src/protocol-detail/info.cpp
+++ b/src/protocol-detail/info.cpp
@@ -49,7 +49,7 @@
}
CaConfigItem
-INFO::decodeDataContentToCaProfile(const Block& block)
+INFO::decodeDataContent(const Block& block)
{
CaConfigItem result;
block.parse();
diff --git a/src/protocol-detail/info.hpp b/src/protocol-detail/info.hpp
index 1c375bb..03f0d61 100644
--- a/src/protocol-detail/info.hpp
+++ b/src/protocol-detail/info.hpp
@@ -38,7 +38,7 @@
* Decode CA configuration from the TLV block of INFO Data packet content.
*/
static CaConfigItem
- decodeDataContentToCaProfile(const Block& block);
+ decodeDataContent(const Block& block);
};
} // namespace ndncert
diff --git a/src/protocol-detail/probe.cpp b/src/protocol-detail/probe.cpp
index 93ba020..c7b72d5 100644
--- a/src/protocol-detail/probe.cpp
+++ b/src/protocol-detail/probe.cpp
@@ -19,8 +19,9 @@
*/
#include "probe.hpp"
-#include <ndn-cxx/encoding/tlv.hpp>
+
#include <boost/throw_exception.hpp>
+#include <ndn-cxx/encoding/tlv.hpp>
namespace ndn {
namespace ndncert {
@@ -38,7 +39,19 @@
return content;
}
-// For CA
+std::vector<std::tuple<std::string, std::string>>
+PROBE::decodeApplicationParameters(const Block& block)
+{
+ std::vector<std::tuple<std::string, std::string>> result;
+ block.parse();
+ for (size_t i = 0; i < block.elements().size() - 1; ++i) {
+ if (block.elements().at(i).type() == tlv_parameter_key && block.elements().at(i + 1).type() == tlv_parameter_value) {
+ result.push_back(std::make_tuple(readString(block.elements().at(i)), readString(block.elements().at(i + 1))));
+ }
+ }
+ return result;
+}
+
Block
PROBE::encodeDataContent(const std::vector<Name>& identifiers, boost::optional<size_t> maxSuffixLength)
{
@@ -53,5 +66,18 @@
return content;
}
+std::vector<Name>
+PROBE::decodeDataContent(const Block& block)
+{
+ std::vector<Name> result;
+ block.parse();
+ for (const auto& item : block.elements()) {
+ if (item.type() == tlv_probe_response) {
+ result.push_back(Name(item.blockFromValue()));
+ }
+ }
+ return result;
+}
+
} // namespace ndncert
} // namespace ndn
\ No newline at end of file
diff --git a/src/protocol-detail/probe.hpp b/src/protocol-detail/probe.hpp
index 126fba4..8d08e4b 100644
--- a/src/protocol-detail/probe.hpp
+++ b/src/protocol-detail/probe.hpp
@@ -28,11 +28,19 @@
class PROBE {
public:
+ // For CA use
static Block
encodeApplicationParameters(std::vector<std::tuple<std::string, std::string>>&& parameters);
+ static std::vector<Name>
+ decodeDataContent(const Block& block);
+
+ // For client use
static Block
encodeDataContent(const std::vector<Name>& identifiers, boost::optional<size_t> maxSuffixLength);
+
+ static std::vector<std::tuple<std::string, std::string>>
+ decodeApplicationParameters(const Block& block);
};
} // namespace ndncert