commons clean up
Change-Id: I13ce15666974e294d2645768dd20194f0584d406
diff --git a/src/protocol-detail/challenge.cpp b/src/protocol-detail/challenge.cpp
index 3504115..d49ca4e 100644
--- a/src/protocol-detail/challenge.cpp
+++ b/src/protocol-detail/challenge.cpp
@@ -26,14 +26,14 @@
Block
CHALLENGE::encodeDataContent(const CaState& request)
{
- Block response = makeEmptyBlock(tlv_encrypted_payload);
- response.push_back(makeNonNegativeIntegerBlock(tlv_status, static_cast<size_t>(request.m_status)));
+ Block response = makeEmptyBlock(tlv::EncryptedPayload);
+ response.push_back(makeNonNegativeIntegerBlock(tlv::Status, static_cast<size_t>(request.m_status)));
if (request.m_challengeState) {
- response.push_back(makeStringBlock(tlv_challenge_status, request.m_challengeState->m_challengeStatus));
+ response.push_back(makeStringBlock(tlv::ChallengeStatus, request.m_challengeState->m_challengeStatus));
response.push_back(
- makeNonNegativeIntegerBlock(tlv_remaining_tries, request.m_challengeState->m_remainingTries));
+ makeNonNegativeIntegerBlock(tlv::RemainingTries, request.m_challengeState->m_remainingTries));
response.push_back(
- makeNonNegativeIntegerBlock(tlv_remaining_time, request.m_challengeState->m_remainingTime.count()));
+ makeNonNegativeIntegerBlock(tlv::RemainingTime, request.m_challengeState->m_remainingTime.count()));
}
response.encode();
return response;
@@ -43,18 +43,18 @@
CHALLENGE::decodeDataContent(const Block& data, RequesterState& state)
{
data.parse();
- state.m_status = static_cast<Status>(readNonNegativeInteger(data.get(tlv_status)));
- if (data.find(tlv_challenge_status) != data.elements_end()) {
- state.m_challengeStatus = readString(data.get(tlv_challenge_status));
+ state.m_status = static_cast<Status>(readNonNegativeInteger(data.get(tlv::Status)));
+ if (data.find(tlv::ChallengeStatus) != data.elements_end()) {
+ state.m_challengeStatus = readString(data.get(tlv::ChallengeStatus));
}
- if (data.find(tlv_remaining_tries) != data.elements_end()) {
- state.m_remainingTries = readNonNegativeInteger(data.get(tlv_remaining_tries));
+ if (data.find(tlv::RemainingTries) != data.elements_end()) {
+ state.m_remainingTries = readNonNegativeInteger(data.get(tlv::RemainingTries));
}
- if (data.find(tlv_remaining_time) != data.elements_end()) {
- state.m_freshBefore = time::system_clock::now() + time::seconds(readNonNegativeInteger(data.get(tlv_remaining_time)));
+ if (data.find(tlv::RemainingTime) != data.elements_end()) {
+ state.m_freshBefore = time::system_clock::now() + time::seconds(readNonNegativeInteger(data.get(tlv::RemainingTime)));
}
- if (data.find(tlv_issued_cert_name) != data.elements_end()) {
- Block issuedCertNameBlock = data.get(tlv_issued_cert_name);
+ if (data.find(tlv::IssuedCertName) != data.elements_end()) {
+ Block issuedCertNameBlock = data.get(tlv::IssuedCertName);
state.m_issuedCertName = Name(issuedCertNameBlock.blockFromValue());
}
}
diff --git a/src/protocol-detail/crypto-helper.hpp b/src/protocol-detail/crypto-helper.hpp
index baa2e66..a590bfa 100644
--- a/src/protocol-detail/crypto-helper.hpp
+++ b/src/protocol-detail/crypto-helper.hpp
@@ -21,7 +21,7 @@
#ifndef NDNCERT_CRYPTO_SUPPORT_CRYPTO_HELPER_HPP
#define NDNCERT_CRYPTO_SUPPORT_CRYPTO_HELPER_HPP
-#include "../ndncert-common.hpp"
+#include "ndncert-common.hpp"
namespace ndn {
namespace ndncert {
diff --git a/src/protocol-detail/enc-tlv.cpp b/src/protocol-detail/enc-tlv.cpp
index b19bfcc..8342300 100644
--- a/src/protocol-detail/enc-tlv.cpp
+++ b/src/protocol-detail/enc-tlv.cpp
@@ -42,9 +42,9 @@
size_t encryptedPayloadLen = aes_gcm_128_encrypt(payload, payloadSize, associatedData, associatedDataSize,
key, iv.data(), encryptedPayload, tag);
auto content = makeEmptyBlock(tlv_type);
- content.push_back(makeBinaryBlock(tlv_initialization_vector, iv.data(), iv.size()));
- content.push_back(makeBinaryBlock(tlv_authentication_tag, tag, 16));
- content.push_back(makeBinaryBlock(tlv_encrypted_payload, encryptedPayload, encryptedPayloadLen));
+ content.push_back(makeBinaryBlock(tlv::InitializationVector, iv.data(), iv.size()));
+ content.push_back(makeBinaryBlock(tlv::AuthenticationTag, tag, 16));
+ content.push_back(makeBinaryBlock(tlv::EncryptedPayload, encryptedPayload, encryptedPayloadLen));
content.encode();
delete[] encryptedPayload;
return content;
@@ -55,12 +55,12 @@
{
block.parse();
Buffer result;
- result.resize(block.get(tlv_encrypted_payload).value_size());
- int resultLen = aes_gcm_128_decrypt(block.get(tlv_encrypted_payload).value(),
- block.get(tlv_encrypted_payload).value_size(),
- associatedData, associatedDataSize, block.get(tlv_authentication_tag).value(),
- key, block.get(tlv_initialization_vector).value(), result.data());
- if (resultLen == -1 || resultLen != (int)block.get(tlv_encrypted_payload).value_size()) {
+ result.resize(block.get(tlv::EncryptedPayload).value_size());
+ int resultLen = aes_gcm_128_decrypt(block.get(tlv::EncryptedPayload).value(),
+ block.get(tlv::EncryptedPayload).value_size(),
+ associatedData, associatedDataSize, block.get(tlv::AuthenticationTag).value(),
+ key, block.get(tlv::InitializationVector).value(), result.data());
+ if (resultLen == -1 || resultLen != (int)block.get(tlv::EncryptedPayload).value_size()) {
return Buffer();
}
return result;
diff --git a/src/protocol-detail/enc-tlv.hpp b/src/protocol-detail/enc-tlv.hpp
index 9e207c0..1c55119 100644
--- a/src/protocol-detail/enc-tlv.hpp
+++ b/src/protocol-detail/enc-tlv.hpp
@@ -21,20 +21,20 @@
#ifndef NDNCERT_CRYPTO_SUPPORT_ENC_TLV_HPP
#define NDNCERT_CRYPTO_SUPPORT_ENC_TLV_HPP
-#include "../ndncert-common.hpp"
+#include "ndncert-common.hpp"
namespace ndn {
namespace ndncert {
/**
* Encode the payload into TLV block with Authenticated GCM 128 Encryption
- * @p tlv_type, intput, the TLV TYPE of the encoded block, either ApplicationParameters or Content
+ * @p tlv::type, intput, the TLV TYPE of the encoded block, either ApplicationParameters or Content
* @p key, intput, 16 Bytes, the AES key used for encryption
* @p payload, input, the plaintext payload
* @p payloadSize, input, the size of the plaintext payload
* @p associatedData, input, associated data used for authentication
* @p associatedDataSize, input, the size of associated data
- * @return the TLV block with @p tlv_type TLV TYPE
+ * @return the TLV block with @p tlv::type TLV TYPE
*/
Block
encodeBlockWithAesGcm128(uint32_t tlv_type, const uint8_t* key, const uint8_t* payload, size_t payloadSize,
diff --git a/src/protocol-detail/error.cpp b/src/protocol-detail/error.cpp
index 79dc535..266e4e6 100644
--- a/src/protocol-detail/error.cpp
+++ b/src/protocol-detail/error.cpp
@@ -27,8 +27,8 @@
ErrorTLV::encodeDataContent(ErrorCode errorCode, const std::string& description)
{
Block response = makeEmptyBlock(tlv::Content);
- response.push_back(makeNonNegativeIntegerBlock(tlv_error_code, static_cast<size_t>(errorCode)));
- response.push_back(makeStringBlock(tlv_error_info, description));
+ response.push_back(makeNonNegativeIntegerBlock(tlv::ErrorCode, static_cast<size_t>(errorCode)));
+ response.push_back(makeStringBlock(tlv::ErrorInfo, description));
response.encode();
return response;
}
@@ -37,11 +37,11 @@
ErrorTLV::decodefromDataContent(const Block& block)
{
block.parse();
- if (block.find(tlv_error_code) == block.elements_end()) {
+ if (block.find(tlv::ErrorCode) == block.elements_end()) {
return std::make_tuple(ErrorCode::NO_ERROR, "");
}
- ErrorCode error = static_cast<ErrorCode>(readNonNegativeInteger(block.get(tlv_error_code)));
- return std::make_tuple(error, readString(block.get(tlv_error_info)));
+ ErrorCode error = static_cast<ErrorCode>(readNonNegativeInteger(block.get(tlv::ErrorCode)));
+ return std::make_tuple(error, readString(block.get(tlv::ErrorInfo)));
}
} // namespace ndncert
diff --git a/src/protocol-detail/info.cpp b/src/protocol-detail/info.cpp
index 08a6997..beef51d 100644
--- a/src/protocol-detail/info.cpp
+++ b/src/protocol-detail/info.cpp
@@ -27,7 +27,7 @@
INFO::encodeDataContent(const CaProfile& caConfig, const security::Certificate& certificate)
{
auto content = makeEmptyBlock(tlv::Content);
- content.push_back(makeNestedBlock(tlv_ca_prefix, caConfig.m_caPrefix));
+ content.push_back(makeNestedBlock(tlv::CaPrefix, caConfig.m_caPrefix));
std::string caInfo = "";
if (caConfig.m_caInfo == "") {
caInfo = "Issued by " + certificate.getSignatureInfo().getKeyLocator().getName().toUri();
@@ -35,12 +35,12 @@
else {
caInfo = caConfig.m_caInfo;
}
- content.push_back(makeStringBlock(tlv_ca_info, caInfo));
+ content.push_back(makeStringBlock(tlv::CaInfo, caInfo));
for (const auto& key : caConfig.m_probeParameterKeys) {
- content.push_back(makeStringBlock(tlv_parameter_key, key));
+ content.push_back(makeStringBlock(tlv::ParameterKey, key));
}
- content.push_back(makeNonNegativeIntegerBlock(tlv_max_validity_period, caConfig.m_maxValidityPeriod.count()));
- content.push_back(makeNestedBlock(tlv_ca_certificate, certificate));
+ content.push_back(makeNonNegativeIntegerBlock(tlv::MaxValidityPeriod, caConfig.m_maxValidityPeriod.count()));
+ content.push_back(makeNestedBlock(tlv::CaCertificate, certificate));
content.encode();
return content;
}
@@ -52,20 +52,20 @@
block.parse();
for (auto const& item : block.elements()) {
switch (item.type()) {
- case tlv_ca_prefix:
+ case tlv::CaPrefix:
item.parse();
result.m_caPrefix.wireDecode(item.get(tlv::Name));
break;
- case tlv_ca_info:
+ case tlv::CaInfo:
result.m_caInfo = readString(item);
break;
- case tlv_parameter_key:
+ case tlv::ParameterKey:
result.m_probeParameterKeys.push_back(readString(item));
break;
- case tlv_max_validity_period:
+ case tlv::MaxValidityPeriod:
result.m_maxValidityPeriod = time::seconds(readNonNegativeInteger(item));
break;
- case tlv_ca_certificate:
+ case tlv::CaCertificate:
item.parse();
result.m_cert = std::make_shared<security::Certificate>(item.get(tlv::Data));
break;
diff --git a/src/protocol-detail/ndncert-common.cpp b/src/protocol-detail/ndncert-common.cpp
new file mode 100644
index 0000000..1915082
--- /dev/null
+++ b/src/protocol-detail/ndncert-common.cpp
@@ -0,0 +1,57 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert 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.
+ *
+ * ndncert 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 copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#include "ndncert-common.hpp"
+
+namespace ndn {
+namespace ndncert {
+
+const std::map<ErrorCode, std::string> errorCodeText = {
+ {ErrorCode::NO_ERROR, "NO_ERROR"},
+ {ErrorCode::BAD_INTEREST_FORMAT, "BAD_INTEREST_FORMAT"},
+ {ErrorCode::BAD_PARAMETER_FORMAT, "BAD_PARAMETER_FORMAT"},
+ {ErrorCode::BAD_SIGNATURE, "BAD_SIGNATURE"},
+ {ErrorCode::INVALID_PARAMETER, "INVALID_PARAMETER"},
+ {ErrorCode::NAME_NOT_ALLOWED, "NAME_NOT_ALLOWED"},
+ {ErrorCode::BAD_VALIDITY_PERIOD, "BAD_VALIDITY_PERIOD"},
+ {ErrorCode::OUT_OF_TRIES, "OUT_OF_TRIES"},
+ {ErrorCode::OUT_OF_TIME, "OUT_OF_TIME"},
+ {ErrorCode::NO_AVAILABLE_NAMES, "NO_AVAILABLE_NAMES"}
+};
+
+const std::map<RequestType, std::string> requestTypeText = {
+ {RequestType::NEW, "New"},
+ {RequestType::RENEW, "Renew"},
+ {RequestType::REVOKE, "Revoke"},
+ {RequestType::NOTINITIALIZED, "Not Initialized"},
+};
+
+std::string errorCodeToString(ErrorCode code)
+{
+ return errorCodeText.at(code);
+}
+
+std::string requestTypeToString(RequestType type)
+{
+ return requestTypeText.at(type);
+}
+
+} // namespace ndncert
+} // namespace ndn
diff --git a/src/protocol-detail/ndncert-common.hpp b/src/protocol-detail/ndncert-common.hpp
new file mode 100644
index 0000000..cf19bb9
--- /dev/null
+++ b/src/protocol-detail/ndncert-common.hpp
@@ -0,0 +1,129 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert 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.
+ *
+ * ndncert 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 copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#ifndef NDNCERT_NDNCERT_COMMON_HPP
+#define NDNCERT_NDNCERT_COMMON_HPP
+
+#include "ndncert-config.hpp"
+
+#ifdef HAVE_TESTS
+#define VIRTUAL_WITH_TESTS virtual
+#define PUBLIC_WITH_TESTS_ELSE_PROTECTED public
+#define PUBLIC_WITH_TESTS_ELSE_PRIVATE public
+#define PROTECTED_WITH_TESTS_ELSE_PRIVATE protected
+#else
+#define VIRTUAL_WITH_TESTS
+#define PUBLIC_WITH_TESTS_ELSE_PROTECTED protected
+#define PUBLIC_WITH_TESTS_ELSE_PRIVATE private
+#define PROTECTED_WITH_TESTS_ELSE_PRIVATE private
+#endif
+
+#include <cstddef>
+#include <cstdint>
+#include <tuple>
+#include <ndn-cxx/encoding/tlv.hpp>
+#include <ndn-cxx/data.hpp>
+#include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/encoding/block-helpers.hpp>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/link.hpp>
+#include <ndn-cxx/lp/nack.hpp>
+#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/security/certificate.hpp>
+#include <ndn-cxx/util/logger.hpp>
+#include <boost/algorithm/string.hpp>
+#include <boost/assert.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/property_tree/info_parser.hpp>
+#include <boost/property_tree/json_parser.hpp>
+#include <boost/property_tree/ptree.hpp>
+
+namespace ndn {
+namespace tlv {
+ enum : uint32_t {
+ CaPrefix = 129,
+ CaInfo = 131,
+ ParameterKey = 133,
+ ParameterValue = 135,
+ CaCertificate = 137,
+ MaxValidityPeriod = 139,
+ ProbeResponse = 141,
+ MaxSuffixLength = 143,
+ EcdhPub = 145,
+ CertRequest = 147,
+ Salt = 149,
+ RequestId = 151,
+ Challenge = 153,
+ Status = 155,
+ InitializationVector = 157,
+ EncryptedPayload = 159,
+ SelectedChallenge = 161,
+ ChallengeStatus = 163,
+ RemainingTries = 165,
+ RemainingTime = 167,
+ IssuedCertName = 169,
+ ErrorCode = 171,
+ ErrorInfo = 173,
+ AuthenticationTag = 175,
+ CertToRevoke = 177,
+ ProbeRedirect = 179
+ };
+} // namespace tlv
+namespace ndncert {
+
+using boost::noncopyable;
+typedef boost::property_tree::ptree JsonSection;
+
+// NDNCERT error code
+enum class ErrorCode : uint16_t {
+ NO_ERROR = 0,
+ BAD_INTEREST_FORMAT = 1,
+ BAD_PARAMETER_FORMAT = 2,
+ BAD_SIGNATURE = 3,
+ INVALID_PARAMETER = 4,
+ NAME_NOT_ALLOWED = 5,
+ BAD_VALIDITY_PERIOD = 6,
+ OUT_OF_TRIES = 7,
+ OUT_OF_TIME = 8,
+ NO_AVAILABLE_NAMES = 9
+};
+
+// Convert error code to string
+std::string
+errorCodeToString(ErrorCode code);
+
+// NDNCERT request type
+enum class RequestType : uint16_t {
+ NOTINITIALIZED = 0,
+ NEW = 1,
+ RENEW = 2,
+ REVOKE = 3
+};
+
+// Convert request type to string
+std::string
+requestTypeToString(RequestType type);
+
+} // namespace ndncert
+} // namespace ndn
+
+#endif // NDNCERT_NDNCERT_COMMON_HPP
diff --git a/src/protocol-detail/new-renew-revoke.cpp b/src/protocol-detail/new-renew-revoke.cpp
index 75ffab7..8c2921e 100644
--- a/src/protocol-detail/new-renew-revoke.cpp
+++ b/src/protocol-detail/new-renew-revoke.cpp
@@ -19,7 +19,7 @@
*/
#include "new-renew-revoke.hpp"
-#include "../ndncert-common.hpp"
+#include "ndncert-common.hpp"
#include <ndn-cxx/security/transform/base64-encode.hpp>
#include <ndn-cxx/security/transform/buffer-source.hpp>
#include <ndn-cxx/security/transform/stream-sink.hpp>
@@ -45,11 +45,11 @@
return request;
}
- request.push_back(makeStringBlock(tlv_ecdh_pub, ecdhPub));
+ request.push_back(makeStringBlock(tlv::EcdhPub, ecdhPub));
if (requestType == RequestType::NEW || requestType == RequestType::RENEW) {
- request.push_back(makeNestedBlock(tlv_cert_request, certRequest));
+ request.push_back(makeNestedBlock(tlv::CertRequest, certRequest));
} else if (requestType == RequestType::REVOKE) {
- request.push_back(makeNestedBlock(tlv_cert_to_revoke, certRequest));
+ request.push_back(makeNestedBlock(tlv::CertToRevoke, certRequest));
}
request.encode();
return request;
@@ -60,13 +60,13 @@
shared_ptr<security::Certificate>& clientCert) {
payload.parse();
- ecdhPub = readString(payload.get(tlv_ecdh_pub));
+ ecdhPub = readString(payload.get(tlv::EcdhPub));
Block requestPayload;
if (requestType == RequestType::NEW) {
- requestPayload = payload.get(tlv_cert_request);
+ requestPayload = payload.get(tlv::CertRequest);
}
else if (requestType == RequestType::REVOKE) {
- requestPayload = payload.get(tlv_cert_to_revoke);
+ requestPayload = payload.get(tlv::CertToRevoke);
}
requestPayload.parse();
@@ -80,12 +80,12 @@
const std::list<std::string>& challenges)
{
Block response = makeEmptyBlock(tlv::Content);
- response.push_back(makeStringBlock(tlv_ecdh_pub, ecdhKey));
- response.push_back(makeStringBlock(tlv_salt, salt));
- response.push_back(makeStringBlock(tlv_request_id, request.m_requestId));
- response.push_back(makeNonNegativeIntegerBlock(tlv_status, static_cast<size_t>(request.m_status)));
+ response.push_back(makeStringBlock(tlv::EcdhPub, ecdhKey));
+ response.push_back(makeStringBlock(tlv::Salt, salt));
+ response.push_back(makeStringBlock(tlv::RequestId, request.m_requestId));
+ response.push_back(makeNonNegativeIntegerBlock(tlv::Status, static_cast<size_t>(request.m_status)));
for (const auto& entry: challenges) {
- response.push_back(makeStringBlock(tlv_challenge, entry));
+ response.push_back(makeStringBlock(tlv::Challenge, entry));
}
response.encode();
return response;
@@ -95,14 +95,14 @@
NEW_RENEW_REVOKE::decodeDataContent(const Block& content)
{
content.parse();
- const auto& ecdhKey = readString(content.get(tlv_ecdh_pub));
- const auto& salt = readString(content.get(tlv_salt));
+ const auto& ecdhKey = readString(content.get(tlv::EcdhPub));
+ const auto& salt = readString(content.get(tlv::Salt));
uint64_t saltInt = std::stoull(salt);
- const auto& requestStatus = static_cast<Status>(readNonNegativeInteger(content.get(tlv_status)));
- const auto& requestId = readString(content.get(tlv_request_id));
+ const auto& requestStatus = static_cast<Status>(readNonNegativeInteger(content.get(tlv::Status)));
+ const auto& requestId = readString(content.get(tlv::RequestId));
std::list<std::string> challenges;
for (auto const& element : content.elements()) {
- if (element.type() == tlv_challenge) {
+ if (element.type() == tlv::Challenge) {
challenges.push_back(readString(element));
}
}
diff --git a/src/protocol-detail/probe.cpp b/src/protocol-detail/probe.cpp
index 04b4bc9..3426145 100644
--- a/src/protocol-detail/probe.cpp
+++ b/src/protocol-detail/probe.cpp
@@ -28,8 +28,8 @@
{
auto content = makeEmptyBlock(tlv::ApplicationParameters);
for (size_t i = 0; i < parameters.size(); ++i) {
- content.push_back(makeStringBlock(tlv_parameter_key, std::get<0>(parameters[i])));
- content.push_back(makeStringBlock(tlv_parameter_value, std::get<1>(parameters[i])));
+ content.push_back(makeStringBlock(tlv::ParameterKey, std::get<0>(parameters[i])));
+ content.push_back(makeStringBlock(tlv::ParameterValue, std::get<1>(parameters[i])));
}
content.encode();
return content;
@@ -41,7 +41,7 @@
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) {
+ if (block.elements().at(i).type() == tlv::ParameterKey && block.elements().at(i + 1).type() == tlv::ParameterValue) {
result.push_back(std::make_tuple(readString(block.elements().at(i)), readString(block.elements().at(i + 1))));
}
}
@@ -54,16 +54,16 @@
{
Block content = makeEmptyBlock(tlv::Content);
for (const auto& name : identifiers) {
- Block item(tlv_probe_response);
+ Block item(tlv::ProbeResponse);
item.push_back(name.wireEncode());
if (maxSuffixLength) {
- item.push_back(makeNonNegativeIntegerBlock(tlv_max_suffix_length, *maxSuffixLength));
+ item.push_back(makeNonNegativeIntegerBlock(tlv::MaxSuffixLength, *maxSuffixLength));
}
content.push_back(item);
}
if (redirectionItems) {
for (const auto& item : *redirectionItems) {
- content.push_back(makeNestedBlock(tlv_probe_redirect, item->getFullName()));
+ content.push_back(makeNestedBlock(tlv::ProbeRedirect, item->getFullName()));
}
}
content.encode();
@@ -77,7 +77,7 @@
{
block.parse();
for (const auto& item : block.elements()) {
- if (item.type() == tlv_probe_response) {
+ if (item.type() == tlv::ProbeResponse) {
item.parse();
Name elementName;
int maxSuffixLength = 0;
@@ -87,7 +87,7 @@
NDN_THROW(std::runtime_error("Invalid probe format"));
}
elementName.wireDecode(subBlock);
- } else if (subBlock.type() == tlv_max_suffix_length) {
+ } else if (subBlock.type() == tlv::MaxSuffixLength) {
maxSuffixLength = readNonNegativeInteger(subBlock);
}
}
@@ -96,7 +96,7 @@
}
availableNames.emplace_back(elementName, maxSuffixLength);
}
- if (item.type() == tlv_probe_redirect) {
+ if (item.type() == tlv::ProbeRedirect) {
availableRedirection.emplace_back(Name(item.blockFromValue()));
}
}