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
190031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallclass IdletimerController {
200031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallpublic:
210031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall
220031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    IdletimerController();
230031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    virtual ~IdletimerController();
240031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall
250031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    int enableIdletimerControl();
260031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    int disableIdletimerControl();
2798f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai    int addInterfaceIdletimer(const char *iface, uint32_t timeout,
2898f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai                              const char *classLabel);
2998f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai    int removeInterfaceIdletimer(const char *iface, uint32_t timeout,
3098f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai                                 const char *classLabel);
310031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    bool setupIptablesHooks();
320031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall
335c4faf7602de0268aa09a3a525b427f83d617b5cHaoyu Bai    static const char* LOCAL_RAW_PREROUTING;
345c4faf7602de0268aa09a3a525b427f83d617b5cHaoyu Bai    static const char* LOCAL_MANGLE_POSTROUTING;
358e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkey
360031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall private:
370031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    enum IptOp { IptOpAdd, IptOpDelete };
380031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    int setDefaults();
390031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    int runIpxtablesCmd(const char *cmd);
4098f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai    int modifyInterfaceIdletimer(IptOp op, const char *iface, uint32_t timeout,
4198f65d32b1530b4da6050e38d52f955710577efbHaoyu Bai                                 const char *classLabel);
420031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall};
430031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall
440031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall#endif
45