NatController.h revision 1caafe66a6b927fa5d8eb4c59ec9eb48b0b1b075
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
229ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat#include <utils/List.h>
239ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
249ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehatclass NatController {
259ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
269ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehatpublic:
279ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    NatController();
289ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    virtual ~NatController();
299ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
309ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    int enableNat(const char *intIface, const char *extIface);
319ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    int disableNat(const char *intIface, const char *extIface);
329ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
339ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehatprivate:
341caafe66a6b927fa5d8eb4c59ec9eb48b0b1b075Robert Greenwalt    int natCount;
351caafe66a6b927fa5d8eb4c59ec9eb48b0b1b075Robert Greenwalt
369ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    int setDefaults();
379ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    int runIptablesCmd(const char *cmd);
389ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat    bool interfaceExists(const char *iface);
391caafe66a6b927fa5d8eb4c59ec9eb48b0b1b075Robert Greenwalt    int doNatCommands(const char *intIface, const char *extIface, bool add);
409ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat};
419ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat
429ff78fb7da7158f5bd7c86d89a842691820259cfSan Mehat#endif
43