blob: 0754932c022fc4dc75e9f2e6dfec7d7cefb70aae [file] [log] [blame]
Pierre Imai1cfa5432016-02-24 18:00:03 +09001/*
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 <sysutils/FrameworkListener.h>
Lorenzo Colittiddf2d5b2016-02-26 11:30:59 +090021
Pierre Imai1cfa5432016-02-24 18:00:03 +090022#include "BandwidthController.h"
Nathan Harold1a371532017-01-30 12:30:48 -080023#include "ClatdController.h"
24#include "EventReporter.h"
25#include "FirewallController.h"
Pierre Imai1cfa5432016-02-24 18:00:03 +090026#include "IdletimerController.h"
27#include "InterfaceController.h"
Narayan Kamatha5ace892017-01-06 15:10:02 +000028#include "IptablesRestoreController.h"
Nathan Harold1a371532017-01-30 12:30:48 -080029#include "NatController.h"
30#include "NetworkController.h"
31#include "PppController.h"
Pierre Imai1cfa5432016-02-24 18:00:03 +090032#include "ResolverController.h"
Pierre Imai1cfa5432016-02-24 18:00:03 +090033#include "StrictController.h"
Nathan Harold1a371532017-01-30 12:30:48 -080034#include "TetherController.h"
Joel Scherpelz08b84cd2017-05-22 13:11:54 +090035#include "WakeupController.h"
Nathan Harold1a371532017-01-30 12:30:48 -080036#include "XfrmController.h"
Pierre Imai1cfa5432016-02-24 18:00:03 +090037
38namespace android {
39namespace net {
40
Lorenzo Colitti1ed96e22017-02-02 12:21:56 +090041class Controllers {
42public:
Pierre Imai1cfa5432016-02-24 18:00:03 +090043 Controllers();
44
45 NetworkController netCtrl;
46 TetherController tetherCtrl;
47 NatController natCtrl;
48 PppController pppCtrl;
Pierre Imai1cfa5432016-02-24 18:00:03 +090049 BandwidthController bandwidthCtrl;
50 IdletimerController idletimerCtrl;
51 ResolverController resolverCtrl;
52 FirewallController firewallCtrl;
Pierre Imai1cfa5432016-02-24 18:00:03 +090053 ClatdController clatdCtrl;
54 StrictController strictCtrl;
Michal Karpinskid5440112016-10-06 16:56:04 +010055 EventReporter eventReporter;
Narayan Kamatha5ace892017-01-06 15:10:02 +000056 IptablesRestoreController iptablesRestoreCtrl;
Joel Scherpelz08b84cd2017-05-22 13:11:54 +090057 WakeupController wakeupCtrl;
Nathan Harold1a371532017-01-30 12:30:48 -080058 XfrmController xfrmCtrl;
Lorenzo Colitti1ed96e22017-02-02 12:21:56 +090059
60 void init();
61
62private:
Lorenzo Colitti341d3a02017-08-08 17:31:35 +090063 friend class ControllersTest;
Lorenzo Colitti1ed96e22017-02-02 12:21:56 +090064 void initIptablesRules();
Lorenzo Colitti341d3a02017-08-08 17:31:35 +090065 static void initChildChains();
66 static void createChildChains(IptablesTarget target, const char* table, const char* parentChain,
67 const char** childChains, bool exclusive);
68 static int (*execIptablesSilently)(IptablesTarget target, ...);
69 static int (*execIptablesRestore)(IptablesTarget, const std::string&);
Pierre Imai1cfa5432016-02-24 18:00:03 +090070};
71
72extern Controllers* gCtls;
73
74} // namespace net
75} // namespace android
76
77#endif // _CONTROLLERS_H__