mgmt: move Flags field from FaceStatus to FaceTraits

refs #3732

Change-Id: I20ce5b608b6238d2c0c05db125ce261edd846dab
diff --git a/src/mgmt/nfd/face-event-notification.cpp b/src/mgmt/nfd/face-event-notification.cpp
index a65c7ba..a322ae9 100644
--- a/src/mgmt/nfd/face-event-notification.cpp
+++ b/src/mgmt/nfd/face-event-notification.cpp
@@ -50,6 +50,8 @@
   size_t totalLength = 0;
 
   totalLength += prependNonNegativeIntegerBlock(encoder,
+                 tlv::nfd::Flags, m_flags);
+  totalLength += prependNonNegativeIntegerBlock(encoder,
                  tlv::nfd::LinkType, m_linkType);
   totalLength += prependNonNegativeIntegerBlock(encoder,
                  tlv::nfd::FacePersistency, m_facePersistency);
@@ -150,6 +152,13 @@
   else {
     BOOST_THROW_EXCEPTION(Error("missing required LinkType field"));
   }
+
+  if (val != m_wire.elements_end() && val->type() == tlv::nfd::Flags) {
+    m_flags = readNonNegativeInteger(*val);
+  }
+  else {
+    BOOST_THROW_EXCEPTION(Error("missing required Flags field"));
+  }
 }
 
 FaceEventNotification&
@@ -192,8 +201,13 @@
      << "LocalUri: " << notification.getLocalUri() << ", "
      << "FaceScope: " << notification.getFaceScope() << ", "
      << "FacePersistency: " << notification.getFacePersistency() << ", "
-     << "LinkType: " << notification.getLinkType()
-     << ")";
+     << "LinkType: " << notification.getLinkType() << ", ";
+
+  auto osFlags = os.flags();
+  os << "Flags: " << std::showbase << std::hex << notification.getFlags();
+  os.flags(osFlags);
+
+  os << ")";
   return os;
 }
 
diff --git a/src/mgmt/nfd/face-status.cpp b/src/mgmt/nfd/face-status.cpp
index 584208c..d54f072 100644
--- a/src/mgmt/nfd/face-status.cpp
+++ b/src/mgmt/nfd/face-status.cpp
@@ -43,7 +43,6 @@
   , m_nOutNacks(0)
   , m_nInBytes(0)
   , m_nOutBytes(0)
-  , m_flags(0)
 {
 }
 
@@ -334,43 +333,6 @@
   return *this;
 }
 
-FaceStatus&
-FaceStatus::setFlags(uint64_t flags)
-{
-  m_wire.reset();
-  m_flags = flags;
-  return *this;
-}
-
-bool
-FaceStatus::getFlagBit(size_t bit) const
-{
-  if (bit >= 64) {
-    BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
-  }
-
-  return m_flags & (1 << bit);
-}
-
-FaceStatus&
-FaceStatus::setFlagBit(size_t bit, bool value)
-{
-  if (bit >= 64) {
-    BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
-  }
-
-  m_wire.reset();
-
-  if (value) {
-    m_flags |= (1 << bit);
-  }
-  else {
-    m_flags &= ~(1 << bit);
-  }
-
-  return *this;
-}
-
 void
 FaceStatus::wireReset() const
 {
diff --git a/src/mgmt/nfd/face-status.hpp b/src/mgmt/nfd/face-status.hpp
index a2ea259..4f20e53 100644
--- a/src/mgmt/nfd/face-status.hpp
+++ b/src/mgmt/nfd/face-status.hpp
@@ -147,21 +147,6 @@
   FaceStatus&
   setNOutBytes(uint64_t nOutBytes);
 
-  uint64_t
-  getFlags() const
-  {
-    return m_flags;
-  }
-
-  FaceStatus&
-  setFlags(uint64_t flags);
-
-  bool
-  getFlagBit(size_t bit) const;
-
-  FaceStatus&
-  setFlagBit(size_t bit, bool value);
-
 protected:
   void
   wireReset() const;
@@ -177,7 +162,6 @@
   uint64_t m_nOutNacks;
   uint64_t m_nInBytes;
   uint64_t m_nOutBytes;
-  uint64_t m_flags;
 
   mutable Block m_wire;
 };
diff --git a/src/mgmt/nfd/face-traits.hpp b/src/mgmt/nfd/face-traits.hpp
index d9422c3..48c2624 100644
--- a/src/mgmt/nfd/face-traits.hpp
+++ b/src/mgmt/nfd/face-traits.hpp
@@ -51,6 +51,7 @@
     , m_faceScope(FACE_SCOPE_NON_LOCAL)
     , m_facePersistency(FACE_PERSISTENCY_PERSISTENT)
     , m_linkType(LINK_TYPE_POINT_TO_POINT)
+    , m_flags(0x0)
   {
   }
 
@@ -138,6 +139,49 @@
     return static_cast<C&>(*this);
   }
 
+  uint64_t
+  getFlags() const
+  {
+    return m_flags;
+  }
+
+  C&
+  setFlags(uint64_t flags)
+  {
+    wireReset();
+    m_flags = flags;
+    return static_cast<C&>(*this);
+  }
+
+  bool
+  getFlagBit(size_t bit) const
+  {
+    if (bit >= 64) {
+      BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
+    }
+
+    return m_flags & (1 << bit);
+  }
+
+  C&
+  setFlagBit(size_t bit, bool value)
+  {
+    if (bit >= 64) {
+      BOOST_THROW_EXCEPTION(std::out_of_range("bit must be within range [0, 64)"));
+    }
+
+    wireReset();
+
+    if (value) {
+      m_flags |= (1 << bit);
+    }
+    else {
+      m_flags &= ~(1 << bit);
+    }
+
+    return static_cast<C&>(*this);
+  }
+
 protected:
   virtual void
   wireReset() const = 0;
@@ -149,6 +193,7 @@
   FaceScope m_faceScope;
   FacePersistency  m_facePersistency;
   LinkType m_linkType;
+  uint64_t m_flags;
 };
 
 } // namespace nfd