1*8542734aSAndroid Build Coastguard Worker /* 2*8542734aSAndroid Build Coastguard Worker * Copyright (C) 2008 The Android Open Source Project 3*8542734aSAndroid Build Coastguard Worker * 4*8542734aSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*8542734aSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*8542734aSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*8542734aSAndroid Build Coastguard Worker * 8*8542734aSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*8542734aSAndroid Build Coastguard Worker * 10*8542734aSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*8542734aSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*8542734aSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*8542734aSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*8542734aSAndroid Build Coastguard Worker * limitations under the License. 15*8542734aSAndroid Build Coastguard Worker */ 16*8542734aSAndroid Build Coastguard Worker 17*8542734aSAndroid Build Coastguard Worker #ifndef _NETLINKHANDLER_H 18*8542734aSAndroid Build Coastguard Worker #define _NETLINKHANDLER_H 19*8542734aSAndroid Build Coastguard Worker 20*8542734aSAndroid Build Coastguard Worker #include <string> 21*8542734aSAndroid Build Coastguard Worker #include <vector> 22*8542734aSAndroid Build Coastguard Worker 23*8542734aSAndroid Build Coastguard Worker #include <sysutils/NetlinkEvent.h> 24*8542734aSAndroid Build Coastguard Worker // TODO: stop depending on sysutils/NetlinkListener.h 25*8542734aSAndroid Build Coastguard Worker #include <sysutils/NetlinkListener.h> 26*8542734aSAndroid Build Coastguard Worker #include "NetlinkManager.h" 27*8542734aSAndroid Build Coastguard Worker 28*8542734aSAndroid Build Coastguard Worker namespace android { 29*8542734aSAndroid Build Coastguard Worker namespace net { 30*8542734aSAndroid Build Coastguard Worker 31*8542734aSAndroid Build Coastguard Worker class NetlinkHandler : public ::NetlinkListener { 32*8542734aSAndroid Build Coastguard Worker NetlinkManager *mNm; 33*8542734aSAndroid Build Coastguard Worker 34*8542734aSAndroid Build Coastguard Worker public: 35*8542734aSAndroid Build Coastguard Worker NetlinkHandler(NetlinkManager *nm, int listenerSocket, int format); 36*8542734aSAndroid Build Coastguard Worker virtual ~NetlinkHandler(); 37*8542734aSAndroid Build Coastguard Worker 38*8542734aSAndroid Build Coastguard Worker int start(); 39*8542734aSAndroid Build Coastguard Worker int stop(); 40*8542734aSAndroid Build Coastguard Worker 41*8542734aSAndroid Build Coastguard Worker protected: 42*8542734aSAndroid Build Coastguard Worker virtual void onEvent(NetlinkEvent *evt); 43*8542734aSAndroid Build Coastguard Worker 44*8542734aSAndroid Build Coastguard Worker void notifyInterfaceAdded(const std::string& ifName); 45*8542734aSAndroid Build Coastguard Worker void notifyInterfaceRemoved(const std::string& ifName); 46*8542734aSAndroid Build Coastguard Worker void notifyInterfaceChanged(const std::string& ifName, bool isUp); 47*8542734aSAndroid Build Coastguard Worker void notifyInterfaceLinkChanged(const std::string& ifName, bool isUp); 48*8542734aSAndroid Build Coastguard Worker void notifyQuotaLimitReached(const std::string& labelName, const std::string& ifName); 49*8542734aSAndroid Build Coastguard Worker void notifyInterfaceClassActivityChanged(int label, bool isActive, int64_t timestamp, int uid); 50*8542734aSAndroid Build Coastguard Worker void notifyAddressUpdated(const std::string& addr, const std::string& ifName, int flags, 51*8542734aSAndroid Build Coastguard Worker int scope); 52*8542734aSAndroid Build Coastguard Worker void notifyAddressRemoved(const std::string& addr, const std::string& ifName, int flags, 53*8542734aSAndroid Build Coastguard Worker int scope); 54*8542734aSAndroid Build Coastguard Worker void notifyInterfaceDnsServers(const std::string& ifName, int64_t lifetime, 55*8542734aSAndroid Build Coastguard Worker const std::vector<std::string>& servers); 56*8542734aSAndroid Build Coastguard Worker void notifyRouteChange(bool updated, const std::string& route, const std::string& gateway, 57*8542734aSAndroid Build Coastguard Worker const std::string& ifName); 58*8542734aSAndroid Build Coastguard Worker void notifyStrictCleartext(uid_t uid, const std::string& hex); 59*8542734aSAndroid Build Coastguard Worker }; 60*8542734aSAndroid Build Coastguard Worker 61*8542734aSAndroid Build Coastguard Worker } // namespace net 62*8542734aSAndroid Build Coastguard Worker } // namespace android 63*8542734aSAndroid Build Coastguard Worker 64*8542734aSAndroid Build Coastguard Worker #endif 65