face+mgmt: accept LocalUri in ProtocolFactory and FaceManager
refs #4016
Change-Id: I3e192e6d3982ae8e6ced1dbfbaa62f1c993f799e
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 9be7c94..d9b2a03 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -78,28 +78,46 @@
const ControlParameters& parameters,
const ndn::mgmt::CommandContinuation& done)
{
- FaceUri uri;
- if (!uri.parse(parameters.getUri())) {
- NFD_LOG_TRACE("failed to parse URI");
+ FaceUri remoteUri;
+ if (!remoteUri.parse(parameters.getUri())) {
+ NFD_LOG_TRACE("failed to parse remote URI: " << parameters.getUri());
done(ControlResponse(400, "Malformed command"));
return;
}
- if (!uri.isCanonical()) {
- NFD_LOG_TRACE("received non-canonical URI");
- done(ControlResponse(400, "Non-canonical URI"));
+ if (!remoteUri.isCanonical()) {
+ NFD_LOG_TRACE("received non-canonical remote URI: " << remoteUri.toString());
+ done(ControlResponse(400, "Non-canonical remote URI"));
return;
}
- ProtocolFactory* factory = m_faceSystem.getFactoryByScheme(uri.getScheme());
+ ndn::optional<FaceUri> localUri;
+ if (parameters.hasLocalUri()) {
+ localUri = FaceUri{};
+
+ if (!localUri->parse(parameters.getLocalUri())) {
+ NFD_LOG_TRACE("failed to parse local URI: " << parameters.getLocalUri());
+ done(ControlResponse(400, "Malformed command"));
+ return;
+ }
+
+ if (!localUri->isCanonical()) {
+ NFD_LOG_TRACE("received non-canonical local URI: " << localUri->toString());
+ done(ControlResponse(400, "Non-canonical local URI"));
+ return;
+ }
+ }
+
+ ProtocolFactory* factory = m_faceSystem.getFactoryByScheme(remoteUri.getScheme());
if (factory == nullptr) {
- NFD_LOG_TRACE("received create request for unsupported protocol");
+ NFD_LOG_TRACE("received create request for unsupported protocol: " << remoteUri.getScheme());
done(ControlResponse(406, "Unsupported protocol"));
return;
}
try {
- factory->createFace(uri,
+ factory->createFace(remoteUri,
+ localUri,
parameters.getFacePersistency(),
parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED),