face: set EthernetTransport UP/DOWN based on netif state
refs #3352
Change-Id: I24476ee293d229cd9222996f91f31cfb15728c47
diff --git a/tests/daemon/face/test-netif.cpp b/tests/daemon/face/test-netif.cpp
index 56b9081..b3e6fde 100644
--- a/tests/daemon/face/test-netif.cpp
+++ b/tests/daemon/face/test-netif.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,13 +26,24 @@
#include "test-netif.hpp"
#include "core/global-io.hpp"
-#include <ndn-cxx/net/network-monitor.hpp>
-
namespace nfd {
namespace face {
namespace tests {
std::vector<shared_ptr<const NetworkInterface>>
+enumerateNetworkInterfaces(NetworkMonitor& netmon)
+{
+ if ((netmon.getCapabilities() & NetworkMonitor::CAP_ENUM) == 0) {
+ BOOST_THROW_EXCEPTION(NetworkMonitor::Error("NetworkMonitor::CAP_ENUM is unavailable"));
+ }
+
+ netmon.onEnumerationCompleted.connect([] { getGlobalIoService().stop(); });
+ getGlobalIoService().run();
+ getGlobalIoService().reset();
+ return netmon.listNetworkInterfaces();
+}
+
+std::vector<shared_ptr<const NetworkInterface>>
collectNetworkInterfaces(bool allowCached)
{
using ndn::net::NetworkMonitor;
@@ -44,15 +55,7 @@
if (!allowCached || cached.empty()) {
NetworkMonitor netmon(getGlobalIoService());
- if ((netmon.getCapabilities() & NetworkMonitor::CAP_ENUM) == 0) {
- BOOST_THROW_EXCEPTION(NetworkMonitor::Error("NetworkMonitor::CAP_ENUM is unavailable"));
- }
-
- netmon.onEnumerationCompleted.connect([] { getGlobalIoService().stop(); });
- getGlobalIoService().run();
- getGlobalIoService().reset();
-
- cached = netmon.listNetworkInterfaces();
+ cached = enumerateNetworkInterfaces(netmon);
}
return cached;