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