face: group parameters to createFace and connect into a common structure
Change-Id: Icb6857602ed7e897be6c5334b05be23793d133bb
diff --git a/core/common.hpp b/core/common.hpp
index b4da8a7..cde5437 100644
--- a/core/common.hpp
+++ b/core/common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -109,15 +109,17 @@
using ndn::Name;
using ndn::PartialName;
+// Not using a namespace alias (namespace tlv = ndn::tlv), because
+// it doesn't allow NFD to add other members to the namespace
namespace tlv {
-// Don't write "namespace tlv = ndn::tlv", because NFD can add other members into this namespace.
using namespace ndn::tlv;
} // namespace tlv
namespace lp = ndn::lp;
namespace name = ndn::name;
-namespace time = ndn::time;
namespace signal = ndn::util::signal;
+namespace time = ndn::time;
+using namespace ndn::time_literals;
} // namespace nfd
diff --git a/daemon/face/channel.hpp b/daemon/face/channel.hpp
index a999b72..1a5ed90 100644
--- a/daemon/face/channel.hpp
+++ b/daemon/face/channel.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -32,16 +32,14 @@
namespace nfd {
namespace face {
-class Face;
-
/** \brief Prototype for the callback that is invoked when a face is created
* (in response to an incoming connection or after a connection is established)
*/
-typedef function<void(const shared_ptr<Face>& newFace)> FaceCreatedCallback;
+using FaceCreatedCallback = function<void(const shared_ptr<Face>& face)>;
/** \brief Prototype for the callback that is invoked when a face fails to be created
*/
-typedef function<void(uint32_t status, const std::string& reason)> FaceCreationFailedCallback;
+using FaceCreationFailedCallback = function<void(uint32_t status, const std::string& reason)>;
/** \brief represent a channel that communicates on a local endpoint
* \sa FaceSystem
@@ -79,6 +77,28 @@
FaceUri m_uri;
};
+/** \brief Parameters used to set Transport properties or LinkService options on a newly created face
+ *
+ * Parameters are passed as a struct rather than individually, so that a future change in the list
+ * of parameters does not require an update to the method signature in all subclasses.
+ */
+class FaceParams
+{
+public:
+ // get rid of this constructor and use aggregate init + NSDMIs when we switch to C++14
+ FaceParams() noexcept
+ : persistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ , wantLocalFields(false)
+ , wantLpReliability(false)
+ {
+ }
+
+public:
+ ndn::nfd::FacePersistency persistency;
+ bool wantLocalFields;
+ bool wantLpReliability;
+};
+
/** \brief invokes a callback when the face is closed
* \param face the face
* \param f the callback to be invoked when the face enters CLOSED state
diff --git a/daemon/face/ethernet-channel.cpp b/daemon/face/ethernet-channel.cpp
index a4d1907..cf60527 100644
--- a/daemon/face/ethernet-channel.cpp
+++ b/daemon/face/ethernet-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -54,14 +54,13 @@
void
EthernetChannel::connect(const ethernet::Address& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLpReliability,
+ const FaceParams& params,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed)
{
shared_ptr<Face> face;
try {
- face = createFace(remoteEndpoint, persistency, wantLpReliability).second;
+ face = createFace(remoteEndpoint, params).second;
}
catch (const boost::system::system_error& e) {
NFD_LOG_CHAN_DEBUG("Face creation for " << remoteEndpoint << " failed: " << e.what());
@@ -166,7 +165,9 @@
bool isCreated = false;
shared_ptr<Face> face;
try {
- std::tie(isCreated, face) = createFace(sender, ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, false);
+ FaceParams params;
+ params.persistency = ndn::nfd::FACE_PERSISTENCY_ON_DEMAND;
+ std::tie(isCreated, face) = createFace(sender, params);
}
catch (const EthernetTransport::Error& e) {
NFD_LOG_CHAN_DEBUG("Face creation for " << sender << " failed: " << e.what());
@@ -187,8 +188,7 @@
std::pair<bool, shared_ptr<Face>>
EthernetChannel::createFace(const ethernet::Address& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLpReliability)
+ const FaceParams& params)
{
auto it = m_channelFaces.find(remoteEndpoint);
if (it != m_channelFaces.end()) {
@@ -201,11 +201,11 @@
GenericLinkService::Options options;
options.allowFragmentation = true;
options.allowReassembly = true;
- options.reliabilityOptions.isEnabled = wantLpReliability;
+ options.reliabilityOptions.isEnabled = params.wantLpReliability;
auto linkService = make_unique<GenericLinkService>(options);
auto transport = make_unique<UnicastEthernetTransport>(*m_localEndpoint, remoteEndpoint,
- persistency, m_idleFaceTimeout);
+ params.persistency, m_idleFaceTimeout);
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
m_channelFaces[remoteEndpoint] = face;
diff --git a/daemon/face/ethernet-channel.hpp b/daemon/face/ethernet-channel.hpp
index 5847af5..36d32be 100644
--- a/daemon/face/ethernet-channel.hpp
+++ b/daemon/face/ethernet-channel.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -76,17 +76,10 @@
/**
* \brief Create a unicast Ethernet face toward \p remoteEndpoint
- *
- * \param remoteEndpoint The remote Ethernet endpoint
- * \param persistency Persistency of the newly created face
- * \param wantLpReliability whether LpReliability should be enabled
- * \param onFaceCreated Callback to notify successful creation of the face
- * \param onConnectFailed Callback to notify errors
*/
void
connect(const ethernet::Address& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLpReliability,
+ const FaceParams& params,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed);
@@ -124,8 +117,7 @@
std::pair<bool, shared_ptr<Face>>
createFace(const ethernet::Address& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLpReliability);
+ const FaceParams& params);
void
updateFilter();
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index 36f7c45..2c6c39c 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,6 +26,7 @@
#include "ethernet-factory.hpp"
#include "generic-link-service.hpp"
#include "multicast-ethernet-transport.hpp"
+
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm/copy.hpp>
@@ -165,27 +166,27 @@
}
void
-EthernetFactory::createFace(const CreateFaceParams& params,
+EthernetFactory::createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure)
{
- BOOST_ASSERT(params.remoteUri.isCanonical());
+ BOOST_ASSERT(req.remoteUri.isCanonical());
- if (!params.localUri || params.localUri->getScheme() != "dev") {
+ if (!req.localUri || req.localUri->getScheme() != "dev") {
NFD_LOG_TRACE("Cannot create unicast Ethernet face without dev:// LocalUri");
onFailure(406, "Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme");
return;
}
- BOOST_ASSERT(params.localUri->isCanonical());
+ BOOST_ASSERT(req.localUri->isCanonical());
- if (params.persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
+ if (req.params.persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
NFD_LOG_TRACE("createFace does not support FACE_PERSISTENCY_ON_DEMAND");
onFailure(406, "Outgoing Ethernet faces do not support on-demand persistency");
return;
}
- ethernet::Address remoteEndpoint(ethernet::Address::fromString(params.remoteUri.getHost()));
- std::string localEndpoint(params.localUri->getHost());
+ ethernet::Address remoteEndpoint(ethernet::Address::fromString(req.remoteUri.getHost()));
+ std::string localEndpoint(req.localUri->getHost());
if (remoteEndpoint.isMulticast()) {
NFD_LOG_TRACE("createFace does not support multicast faces");
@@ -193,7 +194,7 @@
return;
}
- if (params.wantLocalFields) {
+ if (req.params.wantLocalFields) {
// Ethernet faces are never local
NFD_LOG_TRACE("createFace cannot create non-local face with local fields enabled");
onFailure(406, "Local fields can only be enabled on faces with local scope");
@@ -202,8 +203,7 @@
for (const auto& i : m_channels) {
if (i.first == localEndpoint) {
- i.second->connect(remoteEndpoint, params.persistency, params.wantLpReliability,
- onCreated, onFailure);
+ i.second->connect(remoteEndpoint, req.params, onCreated, onFailure);
return;
}
}
diff --git a/daemon/face/ethernet-factory.hpp b/daemon/face/ethernet-factory.hpp
index 7f53cff..11dac9c 100644
--- a/daemon/face/ethernet-factory.hpp
+++ b/daemon/face/ethernet-factory.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -50,7 +50,7 @@
FaceSystem::ConfigContext& context) override;
void
- createFace(const CreateFaceParams& params,
+ createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure) override;
@@ -109,7 +109,7 @@
{
bool isEnabled = false;
bool wantListen = false;
- time::nanoseconds idleTimeout = time::seconds(600);
+ time::nanoseconds idleTimeout = 10_min;
};
UnicastConfig m_unicastConfig;
diff --git a/daemon/face/protocol-factory.hpp b/daemon/face/protocol-factory.hpp
index e0c62a1..fe3f1f8 100644
--- a/daemon/face/protocol-factory.hpp
+++ b/daemon/face/protocol-factory.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -129,29 +129,27 @@
return providedSchemes;
}
- /** \brief Parameters to ProtocolFactory::createFace
+ /** \brief Encapsulates a face creation request and all its parameters
*
* Parameters are passed as a struct rather than individually, so that a future change in the list
* of parameters does not require an update to the method signature in all subclasses.
*/
- struct CreateFaceParams
+ struct CreateFaceRequest
{
FaceUri remoteUri;
ndn::optional<FaceUri> localUri;
- ndn::nfd::FacePersistency persistency;
- bool wantLocalFields;
- bool wantLpReliability;
+ FaceParams params;
};
- /** \brief Try to create face using the supplied parameters
+ /** \brief Try to create a unicast face using the supplied parameters
*
- * \param params parameters to create face with
- * \param onCreated callback if face creation succeeds or face already exists;
- * persistency and local fields settings are not updated on an existing face
+ * \param req request object containing the face creation parameters
+ * \param onCreated callback if face creation succeeds or face already exists; the settings
+ * of an existing face are not updated if they differ from the request
* \param onFailure callback if face creation fails
*/
virtual void
- createFace(const CreateFaceParams& params,
+ createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure) = 0;
@@ -180,7 +178,6 @@
protected:
std::set<std::string> providedSchemes; ///< FaceUri schemes provided by this ProtocolFactory
-
FaceCreatedCallback addFace; ///< callback when a new face is created
/** \brief NetworkMonitor for listing available network interfaces and monitoring their changes
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 1dee521..b6f434d 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -69,9 +69,7 @@
void
TcpChannel::connect(const tcp::Endpoint& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLocalFields,
- bool wantLpReliability,
+ const FaceParams& params,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed,
time::nanoseconds timeout)
@@ -91,17 +89,12 @@
clientSocket->async_connect(remoteEndpoint,
bind(&TcpChannel::handleConnect, this,
boost::asio::placeholders::error, remoteEndpoint, clientSocket,
- // Creating a parameters struct works around limit on number of
- // parameters to bind
- ConnectParams{persistency, wantLocalFields, wantLpReliability},
- timeoutEvent, onFaceCreated, onConnectFailed));
+ params, timeoutEvent, onFaceCreated, onConnectFailed));
}
void
TcpChannel::createFace(ip::tcp::socket&& socket,
- ndn::nfd::FacePersistency persistency,
- bool wantLocalFields,
- bool wantLpReliability,
+ const FaceParams& params,
const FaceCreatedCallback& onFaceCreated)
{
shared_ptr<Face> face;
@@ -110,12 +103,12 @@
auto it = m_channelFaces.find(remoteEndpoint);
if (it == m_channelFaces.end()) {
GenericLinkService::Options options;
- options.allowLocalFields = wantLocalFields;
- options.reliabilityOptions.isEnabled = wantLpReliability;
+ options.allowLocalFields = params.wantLocalFields;
+ options.reliabilityOptions.isEnabled = params.wantLpReliability;
options.allowCongestionMarking = m_wantCongestionMarking;
auto linkService = make_unique<GenericLinkService>(options);
- auto transport = make_unique<TcpTransport>(std::move(socket), persistency);
+ auto transport = make_unique<TcpTransport>(std::move(socket), params.persistency);
face = make_shared<Face>(std::move(linkService), std::move(transport));
m_channelFaces[remoteEndpoint] = face;
@@ -160,7 +153,10 @@
}
NFD_LOG_CHAN_TRACE("Incoming connection from " << m_socket.remote_endpoint());
- createFace(std::move(m_socket), ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, false, false, onFaceCreated);
+
+ FaceParams params;
+ params.persistency = ndn::nfd::FACE_PERSISTENCY_ON_DEMAND;
+ createFace(std::move(m_socket), params, onFaceCreated);
// prepare accepting the next connection
accept(onFaceCreated, onAcceptFailed);
@@ -170,7 +166,7 @@
TcpChannel::handleConnect(const boost::system::error_code& error,
const tcp::Endpoint& remoteEndpoint,
const shared_ptr<ip::tcp::socket>& socket,
- TcpChannel::ConnectParams params,
+ const FaceParams& params,
const scheduler::EventId& connectTimeoutEvent,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed)
@@ -195,8 +191,7 @@
}
NFD_LOG_CHAN_TRACE("Connected to " << socket->remote_endpoint());
- createFace(std::move(*socket), params.persistency, params.wantLocalFields,
- params.wantLpReliability, onFaceCreated);
+ createFace(std::move(*socket), params, onFaceCreated);
}
void
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index 1587b99..0f4c79a 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.hpp
@@ -86,27 +86,15 @@
*/
void
connect(const tcp::Endpoint& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLocalFields,
- bool wantLpReliability,
+ const FaceParams& params,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed,
- time::nanoseconds timeout = time::seconds(4));
-
-private:
- struct ConnectParams
- {
- ndn::nfd::FacePersistency persistency;
- bool wantLocalFields;
- bool wantLpReliability;
- };
+ time::nanoseconds timeout = 8_s);
private:
void
createFace(boost::asio::ip::tcp::socket&& socket,
- ndn::nfd::FacePersistency persistency,
- bool wantLocalFields,
- bool wantLpReliability,
+ const FaceParams& params,
const FaceCreatedCallback& onFaceCreated);
void
@@ -122,7 +110,7 @@
handleConnect(const boost::system::error_code& error,
const tcp::Endpoint& remoteEndpoint,
const shared_ptr<boost::asio::ip::tcp::socket>& socket,
- ConnectParams params,
+ const FaceParams& params,
const scheduler::EventId& connectTimeoutEvent,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed);
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index fae3c54..1477e09 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -129,31 +129,31 @@
}
void
-TcpFactory::createFace(const CreateFaceParams& params,
+TcpFactory::createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure)
{
- BOOST_ASSERT(params.remoteUri.isCanonical());
+ BOOST_ASSERT(req.remoteUri.isCanonical());
- if (params.localUri) {
+ if (req.localUri) {
NFD_LOG_TRACE("Cannot create unicast TCP face with LocalUri");
onFailure(406, "Unicast TCP faces cannot be created with a LocalUri");
return;
}
- if (params.persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
+ if (req.params.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;
}
- tcp::Endpoint endpoint(ndn::ip::addressFromString(params.remoteUri.getHost()),
- boost::lexical_cast<uint16_t>(params.remoteUri.getPort()));
+ tcp::Endpoint endpoint(ndn::ip::addressFromString(req.remoteUri.getHost()),
+ boost::lexical_cast<uint16_t>(req.remoteUri.getPort()));
// a canonical tcp4/tcp6 FaceUri cannot have a multicast address
BOOST_ASSERT(!endpoint.address().is_multicast());
- if (params.wantLocalFields && !endpoint.address().is_loopback()) {
+ if (req.params.wantLocalFields && !endpoint.address().is_loopback()) {
NFD_LOG_TRACE("createFace cannot create non-local face with local fields enabled");
onFailure(406, "Local fields can only be enabled on faces with local scope");
return;
@@ -163,8 +163,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, params.persistency, params.wantLocalFields,
- params.wantLpReliability, onCreated, onFailure);
+ i.second->connect(endpoint, req.params, onCreated, onFailure);
return;
}
}
diff --git a/daemon/face/tcp-factory.hpp b/daemon/face/tcp-factory.hpp
index 7fbac39..874dd8c 100644
--- a/daemon/face/tcp-factory.hpp
+++ b/daemon/face/tcp-factory.hpp
@@ -50,7 +50,7 @@
FaceSystem::ConfigContext& context) override;
void
- createFace(const CreateFaceParams& params,
+ createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure) override;
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index 3f3271e..624b9cd 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -49,14 +49,13 @@
void
UdpChannel::connect(const udp::Endpoint& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLpReliability,
+ const FaceParams& params,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed)
{
shared_ptr<Face> face;
try {
- face = createFace(remoteEndpoint, persistency, wantLpReliability).second;
+ face = createFace(remoteEndpoint, params).second;
}
catch (const boost::system::system_error& e) {
NFD_LOG_CHAN_DEBUG("Face creation for " << remoteEndpoint << " failed: " << e.what());
@@ -121,8 +120,9 @@
bool isCreated = false;
shared_ptr<Face> face;
try {
- std::tie(isCreated, face) = createFace(m_remoteEndpoint, ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- false);
+ FaceParams params;
+ params.persistency = ndn::nfd::FACE_PERSISTENCY_ON_DEMAND;
+ std::tie(isCreated, face) = createFace(m_remoteEndpoint, params);
}
catch (const boost::system::system_error& e) {
NFD_LOG_CHAN_DEBUG("Face creation for " << m_remoteEndpoint << " failed: " << e.what());
@@ -145,8 +145,7 @@
std::pair<bool, shared_ptr<Face>>
UdpChannel::createFace(const udp::Endpoint& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLpReliability)
+ const FaceParams& params)
{
auto it = m_channelFaces.find(remoteEndpoint);
if (it != m_channelFaces.end()) {
@@ -162,10 +161,10 @@
socket.connect(remoteEndpoint);
GenericLinkService::Options options;
- options.reliabilityOptions.isEnabled = wantLpReliability;
+ options.reliabilityOptions.isEnabled = params.wantLpReliability;
options.allowCongestionMarking = m_wantCongestionMarking;
auto linkService = make_unique<GenericLinkService>(options);
- auto transport = make_unique<UnicastUdpTransport>(std::move(socket), persistency, m_idleFaceTimeout);
+ auto transport = make_unique<UnicastUdpTransport>(std::move(socket), params.persistency, m_idleFaceTimeout);
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
m_channelFaces[remoteEndpoint] = face;
diff --git a/daemon/face/udp-channel.hpp b/daemon/face/udp-channel.hpp
index 4441370..89540de 100644
--- a/daemon/face/udp-channel.hpp
+++ b/daemon/face/udp-channel.hpp
@@ -65,17 +65,10 @@
/**
* \brief Create a unicast UDP face toward \p remoteEndpoint
- *
- * \param remoteEndpoint The remote UDP endpoint
- * \param persistency Persistency of the newly created face
- * \param wantLpReliability whether LpReliability should be enabled
- * \param onFaceCreated Callback to notify successful creation of the face
- * \param onConnectFailed Callback to notify errors
*/
void
connect(const udp::Endpoint& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLpReliability,
+ const FaceParams& params,
const FaceCreatedCallback& onFaceCreated,
const FaceCreationFailedCallback& onConnectFailed);
@@ -111,8 +104,7 @@
std::pair<bool, shared_ptr<Face>>
createFace(const udp::Endpoint& remoteEndpoint,
- ndn::nfd::FacePersistency persistency,
- bool wantLpReliability);
+ const FaceParams& params);
private:
const udp::Endpoint m_localEndpoint;
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 0a377ab..74b6974 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -231,26 +231,26 @@
}
void
-UdpFactory::createFace(const CreateFaceParams& params,
+UdpFactory::createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure)
{
- BOOST_ASSERT(params.remoteUri.isCanonical());
+ BOOST_ASSERT(req.remoteUri.isCanonical());
- if (params.localUri) {
+ if (req.localUri) {
NFD_LOG_TRACE("Cannot create unicast UDP face with LocalUri");
onFailure(406, "Unicast UDP faces cannot be created with a LocalUri");
return;
}
- if (params.persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
+ if (req.params.persistency == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
NFD_LOG_TRACE("createFace does not support FACE_PERSISTENCY_ON_DEMAND");
onFailure(406, "Outgoing UDP faces do not support on-demand persistency");
return;
}
- udp::Endpoint endpoint(ndn::ip::addressFromString(params.remoteUri.getHost()),
- boost::lexical_cast<uint16_t>(params.remoteUri.getPort()));
+ udp::Endpoint endpoint(ndn::ip::addressFromString(req.remoteUri.getHost()),
+ boost::lexical_cast<uint16_t>(req.remoteUri.getPort()));
if (endpoint.address().is_multicast()) {
NFD_LOG_TRACE("createFace does not support multicast faces");
@@ -258,7 +258,7 @@
return;
}
- if (params.wantLocalFields) {
+ if (req.params.wantLocalFields) {
// UDP faces are never local
NFD_LOG_TRACE("createFace cannot create non-local face with local fields enabled");
onFailure(406, "Local fields can only be enabled on faces with local scope");
@@ -269,8 +269,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, params.persistency, params.wantLpReliability,
- onCreated, onFailure);
+ i.second->connect(endpoint, req.params, onCreated, onFailure);
return;
}
}
diff --git a/daemon/face/udp-factory.hpp b/daemon/face/udp-factory.hpp
index 62f59ee..9fccdbb 100644
--- a/daemon/face/udp-factory.hpp
+++ b/daemon/face/udp-factory.hpp
@@ -66,7 +66,7 @@
FaceSystem::ConfigContext& context) override;
void
- createFace(const CreateFaceParams& params,
+ createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure) override;
diff --git a/daemon/face/unix-stream-factory.cpp b/daemon/face/unix-stream-factory.cpp
index acbd543..439eff4 100644
--- a/daemon/face/unix-stream-factory.cpp
+++ b/daemon/face/unix-stream-factory.cpp
@@ -86,7 +86,7 @@
}
void
-UnixStreamFactory::createFace(const CreateFaceParams& params,
+UnixStreamFactory::createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure)
{
diff --git a/daemon/face/unix-stream-factory.hpp b/daemon/face/unix-stream-factory.hpp
index d87ffd1..de2391f 100644
--- a/daemon/face/unix-stream-factory.hpp
+++ b/daemon/face/unix-stream-factory.hpp
@@ -50,7 +50,7 @@
FaceSystem::ConfigContext& context) override;
void
- createFace(const CreateFaceParams& params,
+ createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure) override;
diff --git a/daemon/face/websocket-channel.cpp b/daemon/face/websocket-channel.cpp
index 02ae079..d26a0b5 100644
--- a/daemon/face/websocket-channel.cpp
+++ b/daemon/face/websocket-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -35,7 +35,7 @@
WebSocketChannel::WebSocketChannel(const websocket::Endpoint& localEndpoint)
: m_localEndpoint(localEndpoint)
- , m_pingInterval(time::seconds(10))
+ , m_pingInterval(10_s)
{
setUri(FaceUri(m_localEndpoint, "ws"));
NFD_LOG_CHAN_INFO("Creating channel");
diff --git a/daemon/face/websocket-factory.cpp b/daemon/face/websocket-factory.cpp
index e5317a5..c61d900 100644
--- a/daemon/face/websocket-factory.cpp
+++ b/daemon/face/websocket-factory.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -118,7 +118,7 @@
}
void
-WebSocketFactory::createFace(const CreateFaceParams& params,
+WebSocketFactory::createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure)
{
diff --git a/daemon/face/websocket-factory.hpp b/daemon/face/websocket-factory.hpp
index 21eb6fc..9c8639e 100644
--- a/daemon/face/websocket-factory.hpp
+++ b/daemon/face/websocket-factory.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -52,7 +52,7 @@
/** \brief unicast face creation is not supported and will always fail
*/
void
- createFace(const CreateFaceParams& params,
+ createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onFailure) override;
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 936b71e..7ddf6ea 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -115,14 +115,16 @@
return;
}
+ face::FaceParams faceParams;
+ faceParams.persistency = parameters.getFacePersistency();
+ faceParams.wantLocalFields = parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
+ parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED);
+ faceParams.wantLpReliability = parameters.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED) &&
+ parameters.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED);
try {
- factory->createFace({remoteUri, localUri, parameters.getFacePersistency(),
- parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
- parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED),
- parameters.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED) &&
- parameters.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)},
- bind(&FaceManager::afterCreateFaceSuccess, this, parameters, _1, done),
- bind(&FaceManager::afterCreateFaceFailure, this, _1, _2, done));
+ factory->createFace({remoteUri, localUri, faceParams},
+ bind(&FaceManager::afterCreateFaceSuccess, this, parameters, _1, done),
+ bind(&FaceManager::afterCreateFaceFailure, this, _1, _2, done));
}
catch (const std::runtime_error& error) {
NFD_LOG_ERROR("Face creation failed: " << error.what());
diff --git a/tests/daemon/face/ethernet-channel.t.cpp b/tests/daemon/face/ethernet-channel.t.cpp
index 3cb705a..9e70441 100644
--- a/tests/daemon/face/ethernet-channel.t.cpp
+++ b/tests/daemon/face/ethernet-channel.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -76,9 +76,7 @@
BOOST_CHECK_EQUAL(channel->size(), 0);
shared_ptr<nfd::Face> face;
- channel->connect({0x00, 0x00, 0x5e, 0x00, 0x53, 0x5e},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
+ channel->connect({0x00, 0x00, 0x5e, 0x00, 0x53, 0x5e}, {},
[&face] (const shared_ptr<nfd::Face>& newFace) {
BOOST_REQUIRE(newFace != nullptr);
face = newFace;
diff --git a/tests/daemon/face/ethernet-factory.t.cpp b/tests/daemon/face/ethernet-factory.t.cpp
index bb0f119..8bdc139 100644
--- a/tests/daemon/face/ethernet-factory.t.cpp
+++ b/tests/daemon/face/ethernet-factory.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -439,9 +439,7 @@
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:5e]"),
FaceUri("dev://eth0"),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
SKIP_IF_ETHERNET_NETIF_COUNT_LT(1);
@@ -450,33 +448,25 @@
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:5e]"),
localUri,
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:5e]"),
localUri,
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:53]"),
localUri,
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:57]"),
localUri,
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- true,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, true},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
}
@@ -485,45 +475,35 @@
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:5e]"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:5e]"),
FaceUri("udp4://127.0.0.1:20071"),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Creation of unicast Ethernet faces requires a LocalUri with dev:// scheme"});
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:5e]"),
FaceUri("dev://eth0"),
- ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Outgoing Ethernet faces do not support on-demand persistency"});
createFace(factory,
FaceUri("ether://[01:00:5e:90:10:5e]"),
FaceUri("dev://eth0"),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Cannot create multicast Ethernet faces"});
createFace(factory,
FaceUri("ether://[00:00:5e:00:53:5e]"),
FaceUri("dev://eth0"),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- true,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, true, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Local fields can only be enabled on faces with local scope"});
}
diff --git a/tests/daemon/face/face-system.t.cpp b/tests/daemon/face/face-system.t.cpp
index 1ecf33a..b22979a 100644
--- a/tests/daemon/face/face-system.t.cpp
+++ b/tests/daemon/face/face-system.t.cpp
@@ -47,7 +47,7 @@
void
processConfig(OptionalConfigSection configSection,
- FaceSystem::ConfigContext& context) override
+ FaceSystem::ConfigContext& context) final
{
processConfigHistory.push_back({configSection, context.isDryRun,
context.generalConfig.wantCongestionMarking});
@@ -57,15 +57,15 @@
}
void
- createFace(const CreateFaceParams& params,
+ createFace(const CreateFaceRequest& req,
const FaceCreatedCallback& onCreated,
- const FaceCreationFailedCallback& onFailure) override
+ const FaceCreationFailedCallback& onFailure) final
{
BOOST_FAIL("createFace should not be called");
}
std::vector<shared_ptr<const Channel>>
- getChannels() const override
+ getChannels() const final
{
BOOST_FAIL("getChannels should not be called");
return {};
diff --git a/tests/daemon/face/factory-test-common.hpp b/tests/daemon/face/factory-test-common.hpp
index 83cf899..6ea56bf 100644
--- a/tests/daemon/face/factory-test-common.hpp
+++ b/tests/daemon/face/factory-test-common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -34,6 +34,17 @@
namespace face {
namespace tests {
+struct TestFaceParams : public FaceParams
+{
+ TestFaceParams(ndn::nfd::FacePersistency persistency, bool wantLocalFields,
+ bool wantLpReliability) noexcept
+ {
+ this->persistency = persistency;
+ this->wantLocalFields = wantLocalFields;
+ this->wantLpReliability = wantLpReliability;
+ }
+};
+
struct CreateFaceExpectedResult
{
enum { FAILURE, SUCCESS } result;
@@ -45,12 +56,10 @@
createFace(ProtocolFactory& factory,
const FaceUri& remoteUri,
const ndn::optional<FaceUri>& localUri,
- ndn::nfd::FacePersistency persistency,
- bool wantLocalFields,
- bool wantLpReliability,
+ const TestFaceParams& params,
const CreateFaceExpectedResult& expected)
{
- factory.createFace({remoteUri, localUri, persistency, wantLocalFields, wantLpReliability},
+ factory.createFace({remoteUri, localUri, params},
[expected] (const shared_ptr<Face>&) {
BOOST_CHECK_EQUAL(CreateFaceExpectedResult::SUCCESS, expected.result);
},
diff --git a/tests/daemon/face/tcp-channel-fixture.hpp b/tests/daemon/face/tcp-channel-fixture.hpp
index ed91aee..732ad22 100644
--- a/tests/daemon/face/tcp-channel-fixture.hpp
+++ b/tests/daemon/face/tcp-channel-fixture.hpp
@@ -50,7 +50,7 @@
connect(TcpChannel& channel) final
{
g_io.post([&] {
- channel.connect(listenerEp, ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false,
+ channel.connect(listenerEp, {},
[this] (const shared_ptr<Face>& newFace) {
BOOST_REQUIRE(newFace != nullptr);
connectFaceClosedSignal(*newFace, [this] { limitedIo.afterOp(); });
diff --git a/tests/daemon/face/tcp-channel.t.cpp b/tests/daemon/face/tcp-channel.t.cpp
index c3ebf9c..1c2b170 100644
--- a/tests/daemon/face/tcp-channel.t.cpp
+++ b/tests/daemon/face/tcp-channel.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -46,8 +46,7 @@
// do not listen
auto channel = this->makeChannel(typename IpAddressFromFamily<F::value>::type());
- channel->connect(tcp::Endpoint(address, 7040),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false,
+ channel->connect(tcp::Endpoint(address, 7040), {},
[this] (const shared_ptr<nfd::Face>&) {
BOOST_FAIL("Connect succeeded when it should have failed");
this->limitedIo.afterOp();
diff --git a/tests/daemon/face/tcp-factory.t.cpp b/tests/daemon/face/tcp-factory.t.cpp
index 39567d6..934229f 100644
--- a/tests/daemon/face/tcp-factory.t.cpp
+++ b/tests/daemon/face/tcp-factory.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -172,9 +172,7 @@
createFace(factory,
FaceUri("tcp4://127.0.0.1:6363"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
createChannel("127.0.0.1", "20071");
@@ -182,33 +180,25 @@
createFace(factory,
FaceUri("tcp4://127.0.0.1:6363"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("tcp4://127.0.0.1:6363"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("tcp4://127.0.0.1:20072"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("tcp4://127.0.0.1:20073"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- true,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, true},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
}
@@ -219,27 +209,21 @@
createFace(factory,
FaceUri("tcp4://127.0.0.1:20072"),
FaceUri("tcp4://127.0.0.1:20071"),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Unicast TCP faces cannot be created with a LocalUri"});
createFace(factory,
FaceUri("tcp4://127.0.0.1:20072"),
{},
- ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Outgoing TCP faces do not support on-demand persistency"});
createFace(factory,
FaceUri("tcp4://198.51.100.100:6363"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- true,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, true, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Local fields can only be enabled on faces with local scope"});
}
@@ -272,13 +256,11 @@
BOOST_FIXTURE_TEST_CASE(CreateFaceTimeout, CreateFaceTimeoutFixture)
{
createChannel("0.0.0.0", "20070");
-
- factory.createFace({FaceUri("tcp4://192.0.2.1:20070"), {},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
+ factory.createFace({FaceUri("tcp4://192.0.2.1:20070"), {}, {}},
bind(&CreateFaceTimeoutFixture::onFaceCreated, this, _1),
bind(&CreateFaceTimeoutFixture::onConnectFailed, this, _2));
- BOOST_REQUIRE_EQUAL(limitedIo.run(1, time::seconds(10)), LimitedIo::EXCEED_OPS);
+ BOOST_REQUIRE_EQUAL(limitedIo.run(1, 10_s), LimitedIo::EXCEED_OPS);
BOOST_CHECK(face == nullptr);
}
diff --git a/tests/daemon/face/udp-channel-fixture.hpp b/tests/daemon/face/udp-channel-fixture.hpp
index ddf22f7..708813a 100644
--- a/tests/daemon/face/udp-channel-fixture.hpp
+++ b/tests/daemon/face/udp-channel-fixture.hpp
@@ -51,7 +51,7 @@
connect(UdpChannel& channel) final
{
g_io.post([&] {
- channel.connect(listenerEp, ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false,
+ channel.connect(listenerEp, {},
[this] (const shared_ptr<Face>& newFace) {
BOOST_REQUIRE(newFace != nullptr);
connectFaceClosedSignal(*newFace, [this] { limitedIo.afterOp(); });
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index 4ef1451..7303f5c 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -877,9 +877,7 @@
createFace(factory,
FaceUri("udp4://127.0.0.1:6363"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
createChannel("127.0.0.1", 20071);
@@ -887,33 +885,25 @@
createFace(factory,
FaceUri("udp4://127.0.0.1:6363"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("udp4://127.0.0.1:6363"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("udp4://127.0.0.1:20072"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, false},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("udp4://127.0.0.1:20073"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- true,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, true},
{CreateFaceExpectedResult::SUCCESS, 0, ""});
}
@@ -924,36 +914,28 @@
createFace(factory,
FaceUri("udp4://127.0.0.1:20072"),
FaceUri("udp4://127.0.0.1:20071"),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Unicast UDP faces cannot be created with a LocalUri"});
createFace(factory,
FaceUri("udp4://127.0.0.1:20072"),
{},
- ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Outgoing UDP faces do not support on-demand persistency"});
createFace(factory,
FaceUri("udp4://233.252.0.1:23252"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Cannot create multicast UDP faces"});
createFace(factory,
FaceUri("udp4://127.0.0.1:20072"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- true,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, true, false},
{CreateFaceExpectedResult::FAILURE, 406,
"Local fields can only be enabled on faces with local scope"});
}
diff --git a/tests/daemon/face/unix-stream-factory.t.cpp b/tests/daemon/face/unix-stream-factory.t.cpp
index 8d0e484..79eefa6 100644
--- a/tests/daemon/face/unix-stream-factory.t.cpp
+++ b/tests/daemon/face/unix-stream-factory.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -125,25 +125,19 @@
createFace(factory,
FaceUri("unix:///var/run/nfd.sock"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, false, false},
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("unix:///var/run/nfd.sock"),
{},
- ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("unix:///var/run/nfd.sock"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
}
diff --git a/tests/daemon/face/websocket-factory.t.cpp b/tests/daemon/face/websocket-factory.t.cpp
index d813931..bb8a378 100644
--- a/tests/daemon/face/websocket-factory.t.cpp
+++ b/tests/daemon/face/websocket-factory.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -196,25 +196,19 @@
createFace(factory,
FaceUri("ws://127.0.0.1:20070"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, false, false},
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("ws://127.0.0.1:20070"),
{},
- ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERSISTENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("ws://127.0.0.1:20070"),
{},
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ {ndn::nfd::FACE_PERSISTENCY_PERMANENT, false, false},
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
}
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index 7e294d4..d1266dd 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2017, Regents of the University of California,
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -268,7 +268,7 @@
}
void
- createFace(const CreateFaceParams& params,
+ createFace(const CreateFaceRequest& req,
const face::FaceCreatedCallback& onCreated,
const face::FaceCreationFailedCallback& onConnectFailed) final
{
diff --git a/tests/other/face-benchmark.cpp b/tests/other/face-benchmark.cpp
index 3f19441..2557d6f 100644
--- a/tests/other/face-benchmark.cpp
+++ b/tests/other/face-benchmark.cpp
@@ -128,17 +128,12 @@
auto addr = ndn::ip::addressFromString(uriR.getHost());
auto port = boost::lexical_cast<uint16_t>(uriR.getPort());
if (uriR.getScheme() == "tcp4") {
- m_tcpChannel.connect(tcp::Endpoint(addr, port),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
- false,
+ m_tcpChannel.connect(tcp::Endpoint(addr, port), {},
bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
}
else if (uriR.getScheme() == "udp4") {
- m_udpChannel.connect(udp::Endpoint(addr, port),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- false,
+ m_udpChannel.connect(udp::Endpoint(addr, port), {},
bind(&FaceBenchmark::onRightFaceCreated, this, faceL, _1),
bind(&FaceBenchmark::onFaceCreationFailed, _1, _2));
}