From 731d831e91d5d9f8b15ca95367977abe35967166 Mon Sep 17 00:00:00 2001 From: Ashish Sharma Date: Tue, 10 Apr 2012 18:59:16 -0700 Subject: [PATCH] libsysutils: NetlinkEvent: add support for interface xt_IDLETIMER events. xt_IDLETIMER events are used to infer the interface (radio) state based on a inactivity timeout value. Change-Id: I755eb54a048ca1c6ce0c646564d61188d8241851 --- include/sysutils/NetlinkEvent.h | 2 ++ libsysutils/src/NetlinkEvent.cpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/sysutils/NetlinkEvent.h b/include/sysutils/NetlinkEvent.h index 25a56f771..3494a9c5e 100644 --- a/include/sysutils/NetlinkEvent.h +++ b/include/sysutils/NetlinkEvent.h @@ -34,6 +34,8 @@ public: const static int NlActionChange; const static int NlActionLinkDown; const static int NlActionLinkUp; + const static int NlActionIfaceActive; + const static int NlActionIfaceIdle; NetlinkEvent(); virtual ~NetlinkEvent(); diff --git a/libsysutils/src/NetlinkEvent.cpp b/libsysutils/src/NetlinkEvent.cpp index 4beebb73d..643971134 100644 --- a/libsysutils/src/NetlinkEvent.cpp +++ b/libsysutils/src/NetlinkEvent.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include /* From kernel's net/netfilter/xt_quota2.c */ const int QLOG_NL_EVENT = 112; @@ -38,6 +39,8 @@ const int NetlinkEvent::NlActionRemove = 2; const int NetlinkEvent::NlActionChange = 3; const int NetlinkEvent::NlActionLinkUp = 4; const int NetlinkEvent::NlActionLinkDown = 5; +const int NetlinkEvent::NlActionIfaceActive = 6; +const int NetlinkEvent::NlActionIfaceIdle = 7; NetlinkEvent::NetlinkEvent() { mAction = NlActionUnknown; @@ -70,7 +73,8 @@ void NetlinkEvent::dump() { } /* - * Parse an binary message from a NETLINK_ROUTE netlink socket. + * Parse an binary message from a NETLINK_ROUTE netlink socket + * and IDLETIMER netlink socket. */ bool NetlinkEvent::parseBinaryNetlinkMessage(char *buffer, int size) { size_t sz = size; @@ -127,6 +131,14 @@ bool NetlinkEvent::parseBinaryNetlinkMessage(char *buffer, int size) { mSubsystem = strdup("qlog"); mAction = NlActionChange; + } else if (nh->nlmsg_type == NL_EVENT_TYPE_ACTIVE + || nh->nlmsg_type == NL_EVENT_TYPE_INACTIVE) { + char *ifacename; + ifacename = (char *)NLMSG_DATA(nh); + asprintf(&mParams[0], "INTERFACE=%s", ifacename); + mSubsystem = strdup("idletimer"); + mAction = (nh->nlmsg_type == NL_EVENT_TYPE_ACTIVE) ? + NlActionIfaceActive : NlActionIfaceIdle; } else { SLOGD("Unexpected netlink message. type=0x%x\n", nh->nlmsg_type); }