xref: /aosp_15_r20/system/netd/server/Controllers.h (revision 8542734a0dd1db395a4d42aae09c37f3c3c3e7a1)
1*8542734aSAndroid Build Coastguard Worker /*
2*8542734aSAndroid Build Coastguard Worker  * Copyright (C) 2016 The Android Open Source Project
3*8542734aSAndroid Build Coastguard Worker  *
4*8542734aSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*8542734aSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*8542734aSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*8542734aSAndroid Build Coastguard Worker  *
8*8542734aSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*8542734aSAndroid Build Coastguard Worker  *
10*8542734aSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*8542734aSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*8542734aSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*8542734aSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*8542734aSAndroid Build Coastguard Worker  * limitations under the License.
15*8542734aSAndroid Build Coastguard Worker  */
16*8542734aSAndroid Build Coastguard Worker 
17*8542734aSAndroid Build Coastguard Worker #ifndef _CONTROLLERS_H__
18*8542734aSAndroid Build Coastguard Worker #define _CONTROLLERS_H__
19*8542734aSAndroid Build Coastguard Worker 
20*8542734aSAndroid Build Coastguard Worker #include "BandwidthController.h"
21*8542734aSAndroid Build Coastguard Worker #include "EventReporter.h"
22*8542734aSAndroid Build Coastguard Worker #include "FirewallController.h"
23*8542734aSAndroid Build Coastguard Worker #include "IdletimerController.h"
24*8542734aSAndroid Build Coastguard Worker #include "InterfaceController.h"
25*8542734aSAndroid Build Coastguard Worker #include "IptablesRestoreController.h"
26*8542734aSAndroid Build Coastguard Worker #include "NetworkController.h"
27*8542734aSAndroid Build Coastguard Worker #include "StrictController.h"
28*8542734aSAndroid Build Coastguard Worker #include "TcpSocketMonitor.h"
29*8542734aSAndroid Build Coastguard Worker #include "TetherController.h"
30*8542734aSAndroid Build Coastguard Worker #include "WakeupController.h"
31*8542734aSAndroid Build Coastguard Worker #include "XfrmController.h"
32*8542734aSAndroid Build Coastguard Worker #include "netdutils/Log.h"
33*8542734aSAndroid Build Coastguard Worker 
34*8542734aSAndroid Build Coastguard Worker namespace android {
35*8542734aSAndroid Build Coastguard Worker namespace net {
36*8542734aSAndroid Build Coastguard Worker 
37*8542734aSAndroid Build Coastguard Worker class Controllers {
38*8542734aSAndroid Build Coastguard Worker   public:
39*8542734aSAndroid Build Coastguard Worker     Controllers();
40*8542734aSAndroid Build Coastguard Worker 
41*8542734aSAndroid Build Coastguard Worker     NetworkController netCtrl;
42*8542734aSAndroid Build Coastguard Worker     TetherController tetherCtrl;
43*8542734aSAndroid Build Coastguard Worker     BandwidthController bandwidthCtrl;
44*8542734aSAndroid Build Coastguard Worker     IdletimerController idletimerCtrl;
45*8542734aSAndroid Build Coastguard Worker     FirewallController firewallCtrl;
46*8542734aSAndroid Build Coastguard Worker     StrictController strictCtrl;
47*8542734aSAndroid Build Coastguard Worker     EventReporter eventReporter;
48*8542734aSAndroid Build Coastguard Worker     IptablesRestoreController iptablesRestoreCtrl;
49*8542734aSAndroid Build Coastguard Worker     WakeupController wakeupCtrl;
50*8542734aSAndroid Build Coastguard Worker     XfrmController xfrmCtrl;
51*8542734aSAndroid Build Coastguard Worker     TcpSocketMonitor tcpSocketMonitor;
52*8542734aSAndroid Build Coastguard Worker 
53*8542734aSAndroid Build Coastguard Worker     void init();
54*8542734aSAndroid Build Coastguard Worker 
55*8542734aSAndroid Build Coastguard Worker   private:
56*8542734aSAndroid Build Coastguard Worker     friend class ControllersTest;
57*8542734aSAndroid Build Coastguard Worker     void initIptablesRules();
58*8542734aSAndroid Build Coastguard Worker     static void initChildChains();
59*8542734aSAndroid Build Coastguard Worker     static std::set<std::string> findExistingChildChains(const IptablesTarget target,
60*8542734aSAndroid Build Coastguard Worker                                                          const char* table,
61*8542734aSAndroid Build Coastguard Worker                                                          const char* parentChain);
62*8542734aSAndroid Build Coastguard Worker     static void createChildChains(IptablesTarget target, const char* table, const char* parentChain,
63*8542734aSAndroid Build Coastguard Worker                                   const std::vector<const char*>& childChains, bool exclusive);
64*8542734aSAndroid Build Coastguard Worker     static int (*execIptablesRestore)(IptablesTarget, const std::string&);
65*8542734aSAndroid Build Coastguard Worker     static int (*execIptablesRestoreWithOutput)(IptablesTarget, const std::string&, std::string *);
66*8542734aSAndroid Build Coastguard Worker };
67*8542734aSAndroid Build Coastguard Worker 
68*8542734aSAndroid Build Coastguard Worker extern netdutils::Log gLog;
69*8542734aSAndroid Build Coastguard Worker extern netdutils::Log gUnsolicitedLog;
70*8542734aSAndroid Build Coastguard Worker extern Controllers* gCtls;
71*8542734aSAndroid Build Coastguard Worker 
72*8542734aSAndroid Build Coastguard Worker }  // namespace net
73*8542734aSAndroid Build Coastguard Worker }  // namespace android
74*8542734aSAndroid Build Coastguard Worker 
75*8542734aSAndroid Build Coastguard Worker #endif  // _CONTROLLERS_H__
76