mgmt: add LocalUri to ControlParameters

refs #4014

Change-Id: I474dc3f41021687b99804fc2d71dd6e72c5175c5
diff --git a/src/mgmt/nfd/control-parameters.cpp b/src/mgmt/nfd/control-parameters.cpp
index 4958749..a414567 100644
--- a/src/mgmt/nfd/control-parameters.cpp
+++ b/src/mgmt/nfd/control-parameters.cpp
@@ -78,6 +78,13 @@
     totalLength += prependNonNegativeIntegerBlock(encoder,
                    tlv::nfd::LocalControlFeature, m_localControlFeature);
   }
+  if (this->hasLocalUri()) {
+    size_t valLength = encoder.prependByteArray(
+                       reinterpret_cast<const uint8_t*>(m_localUri.c_str()), m_localUri.size());
+    totalLength += valLength;
+    totalLength += encoder.prependVarNumber(valLength);
+    totalLength += encoder.prependVarNumber(tlv::nfd::LocalUri);
+  }
   if (this->hasUri()) {
     size_t valLength = encoder.prependByteArray(
                        reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());
@@ -147,6 +154,12 @@
     m_uri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
   }
 
+  val = m_wire.find(tlv::nfd::LocalUri);
+  m_hasFields[CONTROL_PARAMETER_LOCAL_URI] = val != m_wire.elements_end();
+  if (this->hasLocalUri()) {
+    m_localUri.assign(reinterpret_cast<const char*>(val->value()), val->value_size());
+  }
+
   val = m_wire.find(tlv::nfd::LocalControlFeature);
   m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = val != m_wire.elements_end();
   if (this->hasLocalControlFeature()) {
@@ -292,6 +305,10 @@
     os << "Uri: " << parameters.getUri() << ", ";
   }
 
+  if (parameters.hasLocalUri()) {
+    os << "LocalUri: " << parameters.getLocalUri() << ", ";
+  }
+
   if (parameters.hasLocalControlFeature()) {
     os << "LocalControlFeature: " << parameters.getLocalControlFeature() << ", ";
   }
diff --git a/src/mgmt/nfd/control-parameters.hpp b/src/mgmt/nfd/control-parameters.hpp
index 6c0c599..cd432ca 100644
--- a/src/mgmt/nfd/control-parameters.hpp
+++ b/src/mgmt/nfd/control-parameters.hpp
@@ -37,6 +37,7 @@
   CONTROL_PARAMETER_NAME,
   CONTROL_PARAMETER_FACE_ID,
   CONTROL_PARAMETER_URI,
+  CONTROL_PARAMETER_LOCAL_URI,
   CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE,
   CONTROL_PARAMETER_ORIGIN,
   CONTROL_PARAMETER_COST,
@@ -52,6 +53,7 @@
   "Name",
   "FaceId",
   "Uri",
+  "LocalUri",
   "LocalControlFeature",
   "Origin",
   "Cost",
@@ -74,7 +76,7 @@
 /**
  * \ingroup management
  * \brief represents parameters in a ControlCommand request or response
- * \sa http://redmine.named-data.net/projects/nfd/wiki/ControlCommand#ControlParameters
+ * \sa https://redmine.named-data.net/projects/nfd/wiki/ControlCommand#ControlParameters
  * \details This type is copyable because it's an abstraction of a TLV type.
  */
 class ControlParameters : public mgmt::ControlParameters
@@ -196,6 +198,36 @@
     return *this;
   }
 
+  bool
+  hasLocalUri() const
+  {
+    return m_hasFields[CONTROL_PARAMETER_LOCAL_URI];
+  }
+
+  const std::string&
+  getLocalUri() const
+  {
+    BOOST_ASSERT(this->hasLocalUri());
+    return m_localUri;
+  }
+
+  ControlParameters&
+  setLocalUri(const std::string& localUri)
+  {
+    m_wire.reset();
+    m_localUri = localUri;
+    m_hasFields[CONTROL_PARAMETER_LOCAL_URI] = true;
+    return *this;
+  }
+
+  ControlParameters&
+  unsetLocalUri()
+  {
+    m_wire.reset();
+    m_hasFields[CONTROL_PARAMETER_LOCAL_URI] = false;
+    return *this;
+  }
+
   /**
    * \deprecated use Flags+Mask fields instead
    */
@@ -492,6 +524,7 @@
   Name                m_name;
   uint64_t            m_faceId;
   std::string         m_uri;
+  std::string         m_localUri;
   LocalControlFeature m_localControlFeature;
   uint64_t            m_origin;
   uint64_t            m_cost;