core: enable wildcard matching on interface names for whitelist/blacklist

Change-Id: Iabf5084028d7e8c4a26ec5289c331f4a779c0bf7
Refs: #4009
diff --git a/core/network-interface-predicate.cpp b/core/network-interface-predicate.cpp
index 9c1bb11..81f199b 100644
--- a/core/network-interface-predicate.cpp
+++ b/core/network-interface-predicate.cpp
@@ -29,6 +29,8 @@
 #include "network-interface.hpp"
 #include "network.hpp"
 
+#include <fnmatch.h>
+
 namespace nfd {
 
 NetworkInterfacePredicate::NetworkInterfacePredicate()
@@ -95,6 +97,14 @@
 }
 
 static bool
+doesMatchPattern(const std::string& ifname, const std::string& pattern)
+{
+  // use fnmatch(3) to provide unix glob-style matching for interface names
+  // fnmatch returns 0 if there is a match
+  return ::fnmatch(pattern.data(), ifname.data(), 0) == 0;
+}
+
+static bool
 doesMatchRule(const NetworkInterfaceInfo& netif, const std::string& rule)
 {
   // if '/' is in rule, this is a subnet, check if IP in subnet
@@ -108,7 +118,7 @@
   }
 
   return rule == "*" ||
-         netif.name == rule ||
+         doesMatchPattern(netif.name, rule) ||
          netif.etherAddress.toString() == rule;
 }