diff options
Diffstat (limited to 'include/sysutils')
-rw-r--r-- | include/sysutils/NetlinkEvent.h | 10 | ||||
-rw-r--r-- | include/sysutils/NetlinkListener.h | 14 | ||||
-rw-r--r-- | include/sysutils/SocketClient.h | 5 |
3 files changed, 26 insertions, 3 deletions
diff --git a/include/sysutils/NetlinkEvent.h b/include/sysutils/NetlinkEvent.h index b329b09..25a56f7 100644 --- a/include/sysutils/NetlinkEvent.h +++ b/include/sysutils/NetlinkEvent.h @@ -16,6 +16,8 @@ #ifndef _NETLINKEVENT_H #define _NETLINKEVENT_H +#include <sysutils/NetlinkListener.h> + #define NL_PARAMS_MAX 32 class NetlinkEvent { @@ -30,17 +32,23 @@ public: const static int NlActionAdd; const static int NlActionRemove; const static int NlActionChange; + const static int NlActionLinkDown; + const static int NlActionLinkUp; NetlinkEvent(); virtual ~NetlinkEvent(); - bool decode(char *buffer, int size); + bool decode(char *buffer, int size, int format = NetlinkListener::NETLINK_FORMAT_ASCII); const char *findParam(const char *paramName); const char *getSubsystem() { return mSubsystem; } int getAction() { return mAction; } void dump(); + + protected: + bool parseBinaryNetlinkMessage(char *buffer, int size); + bool parseAsciiNetlinkMessage(char *buffer, int size); }; #endif diff --git a/include/sysutils/NetlinkListener.h b/include/sysutils/NetlinkListener.h index 2880046..beb8bda 100644 --- a/include/sysutils/NetlinkListener.h +++ b/include/sysutils/NetlinkListener.h @@ -22,13 +22,27 @@ class NetlinkEvent; class NetlinkListener : public SocketListener { char mBuffer[64 * 1024]; + int mFormat; public: + static const int NETLINK_FORMAT_ASCII = 0; + static const int NETLINK_FORMAT_BINARY = 1; + +#if 1 + /* temporary version until we can get Motorola to update their + * ril.so. Their prebuilt ril.so is using this private class + * so changing the NetlinkListener() constructor breaks their ril. + */ NetlinkListener(int socket); + NetlinkListener(int socket, int format); +#else + NetlinkListener(int socket, int format = NETLINK_FORMAT_ASCII); +#endif virtual ~NetlinkListener() {} protected: virtual bool onDataAvailable(SocketClient *cli); virtual void onEvent(NetlinkEvent *evt) = 0; }; + #endif diff --git a/include/sysutils/SocketClient.h b/include/sysutils/SocketClient.h index d6bb7d5..7d2b1d6 100644 --- a/include/sysutils/SocketClient.h +++ b/include/sysutils/SocketClient.h @@ -8,6 +8,7 @@ class SocketClient { int mSocket; + bool mSocketOwned; pthread_mutex_t mWriteMutex; /* Peer process ID */ @@ -24,8 +25,8 @@ class SocketClient { int mRefCount; public: - SocketClient(int sock); - virtual ~SocketClient() {} + SocketClient(int sock, bool owned); + virtual ~SocketClient(); int getSocket() { return mSocket; } pid_t getPid() const { return mPid; } |