2 * Copyright (C) 2014 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef NETD_SERVER_ROUTE_CONTROLLER_H
18 #define NETD_SERVER_ROUTE_CONTROLLER_H
20 #include "Permission.h"
22 class RouteController {
24 // How the routing table number is determined for route modification requests.
26 INTERFACE, // Compute the table number based on the interface index.
27 LEGACY, // Based on the UID; such tables can override the default network routes.
28 PRIVILEGED_LEGACY, // Based on the UID; such tables can bypass VPNs.
31 static const int ROUTE_TABLE_OFFSET_FROM_INDEX = 1000;
35 static bool addInterfaceToNetwork(unsigned netId, const char* interface, Permission permission);
36 static bool removeInterfaceFromNetwork(unsigned netId, const char* interface,
37 Permission permission);
38 static bool modifyNetworkPermission(unsigned netId, const char* interface,
39 Permission oldPermission, Permission newPermission);
41 static bool addToDefaultNetwork(const char* interface, Permission permission);
42 static bool removeFromDefaultNetwork(const char* interface, Permission permission);
44 static bool addRoute(const char* interface, const char* destination, const char* nexthop,
45 TableType tableType, unsigned uid);
46 static bool removeRoute(const char* interface, const char* destination, const char* nexthop,
47 TableType tableType, unsigned uid);
50 #endif // NETD_SERVER_ROUTE_CONTROLLER_H