1 /*
2  * Copyright (c) 2021-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 #include "net_conn_service_iface.h"
17 #include "net_conn_service.h"
18 #include "net_mgr_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace NetManagerStandard {
GetIfaceNames(NetBearType bearerType,std::list<std::string> & ifaceNames)22 int32_t NetConnServiceIface::GetIfaceNames(NetBearType bearerType, std::list<std::string> &ifaceNames)
23 {
24     return NetConnService::GetInstance()->GetIfaceNames(bearerType, ifaceNames);
25 }
26 
GetIfaceNameByType(NetBearType bearerType,const std::string & ident,std::string & ifaceName)27 int32_t NetConnServiceIface::GetIfaceNameByType(NetBearType bearerType, const std::string &ident,
28                                                 std::string &ifaceName)
29 {
30     return NetConnService::GetInstance()->GetIfaceNameByType(bearerType, ident, ifaceName);
31 }
32 
EnableVnicNetwork(const sptr<NetLinkInfo> & netLinkInfo,const std::set<int32_t> & uids)33 int32_t NetConnServiceIface::EnableVnicNetwork(const sptr<NetLinkInfo> &netLinkInfo, const std::set<int32_t> &uids)
34 {
35     return NetConnService::GetInstance()->EnableVnicNetwork(netLinkInfo, uids);
36 }
37 
DisableVnicNetwork()38 int32_t NetConnServiceIface::DisableVnicNetwork()
39 {
40     return NetConnService::GetInstance()->DisableVnicNetwork();
41 }
42 
RegisterNetSupplier(NetBearType bearerType,const std::string & ident,const std::set<NetCap> & netCaps,uint32_t & supplierId)43 int32_t NetConnServiceIface::RegisterNetSupplier(NetBearType bearerType, const std::string &ident,
44                                                  const std::set<NetCap> &netCaps, uint32_t &supplierId)
45 {
46     return NetConnService::GetInstance()->RegisterNetSupplier(bearerType, ident, netCaps, supplierId);
47 }
48 
UnregisterNetSupplier(uint32_t supplierId)49 int32_t NetConnServiceIface::UnregisterNetSupplier(uint32_t supplierId)
50 {
51     return NetConnService::GetInstance()->UnregisterNetSupplier(supplierId);
52 }
53 
UpdateNetLinkInfo(uint32_t supplierId,const sptr<NetLinkInfo> & netLinkInfo)54 int32_t NetConnServiceIface::UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo)
55 {
56     return NetConnService::GetInstance()->UpdateNetLinkInfo(supplierId, netLinkInfo);
57 }
58 
UpdateNetSupplierInfo(uint32_t supplierId,const sptr<NetSupplierInfo> & netSupplierInfo)59 int32_t NetConnServiceIface::UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo)
60 {
61     return NetConnService::GetInstance()->UpdateNetSupplierInfo(supplierId, netSupplierInfo);
62 }
63 
RestrictBackgroundChanged(bool isRestrictBackground)64 int32_t NetConnServiceIface::RestrictBackgroundChanged(bool isRestrictBackground)
65 {
66     return NetConnService::GetInstance()->RestrictBackgroundChanged(isRestrictBackground);
67 }
68 
RegisterNetConnCallback(const sptr<INetConnCallback> & callback)69 int32_t NetConnServiceIface::RegisterNetConnCallback(const sptr<INetConnCallback> &callback)
70 {
71     return NetConnService::GetInstance()->RegisterNetConnCallback(callback);
72 }
73 
RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> & callback)74 int32_t NetConnServiceIface::RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback)
75 {
76     return NetConnService::GetInstance()->RegisterNetFactoryResetCallback(callback);
77 }
78 
IsAddrInOtherNetwork(const std::string & ifaceName,int32_t netId,const INetAddr & netAddr)79 bool NetConnServiceIface::IsAddrInOtherNetwork(const std::string &ifaceName, int32_t netId, const INetAddr &netAddr)
80 {
81     return NetConnService::GetInstance()->IsAddrInOtherNetwork(ifaceName, netId, netAddr);
82 }
IsIfaceNameInUse(const std::string & ifaceName,int32_t netId)83 bool NetConnServiceIface::IsIfaceNameInUse(const std::string &ifaceName, int32_t netId)
84 {
85     return NetConnService::GetInstance()->IsIfaceNameInUse(ifaceName, netId);
86 }
87 
GetNetCapabilitiesAsString(const uint32_t supplierId) const88 std::string NetConnServiceIface::GetNetCapabilitiesAsString(const uint32_t supplierId) const
89 {
90     return NetConnService::GetInstance()->GetNetCapabilitiesAsString(supplierId);
91 }
92 } // namespace NetManagerStandard
93 } // namespace OHOS