1fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt/* 2fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * Copyright (C) 2008 The Android Open Source Project 3fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * 4fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * Licensed under the Apache License, Version 2.0 (the "License"); 5fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * you may not use this file except in compliance with the License. 6fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * You may obtain a copy of the License at 7fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * 8fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * http://www.apache.org/licenses/LICENSE-2.0 9fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * 10fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * Unless required by applicable law or agreed to in writing, software 11fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * distributed under the License is distributed on an "AS IS" BASIS, 12fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * See the License for the specific language governing permissions and 14fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt * limitations under the License. 15fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt */ 16fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 17fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt#ifndef _SECONDARY_TABLE_CONTROLLER_H 18fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt#define _SECONDARY_TABLE_CONTROLLER_H 19fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 20fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt#include <sysutils/FrameworkListener.h> 21fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 22970274a61800e047430d81269df977de9dbe45efElliott Hughes#include <net/if.h> 23d14fd4f83ffeea4ad1cd559a41f775f6814565ccJaime A Lopez-Sollano 24d14fd4f83ffeea4ad1cd559a41f775f6814565ccJaime A Lopez-Sollano#ifndef IFNAMSIZ 25d14fd4f83ffeea4ad1cd559a41f775f6814565ccJaime A Lopez-Sollano#define IFNAMSIZ 16 26d14fd4f83ffeea4ad1cd559a41f775f6814565ccJaime A Lopez-Sollano#endif 27d14fd4f83ffeea4ad1cd559a41f775f6814565ccJaime A Lopez-Sollano 28fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwaltstatic const int INTERFACES_TRACKED = 10; 29fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwaltstatic const int BASE_TABLE_NUMBER = 60; 30fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwaltstatic int MAX_TABLE_NUMBER = BASE_TABLE_NUMBER + INTERFACES_TRACKED; 31fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 32fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwaltclass SecondaryTableController { 33fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 34fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwaltpublic: 35fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt SecondaryTableController(); 36fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt virtual ~SecondaryTableController(); 37fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 38fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt int addRoute(SocketClient *cli, char *iface, char *dest, int prefixLen, char *gateway); 39fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt int removeRoute(SocketClient *cli, char *iface, char *dest, int prefixLen, char *gateway); 40fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt int findTableNumber(const char *iface); 41c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt int modifyFromRule(int tableIndex, const char *action, const char *addr); 42c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt int modifyLocalRoute(int tableIndex, const char *action, const char *iface, const char *addr); 43fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 44fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwaltprivate: 45c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt int modifyRoute(SocketClient *cli, const char *action, char *iface, char *dest, int prefix, 46063af322b48ab1bb0c3e09eb0b64915ba568275bRobert Greenwalt char *gateway, int tableIndex); 47063af322b48ab1bb0c3e09eb0b64915ba568275bRobert Greenwalt 48d14fd4f83ffeea4ad1cd559a41f775f6814565ccJaime A Lopez-Sollano char mInterfaceTable[INTERFACES_TRACKED][IFNAMSIZ + 1]; 49fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt int mInterfaceRuleCount[INTERFACES_TRACKED]; 50c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt void modifyRuleCount(int tableIndex, const char *action); 51c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt int verifyTableIndex(int tableIndex); 52c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt const char *getVersion(const char *addr); 53fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 54fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt int runAndFree(SocketClient *cli, char *cmd); 55fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt}; 56fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt 57fc97b82e02979f246d56a4bfd60e4aab8686d3f6Robert Greenwalt#endif 58