blob: 5d0f1673dbb781509d2865171a0204c75bf778d7 [file] [log] [blame]
San Mehatd1830422010-01-15 08:02:39 -08001/*
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 Huang528af602018-08-29 19:06:05 +080020#include <string>
21#include <vector>
22
Jeff Sharkey32fa9ba2015-03-13 13:35:17 -070023#include <sysutils/NetlinkEvent.h>
Luke Huang528af602018-08-29 19:06:05 +080024// TODO: stop depending on sysutils/NetlinkListener.h
San Mehatd1830422010-01-15 08:02:39 -080025#include <sysutils/NetlinkListener.h>
Robert Greenwalt67c57532010-02-17 17:42:37 -080026#include "NetlinkManager.h"
San Mehatd1830422010-01-15 08:02:39 -080027
Lorenzo Colitti7035f222017-02-13 18:29:00 +090028namespace android {
29namespace net {
30
Luke Huang528af602018-08-29 19:06:05 +080031class NetlinkHandler : public ::NetlinkListener {
Robert Greenwalt67c57532010-02-17 17:42:37 -080032 NetlinkManager *mNm;
San Mehatd1830422010-01-15 08:02:39 -080033
34public:
Mike J. Chen564df4e2011-06-23 15:07:35 -070035 NetlinkHandler(NetlinkManager *nm, int listenerSocket, int format);
San Mehatd1830422010-01-15 08:02:39 -080036 virtual ~NetlinkHandler();
37
Luke Huang528af602018-08-29 19:06:05 +080038 int start();
39 int stop();
San Mehatd1830422010-01-15 08:02:39 -080040
Luke Huang528af602018-08-29 19:06:05 +080041 protected:
San Mehatd1830422010-01-15 08:02:39 -080042 virtual void onEvent(NetlinkEvent *evt);
Robert Greenwalt67c57532010-02-17 17:42:37 -080043
Luke Huang528af602018-08-29 19:06:05 +080044 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 Mehatd1830422010-01-15 08:02:39 -080059};
Lorenzo Colitti7035f222017-02-13 18:29:00 +090060
61} // namespace net
62} // namespace android
63
San Mehatd1830422010-01-15 08:02:39 -080064#endif