blob: ec4360a3e7b08b353b28e19db42e0d490d92d2ce [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#define LOG_TAG "Netd"
18
Lorenzo Colitti89faa342016-02-26 11:38:47 +090019#include <vector>
20
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090021#include <android-base/stringprintf.h>
22#include <cutils/log.h>
Robin Lee2cf56172016-09-13 18:55:42 +090023#include <cutils/properties.h>
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090024#include <utils/Errors.h>
Pierre Imaibeedec32016-04-13 06:44:51 +090025#include <utils/String16.h>
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090026
27#include <binder/IPCThreadState.h>
28#include <binder/IServiceManager.h>
29#include "android/net/BnNetd.h"
30
Ben Schwartze7601812017-04-28 16:38:29 -040031#include <openssl/base64.h>
32
Lorenzo Colitti89faa342016-02-26 11:38:47 +090033#include "Controllers.h"
Erik Kline2d3a1632016-03-15 16:33:48 +090034#include "DumpWriter.h"
Michal Karpinskid5440112016-10-06 16:56:04 +010035#include "EventReporter.h"
Erik Kline55b06f82016-07-04 09:57:18 +090036#include "InterfaceController.h"
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090037#include "NetdConstants.h"
38#include "NetdNativeService.h"
Robin Leeb8087362016-03-30 18:43:08 +010039#include "RouteController.h"
Lorenzo Colitti563d98b2016-04-24 13:13:14 +090040#include "SockDiag.h"
Robin Leeb8087362016-03-30 18:43:08 +010041#include "UidRanges.h"
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090042
43using android::base::StringPrintf;
Lorenzo Colitti9a8a9ff2017-01-31 19:06:59 +090044using android::os::PersistableBundle;
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090045
46namespace android {
47namespace net {
48
49namespace {
50
51const char CONNECTIVITY_INTERNAL[] = "android.permission.CONNECTIVITY_INTERNAL";
Joel Scherpelz08b84cd2017-05-22 13:11:54 +090052const char NETWORK_STACK[] = "android.permission.NETWORK_STACK";
Erik Kline2d3a1632016-03-15 16:33:48 +090053const char DUMP[] = "android.permission.DUMP";
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090054
Joel Scherpelz08b84cd2017-05-22 13:11:54 +090055binder::Status toBinderStatus(const netdutils::Status s) {
56 if (isOk(s)) {
57 return binder::Status::ok();
58 }
Joel Scherpelzde937962017-06-01 13:20:21 +090059 return binder::Status::fromServiceSpecificError(s.code(), s.msg().c_str());
Joel Scherpelz08b84cd2017-05-22 13:11:54 +090060}
61
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090062binder::Status checkPermission(const char *permission) {
63 pid_t pid;
64 uid_t uid;
65
66 if (checkCallingPermission(String16(permission), (int32_t *) &pid, (int32_t *) &uid)) {
67 return binder::Status::ok();
68 } else {
69 auto err = StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission);
70 return binder::Status::fromExceptionCode(binder::Status::EX_SECURITY, String8(err.c_str()));
71 }
72}
73
Nathan Harold1a371532017-01-30 12:30:48 -080074binder::Status getXfrmStatus(int xfrmCode) {
75 switch(xfrmCode) {
76 case 0:
77 return binder::Status::ok();
78 case -ENOENT:
79 return binder::Status::fromServiceSpecificError(xfrmCode);
80 }
81 return binder::Status::fromExceptionCode(xfrmCode);
82}
83
Robin Lee2cf56172016-09-13 18:55:42 +090084#define ENFORCE_DEBUGGABLE() { \
85 char value[PROPERTY_VALUE_MAX + 1]; \
86 if (property_get("ro.debuggable", value, NULL) != 1 \
87 || value[0] != '1') { \
88 return binder::Status::fromExceptionCode( \
89 binder::Status::EX_SECURITY, \
90 String8("Not available in production builds.") \
91 ); \
92 } \
93}
94
Lorenzo Colittie4d626e2016-02-02 17:19:04 +090095#define ENFORCE_PERMISSION(permission) { \
96 binder::Status status = checkPermission((permission)); \
97 if (!status.isOk()) { \
98 return status; \
99 } \
100}
101
Lorenzo Colitti89faa342016-02-26 11:38:47 +0900102#define NETD_LOCKING_RPC(permission, lock) \
103 ENFORCE_PERMISSION(permission); \
104 android::RWLock::AutoWLock _lock(lock);
105
106#define NETD_BIG_LOCK_RPC(permission) NETD_LOCKING_RPC((permission), gBigNetdLock)
Lorenzo Colittie4d626e2016-02-02 17:19:04 +0900107} // namespace
108
109
Lorenzo Colittie4851de2016-03-17 13:23:28 +0900110status_t NetdNativeService::start() {
111 IPCThreadState::self()->disableBackgroundScheduling(true);
112 status_t ret = BinderService<NetdNativeService>::publish();
113 if (ret != android::OK) {
114 return ret;
115 }
116 sp<ProcessState> ps(ProcessState::self());
117 ps->startThreadPool();
118 ps->giveThreadPoolName();
119 return android::OK;
120}
121
Erik Kline2d3a1632016-03-15 16:33:48 +0900122status_t NetdNativeService::dump(int fd, const Vector<String16> & /* args */) {
123 const binder::Status dump_permission = checkPermission(DUMP);
124 if (!dump_permission.isOk()) {
125 const String8 msg(dump_permission.toString8());
126 write(fd, msg.string(), msg.size());
127 return PERMISSION_DENIED;
128 }
129
130 // This method does not grab any locks. If individual classes need locking
131 // their dump() methods MUST handle locking appropriately.
132 DumpWriter dw(fd);
133 dw.blankline();
134 gCtls->netCtrl.dump(dw);
135 dw.blankline();
136
137 return NO_ERROR;
138}
139
Lorenzo Colittie4d626e2016-02-02 17:19:04 +0900140binder::Status NetdNativeService::isAlive(bool *alive) {
Lorenzo Colitti89faa342016-02-26 11:38:47 +0900141 NETD_BIG_LOCK_RPC(CONNECTIVITY_INTERNAL);
Lorenzo Colittie4d626e2016-02-02 17:19:04 +0900142
143 *alive = true;
144 return binder::Status::ok();
145}
146
Lorenzo Colitti89faa342016-02-26 11:38:47 +0900147binder::Status NetdNativeService::firewallReplaceUidChain(const android::String16& chainName,
148 bool isWhitelist, const std::vector<int32_t>& uids, bool *ret) {
149 NETD_LOCKING_RPC(CONNECTIVITY_INTERNAL, gCtls->firewallCtrl.lock);
150
151 android::String8 name = android::String8(chainName);
152 int err = gCtls->firewallCtrl.replaceUidChain(name.string(), isWhitelist, uids);
153 *ret = (err == 0);
154 return binder::Status::ok();
Lorenzo Colitti89faa342016-02-26 11:38:47 +0900155}
Lorenzo Colittidedd2712016-03-22 12:36:29 +0900156
157binder::Status NetdNativeService::bandwidthEnableDataSaver(bool enable, bool *ret) {
158 NETD_LOCKING_RPC(CONNECTIVITY_INTERNAL, gCtls->bandwidthCtrl.lock);
159
160 int err = gCtls->bandwidthCtrl.enableDataSaver(enable);
161 *ret = (err == 0);
162 return binder::Status::ok();
163}
164
Robin Leeb8087362016-03-30 18:43:08 +0100165binder::Status NetdNativeService::networkRejectNonSecureVpn(bool add,
166 const std::vector<UidRange>& uidRangeArray) {
167 // TODO: elsewhere RouteController is only used from the tethering and network controllers, so
168 // it should be possible to use the same lock as NetworkController. However, every call through
169 // the CommandListener "network" command will need to hold this lock too, not just the ones that
170 // read/modify network internal state (that is sufficient for ::dump() because it doesn't
171 // look at routes, but it's not enough here).
172 NETD_BIG_LOCK_RPC(CONNECTIVITY_INTERNAL);
173
Lorenzo Colitti563d98b2016-04-24 13:13:14 +0900174 UidRanges uidRanges(uidRangeArray);
Robin Leeb8087362016-03-30 18:43:08 +0100175
176 int err;
177 if (add) {
178 err = RouteController::addUsersToRejectNonSecureNetworkRule(uidRanges);
179 } else {
180 err = RouteController::removeUsersFromRejectNonSecureNetworkRule(uidRanges);
181 }
182
183 if (err != 0) {
184 return binder::Status::fromServiceSpecificError(-err,
185 String8::format("RouteController error: %s", strerror(-err)));
186 }
187 return binder::Status::ok();
188}
189
Lorenzo Colitti563d98b2016-04-24 13:13:14 +0900190binder::Status NetdNativeService::socketDestroy(const std::vector<UidRange>& uids,
191 const std::vector<int32_t>& skipUids) {
192
193 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
194
195 SockDiag sd;
196 if (!sd.open()) {
197 return binder::Status::fromServiceSpecificError(EIO,
198 String8("Could not open SOCK_DIAG socket"));
199 }
200
201 UidRanges uidRanges(uids);
Lorenzo Colittie5c3c992016-07-26 17:53:50 +0900202 int err = sd.destroySockets(uidRanges, std::set<uid_t>(skipUids.begin(), skipUids.end()),
203 true /* excludeLoopback */);
Lorenzo Colitti563d98b2016-04-24 13:13:14 +0900204
205 if (err) {
206 return binder::Status::fromServiceSpecificError(-err,
207 String8::format("destroySockets: %s", strerror(-err)));
208 }
Pierre Imaibeedec32016-04-13 06:44:51 +0900209 return binder::Status::ok();
210}
Lorenzo Colitti563d98b2016-04-24 13:13:14 +0900211
Pierre Imaibeedec32016-04-13 06:44:51 +0900212binder::Status NetdNativeService::setResolverConfiguration(int32_t netId,
213 const std::vector<std::string>& servers, const std::vector<std::string>& domains,
214 const std::vector<int32_t>& params) {
215 // This function intentionally does not lock within Netd, as Bionic is thread-safe.
216 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
217
218 int err = gCtls->resolverCtrl.setResolverConfiguration(netId, servers, domains, params);
219 if (err != 0) {
220 return binder::Status::fromServiceSpecificError(-err,
221 String8::format("ResolverController error: %s", strerror(-err)));
222 }
223 return binder::Status::ok();
224}
225
226binder::Status NetdNativeService::getResolverInfo(int32_t netId,
227 std::vector<std::string>* servers, std::vector<std::string>* domains,
228 std::vector<int32_t>* params, std::vector<int32_t>* stats) {
229 // This function intentionally does not lock within Netd, as Bionic is thread-safe.
230 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
231
232 int err = gCtls->resolverCtrl.getResolverInfo(netId, servers, domains, params, stats);
233 if (err != 0) {
234 return binder::Status::fromServiceSpecificError(-err,
235 String8::format("ResolverController error: %s", strerror(-err)));
236 }
Lorenzo Colitti563d98b2016-04-24 13:13:14 +0900237 return binder::Status::ok();
238}
239
Ben Schwartze7601812017-04-28 16:38:29 -0400240binder::Status NetdNativeService::addPrivateDnsServer(const std::string& server, int32_t port,
241 const std::string& fingerprintAlgorithm, const std::vector<std::string>& fingerprints) {
242 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
243 std::set<std::vector<uint8_t>> decoded_fingerprints;
244 for (const std::string& input : fingerprints) {
245 size_t out_len;
246 if (EVP_DecodedLength(&out_len, input.size()) != 1) {
247 return binder::Status::fromServiceSpecificError(INetd::PRIVATE_DNS_BAD_FINGERPRINT,
248 "ResolverController error: bad fingerprint length");
249 }
250 // out_len is now an upper bound on the output length.
251 std::vector<uint8_t> decoded(out_len);
252 if (EVP_DecodeBase64(decoded.data(), &out_len, decoded.size(),
253 reinterpret_cast<const uint8_t*>(input.data()), input.size()) == 1) {
254 // Possibly shrink the vector if the actual output was smaller than the bound.
255 decoded.resize(out_len);
256 } else {
257 return binder::Status::fromServiceSpecificError(INetd::PRIVATE_DNS_BAD_FINGERPRINT,
258 "ResolverController error: Base64 parsing failed");
259 }
260 decoded_fingerprints.insert(decoded);
261 }
262 const int err = gCtls->resolverCtrl.addPrivateDnsServer(server, port,
263 fingerprintAlgorithm, decoded_fingerprints);
264 if (err != INetd::PRIVATE_DNS_SUCCESS) {
265 return binder::Status::fromServiceSpecificError(err,
266 String8::format("ResolverController error: %d", err));
267 }
268 return binder::Status::ok();
269}
270
271binder::Status NetdNativeService::removePrivateDnsServer(const std::string& server) {
272 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
273 const int err = gCtls->resolverCtrl.removePrivateDnsServer(server);
274 if (err != INetd::PRIVATE_DNS_SUCCESS) {
275 return binder::Status::fromServiceSpecificError(err,
276 String8::format("ResolverController error: %d", err));
277 }
278 return binder::Status::ok();
279}
280
Erik Klinef48e4dd2016-07-18 04:02:07 +0900281binder::Status NetdNativeService::tetherApplyDnsInterfaces(bool *ret) {
Lorenzo Colitti9a8a9ff2017-01-31 19:06:59 +0900282 NETD_LOCKING_RPC(NETWORK_STACK, gCtls->tetherCtrl.lock)
Erik Klinef48e4dd2016-07-18 04:02:07 +0900283
284 *ret = gCtls->tetherCtrl.applyDnsInterfaces();
285 return binder::Status::ok();
286}
287
Lorenzo Colitti9a8a9ff2017-01-31 19:06:59 +0900288namespace {
289
290void tetherAddStats(PersistableBundle *bundle, const TetherController::TetherStats& stats) {
291 String16 iface = String16(stats.extIface.c_str());
292 std::vector<int64_t> statsVector(INetd::TETHER_STATS_ARRAY_SIZE);
293
294 bundle->getLongVector(iface, &statsVector);
295 if (statsVector.size() == 0) {
296 for (int i = 0; i < INetd::TETHER_STATS_ARRAY_SIZE; i++) statsVector.push_back(0);
297 }
298
299 // Note: currently, TetherController::addForwardChainStats swaps TX and RX counters.
300 // Specifically, when parsing iptables counters like this:
301 //
302 // Chain tetherctrl_counters (0 references)
303 // pkts bytes target prot opt in out source destination
304 // 4107 214602 RETURN all -- rndis0 rmnet_data0 0.0.0.0/0 0.0.0.0/0
305 // 6937 10361624 RETURN all -- rmnet_data0 rndis0 0.0.0.0/0 0.0.0.0/0
306 //
307 // it will return a TetherStatsList with one element that has intIface rndis0 and extIface
308 // rmnet_data0 (correct) but with rxBytes=214602 and txBytes=10361624 (swapped). Because the
309 // code in getTetherStats and the corresponding code in NetworkManagementService swaps the
310 // counters again, this all works.
311 //
312 // TODO: once "bandwidth gettetherstats" is gone, swap the counters in addForwardChainStats.
313 statsVector[INetd::TETHER_STATS_RX_BYTES] += stats.txBytes;
314 statsVector[INetd::TETHER_STATS_RX_PACKETS] += stats.txPackets;
315 statsVector[INetd::TETHER_STATS_TX_BYTES] += stats.rxBytes;
316 statsVector[INetd::TETHER_STATS_TX_PACKETS] += stats.rxPackets;
317
318 bundle->putLongVector(iface, statsVector);
319}
320
321} // namespace
322
323binder::Status NetdNativeService::tetherGetStats(PersistableBundle *bundle) {
324 NETD_LOCKING_RPC(NETWORK_STACK, gCtls->tetherCtrl.lock)
325
Lorenzo Colitti5192bf72017-09-04 13:30:59 +0900326 const auto& statsList = gCtls->tetherCtrl.getTetherStats();
Lorenzo Colitti9a8a9ff2017-01-31 19:06:59 +0900327 if (!isOk(statsList)) {
328 return toBinderStatus(statsList);
329 }
330
331 for (const auto& stats : statsList.value()) {
332 tetherAddStats(bundle, stats);
333 }
334
335 return binder::Status::ok();
336}
337
Erik Kline53c20882016-08-02 15:22:53 +0900338binder::Status NetdNativeService::interfaceAddAddress(const std::string &ifName,
339 const std::string &addrString, int prefixLength) {
340 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
341
342 const int err = InterfaceController::addAddress(
343 ifName.c_str(), addrString.c_str(), prefixLength);
344 if (err != 0) {
345 return binder::Status::fromServiceSpecificError(-err,
346 String8::format("InterfaceController error: %s", strerror(-err)));
347 }
348 return binder::Status::ok();
349}
350
351binder::Status NetdNativeService::interfaceDelAddress(const std::string &ifName,
352 const std::string &addrString, int prefixLength) {
353 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
354
355 const int err = InterfaceController::delAddress(
356 ifName.c_str(), addrString.c_str(), prefixLength);
357 if (err != 0) {
358 return binder::Status::fromServiceSpecificError(-err,
359 String8::format("InterfaceController error: %s", strerror(-err)));
360 }
361 return binder::Status::ok();
362}
363
Erik Kline55b06f82016-07-04 09:57:18 +0900364binder::Status NetdNativeService::setProcSysNet(
365 int32_t family, int32_t which, const std::string &ifname, const std::string &parameter,
366 const std::string &value) {
367 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
368
369 const char *familyStr;
370 switch (family) {
371 case INetd::IPV4:
372 familyStr = "ipv4";
373 break;
374 case INetd::IPV6:
375 familyStr = "ipv6";
376 break;
377 default:
378 return binder::Status::fromServiceSpecificError(EAFNOSUPPORT, String8("Bad family"));
379 }
380
381 const char *whichStr;
382 switch (which) {
383 case INetd::CONF:
384 whichStr = "conf";
385 break;
386 case INetd::NEIGH:
387 whichStr = "neigh";
388 break;
389 default:
390 return binder::Status::fromServiceSpecificError(EINVAL, String8("Bad category"));
391 }
392
393 const int err = InterfaceController::setParameter(
394 familyStr, whichStr, ifname.c_str(), parameter.c_str(),
395 value.c_str());
396 if (err != 0) {
397 return binder::Status::fromServiceSpecificError(-err,
398 String8::format("ResolverController error: %s", strerror(-err)));
399 }
400 return binder::Status::ok();
401}
402
Robin Lee2cf56172016-09-13 18:55:42 +0900403binder::Status NetdNativeService::getMetricsReportingLevel(int *reportingLevel) {
404 // This function intentionally does not lock, since the only thing it does is one read from an
405 // atomic_int.
406 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
407 ENFORCE_DEBUGGABLE();
408
Michal Karpinskid5440112016-10-06 16:56:04 +0100409 *reportingLevel = gCtls->eventReporter.getMetricsReportingLevel();
Robin Lee2cf56172016-09-13 18:55:42 +0900410 return binder::Status::ok();
411}
412
413binder::Status NetdNativeService::setMetricsReportingLevel(const int reportingLevel) {
414 // This function intentionally does not lock, since the only thing it does is one write to an
415 // atomic_int.
416 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
417 ENFORCE_DEBUGGABLE();
418
Michal Karpinskid5440112016-10-06 16:56:04 +0100419 return (gCtls->eventReporter.setMetricsReportingLevel(reportingLevel) == 0)
420 ? binder::Status::ok()
421 : binder::Status::fromExceptionCode(binder::Status::EX_ILLEGAL_ARGUMENT);
Robin Lee2cf56172016-09-13 18:55:42 +0900422}
423
Nathan Harold1a371532017-01-30 12:30:48 -0800424binder::Status NetdNativeService::ipSecAllocateSpi(
425 int32_t transformId,
426 int32_t direction,
427 const std::string& localAddress,
428 const std::string& remoteAddress,
429 int32_t inSpi,
430 int32_t* outSpi) {
431 // Necessary locking done in IpSecService and kernel
432 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
433 ALOGD("ipSecAllocateSpi()");
434 return getXfrmStatus(gCtls->xfrmCtrl.ipSecAllocateSpi(
435 transformId,
436 direction,
437 localAddress,
438 remoteAddress,
439 inSpi,
440 outSpi));
441}
442
443binder::Status NetdNativeService::ipSecAddSecurityAssociation(
444 int32_t transformId,
445 int32_t mode,
446 int32_t direction,
447 const std::string& localAddress,
448 const std::string& remoteAddress,
449 int64_t underlyingNetworkHandle,
450 int32_t spi,
451 const std::string& authAlgo, const std::vector<uint8_t>& authKey, int32_t authTruncBits,
452 const std::string& cryptAlgo, const std::vector<uint8_t>& cryptKey, int32_t cryptTruncBits,
453 int32_t encapType,
454 int32_t encapLocalPort,
ludiec836052017-05-20 14:17:05 -0700455 int32_t encapRemotePort) {
Nathan Harold1a371532017-01-30 12:30:48 -0800456 // Necessary locking done in IpSecService and kernel
457 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
458 ALOGD("ipSecAddSecurityAssociation()");
459 return getXfrmStatus(gCtls->xfrmCtrl.ipSecAddSecurityAssociation(
460 transformId, mode, direction, localAddress, remoteAddress,
461 underlyingNetworkHandle,
462 spi,
463 authAlgo, authKey, authTruncBits,
464 cryptAlgo, cryptKey, cryptTruncBits,
ludiec836052017-05-20 14:17:05 -0700465 encapType, encapLocalPort, encapRemotePort));
Nathan Harold1a371532017-01-30 12:30:48 -0800466}
467
468binder::Status NetdNativeService::ipSecDeleteSecurityAssociation(
469 int32_t transformId,
470 int32_t direction,
471 const std::string& localAddress,
472 const std::string& remoteAddress,
473 int32_t spi) {
474 // Necessary locking done in IpSecService and kernel
475 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
476 ALOGD("ipSecDeleteSecurityAssociation()");
477 return getXfrmStatus(gCtls->xfrmCtrl.ipSecDeleteSecurityAssociation(
478 transformId,
479 direction,
480 localAddress,
481 remoteAddress,
482 spi));
483}
484
485binder::Status NetdNativeService::ipSecApplyTransportModeTransform(
486 const android::base::unique_fd& socket,
487 int32_t transformId,
488 int32_t direction,
489 const std::string& localAddress,
490 const std::string& remoteAddress,
491 int32_t spi) {
492 // Necessary locking done in IpSecService and kernel
493 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
494 ALOGD("ipSecApplyTransportModeTransform()");
495 return getXfrmStatus(gCtls->xfrmCtrl.ipSecApplyTransportModeTransform(
496 socket,
497 transformId,
498 direction,
499 localAddress,
500 remoteAddress,
501 spi));
502}
503
504binder::Status NetdNativeService::ipSecRemoveTransportModeTransform(
505 const android::base::unique_fd& socket) {
506 // Necessary locking done in IpSecService and kernel
507 ENFORCE_PERMISSION(CONNECTIVITY_INTERNAL);
508 ALOGD("ipSecRemoveTransportModeTransform()");
509 return getXfrmStatus(gCtls->xfrmCtrl.ipSecRemoveTransportModeTransform(
510 socket));
511}
512
Joel Scherpelzde937962017-06-01 13:20:21 +0900513binder::Status NetdNativeService::setIPv6AddrGenMode(const std::string& ifName,
514 int32_t mode) {
515 ENFORCE_PERMISSION(NETWORK_STACK);
516 return toBinderStatus(InterfaceController::setIPv6AddrGenMode(ifName, mode));
517}
518
Joel Scherpelz08b84cd2017-05-22 13:11:54 +0900519binder::Status NetdNativeService::wakeupAddInterface(const std::string& ifName,
520 const std::string& prefix, int32_t mark,
521 int32_t mask) {
522 ENFORCE_PERMISSION(NETWORK_STACK);
523 return toBinderStatus(gCtls->wakeupCtrl.addInterface(ifName, prefix, mark, mask));
524}
525
526binder::Status NetdNativeService::wakeupDelInterface(const std::string& ifName,
527 const std::string& prefix, int32_t mark,
528 int32_t mask) {
529 ENFORCE_PERMISSION(NETWORK_STACK);
530 return toBinderStatus(gCtls->wakeupCtrl.delInterface(ifName, prefix, mark, mask));
531}
532
Lorenzo Colittie4d626e2016-02-02 17:19:04 +0900533} // namespace net
534} // namespace android