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
diff --git a/src/security/v2/additional-description.hpp b/src/security/v2/additional-description.hpp
index 16281f9..4372807 100644
--- a/src/security/v2/additional-description.hpp
+++ b/src/security/v2/additional-description.hpp
@@ -33,7 +33,7 @@
 
 /**
  * @brief Abstraction of AdditionalDescription
- * @sa docs/tutorials/certificate-format.rst
+ * @sa docs/specs/certificate-format.rst
  */
 class AdditionalDescription
 {
diff --git a/src/security/validity-period.hpp b/src/security/validity-period.hpp
index ee7c602..ba05b7a 100644
--- a/src/security/validity-period.hpp
+++ b/src/security/validity-period.hpp
@@ -32,7 +32,7 @@
 
 
 /** @brief Abstraction of validity period
- *  @sa docs/tutorials/certificate-format.rst
+ *  @sa docs/specs/certificate-format.rst
  */
 class ValidityPeriod
 {
diff --git a/tests/unit-tests/encoding/tlv.t.cpp b/tests/unit-tests/encoding/tlv.t.cpp
index f8e2f9e..a82ffbe 100644
--- a/tests/unit-tests/encoding/tlv.t.cpp
+++ b/tests/unit-tests/encoding/tlv.t.cpp
@@ -486,8 +486,30 @@
 {
   BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(DigestSha256), "DigestSha256");
   BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(SignatureSha256WithRsa), "SignatureSha256WithRsa");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<SignatureTypeValue>(2)), "Unknown(2)");
   BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(SignatureSha256WithEcdsa), "SignatureSha256WithEcdsa");
-  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<SignatureTypeValue>(200)), "Unknown Signature Type");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(SignatureHmacWithSha256), "SignatureHmacWithSha256");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<SignatureTypeValue>(5)), "Unknown(5)");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<SignatureTypeValue>(200)), "Unknown(200)");
+}
+
+BOOST_AUTO_TEST_CASE(PrintContentTypeValue)
+{
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ContentType_Blob), "Blob");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ContentType_Link), "Link");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ContentType_Key), "Key");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ContentType_Nack), "Nack");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ContentType_Manifest), "Manifest");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ContentType_PrefixAnn), "PrefixAnn");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<ContentTypeValue>(6)), "Reserved(6)");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<ContentTypeValue>(1023)), "Reserved(1023)");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(ContentType_Flic), "FLIC");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<ContentTypeValue>(1025)), "Unknown(1025)");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<ContentTypeValue>(8999)), "Unknown(8999)");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<ContentTypeValue>(9000)), "Experimental(9000)");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<ContentTypeValue>(9999)), "Experimental(9999)");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<ContentTypeValue>(10000)), "Unknown(10000)");
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(static_cast<ContentTypeValue>(19910118)), "Unknown(19910118)");
 }
 
 BOOST_AUTO_TEST_SUITE_END() // PrintHelpers