face, mgmt: improve face creation failure and bad URI handling

Prevent creation of faces to endpoints owned by NFD instance

Prevent creation of UDP broadcast faces (255.255.255.255 and
those belonging to machine's interfaces) in response to
face creation command

Sanity check configuration file port numbers in face manager

refs: #1414, #1427

Change-Id: Ia3f0a9337f3d97c34388773eab05bc39ad6dd804
diff --git a/daemon/core/network-interface.cpp b/daemon/core/network-interface.cpp
index ef55e7b..c1cfaa6 100644
--- a/daemon/core/network-interface.cpp
+++ b/daemon/core/network-interface.cpp
@@ -95,6 +95,17 @@
           break;
 #endif
         }
+
+      if (netif->isBroadcastCapable() && ifa->ifa_broadaddr != 0)
+        {
+          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 = boost::asio::ip::address_v4::from_string(address);
+          else
+            NFD_LOG_WARN("inet_ntop() failed on " << ifname);
+        }
     }
 
   ::freeifaddrs(ifa_list);