blob: 1a7ada52ec9b247a5925875b174337ec6c5b4442 [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 Colitti89faa342016-02-26 11:38:47 +090037 binder::Status firewallReplaceUidChain(
Erik Kline2d3a1632016-03-15 16:33:48 +090038 const String16& chainName, bool isWhitelist,
39 const std::vector<int32_t>& uids, bool *ret) override;
Lorenzo Colittidedd2712016-03-22 12:36:29 +090040 binder::Status bandwidthEnableDataSaver(bool enable, bool *ret) override;
Robin Leeb8087362016-03-30 18:43:08 +010041 binder::Status networkRejectNonSecureVpn(bool enable, const std::vector<UidRange>& uids)
42 override;
Lorenzo Colitti563d98b2016-04-24 13:13:14 +090043 binder::Status socketDestroy(const std::vector<UidRange>& uids,
44 const std::vector<int32_t>& skipUids) override;
Pierre Imaibeedec32016-04-13 06:44:51 +090045 binder::Status setResolverConfiguration(int32_t netId, const std::vector<std::string>& servers,
Ben Schwartz4204ecf2017-10-02 12:35:48 -040046 const std::vector<std::string>& domains, const std::vector<int32_t>& params,
47 bool useTls, const std::string& tlsName,
48 const std::vector<std::string>& tlsFingerprints) override;
Pierre Imaibeedec32016-04-13 06:44:51 +090049 binder::Status getResolverInfo(int32_t netId, std::vector<std::string>* servers,
50 std::vector<std::string>* domains, std::vector<int32_t>* params,
51 std::vector<int32_t>* stats) override;
Erik Klinef48e4dd2016-07-18 04:02:07 +090052
Joel Scherpelzde937962017-06-01 13:20:21 +090053 binder::Status setIPv6AddrGenMode(const std::string& ifName, int32_t mode) override;
54
Joel Scherpelz08b84cd2017-05-22 13:11:54 +090055 // NFLOG-related commands
56 binder::Status wakeupAddInterface(const std::string& ifName, const std::string& prefix,
57 int32_t mark, int32_t mask) override;
58
59 binder::Status wakeupDelInterface(const std::string& ifName, const std::string& prefix,
60 int32_t mark, int32_t mask) override;
61
Erik Klinef48e4dd2016-07-18 04:02:07 +090062 // Tethering-related commands.
63 binder::Status tetherApplyDnsInterfaces(bool *ret) override;
Lorenzo Colitti9a8a9ff2017-01-31 19:06:59 +090064 binder::Status tetherGetStats(android::os::PersistableBundle *ret) override;
Erik Kline53c20882016-08-02 15:22:53 +090065
66 binder::Status interfaceAddAddress(const std::string &ifName,
67 const std::string &addrString, int prefixLength) override;
68 binder::Status interfaceDelAddress(const std::string &ifName,
69 const std::string &addrString, int prefixLength) override;
Erik Kline55b06f82016-07-04 09:57:18 +090070
71 binder::Status setProcSysNet(
72 int32_t family, int32_t which, const std::string &ifname, const std::string &parameter,
73 const std::string &value) override;
Robin Lee2cf56172016-09-13 18:55:42 +090074
75 // Metrics reporting level set / get (internal use only).
76 binder::Status getMetricsReportingLevel(int *reportingLevel) override;
77 binder::Status setMetricsReportingLevel(const int reportingLevel) override;
Nathan Harold1a371532017-01-30 12:30:48 -080078
Benedict Wongb2daefb2017-12-06 22:05:46 -080079 binder::Status ipSecSetEncapSocketOwner(const android::base::unique_fd& socket, int newUid);
80
Nathan Harold1a371532017-01-30 12:30:48 -080081 binder::Status ipSecAllocateSpi(
82 int32_t transformId,
Nathan Harold1a371532017-01-30 12:30:48 -080083 const std::string& localAddress,
84 const std::string& remoteAddress,
85 int32_t inSpi,
86 int32_t* outSpi);
87
88 binder::Status ipSecAddSecurityAssociation(
89 int32_t transformId,
90 int32_t mode,
Nathan Haroldda54f122018-01-09 16:42:57 -080091 const std::string& sourceAddress,
92 const std::string& destinationAddress,
Nathan Harold1a371532017-01-30 12:30:48 -080093 int64_t underlyingNetworkHandle,
94 int32_t spi,
95 const std::string& authAlgo,
96 const std::vector<uint8_t>& authKey,
97 int32_t authTruncBits,
98 const std::string& cryptAlgo,
99 const std::vector<uint8_t>& cryptKey,
100 int32_t cryptTruncBits,
Benedict Wongbe65b432017-08-22 21:43:14 -0700101 const std::string& aeadAlgo,
102 const std::vector<uint8_t>& aeadKey,
103 int32_t aeadIcvBits,
Nathan Harold1a371532017-01-30 12:30:48 -0800104 int32_t encapType,
105 int32_t encapLocalPort,
ludiec836052017-05-20 14:17:05 -0700106 int32_t encapRemotePort);
Nathan Harold1a371532017-01-30 12:30:48 -0800107
108 binder::Status ipSecDeleteSecurityAssociation(
109 int32_t transformId,
Nathan Haroldda54f122018-01-09 16:42:57 -0800110 const std::string& sourceAddress,
111 const std::string& destinationAddress,
Nathan Harold1a371532017-01-30 12:30:48 -0800112 int32_t spi);
113
114 binder::Status ipSecApplyTransportModeTransform(
115 const android::base::unique_fd& socket,
116 int32_t transformId,
117 int32_t direction,
Nathan Haroldda54f122018-01-09 16:42:57 -0800118 const std::string& sourceAddress,
119 const std::string& destinationAddress,
Nathan Harold1a371532017-01-30 12:30:48 -0800120 int32_t spi);
121
122 binder::Status ipSecRemoveTransportModeTransform(
123 const android::base::unique_fd& socket);
Lorenzo Colittie4d626e2016-02-02 17:19:04 +0900124};
125
126} // namespace net
127} // namespace android
128
129#endif // _NETD_NATIVE_SERVICE_H_