1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NETSYS_NATIVE_SERVICE_PROXY_H 17 #define NETSYS_NATIVE_SERVICE_PROXY_H 18 19 #include "i_netsys_service.h" 20 #include "iremote_proxy.h" 21 22 namespace OHOS { 23 namespace NetsysNative { 24 class NetsysNativeServiceProxy : public IRemoteProxy<INetsysService> { 25 public: NetsysNativeServiceProxy(const sptr<IRemoteObject> & impl)26 explicit NetsysNativeServiceProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<INetsysService>(impl) {} ~NetsysNativeServiceProxy()27 ~NetsysNativeServiceProxy() override {} 28 bool WriteInterfaceToken(MessageParcel &data); 29 int32_t SetResolverConfig(uint16_t netId, uint16_t baseTimeoutMsec, uint8_t retryCount, 30 const std::vector<std::string> &servers, 31 const std::vector<std::string> &domains) override; 32 int32_t GetResolverConfig(const uint16_t netId, std::vector<std::string> &servers, 33 std::vector<std::string> &domains, uint16_t &baseTimeoutMsec, 34 uint8_t &retryCount) override; 35 int32_t CreateNetworkCache(const uint16_t netId) override; 36 int32_t DestroyNetworkCache(const uint16_t netId) override; 37 int32_t GetAddrInfo(const std::string &hostName, const std::string &serverName, const AddrInfo &hints, 38 uint16_t netId, std::vector<AddrInfo> &res) override; 39 int32_t InterfaceSetMtu(const std::string &interfaceName, int32_t mtu) override; 40 int32_t InterfaceGetMtu(const std::string &interfaceName) override; 41 42 int32_t RegisterNotifyCallback(sptr<INotifyCallback> &callback) override; 43 int32_t UnRegisterNotifyCallback(sptr<INotifyCallback> &callback) override; 44 45 int32_t NetworkAddRoute(int32_t netId, const std::string &interfaceName, const std::string &destination, 46 const std::string &nextHop) override; 47 int32_t NetworkRemoveRoute(int32_t netId, const std::string &interfaceName, const std::string &destination, 48 const std::string &nextHop) override; 49 int32_t NetworkAddRouteParcel(int32_t netId, const RouteInfoParcel &routeInfo) override; 50 int32_t NetworkRemoveRouteParcel(int32_t netId, const RouteInfoParcel &routeInfo) override; 51 int32_t NetworkSetDefault(int32_t netId) override; 52 int32_t NetworkGetDefault() override; 53 int32_t NetworkClearDefault() override; 54 int32_t GetProcSysNet(int32_t ipversion, int32_t which, const std::string &ifname, const std::string ¶meter, 55 std::string &value) override; 56 int32_t SetProcSysNet(int32_t ipversion, int32_t which, const std::string &ifname, const std::string ¶meter, 57 std::string &value) override; 58 int32_t NetworkCreatePhysical(int32_t netId, int32_t permission) override; 59 int32_t InterfaceAddAddress(const std::string &interfaceName, const std::string &addrString, 60 int32_t prefixLength) override; 61 int32_t InterfaceDelAddress(const std::string &interfaceName, const std::string &addrString, 62 int32_t prefixLength) override; 63 int32_t InterfaceSetIpAddress(const std::string &ifaceName, const std::string &ipAddress) override; 64 int32_t InterfaceSetIffUp(const std::string &ifaceName) override; 65 int32_t NetworkAddInterface(int32_t netId, const std::string &iface) override; 66 int32_t NetworkRemoveInterface(int32_t netId, const std::string &iface) override; 67 int32_t NetworkDestroy(int32_t netId) override; 68 int32_t GetFwmarkForNetwork(int32_t netId, MarkMaskParcel &markMaskParcel) override; 69 int32_t InterfaceSetConfig(const InterfaceConfigurationParcel &cfg) override; 70 int32_t InterfaceGetConfig(InterfaceConfigurationParcel &cfg) override; 71 int32_t StartDhcpClient(const std::string &iface, bool bIpv6) override; 72 int32_t InterfaceGetList(std::vector<std::string> &ifaces) override; 73 int32_t StopDhcpClient(const std::string &iface, bool bIpv6) override; 74 int32_t StartDhcpService(const std::string &iface, const std::string &ipv4addr) override; 75 int32_t StopDhcpService(const std::string &iface) override; 76 int32_t IpEnableForwarding(const std::string &requestor) override; 77 int32_t IpDisableForwarding(const std::string &requestor) override; 78 int32_t EnableNat(const std::string &downstreamIface, const std::string &upstreamIface) override; 79 int32_t DisableNat(const std::string &downstreamIface, const std::string &upstreamIface) override; 80 int32_t IpfwdAddInterfaceForward(const std::string &fromIface, const std::string &toIface) override; 81 int32_t IpfwdRemoveInterfaceForward(const std::string &fromIface, const std::string &toIface) override; 82 int32_t FirewallEnableChain(uint32_t chain, bool enable) override; 83 int32_t FirewallSetUidRule(uint32_t chain, uint32_t uid, uint32_t firewallRule) override; 84 int32_t BandwidthRemoveAllowedList(uint32_t uid) override; 85 int32_t FirewallSetUidsAllowedListChain(uint32_t chain, const std::vector<uint32_t> &uids) override; 86 int32_t FirewallSetUidsDeniedListChain(uint32_t chain, const std::vector<uint32_t> &uids) override; 87 int32_t BandwidthRemoveIfaceQuota(const std::string &ifName) override; 88 int32_t BandwidthRemoveDeniedList(uint32_t uid) override; 89 int32_t BandwidthAddDeniedList(uint32_t uid) override; 90 int32_t BandwidthAddAllowedList(uint32_t uid) override; 91 int32_t BandwidthEnableDataSaver(bool enable) override; 92 int32_t BandwidthSetIfaceQuota(const std::string &ifName, int64_t bytes) override; 93 int32_t ShareDnsSet(uint16_t netId) override; 94 int32_t StartDnsProxyListen() override; 95 int32_t StopDnsProxyListen() override; 96 int32_t GetNetworkSharingTraffic(const std::string &downIface, const std::string &upIface, 97 NetworkSharingTraffic &traffic) override; 98 99 private: 100 static inline BrokerDelegator<NetsysNativeServiceProxy> delegator_; 101 }; 102 } // namespace NetsysNative 103 } // namespace OHOS 104 #endif // NETSYS_NATIVE_SERVICE_PROXY_H 105