management: Making LocalControlHeader encoding independent of Interest/Data wire
Boost.Asio support multi-buffer send operation, which is enabled in this
commit for prepending (potentially different) LocalControlHeader's to
Interest/Data wire.
Change-Id: I39b979f89f196d3e47d6466fb71f6d440bce74d4
refs: #1265
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 37b2e6f..3451ffd 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -70,7 +70,8 @@
}
Block::Block(const ConstBufferPtr &buffer,
- const Buffer::const_iterator &begin, const Buffer::const_iterator &end)
+ const Buffer::const_iterator &begin, const Buffer::const_iterator &end,
+ bool verifyLength/* = true*/)
: m_buffer(buffer)
, m_begin(begin)
, m_end(end)
@@ -80,10 +81,13 @@
m_value_end = m_end;
m_type = Tlv::readType(m_value_begin, m_value_end);
- uint64_t length = Tlv::readVarNumber(m_value_begin, m_value_end);
- if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
+ if (verifyLength)
{
- throw Tlv::Error("TLV length doesn't match buffer length");
+ uint64_t length = Tlv::readVarNumber(m_value_begin, m_value_end);
+ if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
+ {
+ throw Tlv::Error("TLV length doesn't match buffer length");
+ }
}
}