face: ProtocolFactory::createFace with FacePersistency

Change-Id: If02510bd631e9aaa63b3cca89ced31a42e192ded
Refs: #2989
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index c422b3d..9387fe6 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -67,6 +67,7 @@
 
 void
 EthernetFactory::createFace(const FaceUri& uri,
+                            ndn::nfd::FacePersistency persistency,
                             const FaceCreatedCallback& onCreated,
                             const FaceConnectFailedCallback& onConnectFailed)
 {
diff --git a/daemon/face/ethernet-factory.hpp b/daemon/face/ethernet-factory.hpp
index aa7861f..2441571 100644
--- a/daemon/face/ethernet-factory.hpp
+++ b/daemon/face/ethernet-factory.hpp
@@ -55,8 +55,9 @@
   // from ProtocolFactory
   virtual void
   createFace(const FaceUri& uri,
+             ndn::nfd::FacePersistency persistency,
              const FaceCreatedCallback& onCreated,
-             const FaceConnectFailedCallback& onConnectFailed);
+             const FaceConnectFailedCallback& onConnectFailed) DECL_OVERRIDE;
 
   /**
    * \brief Create an EthernetFace to communicate with the given multicast group
diff --git a/daemon/face/protocol-factory.hpp b/daemon/face/protocol-factory.hpp
index 1c12cc0..49e1a31 100644
--- a/daemon/face/protocol-factory.hpp
+++ b/daemon/face/protocol-factory.hpp
@@ -58,15 +58,17 @@
     Error(const std::string& what) : std::runtime_error(what) {}
   };
 
-  /** \brief Try to create Face using the supplied Face URI
+  /** \brief Try to create Face using the supplied FaceUri
    *
-   * This method should automatically choose channel, based on supplied Face URI
+   * This method should automatically choose channel, based on supplied FaceUri
    * and create face.
    *
-   * \throws Factory::Error if Factory does not support connect operation
+   * \throw Error Factory does not support connect operation
+   * \throw Error specified \p persistency is not supported
    */
   virtual void
   createFace(const FaceUri& uri,
+             ndn::nfd::FacePersistency persistency,
              const FaceCreatedCallback& onCreated,
              const FaceConnectFailedCallback& onConnectFailed) = 0;
 
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index dc7e369..9c640a1 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -127,9 +127,14 @@
 
 void
 TcpFactory::createFace(const FaceUri& uri,
+                       ndn::nfd::FacePersistency persistency,
                        const FaceCreatedCallback& onCreated,
                        const FaceConnectFailedCallback& onConnectFailed)
 {
+  if (persistency != ndn::nfd::FACE_PERSISTENCY_PERSISTENT) {
+    throw Error("TcpFactory only supports persistent face");
+  }
+
   BOOST_ASSERT(uri.isCanonical());
   boost::asio::ip::address ipAddress = boost::asio::ip::address::from_string(uri.getHost());
   tcp::Endpoint endpoint(ipAddress, boost::lexical_cast<uint16_t>(uri.getPort()));
diff --git a/daemon/face/tcp-factory.hpp b/daemon/face/tcp-factory.hpp
index c577854..2667915 100644
--- a/daemon/face/tcp-factory.hpp
+++ b/daemon/face/tcp-factory.hpp
@@ -77,12 +77,13 @@
   shared_ptr<TcpChannel>
   createChannel(const std::string& localIp, const std::string& localPort);
 
-  // from Factory
+  // from ProtocolFactory
 
   virtual void
   createFace(const FaceUri& uri,
+             ndn::nfd::FacePersistency persistency,
              const FaceCreatedCallback& onCreated,
-             const FaceConnectFailedCallback& onConnectFailed);
+             const FaceConnectFailedCallback& onConnectFailed) DECL_OVERRIDE;
 
   virtual std::list<shared_ptr<const Channel> >
   getChannels() const;
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index ddef35e..3a55b7c 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -250,9 +250,14 @@
 
 void
 UdpFactory::createFace(const FaceUri& uri,
+                       ndn::nfd::FacePersistency persistency,
                        const FaceCreatedCallback& onCreated,
                        const FaceConnectFailedCallback& onConnectFailed)
 {
+  if (persistency != ndn::nfd::FACE_PERSISTENCY_PERSISTENT) {
+    throw Error("UdpFactory only supports persistent face");
+  }
+
   BOOST_ASSERT(uri.isCanonical());
 
   boost::asio::ip::address ipAddress = boost::asio::ip::address::from_string(uri.getHost());
diff --git a/daemon/face/udp-factory.hpp b/daemon/face/udp-factory.hpp
index e59275d..8a4e87a 100644
--- a/daemon/face/udp-factory.hpp
+++ b/daemon/face/udp-factory.hpp
@@ -145,8 +145,9 @@
   // from ProtocolFactory
   virtual void
   createFace(const FaceUri& uri,
+             ndn::nfd::FacePersistency persistency,
              const FaceCreatedCallback& onCreated,
-             const FaceConnectFailedCallback& onConnectFailed);
+             const FaceConnectFailedCallback& onConnectFailed) DECL_OVERRIDE;
 
   virtual std::list<shared_ptr<const Channel>>
   getChannels() const;
