face: process face_system.ether config section in EthernetFactory
This commit also fixes a potential memory access error in EthernetTransport.
refs #3904
Change-Id: I08296e7c6f1039b59b2859d277fc95326af34f52
diff --git a/core/network-interface-predicate.cpp b/core/network-interface-predicate.cpp
index cf5fcd6..9c1bb11 100644
--- a/core/network-interface-predicate.cpp
+++ b/core/network-interface-predicate.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -95,12 +95,12 @@
}
static bool
-doesMatchRule(const NetworkInterfaceInfo& nic, const std::string& rule)
+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 : nic.ipv4Addresses) {
+ for (const auto& addr : netif.ipv4Addresses) {
if (n.doesContain(addr)) {
return true;
}
@@ -108,15 +108,22 @@
}
return rule == "*" ||
- nic.name == rule ||
- nic.etherAddress.toString() == rule;
+ netif.name == rule ||
+ netif.etherAddress.toString() == rule;
}
bool
-NetworkInterfacePredicate::operator()(const NetworkInterfaceInfo& nic) const
+NetworkInterfacePredicate::operator()(const NetworkInterfaceInfo& netif) const
{
- return std::any_of(m_whitelist.begin(), m_whitelist.end(), bind(&doesMatchRule, nic, _1)) &&
- std::none_of(m_blacklist.begin(), m_blacklist.end(), bind(&doesMatchRule, nic, _1));
+ 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 NetworkInterfacePredicate& other) const
+{
+ return this->m_whitelist == other.m_whitelist &&
+ this->m_blacklist == other.m_blacklist;
}
} // namespace nfd
diff --git a/core/network-interface-predicate.hpp b/core/network-interface-predicate.hpp
index 4254623..f48da05 100644
--- a/core/network-interface-predicate.hpp
+++ b/core/network-interface-predicate.hpp
@@ -1,12 +1,12 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, 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
+ * 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.
@@ -41,7 +41,6 @@
* all interfaces. A NetworkInterfaceInfo is accepted if it matches any entry in the whitelist and none
* of the entries in the blacklist.
*/
-
class NetworkInterfacePredicate
{
public:
@@ -60,7 +59,16 @@
parseBlacklist(const boost::property_tree::ptree& list);
bool
- operator()(const NetworkInterfaceInfo& nic) const;
+ operator()(const NetworkInterfaceInfo& netif) const;
+
+ bool
+ operator==(const NetworkInterfacePredicate& other) const;
+
+ bool
+ operator!=(const NetworkInterfacePredicate& other) const
+ {
+ return !this->operator==(other);
+ }
private:
std::set<std::string> m_whitelist;