core: delete NetworkInterfaceInfo class
nfd::NetworkInterfaceInfo has been replaced by
ndn::net::NetworkInterface.
refs #4021
Change-Id: Ic023b935f47f99f3bd74bbd4dc6c0e5bb2b3bf1c
diff --git a/core/network-interface-predicate.cpp b/core/network-interface-predicate.cpp
index daf4cf4..c212ecd 100644
--- a/core/network-interface-predicate.cpp
+++ b/core/network-interface-predicate.cpp
@@ -26,7 +26,6 @@
#include "network-interface-predicate.hpp"
#include "config-file.hpp"
-#include "network-interface.hpp"
#include "network.hpp"
#include <fnmatch.h>
@@ -66,7 +65,7 @@
else if (item.first == "ether") {
// validate ethernet address
auto addr = item.second.get_value<std::string>();
- if (ethernet::Address::fromString(addr).isNull()) {
+ if (ndn::ethernet::Address::fromString(addr).isNull()) {
BOOST_THROW_EXCEPTION(ConfigFile::Error("Malformed ether address \"" + addr +
"\" in \"" + section + "\" section"));
}
@@ -105,25 +104,7 @@
}
static bool
-doesMatchRule(const NetworkInterfaceInfo& 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.ipv4Addresses) {
- if (n.doesContain(addr)) {
- return true;
- }
- }
- }
-
- return rule == "*" ||
- doesMatchPattern(netif.name, rule) ||
- netif.etherAddress.toString() == rule;
-}
-
-static bool
-doesMatchRule2(const ndn::net::NetworkInterface& netif, const std::string& rule)
+doesMatchRule(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) {
@@ -141,17 +122,10 @@
}
bool
-NetworkInterfacePredicate::operator()(const NetworkInterfaceInfo& netif) const
-{
- return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesMatchRule, netif, _1)) &&
- std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesMatchRule, netif, _1));
-}
-
-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));
+ return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesMatchRule, cref(netif), _1)) &&
+ std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesMatchRule, cref(netif), _1));
}
bool
diff --git a/core/network-interface-predicate.hpp b/core/network-interface-predicate.hpp
index 2443735..1b2d5a0 100644
--- a/core/network-interface-predicate.hpp
+++ b/core/network-interface-predicate.hpp
@@ -31,8 +31,6 @@
namespace nfd {
-class NetworkInterfaceInfo;
-
/**
* \brief Represents a predicate to accept or reject a NetworkInterfaceInfo.
*
@@ -60,9 +58,6 @@
parseBlacklist(const boost::property_tree::ptree& list);
bool
- operator()(const NetworkInterfaceInfo& netif) const;
-
- bool
operator()(const ndn::net::NetworkInterface& netif) const;
bool
diff --git a/core/network-interface.cpp b/core/network-interface.cpp
deleted file mode 100644
index ad9485e..0000000
--- a/core/network-interface.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/* -*- 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,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "network-interface.hpp"
-#include "core/logger.hpp"
-#include <ndn-cxx/net/network-monitor-stub.hpp>
-
-#include <cerrno>
-#include <cstring>
-#include <type_traits>
-#include <unordered_map>
-
-#ifdef HAVE_IFADDRS_H
-#include <ifaddrs.h> // for getifaddrs()
-
-#include <arpa/inet.h> // for inet_ntop()
-#include <netinet/in.h> // for struct sockaddr_in{,6}
-
-#if defined(__linux__)
-#include <net/if_arp.h> // for ARPHRD_* constants
-#include <netpacket/packet.h> // for struct sockaddr_ll
-#elif defined(__APPLE__) || defined(__FreeBSD__)
-#include <net/if_dl.h> // for struct sockaddr_dl
-#include <net/if_types.h> // for IFT_* constants
-#endif
-
-#endif // HAVE_IFADDRS_H
-
-
-NFD_LOG_INIT("NetworkInterfaceInfo");
-
-namespace nfd {
-
-static_assert(std::is_standard_layout<NetworkInterfaceInfo>::value,
- "NetworkInterfaceInfo must be a standard layout type");
-#ifdef HAVE_IS_DEFAULT_CONSTRUCTIBLE
-static_assert(std::is_default_constructible<NetworkInterfaceInfo>::value,
- "NetworkInterfaceInfo must provide a default constructor");
-#endif
-
-shared_ptr<ndn::net::NetworkInterface>
-NetworkInterfaceInfo::asNetworkInterface() const
-{
- using namespace ndn::net;
-
- shared_ptr<NetworkInterface> netif = NetworkMonitorStub::makeNetworkInterface();
- netif->setIndex(this->index);
- netif->setName(this->name);
- netif->setEthernetAddress(this->etherAddress);
- netif->setFlags(this->flags);
-
- for (const auto& a4 : this->ipv4Addresses) {
- netif->addNetworkAddress(NetworkAddress(AddressFamily::V4, a4, this->broadcastAddress,
- 32, AddressScope::GLOBAL, 0));
- }
- for (const auto& a6 : this->ipv6Addresses) {
- netif->addNetworkAddress(NetworkAddress(AddressFamily::V6, a6, {},
- 128, AddressScope::GLOBAL, 0));
- }
-
- return netif;
-}
-
-#ifdef WITH_TESTS
-static shared_ptr<std::vector<NetworkInterfaceInfo>> s_debugNetworkInterfaces = nullptr;
-
-void
-setDebugNetworkInterfaces(shared_ptr<std::vector<NetworkInterfaceInfo>> interfaces)
-{
- s_debugNetworkInterfaces = interfaces;
-}
-#endif
-
-std::vector<NetworkInterfaceInfo>
-listNetworkInterfaces()
-{
-#ifdef WITH_TESTS
- if (s_debugNetworkInterfaces != nullptr) {
- return *s_debugNetworkInterfaces;
- }
-#endif
-
-#ifdef HAVE_IFADDRS_H
- using namespace boost::asio::ip;
- using std::strerror;
-
- std::unordered_map<std::string, NetworkInterfaceInfo> ifmap;
- ifaddrs* ifa_list = nullptr;
-
- if (::getifaddrs(&ifa_list) < 0)
- BOOST_THROW_EXCEPTION(std::runtime_error(std::string("getifaddrs() failed: ") +
- strerror(errno)));
-
- for (ifaddrs* ifa = ifa_list; ifa != nullptr; ifa = ifa->ifa_next) {
- std::string ifname(ifa->ifa_name);
- NetworkInterfaceInfo& netif = ifmap[ifname];
- netif.name = ifa->ifa_name;
- netif.flags = ifa->ifa_flags;
-
- if (ifa->ifa_addr == nullptr)
- continue;
-
- switch (ifa->ifa_addr->sa_family) {
-
- case AF_INET: {
- const sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(ifa->ifa_addr);
- char address[INET_ADDRSTRLEN];
- if (::inet_ntop(AF_INET, &sin->sin_addr, address, sizeof(address))) {
- netif.ipv4Addresses.push_back(address_v4::from_string(address));
- NFD_LOG_TRACE(ifname << ": added IPv4 address " << address);
- }
- else
- NFD_LOG_WARN(ifname << ": inet_ntop(AF_INET) failed: " << strerror(errno));
- break;
- }
-
- case AF_INET6: {
- const sockaddr_in6* sin6 = reinterpret_cast<sockaddr_in6*>(ifa->ifa_addr);
- char address[INET6_ADDRSTRLEN];
- if (::inet_ntop(AF_INET6, &sin6->sin6_addr, address, sizeof(address))) {
- netif.ipv6Addresses.push_back(address_v6::from_string(address));
- NFD_LOG_TRACE(ifname << ": added IPv6 address " << address);
- }
- else
- NFD_LOG_WARN(ifname << ": inet_ntop(AF_INET6) failed: " << strerror(errno));
- break;
- }
-
-#if defined(__linux__)
- case AF_PACKET: {
- const sockaddr_ll* sll = reinterpret_cast<sockaddr_ll*>(ifa->ifa_addr);
- netif.index = sll->sll_ifindex;
- if (sll->sll_hatype == ARPHRD_ETHER && sll->sll_halen == ethernet::ADDR_LEN) {
- netif.etherAddress = ethernet::Address(sll->sll_addr);
- NFD_LOG_TRACE(ifname << ": added Ethernet address " << netif.etherAddress);
- }
- else if (sll->sll_hatype != ARPHRD_LOOPBACK) {
- NFD_LOG_DEBUG(ifname << ": ignoring link-layer address for unhandled hardware type "
- << sll->sll_hatype);
- }
- break;
- }
-
-#elif defined(__APPLE__) || defined(__FreeBSD__)
- case AF_LINK: {
- const sockaddr_dl* sdl = reinterpret_cast<sockaddr_dl*>(ifa->ifa_addr);
- netif.index = sdl->sdl_index;
- if (sdl->sdl_type == IFT_ETHER && sdl->sdl_alen == ethernet::ADDR_LEN) {
- netif.etherAddress = ethernet::Address(reinterpret_cast<uint8_t*>(LLADDR(sdl)));
- NFD_LOG_TRACE(ifname << ": added Ethernet address " << netif.etherAddress);
- }
- else if (sdl->sdl_type != IFT_LOOP) {
- NFD_LOG_DEBUG(ifname << ": ignoring link-layer address for unhandled interface type "
- << sdl->sdl_type);
- }
- break;
- }
-#endif
- }
-
- if (netif.isBroadcastCapable() && ifa->ifa_broadaddr != nullptr) {
- const sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(ifa->ifa_broadaddr);
- char address[INET_ADDRSTRLEN];
- if (::inet_ntop(AF_INET, &sin->sin_addr, address, sizeof(address))) {
- netif.broadcastAddress = address_v4::from_string(address);
- NFD_LOG_TRACE(ifname << ": added IPv4 broadcast address " << address);
- }
- else
- NFD_LOG_WARN(ifname << ": inet_ntop(AF_INET) for broadaddr failed: " << strerror(errno));
- }
- }
-
- ::freeifaddrs(ifa_list);
-
- std::vector<NetworkInterfaceInfo> v;
- v.reserve(ifmap.size());
- for (auto&& element : ifmap) {
- v.push_back(element.second);
- }
-
- return v;
-#else
- return {};
-#endif // HAVE_IFADDRS_H
-}
-
-} // namespace nfd
diff --git a/core/network-interface.hpp b/core/network-interface.hpp
deleted file mode 100644
index b94fabd..0000000
--- a/core/network-interface.hpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- 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,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NFD_CORE_NETWORK_INTERFACE_HPP
-#define NFD_CORE_NETWORK_INTERFACE_HPP
-
-#include "common.hpp"
-#include <ndn-cxx/net/ethernet.hpp>
-#include <ndn-cxx/net/network-interface.hpp>
-
-#include <net/if.h>
-
-namespace nfd {
-
-namespace ethernet {
-using namespace ndn::ethernet;
-} // namespace ethernet
-
-/** \brief contains information about a network interface
- */
-class NetworkInterfaceInfo
-{
-public:
- bool
- isLoopback() const;
-
- bool
- isMulticastCapable() const;
-
- bool
- isBroadcastCapable() const;
-
- bool
- isUp() const;
-
- /** \brief Export to ndn::net::NetworkInterface
- * \warning This is a temporary adaptation during the transition from NetworkInterfaceInfo to
- * ndn::net::NetworkInterface. The return value carries the information in this instance
- * and will not track changes in the actual network interface or emit signals.
- */
- shared_ptr<ndn::net::NetworkInterface>
- asNetworkInterface() const;
-
-public:
- int index;
- std::string name;
- ethernet::Address etherAddress;
- std::vector<boost::asio::ip::address_v4> ipv4Addresses;
- std::vector<boost::asio::ip::address_v6> ipv6Addresses;
- boost::asio::ip::address_v4 broadcastAddress;
- unsigned int flags;
-};
-
-inline bool
-NetworkInterfaceInfo::isLoopback() const
-{
- return (flags & IFF_LOOPBACK) != 0;
-}
-
-inline bool
-NetworkInterfaceInfo::isMulticastCapable() const
-{
- return (flags & IFF_MULTICAST) != 0;
-}
-
-inline bool
-NetworkInterfaceInfo::isBroadcastCapable() const
-{
- return (flags & IFF_BROADCAST) != 0;
-}
-
-inline bool
-NetworkInterfaceInfo::isUp() const
-{
- return (flags & IFF_UP) != 0;
-}
-
-/** \brief List configured network interfaces on the system and their info
- * \warning invalid IP addresses (e.g., 0.0.0.0) may be returned in some environments
- */
-std::vector<NetworkInterfaceInfo>
-listNetworkInterfaces();
-
-#ifdef WITH_TESTS
-/** \brief Set a list of network interfaces to be returned by subsequent listNetworkInterfaces call
- * \note To reset to normal behavior, use `setDebugNetworkInterfaces(nullptr);`
- */
-void
-setDebugNetworkInterfaces(shared_ptr<std::vector<NetworkInterfaceInfo>> interfaces);
-#endif
-
-} // namespace nfd
-
-#endif // NFD_CORE_NETWORK_INTERFACE_HPP
diff --git a/daemon/face/face-system.cpp b/daemon/face/face-system.cpp
index 57b391d..cbe02ed 100644
--- a/daemon/face/face-system.cpp
+++ b/daemon/face/face-system.cpp
@@ -93,7 +93,6 @@
{
ConfigContext context;
context.isDryRun = isDryRun;
- context.m_netifs = listNetworkInterfaces();
// process sections in protocol factories
for (const auto& pair : m_factories) {
diff --git a/daemon/face/face-system.hpp b/daemon/face/face-system.hpp
index 039c1c9..b61e7a8 100644
--- a/daemon/face/face-system.hpp
+++ b/daemon/face/face-system.hpp
@@ -28,7 +28,6 @@
#include "channel.hpp"
#include "core/config-file.hpp"
-#include "core/network-interface.hpp"
#include "core/network-interface-predicate.hpp"
#include <ndn-cxx/net/network-address.hpp>
#include <ndn-cxx/net/network-interface.hpp>
@@ -90,20 +89,7 @@
class ConfigContext : noncopyable
{
public:
- /// \deprecated use NetworkMonitor provided as ProtocolFactory::netmon
- const std::vector<NetworkInterfaceInfo>&
- listNetifs() const
- {
- return m_netifs;
- }
-
- public:
bool isDryRun;
-
- private:
- std::vector<NetworkInterfaceInfo> m_netifs;
-
- friend class FaceSystem;
};
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
diff --git a/tests/core/network-interface-predicate.t.cpp b/tests/core/network-interface-predicate.t.cpp
index 3ec581b..9ae6c44 100644
--- a/tests/core/network-interface-predicate.t.cpp
+++ b/tests/core/network-interface-predicate.t.cpp
@@ -24,10 +24,10 @@
*/
#include "core/network-interface-predicate.hpp"
-#include "core/network-interface.hpp"
#include "tests/test-common.hpp"
+#include <ndn-cxx/net/ethernet.hpp>
#include <ndn-cxx/net/network-monitor-stub.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <sstream>
@@ -41,36 +41,8 @@
NetworkInterfacePredicateFixture()
{
using namespace boost::asio::ip;
- interfaces.push_back(
- NetworkInterfaceInfo{0, "eth0",
- ethernet::Address::fromString("3e:15:c2:8b:65:00"),
- {address_v4::from_string("129.82.100.1")},
- {},
- address_v4::from_string("129.82.255.255"),
- IFF_UP});
- interfaces.push_back(
- NetworkInterfaceInfo{1, "eth1",
- ethernet::Address::fromString("3e:15:c2:8b:65:01"),
- {address_v4::from_string("192.168.2.1")},
- {},
- address_v4::from_string("192.168.2.255"),
- IFF_UP});
- interfaces.push_back(
- NetworkInterfaceInfo{2, "eth2",
- ethernet::Address::fromString("3e:15:c2:8b:65:02"),
- {address_v4::from_string("198.51.100.1")},
- {address_v6::from_string("2001:db8::1")},
- address_v4::from_string("198.51.100.255"),
- IFF_MULTICAST | IFF_BROADCAST | IFF_UP});
- interfaces.push_back(
- NetworkInterfaceInfo{3, "enp68s0f1",
- ethernet::Address::fromString("3e:15:c2:8b:65:03"),
- {address_v4::from_string("192.168.2.3")},
- {},
- address_v4::from_string("192.168.2.255"),
- IFF_UP});
-
using namespace ndn::net;
+ namespace ethernet = ndn::ethernet;
netifs.push_back(NetworkMonitorStub::makeNetworkInterface());
netifs.back()->setIndex(0);
@@ -131,7 +103,6 @@
protected:
NetworkInterfacePredicate predicate;
- std::vector<NetworkInterfaceInfo> interfaces;
std::vector<shared_ptr<ndn::net::NetworkInterface>> netifs;
};
@@ -141,11 +112,6 @@
{
parseConfig("");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), true);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
@@ -158,11 +124,6 @@
"{\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), false);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
@@ -176,11 +137,6 @@
" *\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), false);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
@@ -195,11 +151,6 @@
" ifname eth1\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), false);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
@@ -214,11 +165,6 @@
" ifname eth1\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), true);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
@@ -232,11 +178,6 @@
" ifname enp*\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), true);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
@@ -250,11 +191,6 @@
" ifname *th*\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), false);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
@@ -268,11 +204,6 @@
" ifname eth**\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), false);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
@@ -286,11 +217,6 @@
" ifname *\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), true);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
@@ -304,11 +230,6 @@
" ifname eth?\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), false);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
@@ -333,11 +254,6 @@
" ether 3e:15:c2:8b:65:01\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), false);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
@@ -352,11 +268,6 @@
" ether 3e:15:c2:8b:65:01\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), true);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
@@ -380,11 +291,6 @@
" subnet 192.168.0.0/16\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), true);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), false);
@@ -398,11 +304,6 @@
" subnet 192.168.0.0/16\n"
"}");
- BOOST_CHECK_EQUAL(predicate(interfaces[0]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[1]), false);
- BOOST_CHECK_EQUAL(predicate(interfaces[2]), true);
- BOOST_CHECK_EQUAL(predicate(interfaces[3]), false);
-
BOOST_CHECK_EQUAL(predicate(*netifs[0]), true);
BOOST_CHECK_EQUAL(predicate(*netifs[1]), false);
BOOST_CHECK_EQUAL(predicate(*netifs[2]), true);
diff --git a/tests/core/network-interface.t.cpp b/tests/core/network-interface.t.cpp
deleted file mode 100644
index 43436bb..0000000
--- a/tests/core/network-interface.t.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2015, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "core/network-interface.hpp"
-#include "tests/test-common.hpp"
-
-namespace nfd {
-namespace tests {
-
-BOOST_FIXTURE_TEST_SUITE(TestNetworkInterface, BaseFixture)
-
-BOOST_AUTO_TEST_CASE(ListRealNetworkInterfaces)
-{
- std::vector<NetworkInterfaceInfo> netifs;
- BOOST_CHECK_NO_THROW(netifs = listNetworkInterfaces());
-
- for (const auto& netif : netifs) {
- BOOST_TEST_MESSAGE(netif.index << ": " << netif.name);
- BOOST_TEST_MESSAGE("\tether " << netif.etherAddress);
- for (const auto& address : netif.ipv4Addresses)
- BOOST_TEST_MESSAGE("\tinet " << address);
- for (const auto& address : netif.ipv6Addresses)
- BOOST_TEST_MESSAGE("\tinet6 " << address);
- BOOST_TEST_MESSAGE("\tloopback : " << netif.isLoopback());
- BOOST_TEST_MESSAGE("\tmulticast : " << netif.isMulticastCapable());
- BOOST_TEST_MESSAGE("\tup : " << netif.isUp());
- }
-}
-
-class FakeNetworkInterfaceFixture : public BaseFixture
-{
-public:
- FakeNetworkInterfaceFixture()
- {
- using namespace boost::asio::ip;
-
- auto fakeInterfaces = make_shared<std::vector<NetworkInterfaceInfo>>();
-
- fakeInterfaces->push_back(
- NetworkInterfaceInfo {0, "lo0",
- ethernet::Address(),
- {address_v4::from_string("127.0.0.1")},
- {address_v6::from_string("fe80::1")},
- address_v4::from_string("127.255.255.255"),
- IFF_LOOPBACK | IFF_UP});
- fakeInterfaces->push_back(
- NetworkInterfaceInfo {1, "eth0",
- ethernet::Address::fromString("3e:15:c2:8b:65:00"),
- {address_v4::from_string("192.168.2.1")},
- {},
- address_v4::from_string("192.168.2.255"),
- 0});
- fakeInterfaces->push_back(
- NetworkInterfaceInfo {2, "eth1",
- ethernet::Address::fromString("3e:15:c2:8b:65:00"),
- {address_v4::from_string("198.51.100.1")},
- {address_v6::from_string("2001:db8::1")},
- address_v4::from_string("198.51.100.255"),
- IFF_MULTICAST | IFF_BROADCAST | IFF_UP});
-
- setDebugNetworkInterfaces(fakeInterfaces);
- }
-
- ~FakeNetworkInterfaceFixture()
- {
- setDebugNetworkInterfaces(nullptr);
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ListFakeNetworkInterfaces, FakeNetworkInterfaceFixture)
-{
- std::vector<NetworkInterfaceInfo> netifs;
- BOOST_CHECK_NO_THROW(netifs = listNetworkInterfaces());
-
- BOOST_REQUIRE_EQUAL(netifs.size(), 3);
-
- BOOST_CHECK_EQUAL(netifs[0].index, 0);
- BOOST_CHECK_EQUAL(netifs[1].index, 1);
- BOOST_CHECK_EQUAL(netifs[2].index, 2);
-
- BOOST_CHECK_EQUAL(netifs[0].name, "lo0");
- BOOST_CHECK_EQUAL(netifs[1].name, "eth0");
- BOOST_CHECK_EQUAL(netifs[2].name, "eth1");
-
- // no real value of testing other parameters
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace tests
-} // namespace nfd
diff --git a/wscript b/wscript
index ace1e8e..e0fee20 100644
--- a/wscript
+++ b/wscript
@@ -105,9 +105,8 @@
return 0;
}
'''):
- Logs.warn('Dropping privileges is not supported on this platform')
+ Logs.warn('Dropping privileges is not supported on this platform')
- conf.check_cxx(header_name='ifaddrs.h', mandatory=False)
conf.check_cxx(header_name='valgrind/valgrind.h', define_name='HAVE_VALGRIND', mandatory=False)
boost_libs = 'system chrono program_options thread log log_setup'
@@ -140,7 +139,7 @@
errmsg='not found, but required for Ethernet face support. '
'Specify --without-libpcap to disable Ethernet face support.')
else:
- Logs.warn('Warning: Ethernet face support is not supported on this platform with Boost libraries version 1.56. '
+ Logs.warn('Warning: Ethernet face is not supported on this platform with Boost libraries version 1.56. '
'See https://redmine.named-data.net/issues/1877 for more details')
if conf.env['HAVE_LIBPCAP']:
conf.check_cxx(function_name='pcap_set_immediate_mode', header_name='pcap/pcap.h',