change PROBE format for max-suffix-length for each suggested name
Change-Id: Ie0823963fd3c56e40d825e0e80dfadf164f08ca3
diff --git a/src/protocol-detail/probe.cpp b/src/protocol-detail/probe.cpp
index b0ac75c..8132e28 100644
--- a/src/protocol-detail/probe.cpp
+++ b/src/protocol-detail/probe.cpp
@@ -54,10 +54,12 @@
{
Block content = makeEmptyBlock(tlv::Content);
for (const auto& name : identifiers) {
- content.push_back(makeNestedBlock(tlv_probe_response, name));
- }
- if (maxSuffixLength) {
- content.push_back(makeNonNegativeIntegerBlock(tlv_max_suffix_length, *maxSuffixLength));
+ Block item(tlv_probe_response);
+ item.push_back(name.wireEncode());
+ if (maxSuffixLength) {
+ item.push_back(makeNonNegativeIntegerBlock(tlv_max_suffix_length, *maxSuffixLength));
+ }
+ content.push_back(item);
}
if (redirectionItems) {
for (const auto& item : *redirectionItems) {
@@ -70,16 +72,32 @@
void
PROBE::decodeDataContent(const Block& block,
- std::vector<Name>& availableNames,
+ std::vector<std::pair<Name, int>>& availableNames,
std::vector<Name>& availableRedirection)
{
block.parse();
for (const auto& item : block.elements()) {
if (item.type() == tlv_probe_response) {
- availableNames.push_back(Name(item.blockFromValue()));
+ item.parse();
+ Name elementName;
+ int maxSuffixLength = 0;
+ for (const auto& subBlock: item.elements()) {
+ if (subBlock.type() == tlv::Name) {
+ if (!elementName.empty()) {
+ BOOST_THROW_EXCEPTION(std::runtime_error("Invalid probe format"));
+ }
+ elementName.wireDecode(subBlock);
+ } else if (subBlock.type() == tlv_max_suffix_length) {
+ maxSuffixLength = readNonNegativeInteger(subBlock);
+ }
+ }
+ if (elementName.empty()) {
+ BOOST_THROW_EXCEPTION(std::runtime_error("Invalid probe format"));
+ }
+ availableNames.emplace_back(elementName, maxSuffixLength);
}
if (item.type() == tlv_probe_redirect) {
- availableRedirection.push_back(Name(item.blockFromValue()));
+ availableRedirection.emplace_back(Name(item.blockFromValue()));
}
}
}
diff --git a/src/protocol-detail/probe.hpp b/src/protocol-detail/probe.hpp
index 7d61461..e6ff022 100644
--- a/src/protocol-detail/probe.hpp
+++ b/src/protocol-detail/probe.hpp
@@ -33,7 +33,7 @@
encodeApplicationParameters(std::vector<std::tuple<std::string, std::string>>&& parameters);
static void
- decodeDataContent(const Block& block, std::vector<Name>& availableNames,
+ decodeDataContent(const Block& block, std::vector<std::pair<Name, int>>& availableNames,
std::vector<Name>& availableRedirection);
// For CA use
diff --git a/src/requester.cpp b/src/requester.cpp
index 0b5a6c5..2e6a517 100644
--- a/src/requester.cpp
+++ b/src/requester.cpp
@@ -107,7 +107,7 @@
void
Requester::onProbeResponse(const Data& reply, const CaProfile& ca,
- std::vector<Name>& identityNames, std::vector<Name>& otherCas)
+ std::vector<std::pair<Name, int>>& identityNames, std::vector<Name>& otherCas)
{
if (!security::verifySignature(reply, *ca.m_cert)) {
_LOG_ERROR("Cannot verify replied Data packet signature.");
diff --git a/src/requester.hpp b/src/requester.hpp
index 1b64d4b..f08e579 100644
--- a/src/requester.hpp
+++ b/src/requester.hpp
@@ -158,7 +158,7 @@
*/
static void
onProbeResponse(const Data& reply, const CaProfile& ca,
- std::vector<Name>& identityNames, std::vector<Name>& otherCas);
+ std::vector<std::pair<Name, int>>& identityNames, std::vector<Name>& otherCas);
// NEW/REVOKE/RENEW related helpers
/**