Integrate inotify watcher into network daemon

This commit integrates watching for DNS entries and updating
/etc/resolv.conf functionality into network manager daemon
as opposed to having another daemon doing just that.

Change-Id: Id858815675ed4a23ee8c6a31ba3ae6e5ee0054fd
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/network_manager_main.cpp b/network_manager_main.cpp
index 0c95c8d..b08d5ac 100644
--- a/network_manager_main.cpp
+++ b/network_manager_main.cpp
@@ -2,6 +2,8 @@
 #include "network_manager.hpp"
 #include "rtnetlink_server.hpp"
 #include "timer.hpp"
+#include "watch.hpp"
+#include "dns_updater.hpp"
 
 #include <memory>
 
@@ -83,8 +85,6 @@
                                                          OBJ_NETWORK,
                                                          NETWORK_CONF_DIR);
 
-    phosphor::network::rtnetlink::Server svr(eventPtr);
-
     // create the network interface dbus objects and system config
     phosphor::network::manager->createChildObjects();
 
@@ -99,6 +99,22 @@
         // will create it.
         phosphor::network::restartNetwork();
     }
-    return svr.run();
+
+    // RTNETLINK event handler
+    phosphor::network::rtnetlink::Server svr(eventPtr);
+
+    // DNS entry handler
+    phosphor::network::inotify::Watch watch(eventPtr, DNS_ENTRY_FILE,
+            std::bind(&phosphor::network::dns::updater::processDNSEntries,
+                std::placeholders::_1));
+
+    // At this point, we have registered for the notifications for future
+    // events. However, if the file is already populated before this, then
+    // they won't ever get notified and thus we need to read once before
+    // waiting on change events
+    phosphor::network::dns::updater::processDNSEntries(DNS_ENTRY_FILE);
+
+    // Run the server
+    sd_event_loop(eventPtr.get());
 }