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)) {