management: Finalizing LocalControlHeader implementation

IncomingFaceId and NextHopFaceId are now fully supported for specifying
to be efficiently sent towards the forwarding daemon, and to be
automatically decoded from incoming packet from the forwarding daemon.

The current implementation limits exactly one LocalControlHeader for
Interest/Data packet instance. This is not exactly correct (especially
inside NFD), where the same Interest is expected to have multiple
LocalControlHeader (for each individual local face).  The following
commits will fix this problem.

Change-Id: Ia6b124ed12271136d071f4822f13634897ce3228
refs: #1170
diff --git a/src/interest.hpp b/src/interest.hpp
index 842c427..a0d99d8 100644
--- a/src/interest.hpp
+++ b/src/interest.hpp
@@ -10,6 +10,7 @@
 #include "common.hpp"
 #include "name.hpp"
 #include "selectors.hpp"
+#include "management/nfd-local-control-header.hpp"
 
 namespace ndn {
 
@@ -98,13 +99,19 @@
   {
   }
 
+  explicit
+  Interest(const Block& wire)
+  {
+    wireDecode(wire);
+  }
+
   /**
    * @brief Fast encoding or block size estimation
    */
   template<bool T>
   inline size_t
   wireEncode(EncodingImpl<T> &block) const;
-  
+
   /**
    * @brief Encode to a wire format
    */
@@ -116,6 +123,12 @@
    */
   inline void 
   wireDecode(const Block &wire);
+
+  /**
+   * @brief Check if already has wire
+   */
+  inline bool
+  hasWire() const;
   
   /**
    * Encode the name according to the "NDN URI Scheme".  If there are interest selectors, append "?" and
@@ -229,17 +242,31 @@
   }
 
   //
+
+  nfd::LocalControlHeader&
+  getLocalControlHeader()
+  {
+    return m_localControlHeader;
+  }
+
+  const nfd::LocalControlHeader&
+  getLocalControlHeader() const
+  {
+    return m_localControlHeader;
+  }
+
+  // helper methods for LocalControlHeader
   
   uint64_t
   getIncomingFaceId() const
   {
-    return m_incomingFaceId;
+    return getLocalControlHeader().getIncomingFaceId();
   }
-    
+
   Interest&
   setIncomingFaceId(uint64_t incomingFaceId)
   {
-    m_incomingFaceId = incomingFaceId;
+    getLocalControlHeader().setIncomingFaceId(incomingFaceId);
     return *this;
   }
 
@@ -329,8 +356,6 @@
     return *this;
   }
 
-  //
-  
 private:
   Name m_name;
   Selectors m_selectors;
@@ -340,7 +365,8 @@
 
   mutable Block m_wire;
 
-  uint64_t m_incomingFaceId;
+  nfd::LocalControlHeader m_localControlHeader;
+  friend class nfd::LocalControlHeader;
 };
 
 std::ostream &
@@ -412,7 +438,7 @@
   return total_len;
 }
 
-inline const Block &
+inline const Block&
 Interest::wireEncode() const
 {
   if (m_wire.hasWire())
@@ -421,7 +447,7 @@
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
   
-  EncodingBuffer buffer(estimatedSize, 0);
+  EncodingBuffer buffer(estimatedSize + nfd::ESTIMATED_LOCAL_HEADER_RESERVE, 0);
   wireEncode(buffer);
 
   m_wire = buffer.block();
@@ -486,6 +512,12 @@
     }
 }
 
+inline bool
+Interest::hasWire() const
+{
+  return m_wire.hasWire();
+}
+
 
 } // namespace ndn