netd: Add support for interface idletimer netlink notifications.
Change-Id: Ifda5b8ecf68533eea42b133dbe0a581b4401ab11
diff --git a/NetlinkHandler.cpp b/NetlinkHandler.cpp
index 954a478..a4f039c 100644
--- a/NetlinkHandler.cpp
+++ b/NetlinkHandler.cpp
@@ -72,8 +72,16 @@
const char *alertName = evt->findParam("ALERT_NAME");
const char *iface = evt->findParam("INTERFACE");
notifyQuotaLimitReached(alertName, iface);
- }
+ } else if (!strcmp(subsys, "idletimer")) {
+ int action = evt->getAction();
+ const char *iface = evt->findParam("INTERFACE");
+ if (action == evt->NlActionIfaceActive) {
+ notifyInterfaceActivity(iface, true);
+ } else if (action == evt->NlActionIfaceIdle) {
+ notifyInterfaceActivity(iface, false);
+ }
+ }
}
void NetlinkHandler::notifyInterfaceAdded(const char *name) {
@@ -117,3 +125,13 @@
mNm->getBroadcaster()->sendBroadcast(ResponseCode::BandwidthControl,
msg, false);
}
+
+void NetlinkHandler::notifyInterfaceActivity(const char *name, bool isActive) {
+ char msg[255];
+
+ snprintf(msg, sizeof(msg), "Iface %s %s", isActive ? "active" : "idle", name);
+
+ mNm->getBroadcaster()->sendBroadcast(isActive ? ResponseCode::InterfaceActive
+ : ResponseCode::InterfaceIdle,
+ msg, false);
+}