1c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt/* 2c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * Copyright (C) 2012 The Android Open Source Project 3c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * 4c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * Licensed under the Apache License, Version 2.0 (the "License"); 5c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * you may not use this file except in compliance with the License. 6c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * You may obtain a copy of the License at 7c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * 8c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * http://www.apache.org/licenses/LICENSE-2.0 9c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * 10c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * Unless required by applicable law or agreed to in writing, software 11c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * distributed under the License is distributed on an "AS IS" BASIS, 12c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * See the License for the specific language governing permissions and 14c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt * limitations under the License. 15c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt */ 16c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt 17c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt#ifndef _NETD_CONSTANTS_H 18c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt#define _NETD_CONSTANTS_H 19c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt 208e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkey#include <string> 218e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkey#include <list> 228e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkey#include <stdarg.h> 23c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt 242a390120a9e90ec414d347921039ff98724d0ddaChad Brubakerconst int PROTECT_MARK = 0x1; 252a390120a9e90ec414d347921039ff98724d0ddaChad Brubaker 26c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwaltextern const char * const IPTABLES_PATH; 270031cead820149e2fe3ccb3cc2fe05758a3cb5c2JP Abgrallextern const char * const IP6TABLES_PATH; 28c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwaltextern const char * const IP_PATH; 29c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwaltextern const char * const TC_PATH; 30c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwaltextern const char * const OEM_SCRIPT_PATH; 31c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwaltextern const char * const ADD; 32c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwaltextern const char * const DEL; 33c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt 348e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkeyenum IptablesTarget { V4, V6, V4V6 }; 358e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkey 368e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkeyint execIptables(IptablesTarget target, ...); 378e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkeyint execIptablesSilently(IptablesTarget target, ...); 3870afde6ad9b5fce63cca594ac9b230d2fc9b21eeLorenzo Colittiint writeFile(const char *path, const char *value, int size); 396d6c0e6f1164e3182538cb48c2b95d90a2eb780cDmitry Shmidtint readFile(const char *path, char *buf, int *sizep); 4069261cb65186e27dfbdc1e3eec796437f9968ff9JP Abgrallbool isIfaceName(const char *name); 41ba25df989b48f36b784ad39307a49a4fd9c3fd66Lorenzo Colittiint parsePrefix(const char *prefix, uint8_t *family, void *address, int size, uint8_t *prefixlen); 428e188ed5c989ddcc07f0f5e9839493c22d17e7b6Jeff Sharkey 43001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) 44001f0a436e9fe0353dccd98ee34b91095d9ed1a1Rom Lemarchand 45a10ac3214f6a582b7fdb66acc43c702731e53d81Lorenzo Colitti#define __INT_STRLEN(i) sizeof(#i) 46a10ac3214f6a582b7fdb66acc43c702731e53d81Lorenzo Colitti#define _INT_STRLEN(i) __INT_STRLEN(i) 47a10ac3214f6a582b7fdb66acc43c702731e53d81Lorenzo Colitti#define UINT32_STRLEN _INT_STRLEN(UINT32_MAX) 48a10ac3214f6a582b7fdb66acc43c702731e53d81Lorenzo Colitti#define UINT32_HEX_STRLEN sizeof("0x12345678") 49a10ac3214f6a582b7fdb66acc43c702731e53d81Lorenzo Colitti 50f4f6c8de3f091be4b91a5a9d7f14e8882ec6d502Sreeram Ramachandran#define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 51f4f6c8de3f091be4b91a5a9d7f14e8882ec6d502Sreeram Ramachandran 52b1425cc09f8a29350520db0d4f489331df5a689bSreeram Ramachandranconst uid_t INVALID_UID = static_cast<uid_t>(-1); 53b1425cc09f8a29350520db0d4f489331df5a689bSreeram Ramachandran 54c462177bd58e3bf0ac4f618934dae060569e3e0bRobert Greenwalt#endif 55