use enum class for status
Change-Id: Iaba23e0754335a7fecec2d6c4b3446988b2fd9d0
diff --git a/src/ndncert-common.hpp b/src/ndncert-common.hpp
index 4109d58..cbbba39 100644
--- a/src/ndncert-common.hpp
+++ b/src/ndncert-common.hpp
@@ -35,44 +35,42 @@
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE private
#endif
-#include <cstddef>
-#include <cstdint>
-
-#include <ndn-cxx/interest.hpp>
-#include <ndn-cxx/data.hpp>
-#include <ndn-cxx/name.hpp>
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/link.hpp>
-#include <ndn-cxx/encoding/block.hpp>
-#include <ndn-cxx/lp/nack.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/security/v2/certificate.hpp>
-
#include <boost/algorithm/string.hpp>
#include <boost/assert.hpp>
#include <boost/noncopyable.hpp>
#include <boost/throw_exception.hpp>
+#include <cstddef>
+#include <cstdint>
+#include <ndn-cxx/data.hpp>
+#include <ndn-cxx/encoding/block.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/v2/certificate.hpp>
namespace ndn {
namespace ndncert {
-using std::size_t;
using boost::noncopyable;
-using std::shared_ptr;
-using std::unique_ptr;
-using std::weak_ptr;
-using std::make_shared;
-using ndn::make_unique;
-using std::enable_shared_from_this;
-using std::function;
-using std::bind;
-using ndn::Interest;
+using ndn::Block;
using ndn::Data;
+using ndn::Interest;
+using ndn::make_unique;
using ndn::Name;
using ndn::PartialName;
-using ndn::Block;
using ndn::time::system_clock;
using ndn::time::toUnixTimestamp;
+using std::bind;
+using std::enable_shared_from_this;
+using std::function;
+using std::make_shared;
+using std::shared_ptr;
+using std::size_t;
+using std::unique_ptr;
+using std::weak_ptr;
enum : uint32_t {
tlv_ca_prefix = 129,
@@ -81,6 +79,7 @@
tlv_parameter_value = 135,
tlv_ca_certificate = 137,
tlv_max_validity_period = 139,
+ tlv_max_suffix_length = 177,
tlv_probe_response = 141,
tlv_allow_longer_name = 143,
tlv_ecdh_pub = 145,
@@ -99,7 +98,6 @@
tlv_error_code = 171,
tlv_error_info = 173,
tlv_authentication_tag = 175,
- tlv_max_suffix_length = 177,
tlv_cert_to_revoke = 179
};
@@ -111,8 +109,9 @@
const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key";
const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges";
const std::string CONFIG_CHALLENGE = "challenge";
+const std::string CONFIG_MAX_SUFFIX_LENGTH = "max-suffix-length";
-// JSON format for Certificate Issuer (CA)
+// // JSON format for Certificate Issuer (CA)
const std::string JSON_CA_NAME = "name";
const std::string JSON_CA_CONFIG = "ca-config";
const std::string JSON_CA_ECDH = "ecdh-pub";
@@ -123,13 +122,13 @@
const std::string JSON_CA_CHALLENGE_ID = "challenge-id";
const std::string JSON_CA_CERT_ID = "certificate-id";
-// JSON format for Challenge Module
+// // JSON format for Challenge Module
const std::string JSON_CHALLENGE_STATUS = "challenge-status";
const std::string JSON_CHALLENGE_REMAINING_TRIES = "remaining-tries";
const std::string JSON_CHALLENGE_REMAINING_TIME = "remaining-time";
const std::string JSON_CHALLENGE_ISSUED_CERT_NAME = "issued-cert-name";
-// JSON format for Certificate Requester
+// // JSON format for Certificate Requester
const std::string JSON_CLIENT_PROBE_INFO = "probe-info";
const std::string JSON_CLIENT_ECDH = "ecdh-pub";
const std::string JSON_CLIENT_CERT_REQ = "cert-request";
@@ -137,14 +136,28 @@
const std::string JSON_CLIENT_CERT_TO_REVOKE = "cert-to-revoke";
// NDNCERT Status Enum
-enum {
- STATUS_BEFORE_CHALLENGE = 0,
- STATUS_CHALLENGE = 1,
- STATUS_PENDING = 2,
- STATUS_SUCCESS = 3,
- STATUS_FAILURE = 4,
- STATUS_NOT_STARTED = 5,
- STATUS_ENDED = 6
+enum class Status : uint16_t {
+ BEFORE_CHALLENGE = 0,
+ CHALLENGE = 1,
+ PENDING = 2,
+ SUCCESS = 3,
+ FAILURE = 4,
+ NOT_STARTED = 5,
+ ENDED = 6
+};
+
+std::string statusToString(Status status);
+
+enum class Error : uint16_t {
+ 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
};
// Pre-defined challenge status
@@ -153,7 +166,7 @@
const std::string CHALLENGE_STATUS_FAILURE_MAXRETRY = "failure-max-retry";
const std::string CHALLENGE_STATUS_UNKNOWN_CHALLENGE = "unknown-challenge";
-} // namespace ndncert
-} // namespace ndn
+} // namespace ndncert
+} // namespace ndn
-#endif // NDNCERT_NDNCERT_COMMON_HPP
+#endif // NDNCERT_NDNCERT_COMMON_HPP