xref: /aosp_15_r20/system/netd/server/IdletimerController.h (revision 8542734a0dd1db395a4d42aae09c37f3c3c3e7a1)
1*8542734aSAndroid Build Coastguard Worker /*
2*8542734aSAndroid Build Coastguard Worker  * Copyright (C) 2012 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 #ifndef _IDLETIMER_CONTROLLER_H
17*8542734aSAndroid Build Coastguard Worker #define _IDLETIMER_CONTROLLER_H
18*8542734aSAndroid Build Coastguard Worker 
19*8542734aSAndroid Build Coastguard Worker #include <stdint.h>
20*8542734aSAndroid Build Coastguard Worker 
21*8542734aSAndroid Build Coastguard Worker #include "NetdConstants.h"
22*8542734aSAndroid Build Coastguard Worker 
23*8542734aSAndroid Build Coastguard Worker class IdletimerController {
24*8542734aSAndroid Build Coastguard Worker public:
25*8542734aSAndroid Build Coastguard Worker 
26*8542734aSAndroid Build Coastguard Worker     IdletimerController();
27*8542734aSAndroid Build Coastguard Worker     virtual ~IdletimerController();
28*8542734aSAndroid Build Coastguard Worker 
29*8542734aSAndroid Build Coastguard Worker     int addInterfaceIdletimer(const char *iface, uint32_t timeout,
30*8542734aSAndroid Build Coastguard Worker                               const char *classLabel);
31*8542734aSAndroid Build Coastguard Worker     int removeInterfaceIdletimer(const char *iface, uint32_t timeout,
32*8542734aSAndroid Build Coastguard Worker                                  const char *classLabel);
33*8542734aSAndroid Build Coastguard Worker     bool setupIptablesHooks();
34*8542734aSAndroid Build Coastguard Worker 
35*8542734aSAndroid Build Coastguard Worker     static const char* LOCAL_RAW_PREROUTING;
36*8542734aSAndroid Build Coastguard Worker     static const char* LOCAL_MANGLE_POSTROUTING;
37*8542734aSAndroid Build Coastguard Worker     std::mutex lock;
38*8542734aSAndroid Build Coastguard Worker 
39*8542734aSAndroid Build Coastguard Worker   private:
40*8542734aSAndroid Build Coastguard Worker     enum IptOp { IptOpAdd, IptOpDelete };
41*8542734aSAndroid Build Coastguard Worker     int runIpxtablesCmd(int argc, const char **cmd);
42*8542734aSAndroid Build Coastguard Worker     int modifyInterfaceIdletimer(IptOp op, const char *iface, uint32_t timeout,
43*8542734aSAndroid Build Coastguard Worker                                  const char *classLabel);
44*8542734aSAndroid Build Coastguard Worker 
45*8542734aSAndroid Build Coastguard Worker     friend class IdletimerControllerTest;
46*8542734aSAndroid Build Coastguard Worker     static int (*execIptablesRestore)(IptablesTarget, const std::string&);
47*8542734aSAndroid Build Coastguard Worker };
48*8542734aSAndroid Build Coastguard Worker 
49*8542734aSAndroid Build Coastguard Worker #endif
50