• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 _CONTROLLERS_H__
18 #define _CONTROLLERS_H__
19 
20 #include "BandwidthController.h"
21 #include "ClatdController.h"
22 #include "EventReporter.h"
23 #include "FirewallController.h"
24 #include "IdletimerController.h"
25 #include "InterfaceController.h"
26 #include "IptablesRestoreController.h"
27 #include "NetworkController.h"
28 #include "PppController.h"
29 #include "StrictController.h"
30 #include "TcpSocketMonitor.h"
31 #include "TetherController.h"
32 #include "TrafficController.h"
33 #include "WakeupController.h"
34 #include "XfrmController.h"
35 #include "netdutils/Log.h"
36 
37 namespace android {
38 namespace net {
39 
40 class Controllers {
41   public:
42     Controllers();
43 
44     NetworkController netCtrl;
45     TetherController tetherCtrl;
46     PppController pppCtrl;
47     BandwidthController bandwidthCtrl;
48     IdletimerController idletimerCtrl;
49     FirewallController firewallCtrl;
50     ClatdController clatdCtrl;
51     StrictController strictCtrl;
52     EventReporter eventReporter;
53     IptablesRestoreController iptablesRestoreCtrl;
54     WakeupController wakeupCtrl;
55     XfrmController xfrmCtrl;
56     TrafficController trafficCtrl;
57     TcpSocketMonitor tcpSocketMonitor;
58 
59     void init();
60 
61   private:
62     friend class ControllersTest;
63     void initIptablesRules();
64     static void initChildChains();
65     static std::set<std::string> findExistingChildChains(const IptablesTarget target,
66                                                          const char* table,
67                                                          const char* parentChain);
68     static void createChildChains(IptablesTarget target, const char* table, const char* parentChain,
69                                   const std::vector<const char*>& childChains, bool exclusive);
70     static int (*execIptablesRestore)(IptablesTarget, const std::string&);
71     static int (*execIptablesRestoreWithOutput)(IptablesTarget, const std::string&, std::string *);
72 };
73 
74 extern netdutils::Log gLog;
75 extern netdutils::Log gUnsolicitedLog;
76 extern Controllers* gCtls;
77 
78 }  // namespace net
79 }  // namespace android
80 
81 #endif  // _CONTROLLERS_H__
82