NatController.h revision 0031cead820149e2fe3ccb3cc2fe05758a3cb5c2
19ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat/*
29ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * Copyright (C) 2008 The Android Open Source Project
39ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat *
49ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * Licensed under the Apache License, Version 2.0 (the "License");
59ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * you may not use this file except in compliance with the License.
69ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * You may obtain a copy of the License at
79ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat *
89ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat *      http://www.apache.org/licenses/LICENSE-2.0
99ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat *
109ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * Unless required by applicable law or agreed to in writing, software
119ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * distributed under the License is distributed on an "AS IS" BASIS,
129ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * See the License for the specific language governing permissions and
149ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat * limitations under the License.
159ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat */
169ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
179ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat#ifndef _NAT_CONTROLLER_H
189ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat#define _NAT_CONTROLLER_H
199ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
209ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat#include <linux/in.h>
219ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
22fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt#include "SecondaryTableController.h"
23fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt
249ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehatclass NatController {
259ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
269ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehatpublic:
27fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt    NatController(SecondaryTableController *ctrl);
289ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    virtual ~NatController();
299ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
30fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt    int enableNat(const int argc, char **argv);
31fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt    int disableNat(const int argc, char **argv);
320031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrall    int setupIptablesHooks();
339ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
349ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehatprivate:
351caafe66a6b927fa5d8eb4c59ec9eb48b0b1b075Robert Greenwalt    int natCount;
36fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt    SecondaryTableController *secondaryTableCtrl;
371caafe66a6b927fa5d8eb4c59ec9eb48b0b1b075Robert Greenwalt
389ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    int setDefaults();
39fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt    int runCmd(const char *path, const char *cmd);
40fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt    bool checkInterface(const char *iface);
41fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt    int setForwardRules(bool set, const char *intIface, const char *extIface);
429ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat};
439ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
449ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat#endif
45