San Mehat | 168415b | 2009-05-06 11:14:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #ifndef _NETLINKEVENT_H |
| 17 | #define _NETLINKEVENT_H |
| 18 | |
Mike J. Chen | 17260b1 | 2011-06-23 15:00:30 -0700 | [diff] [blame] | 19 | #include <sysutils/NetlinkListener.h> |
| 20 | |
San Mehat | 168415b | 2009-05-06 11:14:21 -0700 | [diff] [blame] | 21 | #define NL_PARAMS_MAX 32 |
| 22 | |
| 23 | class NetlinkEvent { |
| 24 | int mSeq; |
| 25 | char *mPath; |
| 26 | int mAction; |
| 27 | char *mSubsystem; |
| 28 | char *mParams[NL_PARAMS_MAX]; |
| 29 | |
| 30 | public: |
| 31 | const static int NlActionUnknown; |
| 32 | const static int NlActionAdd; |
| 33 | const static int NlActionRemove; |
| 34 | const static int NlActionChange; |
Mike J. Chen | ec16b9d | 2011-06-23 14:55:28 -0700 | [diff] [blame] | 35 | const static int NlActionLinkDown; |
| 36 | const static int NlActionLinkUp; |
San Mehat | 168415b | 2009-05-06 11:14:21 -0700 | [diff] [blame] | 37 | |
| 38 | NetlinkEvent(); |
| 39 | virtual ~NetlinkEvent(); |
| 40 | |
Mike J. Chen | 17260b1 | 2011-06-23 15:00:30 -0700 | [diff] [blame] | 41 | bool decode(char *buffer, int size, int format = NetlinkListener::NETLINK_FORMAT_ASCII); |
San Mehat | 168415b | 2009-05-06 11:14:21 -0700 | [diff] [blame] | 42 | const char *findParam(const char *paramName); |
| 43 | |
| 44 | const char *getSubsystem() { return mSubsystem; } |
| 45 | int getAction() { return mAction; } |
San Mehat | d674413 | 2009-12-24 07:17:09 -0800 | [diff] [blame] | 46 | |
| 47 | void dump(); |
Mike J. Chen | ec16b9d | 2011-06-23 14:55:28 -0700 | [diff] [blame] | 48 | |
| 49 | protected: |
| 50 | bool parseBinaryNetlinkMessage(char *buffer, int size); |
| 51 | bool parseAsciiNetlinkMessage(char *buffer, int size); |
San Mehat | 168415b | 2009-05-06 11:14:21 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | #endif |