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 20 #include <vector> 21 22 #include <binder/BinderService.h> 23 24 #include "android/net/BnNetd.h" 25 #include "android/net/UidRange.h" 26 27 namespace android { 28 namespace net { 29 30 class NetdNativeService : public BinderService<NetdNativeService>, public BnNetd { 31 public: 32 static status_t start(); getServiceName()33 static char const* getServiceName() { return "netd"; } 34 virtual status_t dump(int fd, const Vector<String16> &args) override; 35 36 binder::Status isAlive(bool *alive) override; 37 binder::Status firewallReplaceUidChain( 38 const String16& chainName, bool isWhitelist, 39 const std::vector<int32_t>& uids, bool *ret) override; 40 binder::Status bandwidthEnableDataSaver(bool enable, bool *ret) override; 41 binder::Status networkRejectNonSecureVpn(bool enable, const std::vector<UidRange>& uids) 42 override; 43 binder::Status socketDestroy(const std::vector<UidRange>& uids, 44 const std::vector<int32_t>& skipUids) override; 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; 50 51 // Tethering-related commands. 52 binder::Status tetherApplyDnsInterfaces(bool *ret) override; 53 54 binder::Status interfaceAddAddress(const std::string &ifName, 55 const std::string &addrString, int prefixLength) override; 56 binder::Status interfaceDelAddress(const std::string &ifName, 57 const std::string &addrString, int prefixLength) override; 58 59 binder::Status setProcSysNet( 60 int32_t family, int32_t which, const std::string &ifname, const std::string ¶meter, 61 const std::string &value) override; 62 63 // Metrics reporting level set / get (internal use only). 64 binder::Status getMetricsReportingLevel(int *reportingLevel) override; 65 binder::Status setMetricsReportingLevel(const int reportingLevel) override; 66 67 binder::Status ipSecAllocateSpi( 68 int32_t transformId, 69 int32_t direction, 70 const std::string& localAddress, 71 const std::string& remoteAddress, 72 int32_t inSpi, 73 int32_t* outSpi); 74 75 binder::Status ipSecAddSecurityAssociation( 76 int32_t transformId, 77 int32_t mode, 78 int32_t direction, 79 const std::string& localAddress, 80 const std::string& remoteAddress, 81 int64_t underlyingNetworkHandle, 82 int32_t spi, 83 const std::string& authAlgo, 84 const std::vector<uint8_t>& authKey, 85 int32_t authTruncBits, 86 const std::string& cryptAlgo, 87 const std::vector<uint8_t>& cryptKey, 88 int32_t cryptTruncBits, 89 int32_t encapType, 90 int32_t encapLocalPort, 91 int32_t encapRemotePort, 92 int32_t* allocatedSpi); 93 94 binder::Status ipSecDeleteSecurityAssociation( 95 int32_t transformId, 96 int32_t direction, 97 const std::string& localAddress, 98 const std::string& remoteAddress, 99 int32_t spi); 100 101 binder::Status ipSecApplyTransportModeTransform( 102 const android::base::unique_fd& socket, 103 int32_t transformId, 104 int32_t direction, 105 const std::string& localAddress, 106 const std::string& remoteAddress, 107 int32_t spi); 108 109 binder::Status ipSecRemoveTransportModeTransform( 110 const android::base::unique_fd& socket); 111 112 }; 113 114 } // namespace net 115 } // namespace android 116 117 #endif // _NETD_NATIVE_SERVICE_H_ 118