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");
+        }
     }
 }
 
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index 895df49..52ed7e7 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -56,7 +56,8 @@
    * This version will automatically detect type and position of the value within the 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);
   
   /**
    * @brief A helper version of a constructor to create Block from the raw buffer (type and value-length parsing)
diff --git a/src/encoding/encoding-buffer.hpp b/src/encoding/encoding-buffer.hpp
index 1659c52..b46225b 100644
--- a/src/encoding/encoding-buffer.hpp
+++ b/src/encoding/encoding-buffer.hpp
@@ -85,8 +85,15 @@
   inline const uint8_t*
   buf () const;
 
+  /**
+   * @brief Create Block from the underlying EncodingBuffer
+   *
+   * @param verifyLength If this parameter set to true, Block's constructor
+   *                     will be requested to verify consistency of the encoded
+   *                     length in the Block, otherwise ignored
+   */
   inline Block
-  block () const;
+  block (bool verifyLength = true) const;
 
   inline void
   resize (size_t sz, bool addInFront);
@@ -218,10 +225,11 @@
 }
 
 inline Block
-EncodingImpl<encoding::Buffer>::block () const
+EncodingImpl<encoding::Buffer>::block (bool verifyLength/* = true*/) const
 {
   return Block(m_buffer,
-               m_begin, m_end);
+               m_begin, m_end,
+               verifyLength);
 }
 
 inline void