face: send and receive NACK
refs #2930
Change-Id: I70c969ac12b493d2c83fa892beffae936cc23791
diff --git a/src/lp/detail/field-decl.hpp b/src/lp/detail/field-decl.hpp
index 6804b8a..49e3c07 100644
--- a/src/lp/detail/field-decl.hpp
+++ b/src/lp/detail/field-decl.hpp
@@ -43,10 +43,6 @@
BOOST_CONCEPT_REQUIRES(((WireDecodable<T>)), (T))
decode(const Block& wire)
{
- if (wire.type() != TlvType::value) {
- BOOST_THROW_EXCEPTION(ndn::tlv::Error("Unexpected TLV type " + to_string(wire.type())));
- }
-
T type;
type.wireDecode(wire);
return type;
@@ -59,10 +55,6 @@
static uint64_t
decode(const Block& wire)
{
- if (wire.type() != TlvType::value) {
- BOOST_THROW_EXCEPTION(ndn::tlv::Error("Unexpected TLV type " + to_string(wire.type())));
- }
-
return readNonNegativeInteger(wire);
}
};
@@ -73,10 +65,6 @@
static std::pair<Buffer::const_iterator, Buffer::const_iterator>
decode(const Block& wire)
{
- if (wire.type() != TlvType::value) {
- BOOST_THROW_EXCEPTION(ndn::tlv::Error("Unexpected TLV type " + to_string(wire.type())));
- }
-
if (wire.value_size() == 0) {
BOOST_THROW_EXCEPTION(ndn::tlv::Error(to_string(wire.type()) + " must not be empty"));
}
@@ -129,12 +117,23 @@
typedef std::integral_constant<uint64_t, TYPE> TlvType;
typedef std::integral_constant<bool, REPEATABLE> IsRepeatable;
+ /** \brief decodes a field
+ * \param wire a Block with top-level type \p TYPE
+ * \return value of the field
+ */
static ValueType
decode(const Block& wire)
{
+ if (wire.type() != TlvType::value) {
+ BOOST_THROW_EXCEPTION(ndn::tlv::Error("Unexpected TLV type " + std::to_string(wire.type())));
+ }
+
return DecodeHelper<TlvType, ValueType>::decode(wire);
}
+ /** \brief encodes a field and prepends to \p encoder its Block with top-level type \p TYPE
+ * \param value value of the field
+ */
template<typename encoding::Tag TAG, typename T>
static size_t
encode(EncodingImpl<TAG>& encoder, const T& value)