lp: add NonDiscovery field and tag

refs #4355

Change-Id: Ib3a64589d7ea3bbf204e295a75d91748ef9c85b9
diff --git a/src/lp/empty-value.hpp b/src/lp/empty-value.hpp
new file mode 100644
index 0000000..1587046
--- /dev/null
+++ b/src/lp/empty-value.hpp
@@ -0,0 +1,40 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * @author Teng Liang <philoliang@email.arizona.edu>
+ */
+
+#ifndef NDN_CXX_LP_TLV_EMPTY_VALUE_HPP
+#define NDN_CXX_LP_TLV_EMPTY_VALUE_HPP
+
+namespace ndn {
+namespace lp {
+
+/**
+ * \brief represents a zero-length TLV-VALUE
+ */
+struct EmptyValue
+{
+};
+
+} // namespace lp
+} // namespace ndn
+
+#endif // NDN_CXX_LP_TLV_EMPTY_VALUE_HPP
\ No newline at end of file
diff --git a/src/lp/field-decl.hpp b/src/lp/field-decl.hpp
index a71aceb..755f595 100644
--- a/src/lp/field-decl.hpp
+++ b/src/lp/field-decl.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -22,6 +22,7 @@
 #ifndef NDN_CXX_LP_FIELD_DECL_HPP
 #define NDN_CXX_LP_FIELD_DECL_HPP
 
+#include "empty-value.hpp"
 #include "field.hpp"
 #include "tlv.hpp"
 
@@ -46,6 +47,21 @@
 };
 
 template<typename TlvType>
+struct DecodeHelper<TlvType, EmptyValue>
+{
+  static EmptyValue
+  decode(const Block& wire)
+  {
+    if (wire.value_size() != 0) {
+      BOOST_THROW_EXCEPTION(ndn::tlv::Error("NDNLP field of TLV-TYPE " + to_string(wire.type()) +
+                            " must be empty"));
+    }
+
+    return EmptyValue{};
+  }
+};
+
+template<typename TlvType>
 struct DecodeHelper<TlvType, uint64_t>
 {
   static uint64_t
@@ -62,7 +78,8 @@
   decode(const Block& wire)
   {
     if (wire.value_size() == 0) {
-      BOOST_THROW_EXCEPTION(ndn::tlv::Error(to_string(wire.type()) + " must not be empty"));
+      BOOST_THROW_EXCEPTION(ndn::tlv::Error("NDNLP field of TLV-TYPE " + to_string(wire.type()) +
+                            " cannot be empty"));
     }
 
     return std::make_pair(wire.value_begin(), wire.value_end());
@@ -81,6 +98,19 @@
 };
 
 template<typename encoding::Tag TAG, typename TlvType>
+struct EncodeHelper<TAG, TlvType, EmptyValue>
+{
+  static size_t
+  encode(EncodingImpl<TAG>& encoder, const EmptyValue value)
+  {
+    size_t length = 0;
+    length += encoder.prependVarNumber(0);
+    length += encoder.prependVarNumber(TlvType::value);
+    return length;
+  }
+};
+
+template<typename encoding::Tag TAG, typename TlvType>
 struct EncodeHelper<TAG, TlvType, uint64_t>
 {
   static size_t
diff --git a/src/lp/fields.hpp b/src/lp/fields.hpp
index 5612b16..c8cd0d9 100644
--- a/src/lp/fields.hpp
+++ b/src/lp/fields.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -84,6 +84,11 @@
                   tlv::TxSequence> TxSequenceField;
 BOOST_CONCEPT_ASSERT((Field<TxSequenceField>));
 
+typedef FieldDecl<field_location_tags::Header,
+                  EmptyValue,
+                  tlv::NonDiscovery> NonDiscoveryField;
+BOOST_CONCEPT_ASSERT((Field<NonDiscoveryField>));
+
 /**
  * The value of the wire encoded field is the data between the provided iterators. During
  * encoding, the data is copied from the Buffer into the wire buffer.
@@ -107,7 +112,8 @@
   IncomingFaceIdField,
   CongestionMarkField,
   AckField,
-  TxSequenceField
+  TxSequenceField,
+  NonDiscoveryField
   > FieldSet;
 
 } // namespace lp
diff --git a/src/lp/tags.hpp b/src/lp/tags.hpp
index 4bcadae..b4f430b 100644
--- a/src/lp/tags.hpp
+++ b/src/lp/tags.hpp
@@ -23,6 +23,7 @@
 #define NDN_CXX_LP_TAGS_HPP
 
 #include "cache-policy.hpp"
+#include "empty-value.hpp"
 #include "../tag.hpp"
 
 namespace ndn {
@@ -56,6 +57,13 @@
  */
 typedef SimpleTag<uint64_t, 13> CongestionMarkTag;
 
+/** \class NonDiscoveryTag
+ *  \brief a packet tag for NonDiscovery field
+ *
+ *  This tag can be attached to Interest.
+ */
+typedef SimpleTag<EmptyValue, 14> NonDiscoveryTag;
+
 } // namespace lp
 } // namespace ndn
 
diff --git a/src/lp/tlv.hpp b/src/lp/tlv.hpp
index 5ab1a92..fb24ab3 100644
--- a/src/lp/tlv.hpp
+++ b/src/lp/tlv.hpp
@@ -38,12 +38,13 @@
   Nack = 800,
   NackReason = 801,
   NextHopFaceId = 816,
+  IncomingFaceId = 817,
   CachePolicy = 820,
   CachePolicyType = 821,
-  IncomingFaceId = 817,
   CongestionMark = 832,
   Ack = 836,
-  TxSequence = 840
+  TxSequence = 840,
+  NonDiscovery = 844,
 };
 
 enum {