tlv: require shortest encoding for VAR-NUMBER

refs #4946

Change-Id: If106e6461f7a0b518969db33d9f761a1e20f7d91
diff --git a/changelog.rst b/changelog.rst
index b24c849..94c68d8 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -6,6 +6,8 @@
 
 - Rewrite TLV syntax specifications using `IETF Augmented BNF (RFC 5234) <https://tools.ietf.org/html/rfc5234>`__
 
+  + Require shortest encoding for TLV-TYPE and TLV-LENGTH numbers
+
 - **Interest**
 
   + Remove ``Selectors`` element
diff --git a/tlv.rst b/tlv.rst
index 4e294ec..be2d471 100644
--- a/tlv.rst
+++ b/tlv.rst
@@ -21,17 +21,26 @@
 
 We define a variable-length encoding for numbers in NDN as follows::
 
-     VAR-NUMBER = %x00-FC / %xFD 2OCTET / %xFE 4OCTET / %xFF 8OCTET
+     VAR-NUMBER-1 = %x00-FC
+     VAR-NUMBER-3 = %xFD 2OCTET
+     VAR-NUMBER-5 = %xFE 4OCTET
+     VAR-NUMBER-9 = %xFF 8OCTET
 
 The first octet of the number either carries the actual number, or signals that a multi-octet encoding is present, as defined below:
 
-- if the first octet is less than or equal to 252 (0xFC), the number is encoded in that octet;
+- If the first octet is less than or equal to 252 (0xFC), the number is encoded in that octet.
 
-- if the first octet is 253 (0xFD), the number is encoded in the following 2 octets, in network byte-order;
+- If the first octet is 253 (0xFD), the number is encoded in the following 2 octets, in network byte-order.
+  This number must be greater than 252 (0xFC).
 
-- if the first octet is 254 (0xFE), the number is encoded in the following 4 octets, in network byte-order;
+- If the first octet is 254 (0xFE), the number is encoded in the following 4 octets, in network byte-order.
+  This number must be greater than 65535 (0xFFFF).
 
-- if the first octet is 255 (0xFF), the number is encoded in the following 8 octets, in network byte-order.
+- If the first octet is 255 (0xFF), the number is encoded in the following 8 octets, in network byte-order.
+  This number must be greater than 4294967295 (0xFFFFFFFF).
+
+A number MUST be encoded in the shortest format.
+For example, the number 1024 is encoded as %xFD0400 in VAR-NUMBER-3 format, not %xFE00000400 in VAR-NUMBER-5 format.
 
 .. note::
    The formal grammar of NDN packet format in this specification is given using `Augmented BNF for Syntax Specifications <https://tools.ietf.org/html/rfc5234>`__
@@ -44,8 +53,8 @@
 TLV encoding for NDN packets is defined as follows::
 
     NDN-TLV = TLV-TYPE TLV-LENGTH TLV-VALUE
-    TLV-TYPE = VAR-NUMBER
-    TLV-LENGTH = VAR-NUMBER
+    TLV-TYPE = VAR-NUMBER-1 / VAR-NUMBER-3 / VAR-NUMBER-5
+    TLV-LENGTH = VAR-NUMBER-1 / VAR-NUMBER-3 / VAR-NUMBER-5 / VAR-NUMBER-9
     TLV-VALUE = *OCTET
 
 TLV-TYPE MUST be in the range ``1-4294967295`` (inclusive).
diff --git a/types.rst b/types.rst
index 608b16e..fc63fbf 100644
--- a/types.rst
+++ b/types.rst
@@ -84,7 +84,7 @@
 
 .. note::
    ABNF grammar of this specification denotes TLV-TYPE of element X as ``X-TYPE``.
-   For example, ``INTEREST-TYPE`` means ``%x05``, the TLV-TYPE of ``Interest`` encoded as ``VAR-NUMBER``.
+   For example, ``INTEREST-TYPE`` means ``%x05``, the TLV-TYPE of ``Interest`` encoded in VAR-NUMBER-1 format.
 
 .. _type reservations: