face: construct EthernetTransport with NetworkInterface
EthernetTransport and EthernetChannel constructors now accept
ndn::net::NetworkInterface instead of NetworkInterfaceInfo,
in preparation for the transition to NetworkMonitor.
refs #4021
Change-Id: I1687a13dfaafde4ab3795a6f8c76c728c12929b9
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index 20fda6d..8fc9822 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.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,
@@ -118,9 +118,10 @@
// determine the interfaces on which channels should be created
auto netifs = context.listNetifs() |
- boost::adaptors::filtered([this] (const NetworkInterfaceInfo& netif) {
- return netif.isUp() && !netif.isLoopback();
- });
+ boost::adaptors::transformed([] (const NetworkInterfaceInfo& nii) { return nii.asNetworkInterface(); }) |
+ boost::adaptors::filtered([] (const shared_ptr<const ndn::net::NetworkInterface>& netif) {
+ return netif->isUp() && !netif->isLoopback();
+ });
// create channels
for (const auto& netif : netifs) {
@@ -130,7 +131,7 @@
channel->listen(context.addFace, nullptr);
}
catch (const EthernetChannel::Error& e) {
- NFD_LOG_WARN("Cannot listen on " << netif.name << ": " << e.what());
+ NFD_LOG_WARN("Cannot listen on " << netif->getName() << ": " << e.what());
}
}
}
@@ -218,15 +219,15 @@
}
shared_ptr<EthernetChannel>
-EthernetFactory::createChannel(const NetworkInterfaceInfo& localEndpoint,
+EthernetFactory::createChannel(const shared_ptr<const ndn::net::NetworkInterface>& localEndpoint,
time::nanoseconds idleTimeout)
{
- auto it = m_channels.find(localEndpoint.name);
+ auto it = m_channels.find(localEndpoint->getName());
if (it != m_channels.end())
return it->second;
auto channel = std::make_shared<EthernetChannel>(localEndpoint, idleTimeout);
- m_channels[localEndpoint.name] = channel;
+ m_channels[localEndpoint->getName()] = channel;
return channel;
}
@@ -238,12 +239,12 @@
}
shared_ptr<Face>
-EthernetFactory::createMulticastFace(const NetworkInterfaceInfo& netif,
+EthernetFactory::createMulticastFace(const ndn::net::NetworkInterface& netif,
const ethernet::Address& address)
{
BOOST_ASSERT(address.isMulticast());
- auto key = std::make_pair(netif.name, address);
+ auto key = std::make_pair(netif.getName(), address);
auto found = m_mcastFaces.find(key);
if (found != m_mcastFaces.end()) {
return found->second;
@@ -274,19 +275,19 @@
if (m_mcastConfig.isEnabled) {
// determine interfaces on which faces should be created or retained
auto capableNetifs = context.listNetifs() |
- boost::adaptors::filtered([this] (const NetworkInterfaceInfo& netif) {
- return netif.isUp() && netif.isMulticastCapable() &&
- m_mcastConfig.netifPredicate(netif);
- });
+ boost::adaptors::transformed([] (const NetworkInterfaceInfo& nii) { return nii.asNetworkInterface(); }) |
+ boost::adaptors::filtered([this] (const shared_ptr<const ndn::net::NetworkInterface>& netif) {
+ return netif->isUp() && netif->canMulticast() && m_mcastConfig.netifPredicate(*netif);
+ });
// create faces
for (const auto& netif : capableNetifs) {
shared_ptr<Face> face;
try {
- face = this->createMulticastFace(netif, m_mcastConfig.group);
+ face = this->createMulticastFace(*netif, m_mcastConfig.group);
}
catch (const EthernetTransport::Error& e) {
- NFD_LOG_WARN("Cannot create Ethernet multicast face on " << netif.name << ": " << e.what());
+ NFD_LOG_WARN("Cannot create Ethernet multicast face on " << netif->getName() << ": " << e.what());
continue;
}