Lorenzo Colitti | e4d626e | 2016-02-02 17:19:04 +0900 | [diff] [blame] | 1 | /** |
| 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 Colitti | 89faa34 | 2016-02-26 11:38:47 +0900 | [diff] [blame] | 20 | #include <vector> |
| 21 | |
Lorenzo Colitti | e4d626e | 2016-02-02 17:19:04 +0900 | [diff] [blame] | 22 | #include <binder/BinderService.h> |
| 23 | |
| 24 | #include "android/net/BnNetd.h" |
Robin Lee | 9f9aae9 | 2016-03-30 18:33:07 +0100 | [diff] [blame] | 25 | #include "android/net/UidRange.h" |
Lorenzo Colitti | e4d626e | 2016-02-02 17:19:04 +0900 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | namespace net { |
| 29 | |
| 30 | class NetdNativeService : public BinderService<NetdNativeService>, public BnNetd { |
| 31 | public: |
Lorenzo Colitti | e4851de | 2016-03-17 13:23:28 +0900 | [diff] [blame] | 32 | static status_t start(); |
Lorenzo Colitti | c2c7b75 | 2016-02-23 22:25:11 +0900 | [diff] [blame] | 33 | static char const* getServiceName() { return "netd"; } |
Erik Kline | 2d3a163 | 2016-03-15 16:33:48 +0900 | [diff] [blame] | 34 | virtual status_t dump(int fd, const Vector<String16> &args) override; |
| 35 | |
Lorenzo Colitti | e4d626e | 2016-02-02 17:19:04 +0900 | [diff] [blame] | 36 | binder::Status isAlive(bool *alive) override; |
Lorenzo Colitti | d33e96d | 2016-12-15 23:59:01 +0900 | [diff] [blame] | 37 | |
| 38 | // Firewall commands. |
Lorenzo Colitti | 89faa34 | 2016-02-26 11:38:47 +0900 | [diff] [blame] | 39 | binder::Status firewallReplaceUidChain( |
Erik Kline | 2d3a163 | 2016-03-15 16:33:48 +0900 | [diff] [blame] | 40 | const String16& chainName, bool isWhitelist, |
| 41 | const std::vector<int32_t>& uids, bool *ret) override; |
Lorenzo Colitti | d33e96d | 2016-12-15 23:59:01 +0900 | [diff] [blame] | 42 | |
| 43 | // Bandwidth control commands. |
Lorenzo Colitti | dedd271 | 2016-03-22 12:36:29 +0900 | [diff] [blame] | 44 | binder::Status bandwidthEnableDataSaver(bool enable, bool *ret) override; |
Lorenzo Colitti | d33e96d | 2016-12-15 23:59:01 +0900 | [diff] [blame] | 45 | |
| 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 Lee | b808736 | 2016-03-30 18:43:08 +0100 | [diff] [blame] | 59 | binder::Status networkRejectNonSecureVpn(bool enable, const std::vector<UidRange>& uids) |
| 60 | override; |
Lorenzo Colitti | d33e96d | 2016-12-15 23:59:01 +0900 | [diff] [blame] | 61 | |
| 62 | // SOCK_DIAG commands. |
Lorenzo Colitti | 563d98b | 2016-04-24 13:13:14 +0900 | [diff] [blame] | 63 | binder::Status socketDestroy(const std::vector<UidRange>& uids, |
| 64 | const std::vector<int32_t>& skipUids) override; |
Lorenzo Colitti | d33e96d | 2016-12-15 23:59:01 +0900 | [diff] [blame] | 65 | |
| 66 | // Resolver commands. |
Pierre Imai | beedec3 | 2016-04-13 06:44:51 +0900 | [diff] [blame] | 67 | binder::Status setResolverConfiguration(int32_t netId, const std::vector<std::string>& servers, |
Ben Schwartz | 4204ecf | 2017-10-02 12:35:48 -0400 | [diff] [blame] | 68 | 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 Imai | beedec3 | 2016-04-13 06:44:51 +0900 | [diff] [blame] | 71 | 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 Kline | f48e4dd | 2016-07-18 04:02:07 +0900 | [diff] [blame] | 74 | |
Joel Scherpelz | de93796 | 2017-06-01 13:20:21 +0900 | [diff] [blame] | 75 | binder::Status setIPv6AddrGenMode(const std::string& ifName, int32_t mode) override; |
| 76 | |
Joel Scherpelz | 08b84cd | 2017-05-22 13:11:54 +0900 | [diff] [blame] | 77 | // 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 Kline | f48e4dd | 2016-07-18 04:02:07 +0900 | [diff] [blame] | 84 | // Tethering-related commands. |
| 85 | binder::Status tetherApplyDnsInterfaces(bool *ret) override; |
Lorenzo Colitti | 9a8a9ff | 2017-01-31 19:06:59 +0900 | [diff] [blame] | 86 | binder::Status tetherGetStats(android::os::PersistableBundle *ret) override; |
Erik Kline | 53c2088 | 2016-08-02 15:22:53 +0900 | [diff] [blame] | 87 | |
Lorenzo Colitti | d33e96d | 2016-12-15 23:59:01 +0900 | [diff] [blame] | 88 | // Interface-related commands. |
Erik Kline | 53c2088 | 2016-08-02 15:22:53 +0900 | [diff] [blame] | 89 | 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 Kline | 55b06f8 | 2016-07-04 09:57:18 +0900 | [diff] [blame] | 93 | |
| 94 | binder::Status setProcSysNet( |
| 95 | int32_t family, int32_t which, const std::string &ifname, const std::string ¶meter, |
| 96 | const std::string &value) override; |
Robin Lee | 2cf5617 | 2016-09-13 18:55:42 +0900 | [diff] [blame] | 97 | |
| 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 Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 101 | |
Benedict Wong | b2daefb | 2017-12-06 22:05:46 -0800 | [diff] [blame] | 102 | binder::Status ipSecSetEncapSocketOwner(const android::base::unique_fd& socket, int newUid); |
| 103 | |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 104 | binder::Status ipSecAllocateSpi( |
| 105 | int32_t transformId, |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 106 | 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 Harold | da54f12 | 2018-01-09 16:42:57 -0800 | [diff] [blame] | 114 | const std::string& sourceAddress, |
| 115 | const std::string& destinationAddress, |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 116 | int64_t underlyingNetworkHandle, |
| 117 | int32_t spi, |
Di Lu | 2ccb3e5 | 2018-01-03 16:19:20 -0800 | [diff] [blame^] | 118 | int32_t markValue, |
| 119 | int32_t markMask, |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 120 | 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 Wong | be65b43 | 2017-08-22 21:43:14 -0700 | [diff] [blame] | 126 | const std::string& aeadAlgo, |
| 127 | const std::vector<uint8_t>& aeadKey, |
| 128 | int32_t aeadIcvBits, |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 129 | int32_t encapType, |
| 130 | int32_t encapLocalPort, |
ludi | ec83605 | 2017-05-20 14:17:05 -0700 | [diff] [blame] | 131 | int32_t encapRemotePort); |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 132 | |
| 133 | binder::Status ipSecDeleteSecurityAssociation( |
| 134 | int32_t transformId, |
Nathan Harold | da54f12 | 2018-01-09 16:42:57 -0800 | [diff] [blame] | 135 | const std::string& sourceAddress, |
| 136 | const std::string& destinationAddress, |
Di Lu | 2ccb3e5 | 2018-01-03 16:19:20 -0800 | [diff] [blame^] | 137 | int32_t spi, |
| 138 | int32_t markValue, |
| 139 | int32_t markMask); |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 140 | |
| 141 | binder::Status ipSecApplyTransportModeTransform( |
| 142 | const android::base::unique_fd& socket, |
| 143 | int32_t transformId, |
| 144 | int32_t direction, |
Nathan Harold | da54f12 | 2018-01-09 16:42:57 -0800 | [diff] [blame] | 145 | const std::string& sourceAddress, |
| 146 | const std::string& destinationAddress, |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 147 | int32_t spi); |
| 148 | |
| 149 | binder::Status ipSecRemoveTransportModeTransform( |
| 150 | const android::base::unique_fd& socket); |
Lorenzo Colitti | e4d626e | 2016-02-02 17:19:04 +0900 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | } // namespace net |
| 154 | } // namespace android |
| 155 | |
| 156 | #endif // _NETD_NATIVE_SERVICE_H_ |