face: replace isOnDemand with FacePersistency

Change-Id: Ie6995b2d03bbb90faad158de2b055f72dd9ba73d
Refs: #2989
diff --git a/daemon/face/face.cpp b/daemon/face/face.cpp
index 0974cf2..0dd8169 100644
--- a/daemon/face/face.cpp
+++ b/daemon/face/face.cpp
@@ -34,7 +34,7 @@
   , m_remoteUri(remoteUri)
   , m_localUri(localUri)
   , m_isLocal(isLocal)
-  , m_isOnDemand(false)
+  , m_persistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
   , m_isMultiAccess(isMultiAccess)
   , m_isFailed(false)
 {
@@ -102,8 +102,7 @@
         .setLocalUri(getLocalUri().toString())
         .setFaceScope(isLocal() ? ndn::nfd::FACE_SCOPE_LOCAL
                                 : ndn::nfd::FACE_SCOPE_NON_LOCAL)
-        .setFacePersistency(isOnDemand() ? ndn::nfd::FACE_PERSISTENCY_ON_DEMAND
-                                         : ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+        .setFacePersistency(getPersistency())
         .setLinkType(isMultiAccess() ? ndn::nfd::LINK_TYPE_MULTI_ACCESS
                                      : ndn::nfd::LINK_TYPE_POINT_TO_POINT);
 }
diff --git a/daemon/face/face.hpp b/daemon/face/face.hpp
index 58deb3d..a5923d2 100644
--- a/daemon/face/face.hpp
+++ b/daemon/face/face.hpp
@@ -128,10 +128,10 @@
   bool
   isLocal() const;
 
-  /** \brief Get whether face is created on demand or explicitly via FaceManagement protocol
+  /** \brief Get the persistency setting
    */
-  bool
-  isOnDemand() const;
+  ndn::nfd::FacePersistency
+  getPersistency() const;
 
   /** \brief Get whether packets sent by this face may reach multiple peers
    */
@@ -171,7 +171,7 @@
 
 PUBLIC_WITH_TESTS_ELSE_PROTECTED:
   void
-  setOnDemand(bool isOnDemand);
+  setPersistency(ndn::nfd::FacePersistency persistency);
 
 protected:
   bool
@@ -202,7 +202,7 @@
   const FaceUri m_remoteUri;
   const FaceUri m_localUri;
   const bool m_isLocal;
-  bool m_isOnDemand;
+  ndn::nfd::FacePersistency m_persistency;
   const bool m_isMultiAccess;
   bool m_isFailed;
 
@@ -240,16 +240,16 @@
   return m_isLocal;
 }
 
-inline bool
-Face::isOnDemand() const
+inline ndn::nfd::FacePersistency
+Face::getPersistency() const
 {
-  return m_isOnDemand;
+  return m_persistency;
 }
 
 inline void
-Face::setOnDemand(bool isOnDemand)
+Face::setPersistency(ndn::nfd::FacePersistency persistency)
 {
-  m_isOnDemand = isOnDemand;
+  m_persistency = persistency;
 }
 
 inline bool
diff --git a/daemon/face/stream-face.hpp b/daemon/face/stream-face.hpp
index 94c339a..d08c1d5 100644
--- a/daemon/face/stream-face.hpp
+++ b/daemon/face/stream-face.hpp
@@ -120,7 +120,7 @@
 {
   NFD_LOG_FACE_INFO("Creating face");
 
-  this->setOnDemand(isOnDemand);
+  this->setPersistency(isOnDemand ? ndn::nfd::FACE_PERSISTENCY_ON_DEMAND : ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
   StreamFaceValidator<T, FaceBase>::validateSocket(m_socket);
 
   m_socket.async_receive(boost::asio::buffer(m_inputBuffer, ndn::MAX_NDN_PACKET_SIZE),
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index c0d0d3c..81cf401 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -98,9 +98,10 @@
   auto it = m_channelFaces.find(remoteEndpoint);
   if (it != m_channelFaces.end()) {
     // we already have a face for this endpoint, just reuse it
-    if (!isOnDemand)
-      // only on-demand -> non-on-demand transition is allowed
-      it->second->setOnDemand(false);
+    if (!isOnDemand) {
+      // only on-demand -> persistent transition is allowed
+      it->second->setPersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
+    }
     return {false, it->second};
   }
 
diff --git a/daemon/face/udp-face.cpp b/daemon/face/udp-face.cpp
index a854cc4..20b57cf 100644
--- a/daemon/face/udp-face.cpp
+++ b/daemon/face/udp-face.cpp
@@ -44,7 +44,7 @@
   , m_idleTimeout(idleTimeout)
   , m_lastIdleCheck(time::steady_clock::now())
 {
-  this->setOnDemand(isOnDemand);
+  this->setPersistency(isOnDemand ? ndn::nfd::FACE_PERSISTENCY_ON_DEMAND : ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
 
 #ifdef __linux__
   //
@@ -66,7 +66,7 @@
   }
 #endif
 
-  if (this->isOnDemand() && m_idleTimeout > time::seconds::zero()) {
+  if (this->getPersistency() == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND && m_idleTimeout > time::seconds::zero()) {
     m_closeIfIdleEvent = scheduler::schedule(m_idleTimeout, bind(&UdpFace::closeIfIdle, this));
   }
 }
@@ -76,7 +76,7 @@
 {
   auto status = DatagramFace::getFaceStatus();
 
-  if (isOnDemand()) {
+  if (this->getPersistency() == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
     time::milliseconds left = m_idleTimeout;
     left -= time::duration_cast<time::milliseconds>(time::steady_clock::now() - m_lastIdleCheck);
 
@@ -97,7 +97,7 @@
 {
   // Face can be switched from on-demand to non-on-demand mode
   // (non-on-demand -> on-demand transition is not allowed)
-  if (isOnDemand()) {
+  if (this->getPersistency() == ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) {
     if (!hasBeenUsedRecently()) {
       NFD_LOG_FACE_INFO("Closing for inactivity");
       close();
diff --git a/daemon/face/websocket-face.cpp b/daemon/face/websocket-face.cpp
index 4c781c3..3b94e6e 100644
--- a/daemon/face/websocket-face.cpp
+++ b/daemon/face/websocket-face.cpp
@@ -38,7 +38,7 @@
   , m_closed(false)
 {
   NFD_LOG_FACE_INFO("Creating face");
-  this->setOnDemand(true);
+  this->setPersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND);
 }
 
 void