San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [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 | |
| 17 | #ifndef _NETLINKHANDLER_H |
| 18 | #define _NETLINKHANDLER_H |
| 19 | |
Luke Huang | 528af60 | 2018-08-29 19:06:05 +0800 | [diff] [blame] | 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
Jeff Sharkey | 32fa9ba | 2015-03-13 13:35:17 -0700 | [diff] [blame] | 23 | #include <sysutils/NetlinkEvent.h> |
Luke Huang | 528af60 | 2018-08-29 19:06:05 +0800 | [diff] [blame] | 24 | // TODO: stop depending on sysutils/NetlinkListener.h |
San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [diff] [blame] | 25 | #include <sysutils/NetlinkListener.h> |
Robert Greenwalt | 67c5753 | 2010-02-17 17:42:37 -0800 | [diff] [blame] | 26 | #include "NetlinkManager.h" |
San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [diff] [blame] | 27 | |
Lorenzo Colitti | 7035f22 | 2017-02-13 18:29:00 +0900 | [diff] [blame] | 28 | namespace android { |
| 29 | namespace net { |
| 30 | |
Luke Huang | 528af60 | 2018-08-29 19:06:05 +0800 | [diff] [blame] | 31 | class NetlinkHandler : public ::NetlinkListener { |
Robert Greenwalt | 67c5753 | 2010-02-17 17:42:37 -0800 | [diff] [blame] | 32 | NetlinkManager *mNm; |
San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [diff] [blame] | 33 | |
| 34 | public: |
Mike J. Chen | 564df4e | 2011-06-23 15:07:35 -0700 | [diff] [blame] | 35 | NetlinkHandler(NetlinkManager *nm, int listenerSocket, int format); |
San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [diff] [blame] | 36 | virtual ~NetlinkHandler(); |
| 37 | |
Luke Huang | 528af60 | 2018-08-29 19:06:05 +0800 | [diff] [blame] | 38 | int start(); |
| 39 | int stop(); |
San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [diff] [blame] | 40 | |
Luke Huang | 528af60 | 2018-08-29 19:06:05 +0800 | [diff] [blame] | 41 | protected: |
San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [diff] [blame] | 42 | virtual void onEvent(NetlinkEvent *evt); |
Robert Greenwalt | 67c5753 | 2010-02-17 17:42:37 -0800 | [diff] [blame] | 43 | |
Luke Huang | 528af60 | 2018-08-29 19:06:05 +0800 | [diff] [blame] | 44 | void notifyInterfaceAdded(const std::string& ifName); |
| 45 | void notifyInterfaceRemoved(const std::string& ifName); |
| 46 | void notifyInterfaceChanged(const std::string& ifName, bool isUp); |
| 47 | void notifyInterfaceLinkChanged(const std::string& ifName, bool isUp); |
| 48 | void notifyQuotaLimitReached(const std::string& labelName, const std::string& ifName); |
| 49 | void notifyInterfaceClassActivityChanged(int label, bool isActive, int64_t timestamp, int uid); |
| 50 | void notifyAddressUpdated(const std::string& addr, const std::string& ifName, int flags, |
| 51 | int scope); |
| 52 | void notifyAddressRemoved(const std::string& addr, const std::string& ifName, int flags, |
| 53 | int scope); |
| 54 | void notifyInterfaceDnsServers(const std::string& ifName, int64_t lifetime, |
| 55 | const std::vector<std::string>& servers); |
| 56 | void notifyRouteChange(bool updated, const std::string& route, const std::string& gateway, |
| 57 | const std::string& ifName); |
| 58 | void notifyStrictCleartext(uid_t uid, const std::string& hex); |
San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [diff] [blame] | 59 | }; |
Lorenzo Colitti | 7035f22 | 2017-02-13 18:29:00 +0900 | [diff] [blame] | 60 | |
| 61 | } // namespace net |
| 62 | } // namespace android |
| 63 | |
San Mehat | d183042 | 2010-01-15 08:02:39 -0800 | [diff] [blame] | 64 | #endif |