face: use NetworkInterfaceInfo directly in EthernetFace.

Finally getting rid of EthernetFactory::findAllInterfaces()
and EthernetFace::getInterfaceAddress().

Change-Id: I94fe2016cc98778af3115569b1d21d5c48425d9c
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index 78adf6f..2801c4f 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -6,6 +6,7 @@
 
 #include "ethernet-factory.hpp"
 #include "core/global-io.hpp"
+#include "core/network-interface.hpp"
 
 #include <boost/algorithm/string/predicate.hpp>
 #include <pcap/pcap.h>
@@ -15,17 +16,14 @@
 NFD_LOG_INIT("EthernetFactory")
 
 shared_ptr<EthernetFace>
-EthernetFactory::createMulticastFace(const ethernet::Endpoint& interface,
-                                     const ethernet::Address& address)
+EthernetFactory::createMulticastFace(const shared_ptr<NetworkInterfaceInfo> &interface,
+                                     const ethernet::Address &address)
 {
-  std::vector<ethernet::Endpoint> ifs = findAllInterfaces();
-  if (std::find(ifs.begin(), ifs.end(), interface) == ifs.end())
-    throw Error(interface + " does not exist");
-
   if (!address.isMulticast())
     throw Error(address.toString() + " is not a multicast address");
 
-  shared_ptr<EthernetFace> face = findMulticastFace(interface, address);
+  const std::string& name = interface->name;
+  shared_ptr<EthernetFace> face = findMulticastFace(name, address);
   if (face)
     return face;
 
@@ -36,66 +34,25 @@
                                    boost::cref(interface),
                                    boost::cref(address));
   face->onFail += bind(&EthernetFactory::afterFaceFailed,
-                       this, interface, address);
-  m_multicastFaces[std::make_pair(interface, address)] = face;
+                       this, name, address);
+  m_multicastFaces[std::make_pair(name, address)] = face;
 
   return face;
 }
 
-std::vector<ethernet::Endpoint>
-EthernetFactory::findAllInterfaces()
-{
-  std::vector<ethernet::Endpoint> interfaces;
-  char errbuf[PCAP_ERRBUF_SIZE];
-  errbuf[0] = '\0';
-
-  pcap_if_t* alldevs;
-  if (pcap_findalldevs(&alldevs, errbuf) < 0)
-    {
-      NFD_LOG_WARN("pcap_findalldevs() failed: " << errbuf);
-      return interfaces;
-    }
-
-  for (pcap_if_t* device = alldevs; device != 0; device = device->next)
-    {
-      if ((device->flags & PCAP_IF_LOOPBACK) != 0)
-        // ignore loopback devices
-        continue;
-
-      ethernet::Endpoint interface(device->name);
-      if (interface == "any")
-        // ignore libpcap "any" pseudo-device
-        continue;
-      if (boost::starts_with(interface, "nflog") ||
-          boost::starts_with(interface, "nfqueue"))
-        // ignore Linux netfilter devices
-        continue;
-      if (boost::starts_with(interface, "fw"))
-        // ignore OSX firewire interface
-        continue;
-
-      // maybe add interface addresses too
-      // interface.addAddress ...
-      interfaces.push_back(interface);
-    }
-
-  pcap_freealldevs(alldevs);
-  return interfaces;
-}
-
 void
-EthernetFactory::afterFaceFailed(const ethernet::Endpoint& interface,
+EthernetFactory::afterFaceFailed(const std::string& interfaceName,
                                  const ethernet::Address& address)
 {
-  NFD_LOG_DEBUG("afterFaceFailed: " << interface << "/" << address);
-  m_multicastFaces.erase(std::make_pair(interface, address));
+  NFD_LOG_DEBUG("afterFaceFailed: " << interfaceName << "/" << address);
+  m_multicastFaces.erase(std::make_pair(interfaceName, address));
 }
 
 shared_ptr<EthernetFace>
-EthernetFactory::findMulticastFace(const ethernet::Endpoint& interface,
+EthernetFactory::findMulticastFace(const std::string& interfaceName,
                                    const ethernet::Address& address) const
 {
-  MulticastFacesMap::const_iterator i = m_multicastFaces.find(std::make_pair(interface, address));
+  MulticastFacesMap::const_iterator i = m_multicastFaces.find(std::make_pair(interfaceName, address));
   if (i != m_multicastFaces.end())
     return i->second;
   else