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 
EnableDistributedClientNet(const std::string &virnicAddr, const std::string &iif)43 int32_t NetConnServiceIface::EnableDistributedClientNet(const std::string &virnicAddr, const std::string &iif)
44 {
45     return NetConnService::GetInstance()->EnableDistributedClientNet(virnicAddr, iif);
46 }
47 
EnableDistributedServerNet(const std::string &iif, const std::string &devIface, const std::string &dstAddr)48 int32_t NetConnServiceIface::EnableDistributedServerNet(const std::string &iif, const std::string &devIface,
49                                                         const std::string &dstAddr)
50 {
51     return NetConnService::GetInstance()->EnableDistributedServerNet(iif, devIface, dstAddr);
52 }
53 
DisableDistributedNet(bool isServer)54 int32_t NetConnServiceIface::DisableDistributedNet(bool isServer)
55 {
56     return NetConnService::GetInstance()->DisableDistributedNet(isServer);
57 }
58 
RegisterNetSupplier(NetBearType bearerType, const std::string &ident, const std::set<NetCap> &netCaps, uint32_t &supplierId)59 int32_t NetConnServiceIface::RegisterNetSupplier(NetBearType bearerType, const std::string &ident,
60                                                  const std::set<NetCap> &netCaps, uint32_t &supplierId)
61 {
62     return NetConnService::GetInstance()->RegisterNetSupplier(bearerType, ident, netCaps, supplierId);
63 }
64 
UnregisterNetSupplier(uint32_t supplierId)65 int32_t NetConnServiceIface::UnregisterNetSupplier(uint32_t supplierId)
66 {
67     return NetConnService::GetInstance()->UnregisterNetSupplier(supplierId);
68 }
69 
UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo)70 int32_t NetConnServiceIface::UpdateNetLinkInfo(uint32_t supplierId, const sptr<NetLinkInfo> &netLinkInfo)
71 {
72     return NetConnService::GetInstance()->UpdateNetLinkInfo(supplierId, netLinkInfo);
73 }
74 
UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo)75 int32_t NetConnServiceIface::UpdateNetSupplierInfo(uint32_t supplierId, const sptr<NetSupplierInfo> &netSupplierInfo)
76 {
77     return NetConnService::GetInstance()->UpdateNetSupplierInfo(supplierId, netSupplierInfo);
78 }
79 
RestrictBackgroundChanged(bool isRestrictBackground)80 int32_t NetConnServiceIface::RestrictBackgroundChanged(bool isRestrictBackground)
81 {
82     return NetConnService::GetInstance()->RestrictBackgroundChanged(isRestrictBackground);
83 }
84 
RegisterNetConnCallback(const sptr<INetConnCallback> &callback)85 int32_t NetConnServiceIface::RegisterNetConnCallback(const sptr<INetConnCallback> &callback)
86 {
87     return NetConnService::GetInstance()->RegisterNetConnCallback(callback);
88 }
89 
RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback)90 int32_t NetConnServiceIface::RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback)
91 {
92     return NetConnService::GetInstance()->RegisterNetFactoryResetCallback(callback);
93 }
94 
IsIfaceNameInUse(const std::string &ifaceName, int32_t netId)95 bool NetConnServiceIface::IsIfaceNameInUse(const std::string &ifaceName, int32_t netId)
96 {
97     return NetConnService::GetInstance()->IsIfaceNameInUse(ifaceName, netId);
98 }
99 
GetNetCapabilitiesAsString(const uint32_t supplierId) const100 std::string NetConnServiceIface::GetNetCapabilitiesAsString(const uint32_t supplierId) const
101 {
102     return NetConnService::GetInstance()->GetNetCapabilitiesAsString(supplierId);
103 }
104 } // namespace NetManagerStandard
105 } // namespace OHOS