tests: add support for link-local addresses in getTestIp

Change-Id: If57cb93f1c25a18b680aef12895ee5924ca90cfa
diff --git a/tests/daemon/face/test-netif-ip.cpp b/tests/daemon/face/test-netif-ip.cpp
index 3471ba3..82f4b89 100644
--- a/tests/daemon/face/test-netif-ip.cpp
+++ b/tests/daemon/face/test-netif-ip.cpp
@@ -25,6 +25,7 @@
 
 #include "test-netif-ip.hpp"
 #include "core/global-io.hpp"
+
 #include <ndn-cxx/net/network-monitor.hpp>
 
 namespace nfd {
@@ -56,67 +57,37 @@
   return cached;
 }
 
-namespace {
-
 template<typename E>
-bool
+static bool
 matchTristate(E e, bool b)
 {
-  return (e == E::DontCare) ||
+  return (e == E::Unspecified) ||
          (e == E::Yes && b) ||
          (e == E::No && !b);
 }
 
-template<AddressFamily AF>
-typename IpAddressFromFamily<AF>::type
-fromIpAddress(const boost::asio::ip::address& a);
-
-template<>
-IpAddressFromFamily<AddressFamily::V4>::type
-fromIpAddress<AddressFamily::V4>(const boost::asio::ip::address& a)
-{
-  return a.to_v4();
-}
-
-template<>
-IpAddressFromFamily<AddressFamily::V6>::type
-fromIpAddress<AddressFamily::V6>(const boost::asio::ip::address& a)
-{
-  return a.to_v6();
-}
-
-} // unnamed namespace
-
-template<AddressFamily AF>
-typename IpAddressFromFamily<AF>::type
-getTestIp(LoopbackAddress loopback, MulticastInterface mcast)
+boost::asio::ip::address
+getTestIp(AddressFamily family, AddressScope scope, MulticastInterface mcast)
 {
   for (const auto& interface : collectNetworkInterfaces()) {
     if (!interface->isUp() ||
-        !matchTristate(loopback, interface->isLoopback()) ||
         !matchTristate(mcast, interface->canMulticast())) {
       continue;
     }
     for (const auto& address : interface->getNetworkAddresses()) {
-      if (isAddressFamily<AF>(address) &&
-          !address.getIp().is_unspecified() &&
-          address.getScope() != ndn::net::AddressScope::NOWHERE &&
-          address.getScope() != ndn::net::AddressScope::LINK && // link-local addresses are not supported yet (#1428)
-          matchTristate(loopback, address.getIp().is_loopback())) {
-        return fromIpAddress<AF>(address.getIp());
+      if (!address.getIp().is_unspecified() &&
+          (family == AddressFamily::UNSPECIFIED ||
+           family == address.getFamily()) &&
+          (scope == AddressScope::Unspecified ||
+           static_cast<int>(scope) == static_cast<int>(address.getScope())) &&
+          (scope != AddressScope::Loopback ||
+           address.getIp().is_loopback())) {
+        return address.getIp();
       }
     }
   }
   return {};
 }
 
-template
-IpAddressFromFamily<AddressFamily::V4>::type
-getTestIp<AddressFamily::V4>(LoopbackAddress loopback, MulticastInterface mcast);
-
-template
-IpAddressFromFamily<AddressFamily::V6>::type
-getTestIp<AddressFamily::V6>(LoopbackAddress loopback, MulticastInterface mcast);
-
 } // namespace tests
 } // namespace nfd