face: allow the creation of permanent TCP faces
Change-Id: I516c176b000a78012f2ef7bd7f1f3e74c1758a94
Refs: #3167
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index f9a8eb7..dee9fa6 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -68,6 +68,7 @@
void
TcpChannel::connect(const tcp::Endpoint& remoteEndpoint,
+ ndn::nfd::FacePersistency persistency,
bool wantLocalFieldsEnabled,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed,
@@ -88,8 +89,8 @@
clientSocket->async_connect(remoteEndpoint,
bind(&TcpChannel::handleConnect, this,
boost::asio::placeholders::error, remoteEndpoint,
- clientSocket, wantLocalFieldsEnabled, timeoutEvent,
- onFaceCreated, onConnectFailed));
+ clientSocket, persistency, wantLocalFieldsEnabled,
+ timeoutEvent, onFaceCreated, onConnectFailed));
}
void
@@ -153,9 +154,7 @@
}
NFD_LOG_CHAN_TRACE("Incoming connection from " << m_socket.remote_endpoint());
-
- createFace(std::move(m_socket), ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- false, onFaceCreated);
+ createFace(std::move(m_socket), ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, false, onFaceCreated);
// prepare accepting the next connection
accept(onFaceCreated, onAcceptFailed);
@@ -165,6 +164,7 @@
TcpChannel::handleConnect(const boost::system::error_code& error,
const tcp::Endpoint& remoteEndpoint,
const shared_ptr<ip::tcp::socket>& socket,
+ ndn::nfd::FacePersistency persistency,
bool wantLocalFieldsEnabled,
const scheduler::EventId& connectTimeoutEvent,
const FaceCreatedCallback& onFaceCreated,
@@ -190,8 +190,7 @@
}
NFD_LOG_CHAN_TRACE("Connected to " << socket->remote_endpoint());
- createFace(std::move(*socket), ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- wantLocalFieldsEnabled, onFaceCreated);
+ createFace(std::move(*socket), persistency, wantLocalFieldsEnabled, onFaceCreated);
}
void
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index ea28c3e..129587e 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.hpp
@@ -87,6 +87,7 @@
*/
void
connect(const tcp::Endpoint& remoteEndpoint,
+ ndn::nfd::FacePersistency persistency,
bool wantLocalFieldsEnabled,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed,
@@ -112,6 +113,7 @@
handleConnect(const boost::system::error_code& error,
const tcp::Endpoint& remoteEndpoint,
const shared_ptr<boost::asio::ip::tcp::socket>& socket,
+ ndn::nfd::FacePersistency persistency,
bool wantLocalFieldsEnabled,
const scheduler::EventId& connectTimeoutEvent,
const FaceCreatedCallback& onFaceCreated,
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index 5e8f3fb..49f1307 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -135,9 +135,9 @@
return;
}
- if (persistency != ndn::nfd::FACE_PERSISTENCY_PERSISTENT) {
- NFD_LOG_TRACE("createFace only supports FACE_PERSISTENCY_PERSISTENT");
- onFailure(406, "Outgoing TCP faces only support persistent persistency");
+ if (persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
+ NFD_LOG_TRACE("createFace does not support FACE_PERSISTENCY_ON_DEMAND");
+ onFailure(406, "Outgoing TCP faces do not support on-demand persistency");
return;
}
@@ -145,9 +145,9 @@
boost::lexical_cast<uint16_t>(remoteUri.getPort()));
if (endpoint.address().is_multicast()) {
- NFD_LOG_TRACE("createFace cannot create multicast faces");
- onFailure(406, "Cannot create multicast TCP faces");
- return;
+ NFD_LOG_TRACE("createFace does not support multicast faces");
+ onFailure(406, "Cannot create multicast TCP faces");
+ return;
}
if (m_prohibitedEndpoints.find(endpoint) != m_prohibitedEndpoints.end()) {
@@ -167,7 +167,7 @@
for (const auto& i : m_channels) {
if ((i.first.address().is_v4() && endpoint.address().is_v4()) ||
(i.first.address().is_v6() && endpoint.address().is_v6())) {
- i.second->connect(endpoint, wantLocalFieldsEnabled, onCreated, onFailure);
+ i.second->connect(endpoint, persistency, wantLocalFieldsEnabled, onCreated, onFailure);
return;
}
}