netd: Add support for interface idletimer netlink notifications.

Change-Id: Ifda5b8ecf68533eea42b133dbe0a581b4401ab11
diff --git a/NetlinkManager.cpp b/NetlinkManager.cpp
index 73e5599..2d8a4de 100644
--- a/NetlinkManager.cpp
+++ b/NetlinkManager.cpp
@@ -34,6 +34,7 @@
 #include "NetlinkHandler.h"
 
 const int NetlinkManager::NFLOG_QUOTA_GROUP = 1;
+const int NetlinkManager::IDLETIMER_GROUP = 1;
 
 NetlinkManager *NetlinkManager::sInstance = NULL;
 
@@ -111,6 +112,12 @@
         ALOGE("Unable to open quota2 logging socket");
         // TODO: return -1 once the emulator gets a new kernel.
     }
+
+    if ((mIfaceIdleTimerHandler = setupSocket(&mIfaceIdleTimerSock, NETLINK_IDLETIMER,
+        IDLETIMER_GROUP, NetlinkListener::NETLINK_FORMAT_BINARY)) == NULL) {
+        // TODO: switch back to using NETLINK_NFLOG with a custom type.
+	ALOGE("Unable to open iface idletimer socket");
+    }
     return 0;
 }
 
@@ -151,5 +158,19 @@
         close(mQuotaSock);
         mQuotaSock = -1;
     }
+
+    if (mIfaceIdleTimerHandler) {
+        if (mIfaceIdleTimerHandler->stop()) {
+            ALOGE("Unable to stop iface IDLETIMER NetlinkHandler: %s", strerror(errno));
+            status = -1;
+        }
+
+        delete mIfaceIdleTimerHandler;
+        mIfaceIdleTimerHandler = NULL;
+
+        close(mIfaceIdleTimerSock);
+        mIfaceIdleTimerSock = -1;
+    }
+
     return status;
 }