mgmt: enable LocalUri in faces/create command response
Display LocalUri in 'nfdc face create' output.
refs #3956
Change-Id: I3c9ce266f218547bd6ba9509437178d271f680f7
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index eeea696..95c8a82 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -144,8 +144,7 @@
if (face->getId() != face::INVALID_FACEID) {// Face already exists
NFD_LOG_TRACE("Attempted to create duplicate face of " << face->getId());
- ControlParameters response = collectFaceProperties(*face);
- response.setUri(face->getRemoteUri().toString());
+ ControlParameters response = collectFaceProperties(*face, true);
done(ControlResponse(409, "Face with remote URI already exists").setBody(response.wireEncode()));
return;
}
@@ -159,7 +158,7 @@
m_faceTable.add(face);
- ControlParameters response = collectFaceProperties(*face);
+ ControlParameters response = collectFaceProperties(*face, true);
done(ControlResponse(200, "OK").setBody(response.wireEncode()));
}
@@ -233,7 +232,7 @@
setLinkServiceOptions(*face, parameters, response);
// Set ControlResponse fields
- response = collectFaceProperties(*face);
+ response = collectFaceProperties(*face, false);
done(ControlResponse(200, "OK").setBody(response.wireEncode()));
}
@@ -271,16 +270,21 @@
}
ControlParameters
-FaceManager::collectFaceProperties(const Face& face)
+FaceManager::collectFaceProperties(const Face& face, bool wantUris)
{
auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
BOOST_ASSERT(linkService != nullptr);
auto options = linkService->getOptions();
- return ControlParameters()
- .setFaceId(face.getId())
- .setFacePersistency(face.getPersistency())
- .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, options.allowLocalFields, false);
+ ControlParameters params;
+ params.setFaceId(face.getId())
+ .setFacePersistency(face.getPersistency())
+ .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, options.allowLocalFields, false);
+ if (wantUris) {
+ params.setUri(face.getRemoteUri().toString())
+ .setLocalUri(face.getLocalUri().toString());
+ }
+ return params;
}
void
diff --git a/daemon/mgmt/face-manager.hpp b/daemon/mgmt/face-manager.hpp
index 77e820c..4e43716 100644
--- a/daemon/mgmt/face-manager.hpp
+++ b/daemon/mgmt/face-manager.hpp
@@ -83,7 +83,7 @@
ControlParameters& response);
static ControlParameters
- collectFaceProperties(const Face& face);
+ collectFaceProperties(const Face& face, bool wantUris);
PUBLIC_WITH_TESTS_ELSE_PRIVATE: // StatusDataset
void