face: use NetworkMonitor in EthernetFactory

EthernetFactory now creates unicast channels and multicast faces
on eligible netifs found by NetworkMonitor. However,
EthernetFactory does not yet react to fine-grained signals from
NetworkMonitor.

refs #4021

Change-Id: I58aac67d5a1b00d3cda76e78627b887f93ffa541
diff --git a/tests/daemon/face/ethernet-factory.t.cpp b/tests/daemon/face/ethernet-factory.t.cpp
index e48c38f..27a2489 100644
--- a/tests/daemon/face/ethernet-factory.t.cpp
+++ b/tests/daemon/face/ethernet-factory.t.cpp
@@ -26,9 +26,9 @@
 #include "face/ethernet-factory.hpp"
 #include "face/face.hpp"
 
-#include "factory-test-common.hpp"
 #include "ethernet-fixture.hpp"
 #include "face-system-fixture.hpp"
+#include "factory-test-common.hpp"
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/range/algorithm/count_if.hpp>
 
@@ -40,6 +40,11 @@
                              , public FaceSystemFactoryFixture<EthernetFactory>
 {
 protected:
+  EthernetFactoryFixture()
+  {
+    this->copyRealNetifsToNetmon();
+  }
+
   std::vector<const Face*>
   listEtherMcastFaces(ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_MULTI_ACCESS) const
   {
diff --git a/tests/daemon/face/face-system-fixture.hpp b/tests/daemon/face/face-system-fixture.hpp
index b6143d4..530b8e1 100644
--- a/tests/daemon/face/face-system-fixture.hpp
+++ b/tests/daemon/face/face-system-fixture.hpp
@@ -32,6 +32,7 @@
 #include "fw/face-table.hpp"
 
 #include "tests/test-common.hpp"
+#include "test-netif-ip.hpp"
 #include <ndn-cxx/net/network-monitor-stub.hpp>
 
 namespace nfd {
@@ -50,6 +51,31 @@
     faceSystem.setConfigFile(configFile);
   }
 
+  /** \brief Copy a snapshot of NetworkInterface information to \p netmon
+   *  \pre netmon contains no NetworkInterface
+   */
+  void
+  copyRealNetifsToNetmon()
+  {
+    BOOST_ASSERT(netmon->listNetworkInterfaces().empty());
+    for (const auto& netif : collectNetworkInterfaces()) {
+      auto copy = netmon->makeNetworkInterface();
+      copy->setIndex(netif->getIndex());
+      copy->setName(netif->getName());
+      copy->setType(netif->getType());
+      copy->setFlags(netif->getFlags());
+      copy->setState(netif->getState());
+      copy->setMtu(netif->getMtu());
+      copy->setEthernetAddress(netif->getEthernetAddress());
+      copy->setEthernetBroadcastAddress(netif->getEthernetBroadcastAddress());
+      for (const auto& na : netif->getNetworkAddresses()) {
+        copy->addNetworkAddress(na);
+      }
+      netmon->addInterface(copy);
+    }
+    netmon->emitEnumerationCompleted();
+  }
+
   void
   parseConfig(const std::string& text, bool isDryRun)
   {
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index b5225cd..a095a99 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -118,22 +118,9 @@
       if (netif->isUp() && netif->canMulticast() && hasAddressFamily<AddressFamily::V4>(*netif)) {
         netifs.push_back(netif);
       }
-
-      auto copy = netmon->makeNetworkInterface();
-      copy->setIndex(netif->getIndex());
-      copy->setName(netif->getName());
-      copy->setType(netif->getType());
-      copy->setFlags(netif->getFlags());
-      copy->setState(netif->getState());
-      copy->setMtu(netif->getMtu());
-      copy->setEthernetAddress(netif->getEthernetAddress());
-      copy->setEthernetBroadcastAddress(netif->getEthernetBroadcastAddress());
-      for (const auto& na : netif->getNetworkAddresses()) {
-        copy->addNetworkAddress(na);
-      }
-      netmon->addInterface(copy);
     }
-    netmon->emitEnumerationCompleted();
+
+    this->copyRealNetifsToNetmon();
   }
 
   std::vector<const Face*>