1 /* 2 * Copyright (c) 2022 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 void RegisterConnService(const sptr<NetConnBaseService> &service); 41 42 int32_t GetIfaceStatsDetail(const std::string &iface, uint32_t start, uint32_t end, NetStatsInfo &info); 43 int32_t ResetStatsFactory(); 44 void RegisterStatsService(const sptr<NetStatsBaseService> &service); 45 46 int32_t ResetPolicyFactory(); 47 int32_t ResetPolicies(); 48 void RegisterPolicyService(const sptr<NetPolicyBaseService> &service); 49 50 int32_t ResetEthernetFactory(); 51 void RegisterEthernetService(const sptr<NetEthernetBaseService> &service); 52 53 int32_t GetAddressesByName(const std::string &hostName, int32_t netId, std::vector<INetAddr> &addrInfo); 54 void RegisterDnsService(const sptr<DnsBaseService> &service); 55 56 int32_t RestrictBackgroundChanged(bool isRestrictBackground); 57 bool IsUidNetAccess(uint32_t uid, bool metered); 58 bool IsUidNetAllowed(uint32_t uid, bool metered); 59 60 private: 61 sptr<NetConnBaseService> connService_; 62 sptr<NetStatsBaseService> statsService_; 63 sptr<NetPolicyBaseService> policyService_; 64 sptr<NetEthernetBaseService> ethernetService_; 65 sptr<DnsBaseService> dnsService_; 66 }; 67 } // namespace NetManagerStandard 68 } // namespace OHOS 69 #endif // NET_MANAGER_CENTER_H 70