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 | 89faa34 | 2016-02-26 11:38:47 +0900 | [diff] [blame] | 37 | binder::Status firewallReplaceUidChain( |
Erik Kline | 2d3a163 | 2016-03-15 16:33:48 +0900 | [diff] [blame] | 38 | const String16& chainName, bool isWhitelist, |
| 39 | const std::vector<int32_t>& uids, bool *ret) override; |
Lorenzo Colitti | dedd271 | 2016-03-22 12:36:29 +0900 | [diff] [blame] | 40 | binder::Status bandwidthEnableDataSaver(bool enable, bool *ret) override; |
Robin Lee | b808736 | 2016-03-30 18:43:08 +0100 | [diff] [blame] | 41 | binder::Status networkRejectNonSecureVpn(bool enable, const std::vector<UidRange>& uids) |
| 42 | override; |
Lorenzo Colitti | 563d98b | 2016-04-24 13:13:14 +0900 | [diff] [blame] | 43 | binder::Status socketDestroy(const std::vector<UidRange>& uids, |
| 44 | const std::vector<int32_t>& skipUids) override; |
Pierre Imai | beedec3 | 2016-04-13 06:44:51 +0900 | [diff] [blame] | 45 | binder::Status setResolverConfiguration(int32_t netId, const std::vector<std::string>& servers, |
| 46 | const std::vector<std::string>& domains, const std::vector<int32_t>& params) override; |
| 47 | binder::Status getResolverInfo(int32_t netId, std::vector<std::string>* servers, |
| 48 | std::vector<std::string>* domains, std::vector<int32_t>* params, |
| 49 | std::vector<int32_t>* stats) override; |
Erik Kline | f48e4dd | 2016-07-18 04:02:07 +0900 | [diff] [blame] | 50 | |
Joel Scherpelz | 08b84cd | 2017-05-22 13:11:54 +0900 | [diff] [blame^] | 51 | // NFLOG-related commands |
| 52 | binder::Status wakeupAddInterface(const std::string& ifName, const std::string& prefix, |
| 53 | int32_t mark, int32_t mask) override; |
| 54 | |
| 55 | binder::Status wakeupDelInterface(const std::string& ifName, const std::string& prefix, |
| 56 | int32_t mark, int32_t mask) override; |
| 57 | |
Erik Kline | f48e4dd | 2016-07-18 04:02:07 +0900 | [diff] [blame] | 58 | // Tethering-related commands. |
| 59 | binder::Status tetherApplyDnsInterfaces(bool *ret) override; |
Erik Kline | 53c2088 | 2016-08-02 15:22:53 +0900 | [diff] [blame] | 60 | |
| 61 | binder::Status interfaceAddAddress(const std::string &ifName, |
| 62 | const std::string &addrString, int prefixLength) override; |
| 63 | binder::Status interfaceDelAddress(const std::string &ifName, |
| 64 | const std::string &addrString, int prefixLength) override; |
Erik Kline | 55b06f8 | 2016-07-04 09:57:18 +0900 | [diff] [blame] | 65 | |
| 66 | binder::Status setProcSysNet( |
| 67 | int32_t family, int32_t which, const std::string &ifname, const std::string ¶meter, |
| 68 | const std::string &value) override; |
Robin Lee | 2cf5617 | 2016-09-13 18:55:42 +0900 | [diff] [blame] | 69 | |
| 70 | // Metrics reporting level set / get (internal use only). |
| 71 | binder::Status getMetricsReportingLevel(int *reportingLevel) override; |
| 72 | binder::Status setMetricsReportingLevel(const int reportingLevel) override; |
Nathan Harold | 1a37153 | 2017-01-30 12:30:48 -0800 | [diff] [blame] | 73 | |
| 74 | binder::Status ipSecAllocateSpi( |
| 75 | int32_t transformId, |
| 76 | int32_t direction, |
| 77 | const std::string& localAddress, |
| 78 | const std::string& remoteAddress, |
| 79 | int32_t inSpi, |
| 80 | int32_t* outSpi); |
| 81 | |
| 82 | binder::Status ipSecAddSecurityAssociation( |
| 83 | int32_t transformId, |
| 84 | int32_t mode, |
| 85 | int32_t direction, |
| 86 | const std::string& localAddress, |
| 87 | const std::string& remoteAddress, |
| 88 | int64_t underlyingNetworkHandle, |
| 89 | int32_t spi, |
| 90 | const std::string& authAlgo, |
| 91 | const std::vector<uint8_t>& authKey, |
| 92 | int32_t authTruncBits, |
| 93 | const std::string& cryptAlgo, |
| 94 | const std::vector<uint8_t>& cryptKey, |
| 95 | int32_t cryptTruncBits, |
| 96 | int32_t encapType, |
| 97 | int32_t encapLocalPort, |
| 98 | int32_t encapRemotePort, |
| 99 | int32_t* allocatedSpi); |
| 100 | |
| 101 | binder::Status ipSecDeleteSecurityAssociation( |
| 102 | int32_t transformId, |
| 103 | int32_t direction, |
| 104 | const std::string& localAddress, |
| 105 | const std::string& remoteAddress, |
| 106 | int32_t spi); |
| 107 | |
| 108 | binder::Status ipSecApplyTransportModeTransform( |
| 109 | const android::base::unique_fd& socket, |
| 110 | int32_t transformId, |
| 111 | int32_t direction, |
| 112 | const std::string& localAddress, |
| 113 | const std::string& remoteAddress, |
| 114 | int32_t spi); |
| 115 | |
| 116 | binder::Status ipSecRemoveTransportModeTransform( |
| 117 | const android::base::unique_fd& socket); |
Lorenzo Colitti | e4d626e | 2016-02-02 17:19:04 +0900 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | } // namespace net |
| 121 | } // namespace android |
| 122 | |
| 123 | #endif // _NETD_NATIVE_SERVICE_H_ |