core: NetworkInterfacePredicate accepts ndn::net::NetworkInterface

refs #4021

Change-Id: I6612a67db03b6651e8fbccad91f776ae502283d9
diff --git a/core/network-interface-predicate.cpp b/core/network-interface-predicate.cpp
index 81f199b..daf4cf4 100644
--- a/core/network-interface-predicate.cpp
+++ b/core/network-interface-predicate.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2014-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
@@ -122,6 +122,24 @@
          netif.etherAddress.toString() == rule;
 }
 
+static bool
+doesMatchRule2(const ndn::net::NetworkInterface& netif, const std::string& rule)
+{
+  // if '/' is in rule, this is a subnet, check if IP in subnet
+  if (rule.find('/') != std::string::npos) {
+    Network n = boost::lexical_cast<Network>(rule);
+    for (const auto& addr : netif.getNetworkAddresses()) {
+      if (n.doesContain(addr.getIp())) {
+        return true;
+      }
+    }
+  }
+
+  return rule == "*" ||
+         doesMatchPattern(netif.getName(), rule) ||
+         netif.getEthernetAddress().toString() == rule;
+}
+
 bool
 NetworkInterfacePredicate::operator()(const NetworkInterfaceInfo& netif) const
 {
@@ -130,6 +148,13 @@
 }
 
 bool
+NetworkInterfacePredicate::operator()(const ndn::net::NetworkInterface& netif) const
+{
+  return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesMatchRule2, cref(netif), _1)) &&
+         std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesMatchRule2, cref(netif), _1));
+}
+
+bool
 NetworkInterfacePredicate::operator==(const NetworkInterfacePredicate& other) const
 {
   return this->m_whitelist == other.m_whitelist &&
diff --git a/core/network-interface-predicate.hpp b/core/network-interface-predicate.hpp
index f48da05..2443735 100644
--- a/core/network-interface-predicate.hpp
+++ b/core/network-interface-predicate.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2014-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
@@ -27,6 +27,7 @@
 #define NFD_CORE_NETWORK_INTERFACE_PREDICATE_HPP
 
 #include "common.hpp"
+#include <ndn-cxx/net/network-interface.hpp>
 
 namespace nfd {
 
@@ -62,6 +63,9 @@
   operator()(const NetworkInterfaceInfo& netif) const;
 
   bool
+  operator()(const ndn::net::NetworkInterface& netif) const;
+
+  bool
   operator==(const NetworkInterfacePredicate& other) const;
 
   bool