• 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 #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 GetAllNetworkInterfaces(MessageParcel &data, std::vector<std::string> &networkInterface);
37     int32_t GetIpOrMacAddress(const AppExecFwk::ElementName &admin, const std::string &networkInterface, int policyCode,
38         std::string &info, bool isSync = false);
39     int32_t GetIpOrMacAddress(MessageParcel &data, int policyCode, std::string &info);
40     int32_t SetNetworkInterfaceDisabled(const AppExecFwk::ElementName &admin, const std::string &networkInterface,
41         bool isDisabled, bool isSync = false);
42     int32_t SetNetworkInterfaceDisabled(MessageParcel &data);
43     int32_t IsNetworkInterfaceDisabled(const AppExecFwk::ElementName &admin, const std::string &networkInterface,
44         bool &status, bool isSync = false);
45     int32_t IsNetworkInterfaceDisabled(MessageParcel &data, bool &status);
46     int32_t AddIptablesFilterRule(MessageParcel &data);
47     int32_t RemoveIptablesFilterRule(MessageParcel &data);
48     int32_t ListIptablesFilterRules(MessageParcel &data, std::string &result);
49     int32_t AddFirewallRule(MessageParcel &data);
50     int32_t RemoveFirewallRule(const AppExecFwk::ElementName &admin, const IPTABLES::FirewallRule &rule);
51     int32_t GetFirewallRules(MessageParcel &data, std::vector<IPTABLES::FirewallRule> &result);
52     int32_t AddDomainFilterRule(MessageParcel &data);
53     int32_t RemoveDomainFilterRule(const AppExecFwk::ElementName &admin, const IPTABLES::DomainFilterRule &rule);
54     int32_t GetDomainFilterRules(MessageParcel &data, std::vector<IPTABLES::DomainFilterRule> &rule);
55 #ifdef NETMANAGER_BASE_EDM_ENABLE
56     int32_t SetGlobalHttpProxy(MessageParcel &data);
57     int32_t GetGlobalHttpProxy(const AppExecFwk::ElementName *admin, NetManagerStandard::HttpProxy &httpProxy,
58         int32_t accountId = -1);
59 #endif
60 private:
61     static std::shared_ptr<NetworkManagerProxy> instance_;
62     static std::once_flag flag_;
63 };
64 } // namespace EDM
65 } // namespace OHOS
66 
67 #endif // INTERFACES_INNER_API_NETWORK_MANAGER_INCLUDE_NETWORK_MANAGER_PROXY_H
68