1b1b8bc3fSopenharmony_ci/*
2b1b8bc3fSopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3b1b8bc3fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4b1b8bc3fSopenharmony_ci * you may not use this file except in compliance with the License.
5b1b8bc3fSopenharmony_ci * You may obtain a copy of the License at
6b1b8bc3fSopenharmony_ci *
7b1b8bc3fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8b1b8bc3fSopenharmony_ci *
9b1b8bc3fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10b1b8bc3fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11b1b8bc3fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12b1b8bc3fSopenharmony_ci * See the License for the specific language governing permissions and
13b1b8bc3fSopenharmony_ci * limitations under the License.
14b1b8bc3fSopenharmony_ci */
15b1b8bc3fSopenharmony_ci
16b1b8bc3fSopenharmony_ci#ifndef NET_MANAGER_CENTER_H
17b1b8bc3fSopenharmony_ci#define NET_MANAGER_CENTER_H
18b1b8bc3fSopenharmony_ci
19b1b8bc3fSopenharmony_ci#include <set>
20b1b8bc3fSopenharmony_ci
21b1b8bc3fSopenharmony_ci#include "dns_base_service.h"
22b1b8bc3fSopenharmony_ci#include "net_all_capabilities.h"
23b1b8bc3fSopenharmony_ci#include "net_conn_base_service.h"
24b1b8bc3fSopenharmony_ci#include "net_ethernet_base_service.h"
25b1b8bc3fSopenharmony_ci#include "net_policy_base_service.h"
26b1b8bc3fSopenharmony_ci#include "net_stats_base_service.h"
27b1b8bc3fSopenharmony_ci
28b1b8bc3fSopenharmony_cinamespace OHOS {
29b1b8bc3fSopenharmony_cinamespace NetManagerStandard {
30b1b8bc3fSopenharmony_ciclass NetManagerCenter {
31b1b8bc3fSopenharmony_cipublic:
32b1b8bc3fSopenharmony_ci    static NetManagerCenter &GetInstance();
33b1b8bc3fSopenharmony_ci    int32_t GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames);
34b1b8bc3fSopenharmony_ci    int32_t GetIfaceNameByType(NetBearType bearerType, const std::string &ident, std::string &ifaceName);
35b1b8bc3fSopenharmony_ci    int32_t RegisterNetSupplier(NetBearType bearerType, const std::string &ident, const std::set<NetCap> &netCaps,
36b1b8bc3fSopenharmony_ci                                uint32_t &supplierId);
37b1b8bc3fSopenharmony_ci    int32_t UnregisterNetSupplier(uint32_t supplierId);
38b1b8bc3fSopenharmony_ci    int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo);
39b1b8bc3fSopenharmony_ci    int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo);
40b1b8bc3fSopenharmony_ci    int32_t RegisterNetConnCallback(const sptr<INetConnCallback> &callback);
41b1b8bc3fSopenharmony_ci    void RegisterConnService(const sptr<NetConnBaseService> &service);
42b1b8bc3fSopenharmony_ci
43b1b8bc3fSopenharmony_ci    int32_t GetIfaceStatsDetail(const std::string &iface, uint64_t start, uint64_t end, NetStatsInfo &info);
44b1b8bc3fSopenharmony_ci    int32_t ResetStatsFactory();
45b1b8bc3fSopenharmony_ci    void RegisterStatsService(const sptr<NetStatsBaseService> &service);
46b1b8bc3fSopenharmony_ci
47b1b8bc3fSopenharmony_ci    int32_t ResetPolicyFactory();
48b1b8bc3fSopenharmony_ci    int32_t ResetPolicies();
49b1b8bc3fSopenharmony_ci    void RegisterPolicyService(const sptr<NetPolicyBaseService> &service);
50b1b8bc3fSopenharmony_ci
51b1b8bc3fSopenharmony_ci    int32_t ResetEthernetFactory();
52b1b8bc3fSopenharmony_ci    void RegisterEthernetService(const sptr<NetEthernetBaseService> &service);
53b1b8bc3fSopenharmony_ci
54b1b8bc3fSopenharmony_ci    int32_t GetAddressesByName(const std::string &hostName, int32_t netId, std::vector<INetAddr> &addrInfo);
55b1b8bc3fSopenharmony_ci    void RegisterDnsService(const sptr<DnsBaseService> &service);
56b1b8bc3fSopenharmony_ci
57b1b8bc3fSopenharmony_ci    int32_t RestrictBackgroundChanged(bool isRestrictBackground);
58b1b8bc3fSopenharmony_ci    bool IsUidNetAccess(uint32_t uid, bool metered);
59b1b8bc3fSopenharmony_ci    bool IsUidNetAllowed(uint32_t uid, bool metered);
60b1b8bc3fSopenharmony_ci
61b1b8bc3fSopenharmony_ci    int32_t RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback);
62b1b8bc3fSopenharmony_ci
63b1b8bc3fSopenharmony_ciprivate:
64b1b8bc3fSopenharmony_ci    sptr<NetConnBaseService> connService_;
65b1b8bc3fSopenharmony_ci    sptr<NetStatsBaseService> statsService_;
66b1b8bc3fSopenharmony_ci    sptr<NetPolicyBaseService> policyService_;
67b1b8bc3fSopenharmony_ci    sptr<NetEthernetBaseService> ethernetService_;
68b1b8bc3fSopenharmony_ci    sptr<DnsBaseService> dnsService_;
69b1b8bc3fSopenharmony_ci};
70b1b8bc3fSopenharmony_ci} // namespace NetManagerStandard
71b1b8bc3fSopenharmony_ci} // namespace OHOS
72b1b8bc3fSopenharmony_ci#endif // NET_MANAGER_CENTER_H
73