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