• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 #include <string>
21 #include <vector>
22 
23 #include <sysutils/NetlinkEvent.h>
24 // TODO: stop depending on sysutils/NetlinkListener.h
25 #include <sysutils/NetlinkListener.h>
26 #include "NetlinkManager.h"
27 
28 namespace android {
29 namespace net {
30 
31 class NetlinkHandler : public ::NetlinkListener {
32     NetlinkManager *mNm;
33 
34 public:
35     NetlinkHandler(NetlinkManager *nm, int listenerSocket, int format);
36     virtual ~NetlinkHandler();
37 
38     int start();
39     int stop();
40 
41   protected:
42     virtual void onEvent(NetlinkEvent *evt);
43 
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);
59 };
60 
61 }  // namespace net
62 }  // namespace android
63 
64 #endif
65