Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 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 <sysutils/FrameworkListener.h> |
Lorenzo Colitti | ddf2d5b | 2016-02-26 11:30:59 +0900 | [diff] [blame] | 21 | |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 22 | #include "BandwidthController.h" |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 23 | #include "ClatdController.h" |
| 24 | #include "EventReporter.h" |
| 25 | #include "FirewallController.h" |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 26 | #include "IdletimerController.h" |
| 27 | #include "InterfaceController.h" |
Narayan Kamath | a5ace89 | 2017-01-06 15:10:02 +0000 | [diff] [blame] | 28 | #include "IptablesRestoreController.h" |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 29 | #include "NetworkController.h" |
| 30 | #include "PppController.h" |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 31 | #include "ResolverController.h" |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 32 | #include "StrictController.h" |
Erik Kline | b31fd69 | 2018-06-06 20:50:11 +0900 | [diff] [blame^] | 33 | #include "TcpSocketMonitor.h" |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 34 | #include "TetherController.h" |
Chenbo Feng | f275968 | 2017-10-10 17:31:57 -0700 | [diff] [blame] | 35 | #include "TrafficController.h" |
Joel Scherpelz | 08b84cd | 2017-05-22 13:11:54 +0900 | [diff] [blame] | 36 | #include "WakeupController.h" |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 37 | #include "XfrmController.h" |
Erik Kline | b31fd69 | 2018-06-06 20:50:11 +0900 | [diff] [blame^] | 38 | #include "netdutils/Log.h" |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 39 | |
| 40 | namespace android { |
| 41 | namespace net { |
| 42 | |
Lorenzo Colitti | 1ed96e2 | 2017-02-02 12:21:56 +0900 | [diff] [blame] | 43 | class Controllers { |
Erik Kline | b31fd69 | 2018-06-06 20:50:11 +0900 | [diff] [blame^] | 44 | public: |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 45 | Controllers(); |
| 46 | |
| 47 | NetworkController netCtrl; |
| 48 | TetherController tetherCtrl; |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 49 | PppController pppCtrl; |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 50 | BandwidthController bandwidthCtrl; |
| 51 | IdletimerController idletimerCtrl; |
| 52 | ResolverController resolverCtrl; |
| 53 | FirewallController firewallCtrl; |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 54 | ClatdController clatdCtrl; |
| 55 | StrictController strictCtrl; |
Michal Karpinski | d544011 | 2016-10-06 16:56:04 +0100 | [diff] [blame] | 56 | EventReporter eventReporter; |
Narayan Kamath | a5ace89 | 2017-01-06 15:10:02 +0000 | [diff] [blame] | 57 | IptablesRestoreController iptablesRestoreCtrl; |
Joel Scherpelz | 08b84cd | 2017-05-22 13:11:54 +0900 | [diff] [blame] | 58 | WakeupController wakeupCtrl; |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 59 | XfrmController xfrmCtrl; |
Chenbo Feng | f275968 | 2017-10-10 17:31:57 -0700 | [diff] [blame] | 60 | TrafficController trafficCtrl; |
Hugo Benichi | 7b314e1 | 2018-01-15 21:54:00 +0900 | [diff] [blame] | 61 | TcpSocketMonitor tcpSocketMonitor; |
Lorenzo Colitti | 1ed96e2 | 2017-02-02 12:21:56 +0900 | [diff] [blame] | 62 | |
| 63 | void init(); |
| 64 | |
Erik Kline | b31fd69 | 2018-06-06 20:50:11 +0900 | [diff] [blame^] | 65 | private: |
Lorenzo Colitti | 341d3a0 | 2017-08-08 17:31:35 +0900 | [diff] [blame] | 66 | friend class ControllersTest; |
Lorenzo Colitti | 1ed96e2 | 2017-02-02 12:21:56 +0900 | [diff] [blame] | 67 | void initIptablesRules(); |
Lorenzo Colitti | 341d3a0 | 2017-08-08 17:31:35 +0900 | [diff] [blame] | 68 | static void initChildChains(); |
Lorenzo Colitti | adc3a5f | 2017-08-08 17:23:12 +0900 | [diff] [blame] | 69 | static std::set<std::string> findExistingChildChains(const IptablesTarget target, |
| 70 | const char* table, |
| 71 | const char* parentChain); |
Lorenzo Colitti | 341d3a0 | 2017-08-08 17:31:35 +0900 | [diff] [blame] | 72 | static void createChildChains(IptablesTarget target, const char* table, const char* parentChain, |
Lorenzo Colitti | adc3a5f | 2017-08-08 17:23:12 +0900 | [diff] [blame] | 73 | const std::vector<const char*>& childChains, bool exclusive); |
Lorenzo Colitti | 341d3a0 | 2017-08-08 17:31:35 +0900 | [diff] [blame] | 74 | static int (*execIptablesRestore)(IptablesTarget, const std::string&); |
Lorenzo Colitti | adc3a5f | 2017-08-08 17:23:12 +0900 | [diff] [blame] | 75 | static int (*execIptablesRestoreWithOutput)(IptablesTarget, const std::string&, std::string *); |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 76 | }; |
| 77 | |
Erik Kline | b31fd69 | 2018-06-06 20:50:11 +0900 | [diff] [blame^] | 78 | extern netdutils::Log gLog; |
Pierre Imai | 1cfa543 | 2016-02-24 18:00:03 +0900 | [diff] [blame] | 79 | extern Controllers* gCtls; |
| 80 | |
| 81 | } // namespace net |
| 82 | } // namespace android |
| 83 | |
| 84 | #endif // _CONTROLLERS_H__ |