encoding: update number assignments
This commit declares:
* TLV-TYPEs for typed name components in NDN naming conventions
* SignatureType number for HMAC
* ContentType numbers for Prefix Announcement and FLIC
This commit also:
* Improves stream insertion operator for SignatureTypeValue
* Adds stream insertion operator for ContentTypeValue
* Corrects several references to certificate format spec
refs #4577, #4649
Change-Id: Ibfd5cc1408cf892e38a2be93bf17e76f628f255d
diff --git a/src/encoding/tlv.cpp b/src/encoding/tlv.cpp
index 712291c..c210949 100644
--- a/src/encoding/tlv.cpp
+++ b/src/encoding/tlv.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -25,17 +25,51 @@
namespace tlv {
std::ostream&
-operator<<(std::ostream& os, SignatureTypeValue signatureType)
+operator<<(std::ostream& os, SignatureTypeValue st)
{
- switch (signatureType) {
- case SignatureTypeValue::DigestSha256:
+ switch (st) {
+ case DigestSha256:
return os << "DigestSha256";
- case SignatureTypeValue::SignatureSha256WithRsa:
+ case SignatureSha256WithRsa:
return os << "SignatureSha256WithRsa";
- case SignatureTypeValue::SignatureSha256WithEcdsa:
+ case SignatureSha256WithEcdsa:
return os << "SignatureSha256WithEcdsa";
+ case SignatureHmacWithSha256:
+ return os << "SignatureHmacWithSha256";
}
- return os << "Unknown Signature Type";
+ return os << "Unknown(" << static_cast<uint32_t>(st) << ')';
+}
+
+std::ostream&
+operator<<(std::ostream& os, ContentTypeValue ct)
+{
+ switch (ct) {
+ case ContentType_Blob:
+ return os << "Blob";
+ case ContentType_Link:
+ return os << "Link";
+ case ContentType_Key:
+ return os << "Key";
+ case ContentType_Nack:
+ return os << "Nack";
+ case ContentType_Manifest:
+ return os << "Manifest";
+ case ContentType_PrefixAnn:
+ return os << "PrefixAnn";
+ case ContentType_Flic:
+ return os << "FLIC";
+ }
+
+ if (ct >= 6 && ct <= 1023) {
+ os << "Reserved(";
+ }
+ else if (ct >= 9000 && ct <= 9999) {
+ os << "Experimental(";
+ }
+ else {
+ os << "Unknown(";
+ }
+ return os << static_cast<uint32_t>(ct) << ')';
}
} // namespace tlv
diff --git a/src/encoding/tlv.hpp b/src/encoding/tlv.hpp
index f7b7240..c105b70 100644
--- a/src/encoding/tlv.hpp
+++ b/src/encoding/tlv.hpp
@@ -108,18 +108,33 @@
[[deprecated("use GenericNameComponent")]]
constexpr int NameComponent = GenericNameComponent;
+/** @brief TLV-TYPE numbers for typed name components.
+ * @sa https://redmine.named-data.net/projects/ndn-tlv/wiki/NameComponentType
+ */
+enum {
+ KeywordNameComponent = 32,
+ SegmentNameComponent = 33,
+ ByteOffsetNameComponent = 34,
+ VersionNameComponent = 35,
+ TimestampNameComponent = 36,
+ SequenceNumNameComponent = 37,
+};
+
+/** @brief SignatureType values
+ * @sa https://named-data.net/doc/NDN-packet-spec/current/signature.html
+ */
enum SignatureTypeValue : uint16_t {
- DigestSha256 = 0,
- SignatureSha256WithRsa = 1,
- // <Unassigned> = 2,
- SignatureSha256WithEcdsa = 3
+ DigestSha256 = 0,
+ SignatureSha256WithRsa = 1,
+ SignatureSha256WithEcdsa = 3,
+ SignatureHmacWithSha256 = 4,
};
std::ostream&
-operator<<(std::ostream& os, SignatureTypeValue signatureType);
+operator<<(std::ostream& os, SignatureTypeValue st);
/** @brief TLV-TYPE numbers for SignatureInfo features
- * @sa docs/tutorials/certificate-format.rst
+ * @sa docs/specs/certificate-format.rst
*/
enum {
ValidityPeriod = 253,
@@ -132,26 +147,22 @@
DescriptionValue = 514
};
-/** @brief indicates a possible value of ContentType field
+/** @brief ContentType values
+ * @sa https://redmine.named-data.net/projects/ndn-tlv/wiki/ContentType
*/
-enum ContentTypeValue {
- /** @brief indicates content is the actual data bits
- */
- ContentType_Blob = 0,
-
- /** @brief indicates content is another name which identifies actual data content
- */
- ContentType_Link = 1,
-
- /** @brief indicates content is a public key
- */
- ContentType_Key = 2,
-
- /** @brief indicates a producer generated NACK
- */
- ContentType_Nack = 3
+enum ContentTypeValue : uint32_t {
+ ContentType_Blob = 0, ///< payload
+ ContentType_Link = 1, ///< another name that identifies the actual data content
+ ContentType_Key = 2, ///< public key, certificate
+ ContentType_Nack = 3, ///< application-level nack
+ ContentType_Manifest = 4,
+ ContentType_PrefixAnn = 5, ///< prefix announcement
+ ContentType_Flic = 1024, ///< File-Like ICN Collection
};
+std::ostream&
+operator<<(std::ostream& os, ContentTypeValue ct);
+
/**
* @brief Determine whether a TLV-TYPE is "critical" for evolvability purpose.
* @sa https://named-data.net/doc/NDN-packet-spec/0.3/tlv.html#considerations-for-evolvability-of-tlv-based-encoding