face+mgmt: enable local fields through ProtocolFactory::createFace
refs #3731
Change-Id: I569dae59cda150ffcb1c0ff1d01a575d8850beca
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 163b0e9..656b671 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -66,6 +66,7 @@
void
TcpChannel::connect(const tcp::Endpoint& remoteEndpoint,
+ bool wantLocalFieldsEnabled,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed,
const time::seconds& timeout/* = time::seconds(4)*/)
@@ -83,8 +84,8 @@
clientSocket->async_connect(remoteEndpoint,
bind(&TcpChannel::handleConnect, this,
- boost::asio::placeholders::error,
- clientSocket, connectTimeoutEvent,
+ boost::asio::placeholders::error, clientSocket,
+ wantLocalFieldsEnabled, connectTimeoutEvent,
onFaceCreated, onConnectFailed));
}
@@ -96,8 +97,9 @@
void
TcpChannel::createFace(ip::tcp::socket&& socket,
- const FaceCreatedCallback& onFaceCreated,
- bool isOnDemand)
+ bool isOnDemand,
+ bool wantLocalFieldsEnabled,
+ const FaceCreatedCallback& onFaceCreated)
{
shared_ptr<Face> face;
tcp::Endpoint remoteEndpoint = socket.remote_endpoint();
@@ -107,7 +109,12 @@
auto persistency = isOnDemand ? ndn::nfd::FACE_PERSISTENCY_ON_DEMAND
: ndn::nfd::FACE_PERSISTENCY_PERSISTENT;
auto linkService = make_unique<face::GenericLinkService>();
+ auto options = linkService->getOptions();
+ options.allowLocalFields = wantLocalFieldsEnabled;
+ linkService->setOptions(options);
+
auto transport = make_unique<face::TcpTransport>(std::move(socket), persistency);
+
face = make_shared<Face>(std::move(linkService), std::move(transport));
m_channelFaces[remoteEndpoint] = face;
@@ -157,7 +164,7 @@
NFD_LOG_DEBUG("[" << m_localEndpoint << "] Connection from " << m_acceptSocket.remote_endpoint());
- createFace(std::move(m_acceptSocket), onFaceCreated, true);
+ createFace(std::move(m_acceptSocket), true, false, onFaceCreated);
// prepare accepting the next connection
accept(onFaceCreated, onAcceptFailed);
@@ -166,6 +173,7 @@
void
TcpChannel::handleConnect(const boost::system::error_code& error,
const shared_ptr<ip::tcp::socket>& socket,
+ bool wantLocalFieldsEnabled,
const scheduler::EventId& connectTimeoutEvent,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed)
@@ -195,7 +203,7 @@
NFD_LOG_DEBUG("[" << m_localEndpoint << "] Connected to " << socket->remote_endpoint());
- createFace(std::move(*socket), onFaceCreated, false);
+ createFace(std::move(*socket), false, wantLocalFieldsEnabled, onFaceCreated);
}
void