1 /* 2 * Copyright (c) 2023 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 INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_NETWORK_MANAGER_PROXY_H 17 #define INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_NETWORK_MANAGER_PROXY_H 18 19 #include "enterprise_device_mgr_proxy.h" 20 #ifdef NETMANAGER_BASE_EDM_ENABLE 21 #include "http_proxy.h" 22 #endif 23 #include "domain_filter_rule.h" 24 #include "firewall_rule.h" 25 #include "iptables_utils.h" 26 27 namespace OHOS { 28 namespace EDM { 29 class NetworkManagerProxy { 30 public: 31 NetworkManagerProxy(); 32 ~NetworkManagerProxy(); 33 static std::shared_ptr<NetworkManagerProxy> GetNetworkManagerProxy(); 34 int32_t GetAllNetworkInterfaces(const AppExecFwk::ElementName &admin, std::vector<std::string> &networkInterface, 35 bool isSync = false); 36 int32_t GetIpOrMacAddress(const AppExecFwk::ElementName &admin, const std::string &networkInterface, int policyCode, 37 std::string &info, bool isSync = false); 38 int32_t SetNetworkInterfaceDisabled(const AppExecFwk::ElementName &admin, const std::string &networkInterface, 39 bool isDisabled, bool isSync = false); 40 int32_t IsNetworkInterfaceDisabled(const AppExecFwk::ElementName &admin, const std::string &networkInterface, 41 bool &status, bool isSync = false); 42 int32_t AddIptablesFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::AddFilter &filter); 43 int32_t RemoveIptablesFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::RemoveFilter &filter); 44 int32_t ListIptablesFilterRules(const AppExecFwk::ElementName &admin, std::string &result); 45 int32_t AddFirewallRule(const AppExecFwk::ElementName &admin, const IPTABLES::FirewallRule &rule); 46 int32_t RemoveFirewallRule(const AppExecFwk::ElementName &admin, const IPTABLES::FirewallRule &rule); 47 int32_t GetFirewallRules(const AppExecFwk::ElementName &admin, std::vector<IPTABLES::FirewallRule> &result); 48 int32_t AddDomainFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::DomainFilterRule &rule); 49 int32_t RemoveDomainFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::DomainFilterRule &rule); 50 int32_t GetDomainFilterRules(const AppExecFwk::ElementName &admin, std::vector<IPTABLES::DomainFilterRule> &rule); 51 #ifdef NETMANAGER_BASE_EDM_ENABLE 52 int32_t SetGlobalHttpProxy(const AppExecFwk::ElementName &admin, const NetManagerStandard::HttpProxy &httpProxy); 53 int32_t GetGlobalHttpProxy(const AppExecFwk::ElementName *admin, NetManagerStandard::HttpProxy &httpProxy); 54 #endif 55 private: 56 static std::shared_ptr<NetworkManagerProxy> instance_; 57 static std::mutex mutexLock_; 58 }; 59 } // namespace EDM 60 } // namespace OHOS 61 62 #endif // INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_NETWORK_MANAGER_PROXY_H 63