mgmt: Create UDP multicast faces according to whitelist/blacklist

refs #1712

Change-Id: Ia957bb1a3a3a0108d06716bfb25ecd29c6952d62
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index d4ee086..8ea503c 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -66,6 +66,13 @@
   //   mcast yes
   //   mcast_group 224.0.23.170
   //   mcast_port 56363
+  //   whitelist
+  //   {
+  //     *
+  //   }
+  //   blacklist
+  //   {
+  //   }
   // }
 
   uint16_t port = 6363;
@@ -116,6 +123,12 @@
       else if (key == "mcast_port") {
         mcastConfig.group.port(ConfigFile::parseNumber<uint16_t>(pair, "face_system.udp"));
       }
+      else if (key == "whitelist") {
+        mcastConfig.netifPredicate.parseWhitelist(value);
+      }
+      else if (key == "blacklist") {
+        mcastConfig.netifPredicate.parseBlacklist(value);
+      }
       else {
         BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option face_system.udp." + key));
       }
@@ -167,6 +180,9 @@
       NFD_LOG_INFO("changing multicast group from " << m_mcastConfig.group <<
                    " to " << mcastConfig.group);
     }
+    else if (m_mcastConfig.netifPredicate != mcastConfig.netifPredicate) {
+      NFD_LOG_INFO("changing whitelist/blacklist");
+    }
     else {
       // There's no configuration change, but we still need to re-apply configuration because
       // netifs may have changed.
@@ -456,7 +472,8 @@
     auto capableNetifRange = context.listNetifs() |
                              boost::adaptors::filtered([this] (const NetworkInterfaceInfo& netif) {
                                return netif.isUp() && netif.isMulticastCapable() &&
-                                      !netif.ipv4Addresses.empty();
+                                      !netif.ipv4Addresses.empty() &&
+                                      m_mcastConfig.netifPredicate(netif);
                              });
 
     bool needIfname = false;
diff --git a/daemon/face/udp-factory.hpp b/daemon/face/udp-factory.hpp
index 1e1a6ab..9b68448 100644
--- a/daemon/face/udp-factory.hpp
+++ b/daemon/face/udp-factory.hpp
@@ -199,6 +199,7 @@
   {
     bool isEnabled = false;
     udp::Endpoint group = udp::getDefaultMulticastGroup();
+    NetworkInterfacePredicate netifPredicate;
   };
 
   MulticastConfig m_mcastConfig;