lp: correct rules for whether an unknown field can be ignored

Add TLV-TYPE to exception output for unignorable unknown and unrepeatable fields

refs #3884

Change-Id: I52c6cc2b6b5363432d8cc5bf60407ccf6ece7dc0
diff --git a/src/lp/detail/field-info.cpp b/src/lp/detail/field-info.cpp
index fadd858..f2eca34 100644
--- a/src/lp/detail/field-info.cpp
+++ b/src/lp/detail/field-info.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -65,10 +65,10 @@
   boost::mpl::for_each<FieldSet>(boost::bind(ExtractFieldInfo(), this, _1));
   if (!isRecognized) {
     canIgnore = tlv::HEADER3_MIN <= tlvType && tlvType <= tlv::HEADER3_MAX &&
-                (tlvType & 0x01) == 0x01;
+                (tlvType & 0x03) == 0x00;
   }
 }
 
 } // namespace detail
 } // namespace lp
-} // namespace ndn
\ No newline at end of file
+} // namespace ndn
diff --git a/src/lp/packet.cpp b/src/lp/packet.cpp
index 8d62ed9..7b71c72 100644
--- a/src/lp/packet.cpp
+++ b/src/lp/packet.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -109,12 +109,12 @@
     detail::FieldInfo info(element.type());
 
     if (!info.isRecognized && !info.canIgnore) {
-      BOOST_THROW_EXCEPTION(Error("unrecognized field cannot be ignored"));
+      BOOST_THROW_EXCEPTION(Error("unrecognized field " + to_string(element.type()) + " cannot be ignored"));
     }
 
     if (!isFirst) {
       if (info.tlvType == prev.tlvType && !info.isRepeatable) {
-        BOOST_THROW_EXCEPTION(Error("non-repeatable field cannot be repeated"));
+        BOOST_THROW_EXCEPTION(Error("non-repeatable field " + to_string(element.type()) + " cannot be repeated"));
       }
 
       else if (info.tlvType != prev.tlvType && !detail::compareFieldSortOrder(prev, info)) {
diff --git a/tests/unit-tests/lp/packet.t.cpp b/tests/unit-tests/lp/packet.t.cpp
index 0a7f1d5..2dd055e 100644
--- a/tests/unit-tests/lp/packet.t.cpp
+++ b/tests/unit-tests/lp/packet.t.cpp
@@ -275,7 +275,7 @@
     0x64, 0x0c, // LpPacket
           0x52, 0x01, // FragIndex
                 0x00,
-          0xfd, 0x03, 0x23, 0x01, // unknown TLV-TYPE 803 (ignored)
+          0xfd, 0x03, 0x24, 0x01, // unknown TLV-TYPE 804 (ignored)
                 0x02,
           0x50, 0x02, // Fragment
                 0x03, 0xe8,