1 /* 2 * Copyright (c) 2022-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 NET_MANAGER_CENTER_H 17 #define NET_MANAGER_CENTER_H 18 19 #include <set> 20 21 #include "dns_base_service.h" 22 #include "net_all_capabilities.h" 23 #include "net_conn_base_service.h" 24 #include "net_ethernet_base_service.h" 25 #include "net_policy_base_service.h" 26 #include "net_stats_base_service.h" 27 28 namespace OHOS { 29 namespace NetManagerStandard { 30 class NetManagerCenter { 31 public: 32 static NetManagerCenter &GetInstance(); 33 int32_t GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames); 34 int32_t GetIfaceNameByType(NetBearType bearerType, const std::string &ident, std::string &ifaceName); 35 int32_t RegisterNetSupplier(NetBearType bearerType, const std::string &ident, const std::set<NetCap> &netCaps, 36 uint32_t &supplierId); 37 int32_t UnregisterNetSupplier(uint32_t supplierId); 38 int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo); 39 int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo); 40 int32_t RegisterNetConnCallback(const sptr<INetConnCallback> &callback); 41 void RegisterConnService(const sptr<NetConnBaseService> &service); 42 43 int32_t GetIfaceStatsDetail(const std::string &iface, uint64_t start, uint64_t end, NetStatsInfo &info); 44 int32_t ResetStatsFactory(); 45 void RegisterStatsService(const sptr<NetStatsBaseService> &service); 46 47 int32_t ResetPolicyFactory(); 48 int32_t ResetPolicies(); 49 void RegisterPolicyService(const sptr<NetPolicyBaseService> &service); 50 51 int32_t ResetEthernetFactory(); 52 void RegisterEthernetService(const sptr<NetEthernetBaseService> &service); 53 54 int32_t GetAddressesByName(const std::string &hostName, int32_t netId, std::vector<INetAddr> &addrInfo); 55 void RegisterDnsService(const sptr<DnsBaseService> &service); 56 57 int32_t RestrictBackgroundChanged(bool isRestrictBackground); 58 bool IsUidNetAccess(uint32_t uid, bool metered); 59 bool IsUidNetAllowed(uint32_t uid, bool metered); 60 61 int32_t RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback); 62 63 private: 64 sptr<NetConnBaseService> connService_; 65 sptr<NetStatsBaseService> statsService_; 66 sptr<NetPolicyBaseService> policyService_; 67 sptr<NetEthernetBaseService> ethernetService_; 68 sptr<DnsBaseService> dnsService_; 69 }; 70 } // namespace NetManagerStandard 71 } // namespace OHOS 72 #endif // NET_MANAGER_CENTER_H 73