• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 #include "http_proxy.h"
22 
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     int32_t GetIpOrMacAddress(const AppExecFwk::ElementName &admin, const std::string &networkInterface, int policyCode,
36         std::string &info);
37     int32_t SetNetworkInterfaceDisabled(const AppExecFwk::ElementName &admin, const std::string &networkInterface,
38         bool isDisabled);
39     int32_t IsNetworkInterfaceDisabled(const AppExecFwk::ElementName &admin, const std::string &networkInterface,
40         bool &status);
41     int32_t AddIptablesFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::AddFilter &filter);
42     int32_t RemoveIptablesFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::RemoveFilter &filter);
43     int32_t ListIptablesFilterRules(const AppExecFwk::ElementName &admin, std::string &result);
44     int32_t AddFirewallRule(const AppExecFwk::ElementName &admin, const IPTABLES::FirewallRule &rule);
45     int32_t RemoveFirewallRule(const AppExecFwk::ElementName &admin, const IPTABLES::FirewallRule &rule);
46     int32_t GetFirewallRules(const AppExecFwk::ElementName &admin, std::vector<IPTABLES::FirewallRule> &result);
47     int32_t AddDomainFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::DomainFilterRule &rule);
48     int32_t RemoveDomainFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::DomainFilterRule &rule);
49     int32_t GetDomainFilterRules(const AppExecFwk::ElementName &admin, std::vector<IPTABLES::DomainFilterRule> &rule);
50     int32_t SetGlobalHttpProxy(const AppExecFwk::ElementName &admin, const NetManagerStandard::HttpProxy &httpProxy);
51     int32_t GetGlobalHttpProxy(const AppExecFwk::ElementName *admin, NetManagerStandard::HttpProxy &httpProxy);
52 
53 private:
54     static std::shared_ptr<NetworkManagerProxy> instance_;
55     static std::mutex mutexLock_;
56 };
57 } // namespace EDM
58 } // namespace OHOS
59 
60 #endif // INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_NETWORK_MANAGER_PROXY_H
61