blob: 2f6cb8049f34976fcfd1f7d7da81f94e1ce6b9af [file] [log] [blame]
Lorenzo Colittie4d626e2016-02-02 17:19:04 +09001/**
2 * Copyright (c) 2016, The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#ifndef _NETD_NATIVE_SERVICE_H_
18#define _NETD_NATIVE_SERVICE_H_
19
Lorenzo Colitti89faa342016-02-26 11:38:47 +090020#include <vector>
21
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090022#include <binder/BinderService.h>
23
24#include "android/net/BnNetd.h"
Robin Lee9f9aae92016-03-30 18:33:07 +010025#include "android/net/UidRange.h"
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090026
27namespace android {
28namespace net {
29
30class NetdNativeService : public BinderService<NetdNativeService>, public BnNetd {
31 public:
Lorenzo Colittie4851de2016-03-17 13:23:28 +090032 static status_t start();
Lorenzo Colittic2c7b752016-02-23 22:25:11 +090033 static char const* getServiceName() { return "netd"; }
Erik Kline2d3a1632016-03-15 16:33:48 +090034 virtual status_t dump(int fd, const Vector<String16> &args) override;
35
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090036 binder::Status isAlive(bool *alive) override;
Lorenzo Colittid33e96d2016-12-15 23:59:01 +090037
38 // Firewall commands.
Lorenzo Colitti89faa342016-02-26 11:38:47 +090039 binder::Status firewallReplaceUidChain(
Erik Kline2d3a1632016-03-15 16:33:48 +090040 const String16& chainName, bool isWhitelist,
41 const std::vector<int32_t>& uids, bool *ret) override;
Lorenzo Colittid33e96d2016-12-15 23:59:01 +090042
43 // Bandwidth control commands.
Lorenzo Colittidedd2712016-03-22 12:36:29 +090044 binder::Status bandwidthEnableDataSaver(bool enable, bool *ret) override;
Lorenzo Colittid33e96d2016-12-15 23:59:01 +090045
46 // Network and routing commands.
47 binder::Status networkCreatePhysical(int32_t netId, const std::string& permission)
48 override;
49 binder::Status networkCreateVpn(int32_t netId, bool hasDns, bool secure) override;
50 binder::Status networkDestroy(int32_t netId) override;
51
52 binder::Status networkAddInterface(int32_t netId, const std::string& iface) override;
53 binder::Status networkRemoveInterface(int32_t netId, const std::string& iface) override;
54
55 binder::Status networkAddUidRanges(int32_t netId, const std::vector<UidRange>& uids)
56 override;
57 binder::Status networkRemoveUidRanges(int32_t netId, const std::vector<UidRange>& uids)
58 override;
Robin Leeb8087362016-03-30 18:43:08 +010059 binder::Status networkRejectNonSecureVpn(bool enable, const std::vector<UidRange>& uids)
60 override;
Lorenzo Colittid33e96d2016-12-15 23:59:01 +090061
62 // SOCK_DIAG commands.
Lorenzo Colitti563d98b2016-04-24 13:13:14 +090063 binder::Status socketDestroy(const std::vector<UidRange>& uids,
64 const std::vector<int32_t>& skipUids) override;
Lorenzo Colittid33e96d2016-12-15 23:59:01 +090065
66 // Resolver commands.
Pierre Imaibeedec32016-04-13 06:44:51 +090067 binder::Status setResolverConfiguration(int32_t netId, const std::vector<std::string>& servers,
Ben Schwartz4204ecf2017-10-02 12:35:48 -040068 const std::vector<std::string>& domains, const std::vector<int32_t>& params,
69 bool useTls, const std::string& tlsName,
70 const std::vector<std::string>& tlsFingerprints) override;
Pierre Imaibeedec32016-04-13 06:44:51 +090071 binder::Status getResolverInfo(int32_t netId, std::vector<std::string>* servers,
72 std::vector<std::string>* domains, std::vector<int32_t>* params,
73 std::vector<int32_t>* stats) override;
Erik Klinef48e4dd2016-07-18 04:02:07 +090074
Joel Scherpelzde937962017-06-01 13:20:21 +090075 binder::Status setIPv6AddrGenMode(const std::string& ifName, int32_t mode) override;
76
Joel Scherpelz08b84cd2017-05-22 13:11:54 +090077 // NFLOG-related commands
78 binder::Status wakeupAddInterface(const std::string& ifName, const std::string& prefix,
79 int32_t mark, int32_t mask) override;
80
81 binder::Status wakeupDelInterface(const std::string& ifName, const std::string& prefix,
82 int32_t mark, int32_t mask) override;
83
Erik Klinef48e4dd2016-07-18 04:02:07 +090084 // Tethering-related commands.
85 binder::Status tetherApplyDnsInterfaces(bool *ret) override;
Lorenzo Colitti9a8a9ff2017-01-31 19:06:59 +090086 binder::Status tetherGetStats(android::os::PersistableBundle *ret) override;
Erik Kline53c20882016-08-02 15:22:53 +090087
Lorenzo Colittid33e96d2016-12-15 23:59:01 +090088 // Interface-related commands.
Erik Kline53c20882016-08-02 15:22:53 +090089 binder::Status interfaceAddAddress(const std::string &ifName,
90 const std::string &addrString, int prefixLength) override;
91 binder::Status interfaceDelAddress(const std::string &ifName,
92 const std::string &addrString, int prefixLength) override;
Erik Kline55b06f82016-07-04 09:57:18 +090093
94 binder::Status setProcSysNet(
95 int32_t family, int32_t which, const std::string &ifname, const std::string &parameter,
96 const std::string &value) override;
Robin Lee2cf56172016-09-13 18:55:42 +090097
98 // Metrics reporting level set / get (internal use only).
99 binder::Status getMetricsReportingLevel(int *reportingLevel) override;
100 binder::Status setMetricsReportingLevel(const int reportingLevel) override;
Nathan Harold1a371532017-01-30 12:30:48 -0800101
Benedict Wongb2daefb2017-12-06 22:05:46 -0800102 binder::Status ipSecSetEncapSocketOwner(const android::base::unique_fd& socket, int newUid);
103
Nathan Harold1a371532017-01-30 12:30:48 -0800104 binder::Status ipSecAllocateSpi(
105 int32_t transformId,
Nathan Harold1a371532017-01-30 12:30:48 -0800106 const std::string& localAddress,
107 const std::string& remoteAddress,
108 int32_t inSpi,
109 int32_t* outSpi);
110
111 binder::Status ipSecAddSecurityAssociation(
112 int32_t transformId,
113 int32_t mode,
Nathan Haroldda54f122018-01-09 16:42:57 -0800114 const std::string& sourceAddress,
115 const std::string& destinationAddress,
Benedict Wong96abf482018-01-22 13:56:41 -0800116 int32_t underlyingNetId,
Nathan Harold1a371532017-01-30 12:30:48 -0800117 int32_t spi,
Di Lu2ccb3e52018-01-03 16:19:20 -0800118 int32_t markValue,
119 int32_t markMask,
Nathan Harold1a371532017-01-30 12:30:48 -0800120 const std::string& authAlgo,
121 const std::vector<uint8_t>& authKey,
122 int32_t authTruncBits,
123 const std::string& cryptAlgo,
124 const std::vector<uint8_t>& cryptKey,
125 int32_t cryptTruncBits,
Benedict Wongbe65b432017-08-22 21:43:14 -0700126 const std::string& aeadAlgo,
127 const std::vector<uint8_t>& aeadKey,
128 int32_t aeadIcvBits,
Nathan Harold1a371532017-01-30 12:30:48 -0800129 int32_t encapType,
130 int32_t encapLocalPort,
ludiec836052017-05-20 14:17:05 -0700131 int32_t encapRemotePort);
Nathan Harold1a371532017-01-30 12:30:48 -0800132
133 binder::Status ipSecDeleteSecurityAssociation(
134 int32_t transformId,
Nathan Haroldda54f122018-01-09 16:42:57 -0800135 const std::string& sourceAddress,
136 const std::string& destinationAddress,
Di Lu2ccb3e52018-01-03 16:19:20 -0800137 int32_t spi,
138 int32_t markValue,
139 int32_t markMask);
Nathan Harold1a371532017-01-30 12:30:48 -0800140
141 binder::Status ipSecApplyTransportModeTransform(
142 const android::base::unique_fd& socket,
143 int32_t transformId,
144 int32_t direction,
Nathan Haroldda54f122018-01-09 16:42:57 -0800145 const std::string& sourceAddress,
146 const std::string& destinationAddress,
Nathan Harold1a371532017-01-30 12:30:48 -0800147 int32_t spi);
148
149 binder::Status ipSecRemoveTransportModeTransform(
150 const android::base::unique_fd& socket);
Chenbo Feng07d43fe2017-12-21 14:38:51 -0800151
Benedict Wong84a8dca2018-01-19 12:12:17 -0800152 binder::Status ipSecAddSecurityPolicy(
153 int32_t transformId,
154 int32_t direction,
155 const std::string& sourceAddress,
156 const std::string& destinationAddress,
157 int32_t spi,
158 int32_t markValue,
159 int32_t markMask);
160
161 binder::Status ipSecUpdateSecurityPolicy(
162 int32_t transformId,
163 int32_t direction,
164 const std::string& sourceAddress,
165 const std::string& destinationAddress,
166 int32_t spi,
167 int32_t markValue,
168 int32_t markMask);
169
170 binder::Status ipSecDeleteSecurityPolicy(
171 int32_t transformId,
172 int32_t direction,
173 const std::string& sourceAddress,
174 const std::string& destinationAddress,
175 int32_t markValue,
176 int32_t markMask);
177
Chenbo Feng07d43fe2017-12-21 14:38:51 -0800178 binder::Status trafficCheckBpfStatsEnable(bool* ret) override;
manojboopathi8707f232018-01-02 14:45:47 -0800179
180 binder::Status addVirtualTunnelInterface(
181 const std::string& deviceName,
182 const std::string& localAddress,
183 const std::string& remoteAddress,
184 int32_t iKey,
185 int32_t oKey);
186
187 binder::Status updateVirtualTunnelInterface(
188 const std::string& deviceName,
189 const std::string& localAddress,
190 const std::string& remoteAddress,
191 int32_t iKey,
192 int32_t oKey);
193
194 binder::Status removeVirtualTunnelInterface(const std::string& deviceName);
Lorenzo Colittie4d626e2016-02-02 17:19:04 +0900195};
196
197} // namespace net
198} // namespace android
199
200#endif // _NETD_NATIVE_SERVICE_H_