diff --git a/daemon/face/unix-stream-factory.cpp b/daemon/face/unix-stream-factory.cpp
index d7513f6..16a01a9 100644
--- a/daemon/face/unix-stream-factory.cpp
+++ b/daemon/face/unix-stream-factory.cpp
@@ -57,6 +57,7 @@
 
 void
 UnixStreamFactory::createFace(const FaceUri& uri,
+                              ndn::nfd::FacePersistency persistency,
                               const FaceCreatedCallback& onCreated,
                               const FaceConnectFailedCallback& onConnectFailed)
 {
diff --git a/daemon/face/unix-stream-factory.hpp b/daemon/face/unix-stream-factory.hpp
index e2aff30..ecb679b 100644
--- a/daemon/face/unix-stream-factory.hpp
+++ b/daemon/face/unix-stream-factory.hpp
@@ -61,8 +61,9 @@
 
   virtual void
   createFace(const FaceUri& uri,
+             ndn::nfd::FacePersistency persistency,
              const FaceCreatedCallback& onCreated,
-             const FaceConnectFailedCallback& onConnectFailed);
+             const FaceConnectFailedCallback& onConnectFailed) DECL_OVERRIDE;
 
   virtual std::list<shared_ptr<const Channel> >
   getChannels() const;
diff --git a/daemon/face/websocket-factory.cpp b/daemon/face/websocket-factory.cpp
index 5fbdf25..e911827 100644
--- a/daemon/face/websocket-factory.cpp
+++ b/daemon/face/websocket-factory.cpp
@@ -67,6 +67,7 @@
 
 void
 WebSocketFactory::createFace(const FaceUri& uri,
+                             ndn::nfd::FacePersistency persistency,
                              const FaceCreatedCallback& onCreated,
                              const FaceConnectFailedCallback& onConnectFailed)
 {
diff --git a/daemon/face/websocket-factory.hpp b/daemon/face/websocket-factory.hpp
index a522036..3859893 100644
--- a/daemon/face/websocket-factory.hpp
+++ b/daemon/face/websocket-factory.hpp
@@ -81,8 +81,9 @@
   // from ProtocolFactory
   virtual void
   createFace(const FaceUri& uri,
+             ndn::nfd::FacePersistency persistency,
              const FaceCreatedCallback& onCreated,
-             const FaceConnectFailedCallback& onConnectFailed);
+             const FaceConnectFailedCallback& onConnectFailed) DECL_OVERRIDE;
 
   virtual std::list<shared_ptr<const Channel> >
   getChannels() const;
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 3c590f5..eecf25c 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -975,6 +975,7 @@
   try
     {
       factory->second->createFace(uri,
+                                  ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
                                   bind(&FaceManager::onCreated,
                                        this, requestName, parameters, _1),
                                   bind(&FaceManager::onConnectFailed,