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