1 /* 2 * Copyright (c) 2021 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 #ifndef NETSYS_NATIVE_SERVICE_PROXY_H__ 16 #define NETSYS_NATIVE_SERVICE_PROXY_H__ 17 18 #include "i_netsys_service.h" 19 #include "iremote_proxy.h" 20 21 namespace OHOS { 22 namespace NetsysNative { 23 class NetsysNativeServiceProxy : public IRemoteProxy<INetsysService> { 24 public: NetsysNativeServiceProxy(const sptr<IRemoteObject> & impl)25 explicit NetsysNativeServiceProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<INetsysService>(impl) {} ~NetsysNativeServiceProxy()26 ~NetsysNativeServiceProxy() override {} 27 bool WriteInterfaceToken(MessageParcel &data); 28 int32_t SetResolverConfigParcel(const DnsresolverParamsParcel& resolvParams) override; 29 int32_t SetResolverConfig(const DnsresolverParams &resolvParams) override; 30 int32_t GetResolverConfig(const uint16_t netid, std::vector<std::string> &servers, 31 std::vector<std::string> &domains, nmd::DnsResParams ¶m) override; 32 int32_t CreateNetworkCache(const uint16_t netid) override; 33 int32_t FlushNetworkCache(const uint16_t netid) override; 34 int32_t DestroyNetworkCache(const uint16_t netid) override; 35 int32_t Getaddrinfo(const char* node, const char* service, const struct addrinfo* hints, 36 struct addrinfo** result, uint16_t netid) override; 37 int32_t InterfaceSetMtu(const std::string &interfaceName, int32_t mtu) override; 38 int32_t InterfaceGetMtu(const std::string &interfaceName) override; 39 40 int32_t RegisterNotifyCallback(sptr<INotifyCallback> &callback) override; 41 42 int32_t NetworkAddRoute(int32_t netId, const std::string &interfaceName, const std::string &destination, 43 const std::string &nextHop) override; 44 int32_t NetworkRemoveRoute(int32_t netId, const std::string &interfaceName, const std::string &destination, 45 const std::string &nextHop) override; 46 int32_t NetworkAddRouteParcel(int32_t netId, const RouteInfoParcel &routeInfo) override; 47 int32_t NetworkRemoveRouteParcel(int32_t netId, const RouteInfoParcel &routeInfo) override; 48 int32_t NetworkSetDefault(int32_t netId) override; 49 int32_t NetworkGetDefault() override; 50 int32_t NetworkClearDefault() override; 51 int32_t GetProcSysNet(int32_t ipversion, int32_t which, const std::string &ifname, 52 const std::string ¶meter, std::string &value) override; 53 int32_t SetProcSysNet(int32_t ipversion, int32_t which, const std::string &ifname, 54 const std::string ¶meter, std::string &value) override; 55 int32_t NetworkCreatePhysical(int32_t netId, int32_t permission) override; 56 int32_t InterfaceAddAddress(const std::string &interfaceName, const std::string &addrString, 57 int32_t prefixLength) override; 58 int32_t InterfaceDelAddress(const std::string &interfaceName, const std::string &addrString, 59 int32_t prefixLength) override; 60 int32_t NetworkAddInterface(int32_t netId, const std::string &iface) override; 61 int32_t NetworkRemoveInterface(int32_t netId, const std::string &iface) override; 62 int32_t NetworkDestroy(int32_t netId) override; 63 int32_t GetFwmarkForNetwork(int32_t netId, MarkMaskParcel &markMaskParcel) override; 64 int32_t InterfaceSetConfig(const InterfaceConfigurationParcel &cfg) override; 65 int32_t InterfaceGetConfig(InterfaceConfigurationParcel &cfg) override ; 66 int32_t StartDhcpClient(const std::string &iface, bool bIpv6) override; 67 int32_t InterfaceGetList(std::vector<std::string> &ifaces) override; 68 int32_t StopDhcpClient(const std::string &iface, bool bIpv6) override; 69 int32_t StartDhcpService(const std::string &iface, const std::string &ipv4addr) override; 70 int32_t StopDhcpService(const std::string &iface) override; 71 private: 72 static inline BrokerDelegator<NetsysNativeServiceProxy> delegator_; 73 }; 74 } // namespace NetsysNative 75 } // namespace OHOS 76 #endif