10031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall/* 20031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Copyright (C) 2012 The Android Open Source Project 30031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 40031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Licensed under the Apache License, Version 2.0 (the "License"); 50031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * you may not use this file except in compliance with the License. 60031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * You may obtain a copy of the License at 70031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 80031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * http://www.apache.org/licenses/LICENSE-2.0 90031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * 100031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * Unless required by applicable law or agreed to in writing, software 110031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * distributed under the License is distributed on an "AS IS" BASIS, 120031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * See the License for the specific language governing permissions and 140031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall * limitations under the License. 150031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall */ 160031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#ifndef _IDLETIMER_CONTROLLER_H 170031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#define _IDLETIMER_CONTROLLER_H 180031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 191171ea500e70ea2748bc746cb01947a99b89a389Lorenzo Colitti#include <stdint.h> 201171ea500e70ea2748bc746cb01947a99b89a389Lorenzo Colitti 21c54d6728fba734cb9bb30565a110e0ef1d6be2c4Lorenzo Colitti#include "NetdConstants.h" 22c54d6728fba734cb9bb30565a110e0ef1d6be2c4Lorenzo Colitti 230031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallclass IdletimerController { 240031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallpublic: 250031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 260031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall IdletimerController(); 270031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall virtual ~IdletimerController(); 280031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 290031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall int enableIdletimerControl(); 300031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall int disableIdletimerControl(); 3198f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai int addInterfaceIdletimer(const char *iface, uint32_t timeout, 3298f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai const char *classLabel); 3398f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai int removeInterfaceIdletimer(const char *iface, uint32_t timeout, 3498f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai const char *classLabel); 350031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall bool setupIptablesHooks(); 360031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 378c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai static const char* LOCAL_RAW_PREROUTING; 388c54ec5de3818ff0c0cfc735c817be2516454415Haoyu Bai static const char* LOCAL_MANGLE_POSTROUTING; 398e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkey 400031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall private: 410031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall enum IptOp { IptOpAdd, IptOpDelete }; 420031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall int setDefaults(); 43001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand int runIpxtablesCmd(int argc, const char **cmd); 4498f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai int modifyInterfaceIdletimer(IptOp op, const char *iface, uint32_t timeout, 4598f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai const char *classLabel); 461171ea500e70ea2748bc746cb01947a99b89a389Lorenzo Colitti 471171ea500e70ea2748bc746cb01947a99b89a389Lorenzo Colitti friend class IdletimerControllerTest; 48c54d6728fba734cb9bb30565a110e0ef1d6be2c4Lorenzo Colitti static int (*execIptablesRestore)(IptablesTarget, const std::string&); 490031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall}; 500031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall 510031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#endif 52