NetlinkEvent.h revision c7eec83f08329a2a0008ba939c07dd1dc7d9b7ff
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 19#include <sysutils/NetlinkListener.h> 20 21#define NL_PARAMS_MAX 32 22 23class NetlinkEvent { 24 int mSeq; 25 char *mPath; 26 int mAction; 27 char *mSubsystem; 28 char *mParams[NL_PARAMS_MAX]; 29 30public: 31 const static int NlActionUnknown; 32 const static int NlActionAdd; 33 const static int NlActionRemove; 34 const static int NlActionChange; 35 const static int NlActionLinkDown; 36 const static int NlActionLinkUp; 37 const static int NlActionAddressUpdated; 38 const static int NlActionAddressRemoved; 39 const static int NlActionRdnss; 40 41 NetlinkEvent(); 42 virtual ~NetlinkEvent(); 43 44 bool decode(char *buffer, int size, int format = NetlinkListener::NETLINK_FORMAT_ASCII); 45 const char *findParam(const char *paramName); 46 47 const char *getSubsystem() { return mSubsystem; } 48 int getAction() { return mAction; } 49 50 void dump(); 51 52 protected: 53 bool parseBinaryNetlinkMessage(char *buffer, int size); 54 bool parseAsciiNetlinkMessage(char *buffer, int size); 55 bool parseIfAddrMessage(int type, struct ifaddrmsg *ifaddr, int rtasize); 56 bool parseNdUserOptMessage(struct nduseroptmsg *msg, int optsize); 57}; 58 59#endif 60