1 /*
2 * Copyright (c) 2021-2024 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 "netsys_controller_service_impl.h"
17
18 #include "net_mgr_log_wrapper.h"
19 #include "netmanager_base_common_utils.h"
20
21 using namespace OHOS::NetManagerStandard::CommonUtils;
22 namespace OHOS {
23 namespace NetManagerStandard {
24 namespace {
25 using namespace OHOS::NetsysNative;
26 } // namespace
27
Init()28 void NetsysControllerServiceImpl::Init()
29 {
30 mockNetsysClient_.RegisterMockApi();
31 }
32
SetInternetPermission(uint32_t uid,uint8_t allow)33 int32_t NetsysControllerServiceImpl::SetInternetPermission(uint32_t uid, uint8_t allow)
34 {
35 return netsysClient_.SetInternetPermission(uid, allow);
36 }
37
NetworkCreatePhysical(int32_t netId,int32_t permission)38 int32_t NetsysControllerServiceImpl::NetworkCreatePhysical(int32_t netId, int32_t permission)
39 {
40 NETMGR_LOG_I("Create Physical network: netId[%{public}d], permission[%{public}d]", netId, permission);
41 if (mockNetsysClient_.CheckMockApi(MOCK_NETWORKCREATEPHYSICAL_API)) {
42 return mockNetsysClient_.NetworkCreatePhysical(netId, permission);
43 }
44 return netsysClient_.NetworkCreatePhysical(netId, permission);
45 }
46
NetworkCreateVirtual(int32_t netId,bool hasDns)47 int32_t NetsysControllerServiceImpl::NetworkCreateVirtual(int32_t netId, bool hasDns)
48 {
49 NETMGR_LOG_I("Create Virtual network: netId[%{public}d], hasDns[%{public}d]", netId, hasDns);
50 return netsysClient_.NetworkCreateVirtual(netId, hasDns);
51 }
52
NetworkDestroy(int32_t netId)53 int32_t NetsysControllerServiceImpl::NetworkDestroy(int32_t netId)
54 {
55 NETMGR_LOG_I("Destroy network: netId[%{public}d]", netId);
56 if (mockNetsysClient_.CheckMockApi(MOCK_NETWORKDESTROY_API)) {
57 return mockNetsysClient_.NetworkDestroy(netId);
58 }
59 return netsysClient_.NetworkDestroy(netId);
60 }
61
CreateVnic(uint16_t mtu,const std::string & tunAddr,int32_t prefix,const std::set<int32_t> & uids)62 int32_t NetsysControllerServiceImpl::CreateVnic(uint16_t mtu, const std::string &tunAddr, int32_t prefix,
63 const std::set<int32_t> &uids)
64 {
65 NETMGR_LOG_I("Create Vnic network");
66 return netsysClient_.CreateVnic(mtu, tunAddr, prefix, uids);
67 }
68
DestroyVnic()69 int32_t NetsysControllerServiceImpl::DestroyVnic()
70 {
71 NETMGR_LOG_I("Destroy Vnic network");
72 return netsysClient_.DestroyVnic();
73 }
74
NetworkAddUids(int32_t netId,const std::vector<UidRange> & uidRanges)75 int32_t NetsysControllerServiceImpl::NetworkAddUids(int32_t netId, const std::vector<UidRange> &uidRanges)
76 {
77 NETMGR_LOG_I("Add uids to vpn network: netId[%{public}d]", netId);
78 return netsysClient_.NetworkAddUids(netId, uidRanges);
79 }
80
NetworkDelUids(int32_t netId,const std::vector<UidRange> & uidRanges)81 int32_t NetsysControllerServiceImpl::NetworkDelUids(int32_t netId, const std::vector<UidRange> &uidRanges)
82 {
83 NETMGR_LOG_I("Remove uids from vpn network: netId[%{public}d]", netId);
84 return netsysClient_.NetworkDelUids(netId, uidRanges);
85 }
86
NetworkAddInterface(int32_t netId,const std::string & iface,NetBearType netBearerType)87 int32_t NetsysControllerServiceImpl::NetworkAddInterface(int32_t netId, const std::string &iface,
88 NetBearType netBearerType)
89 {
90 NETMGR_LOG_I("Add network interface: netId[%{public}d], iface[%{public}s]", netId,
91 iface.c_str());
92 if (mockNetsysClient_.CheckMockApi(MOCK_NETWORKADDINTERFACE_API)) {
93 return mockNetsysClient_.NetworkAddInterface(netId, iface, netBearerType);
94 }
95 return netsysClient_.NetworkAddInterface(netId, iface, netBearerType);
96 }
97
NetworkRemoveInterface(int32_t netId,const std::string & iface)98 int32_t NetsysControllerServiceImpl::NetworkRemoveInterface(int32_t netId, const std::string &iface)
99 {
100 NETMGR_LOG_I("Remove network interface: netId[%{public}d], iface[%{public}s]", netId, iface.c_str());
101 if (mockNetsysClient_.CheckMockApi(MOCK_NETWORKREMOVEINTERFACE_API)) {
102 return mockNetsysClient_.NetworkRemoveInterface(netId, iface);
103 }
104 return netsysClient_.NetworkRemoveInterface(netId, iface);
105 }
106
NetworkAddRoute(int32_t netId,const std::string & ifName,const std::string & destination,const std::string & nextHop)107 int32_t NetsysControllerServiceImpl::NetworkAddRoute(int32_t netId, const std::string &ifName,
108 const std::string &destination, const std::string &nextHop)
109 {
110 NETMGR_LOG_I("Add Route: netId[%{public}d], ifName[%{public}s], destination[%{public}s], nextHop[%{public}s]",
111 netId, ifName.c_str(), ToAnonymousIp(destination).c_str(), ToAnonymousIp(nextHop).c_str());
112 if (mockNetsysClient_.CheckMockApi(MOCK_NETWORKADDROUTE_API)) {
113 return mockNetsysClient_.NetworkAddRoute(netId, ifName, destination, nextHop);
114 }
115 return netsysClient_.NetworkAddRoute(netId, ifName, destination, nextHop);
116 }
117
NetworkRemoveRoute(int32_t netId,const std::string & ifName,const std::string & destination,const std::string & nextHop)118 int32_t NetsysControllerServiceImpl::NetworkRemoveRoute(int32_t netId, const std::string &ifName,
119 const std::string &destination, const std::string &nextHop)
120 {
121 NETMGR_LOG_I("Remove Route: netId[%{public}d], ifName[%{public}s], destination[%{public}s], nextHop[%{public}s]",
122 netId, ifName.c_str(), ToAnonymousIp(destination).c_str(), ToAnonymousIp(nextHop).c_str());
123 if (mockNetsysClient_.CheckMockApi(MOCK_NETWORKREMOVEROUTE_API)) {
124 return mockNetsysClient_.NetworkRemoveRoute(netId, ifName, destination, nextHop);
125 }
126 return netsysClient_.NetworkRemoveRoute(netId, ifName, destination, nextHop);
127 }
128
GetInterfaceConfig(OHOS::nmd::InterfaceConfigurationParcel & cfg)129 int32_t NetsysControllerServiceImpl::GetInterfaceConfig(OHOS::nmd::InterfaceConfigurationParcel &cfg)
130 {
131 NETMGR_LOG_I("Interface get config");
132 return netsysClient_.GetInterfaceConfig(cfg);
133 }
134
SetInterfaceConfig(const OHOS::nmd::InterfaceConfigurationParcel & cfg)135 int32_t NetsysControllerServiceImpl::SetInterfaceConfig(const OHOS::nmd::InterfaceConfigurationParcel &cfg)
136 {
137 NETMGR_LOG_I("Interface set config");
138 return netsysClient_.SetInterfaceConfig(cfg);
139 }
140
SetInterfaceDown(const std::string & iface)141 int32_t NetsysControllerServiceImpl::SetInterfaceDown(const std::string &iface)
142 {
143 NETMGR_LOG_I("Set interface down: iface[%{public}s]", iface.c_str());
144 if (mockNetsysClient_.CheckMockApi(MOCK_SETINTERFACEDOWN_API)) {
145 return mockNetsysClient_.SetInterfaceDown(iface);
146 }
147 return netsysClient_.SetInterfaceDown(iface);
148 }
149
SetInterfaceUp(const std::string & iface)150 int32_t NetsysControllerServiceImpl::SetInterfaceUp(const std::string &iface)
151 {
152 NETMGR_LOG_I("Set interface up: iface[%{public}s]", iface.c_str());
153 if (mockNetsysClient_.CheckMockApi(MOCK_SETINTERFACEUP_API)) {
154 return mockNetsysClient_.SetInterfaceUp(iface);
155 }
156 return netsysClient_.SetInterfaceUp(iface);
157 }
158
ClearInterfaceAddrs(const std::string & ifName)159 void NetsysControllerServiceImpl::ClearInterfaceAddrs(const std::string &ifName)
160 {
161 NETMGR_LOG_I("Clear addrs: ifName[%{public}s]", ifName.c_str());
162 if (mockNetsysClient_.CheckMockApi(MOCK_INTERFACECLEARADDRS_API)) {
163 return mockNetsysClient_.ClearInterfaceAddrs(ifName);
164 }
165 return netsysClient_.ClearInterfaceAddrs(ifName);
166 }
167
GetInterfaceMtu(const std::string & ifName)168 int32_t NetsysControllerServiceImpl::GetInterfaceMtu(const std::string &ifName)
169 {
170 NETMGR_LOG_I("Get mtu: ifName[%{public}s]", ifName.c_str());
171 if (mockNetsysClient_.CheckMockApi(MOCK_INTERFACEGETMTU_API)) {
172 return mockNetsysClient_.GetInterfaceMtu(ifName);
173 }
174 return netsysClient_.GetInterfaceMtu(ifName);
175 }
176
SetInterfaceMtu(const std::string & ifName,int32_t mtu)177 int32_t NetsysControllerServiceImpl::SetInterfaceMtu(const std::string &ifName, int32_t mtu)
178 {
179 NETMGR_LOG_I("Set mtu: ifName[%{public}s], mtu[%{public}d]", ifName.c_str(), mtu);
180 if (mockNetsysClient_.CheckMockApi(MOCK_INTERFACESETMTU_API)) {
181 return mockNetsysClient_.SetInterfaceMtu(ifName, mtu);
182 }
183 return netsysClient_.SetInterfaceMtu(ifName, mtu);
184 }
185
SetTcpBufferSizes(const std::string & tcpBufferSizes)186 int32_t NetsysControllerServiceImpl::SetTcpBufferSizes(const std::string &tcpBufferSizes)
187 {
188 NETMGR_LOG_I("Set tcp buffer sizes: tcpBufferSizes[%{public}s]", tcpBufferSizes.c_str());
189 return netsysClient_.SetTcpBufferSizes(tcpBufferSizes);
190 }
191
AddInterfaceAddress(const std::string & ifName,const std::string & ipAddr,int32_t prefixLength)192 int32_t NetsysControllerServiceImpl::AddInterfaceAddress(const std::string &ifName, const std::string &ipAddr,
193 int32_t prefixLength)
194 {
195 NETMGR_LOG_I("Add address: ifName[%{public}s], ipAddr[%{public}s], prefixLength[%{public}d]", ifName.c_str(),
196 ToAnonymousIp(ipAddr).c_str(), prefixLength);
197 if (mockNetsysClient_.CheckMockApi(MOCK_INTERFACEADDADDRESS_API)) {
198 return mockNetsysClient_.AddInterfaceAddress(ifName, ipAddr, prefixLength);
199 }
200 return netsysClient_.AddInterfaceAddress(ifName, ipAddr, prefixLength);
201 }
202
DelInterfaceAddress(const std::string & ifName,const std::string & ipAddr,int32_t prefixLength)203 int32_t NetsysControllerServiceImpl::DelInterfaceAddress(const std::string &ifName, const std::string &ipAddr,
204 int32_t prefixLength)
205 {
206 NETMGR_LOG_I("Delete address: ifName[%{public}s], ipAddr[%{public}s], prefixLength[%{public}d]", ifName.c_str(),
207 ToAnonymousIp(ipAddr).c_str(), prefixLength);
208 if (mockNetsysClient_.CheckMockApi(MOCK_INTERFACEDELADDRESS_API)) {
209 return mockNetsysClient_.DelInterfaceAddress(ifName, ipAddr, prefixLength);
210 }
211 return netsysClient_.DelInterfaceAddress(ifName, ipAddr, prefixLength);
212 }
213
DelInterfaceAddress(const std::string & ifName,const std::string & ipAddr,int32_t prefixLength,const std::string & netCapabilities)214 int32_t NetsysControllerServiceImpl::DelInterfaceAddress(const std::string &ifName, const std::string &ipAddr,
215 int32_t prefixLength, const std::string &netCapabilities)
216 {
217 NETMGR_LOG_I("Delete address: ifName[%{public}s], ipAddr[%{public}s], prefixLength[%{public}d]", ifName.c_str(),
218 ToAnonymousIp(ipAddr).c_str(), prefixLength);
219 if (mockNetsysClient_.CheckMockApi(MOCK_INTERFACEDELADDRESS_API)) {
220 return mockNetsysClient_.DelInterfaceAddress(ifName, ipAddr, prefixLength);
221 }
222 return netsysClient_.DelInterfaceAddress(ifName, ipAddr, prefixLength, netCapabilities);
223 }
224
InterfaceSetIpAddress(const std::string & ifaceName,const std::string & ipAddress)225 int32_t NetsysControllerServiceImpl::InterfaceSetIpAddress(const std::string &ifaceName, const std::string &ipAddress)
226 {
227 NETMGR_LOG_I("set ip address: ifName[%{public}s], ipAddr[%{public}s]", ifaceName.c_str(),
228 ToAnonymousIp(ipAddress).c_str());
229 return netsysClient_.InterfaceSetIpAddress(ifaceName, ipAddress);
230 }
231
InterfaceSetIffUp(const std::string & ifaceName)232 int32_t NetsysControllerServiceImpl::InterfaceSetIffUp(const std::string &ifaceName)
233 {
234 NETMGR_LOG_I("set iff up: ifName[%{public}s]", ifaceName.c_str());
235 return netsysClient_.InterfaceSetIffUp(ifaceName);
236 }
237
SetResolverConfig(uint16_t netId,uint16_t baseTimeoutMsec,uint8_t retryCount,const std::vector<std::string> & servers,const std::vector<std::string> & domains)238 int32_t NetsysControllerServiceImpl::SetResolverConfig(uint16_t netId, uint16_t baseTimeoutMsec, uint8_t retryCount,
239 const std::vector<std::string> &servers,
240 const std::vector<std::string> &domains)
241 {
242 NETMGR_LOG_I("Set resolver config: netId[%{public}d]", netId);
243 if (mockNetsysClient_.CheckMockApi(MOCK_SETRESOLVERCONFIG_API)) {
244 return mockNetsysClient_.SetResolverConfig(netId, baseTimeoutMsec, retryCount, servers, domains);
245 }
246 return netsysClient_.SetResolverConfig(netId, baseTimeoutMsec, retryCount, servers, domains);
247 }
248
GetResolverConfig(uint16_t netId,std::vector<std::string> & servers,std::vector<std::string> & domains,uint16_t & baseTimeoutMsec,uint8_t & retryCount)249 int32_t NetsysControllerServiceImpl::GetResolverConfig(uint16_t netId, std::vector<std::string> &servers,
250 std::vector<std::string> &domains, uint16_t &baseTimeoutMsec,
251 uint8_t &retryCount)
252 {
253 NETMGR_LOG_I("Get resolver config: netId[%{public}d]", netId);
254 if (mockNetsysClient_.CheckMockApi(MOCK_GETRESOLVERICONFIG_API)) {
255 return mockNetsysClient_.GetResolverConfig(netId, servers, domains, baseTimeoutMsec, retryCount);
256 }
257 return netsysClient_.GetResolverConfig(netId, servers, domains, baseTimeoutMsec, retryCount);
258 }
259
CreateNetworkCache(uint16_t netId)260 int32_t NetsysControllerServiceImpl::CreateNetworkCache(uint16_t netId)
261 {
262 NETMGR_LOG_I("create dns cache: netId[%{public}d]", netId);
263 if (mockNetsysClient_.CheckMockApi(MOCK_CREATENETWORKCACHE_API)) {
264 return mockNetsysClient_.CreateNetworkCache(netId);
265 }
266 return netsysClient_.CreateNetworkCache(netId);
267 }
268
DestroyNetworkCache(uint16_t netId)269 int32_t NetsysControllerServiceImpl::DestroyNetworkCache(uint16_t netId)
270 {
271 NETMGR_LOG_D("Destroy dns cache: netId[%{public}d]", netId);
272 return netsysClient_.DestroyNetworkCache(netId);
273 }
274
GetAddrInfo(const std::string & hostName,const std::string & serverName,const AddrInfo & hints,uint16_t netId,std::vector<AddrInfo> & res)275 int32_t NetsysControllerServiceImpl::GetAddrInfo(const std::string &hostName, const std::string &serverName,
276 const AddrInfo &hints, uint16_t netId, std::vector<AddrInfo> &res)
277 {
278 return netsysClient_.GetAddrInfo(hostName, serverName, hints, netId, res);
279 }
280
GetNetworkSharingTraffic(const std::string & downIface,const std::string & upIface,nmd::NetworkSharingTraffic & traffic)281 int32_t NetsysControllerServiceImpl::GetNetworkSharingTraffic(const std::string &downIface, const std::string &upIface,
282 nmd::NetworkSharingTraffic &traffic)
283 {
284 NETMGR_LOG_I("GetNetworkSharingTraffic");
285 return netsysClient_.GetNetworkSharingTraffic(downIface, upIface, traffic);
286 }
287
GetCellularRxBytes()288 int64_t NetsysControllerServiceImpl::GetCellularRxBytes()
289 {
290 NETMGR_LOG_I("GetCellularRxBytes");
291 if (mockNetsysClient_.CheckMockApi(MOCK_GETCELLULARRXBYTES_API)) {
292 return mockNetsysClient_.GetCellularRxBytes();
293 }
294 return netsysClient_.GetCellularRxBytes();
295 }
296
GetCellularTxBytes()297 int64_t NetsysControllerServiceImpl::GetCellularTxBytes()
298 {
299 NETMGR_LOG_I("GetCellularTxBytes");
300 if (mockNetsysClient_.CheckMockApi(MOCK_GETCELLULARTXBYTES_API)) {
301 return mockNetsysClient_.GetCellularTxBytes();
302 }
303 return netsysClient_.GetCellularTxBytes();
304 }
305
GetAllRxBytes()306 int64_t NetsysControllerServiceImpl::GetAllRxBytes()
307 {
308 NETMGR_LOG_I("GetAllRxBytes");
309 if (mockNetsysClient_.CheckMockApi(MOCK_GETALLRXBYTES_API)) {
310 return mockNetsysClient_.GetAllRxBytes();
311 }
312 return netsysClient_.GetAllRxBytes();
313 }
314
GetAllTxBytes()315 int64_t NetsysControllerServiceImpl::GetAllTxBytes()
316 {
317 NETMGR_LOG_I("GetAllTxBytes");
318 if (mockNetsysClient_.CheckMockApi(MOCK_GETALLTXBYTES_API)) {
319 return mockNetsysClient_.GetAllTxBytes();
320 }
321 return netsysClient_.GetAllTxBytes();
322 }
323
GetUidRxBytes(uint32_t uid)324 int64_t NetsysControllerServiceImpl::GetUidRxBytes(uint32_t uid)
325 {
326 NETMGR_LOG_I("GetUidRxBytes");
327 if (mockNetsysClient_.CheckMockApi(MOCK_GETUIDRXBYTES_API)) {
328 return mockNetsysClient_.GetUidRxBytes(uid);
329 }
330 return netsysClient_.GetUidRxBytes(uid);
331 }
332
GetUidTxBytes(uint32_t uid)333 int64_t NetsysControllerServiceImpl::GetUidTxBytes(uint32_t uid)
334 {
335 NETMGR_LOG_I("GetUidTxBytes");
336 if (mockNetsysClient_.CheckMockApi(MOCK_GETUIDTXBYTES_API)) {
337 return mockNetsysClient_.GetUidTxBytes(uid);
338 }
339 return netsysClient_.GetUidTxBytes(uid);
340 }
341
GetUidOnIfaceRxBytes(uint32_t uid,const std::string & interfaceName)342 int64_t NetsysControllerServiceImpl::GetUidOnIfaceRxBytes(uint32_t uid, const std::string &interfaceName)
343 {
344 NETMGR_LOG_I("GetUidOnIfaceRxBytes");
345 if (mockNetsysClient_.CheckMockApi(MOCK_GETUIDRXBYTES_API)) {
346 return mockNetsysClient_.GetUidOnIfaceRxBytes(uid, interfaceName);
347 }
348 return netsysClient_.GetUidOnIfaceRxBytes(uid, interfaceName);
349 }
350
GetUidOnIfaceTxBytes(uint32_t uid,const std::string & interfaceName)351 int64_t NetsysControllerServiceImpl::GetUidOnIfaceTxBytes(uint32_t uid, const std::string &interfaceName)
352 {
353 NETMGR_LOG_I("GetUidOnIfaceTxBytes");
354 if (mockNetsysClient_.CheckMockApi(MOCK_GETUIDTXBYTES_API)) {
355 return mockNetsysClient_.GetUidOnIfaceTxBytes(uid, interfaceName);
356 }
357 return netsysClient_.GetUidOnIfaceTxBytes(uid, interfaceName);
358 }
359
GetIfaceRxBytes(const std::string & interfaceName)360 int64_t NetsysControllerServiceImpl::GetIfaceRxBytes(const std::string &interfaceName)
361 {
362 NETMGR_LOG_I("GetIfaceRxBytes");
363 if (mockNetsysClient_.CheckMockApi(MOCK_GETIFACERXBYTES_API)) {
364 return mockNetsysClient_.GetIfaceRxBytes(interfaceName);
365 }
366 return netsysClient_.GetIfaceRxBytes(interfaceName);
367 }
368
GetIfaceTxBytes(const std::string & interfaceName)369 int64_t NetsysControllerServiceImpl::GetIfaceTxBytes(const std::string &interfaceName)
370 {
371 NETMGR_LOG_I("GetIfaceTxBytes");
372 if (mockNetsysClient_.CheckMockApi(MOCK_GETIFACETXBYTES_API)) {
373 return mockNetsysClient_.GetIfaceTxBytes(interfaceName);
374 }
375 return netsysClient_.GetIfaceTxBytes(interfaceName);
376 }
377
InterfaceGetList()378 std::vector<std::string> NetsysControllerServiceImpl::InterfaceGetList()
379 {
380 NETMGR_LOG_I("InterfaceGetList");
381 if (mockNetsysClient_.CheckMockApi(MOCK_INTERFACEGETLIST_API)) {
382 return mockNetsysClient_.InterfaceGetList();
383 }
384 return netsysClient_.InterfaceGetList();
385 }
386
UidGetList()387 std::vector<std::string> NetsysControllerServiceImpl::UidGetList()
388 {
389 NETMGR_LOG_I("UidGetList");
390 if (mockNetsysClient_.CheckMockApi(MOCK_UIDGETLIST_API)) {
391 return mockNetsysClient_.UidGetList();
392 }
393 return netsysClient_.UidGetList();
394 }
395
GetIfaceRxPackets(const std::string & interfaceName)396 int64_t NetsysControllerServiceImpl::GetIfaceRxPackets(const std::string &interfaceName)
397 {
398 NETMGR_LOG_D("GetIfaceRxPackets");
399 if (mockNetsysClient_.CheckMockApi(MOCK_GETIFACERXPACKETS_API)) {
400 return mockNetsysClient_.GetIfaceRxPackets(interfaceName);
401 }
402 return netsysClient_.GetIfaceRxPackets(interfaceName);
403 }
404
GetIfaceTxPackets(const std::string & interfaceName)405 int64_t NetsysControllerServiceImpl::GetIfaceTxPackets(const std::string &interfaceName)
406 {
407 NETMGR_LOG_D("GetIfaceTxPackets");
408 if (mockNetsysClient_.CheckMockApi(MOCK_GETIFACETXPACKETS_API)) {
409 return mockNetsysClient_.GetIfaceTxPackets(interfaceName);
410 }
411 return netsysClient_.GetIfaceTxPackets(interfaceName);
412 }
413
SetDefaultNetWork(int32_t netId)414 int32_t NetsysControllerServiceImpl::SetDefaultNetWork(int32_t netId)
415 {
416 NETMGR_LOG_D("SetDefaultNetWork");
417 if (mockNetsysClient_.CheckMockApi(MOCK_SETDEFAULTNETWORK_API)) {
418 return mockNetsysClient_.SetDefaultNetWork(netId);
419 }
420 return netsysClient_.SetDefaultNetWork(netId);
421 }
422
ClearDefaultNetWorkNetId()423 int32_t NetsysControllerServiceImpl::ClearDefaultNetWorkNetId()
424 {
425 NETMGR_LOG_D("ClearDefaultNetWorkNetId");
426 if (mockNetsysClient_.CheckMockApi(MOCK_CLEARDEFAULTNETWORK_API)) {
427 return mockNetsysClient_.ClearDefaultNetWorkNetId();
428 }
429 return netsysClient_.ClearDefaultNetWorkNetId();
430 }
431
BindSocket(int32_t socketFd,uint32_t netId)432 int32_t NetsysControllerServiceImpl::BindSocket(int32_t socketFd, uint32_t netId)
433 {
434 NETMGR_LOG_D("BindSocket");
435 if (mockNetsysClient_.CheckMockApi(MOCK_BINDSOCKET_API)) {
436 return mockNetsysClient_.BindSocket(socketFd, netId);
437 }
438 return netsysClient_.BindSocket(socketFd, netId);
439 }
440
IpEnableForwarding(const std::string & requestor)441 int32_t NetsysControllerServiceImpl::IpEnableForwarding(const std::string &requestor)
442 {
443 NETMGR_LOG_D("IpEnableForwarding");
444 return netsysClient_.IpEnableForwarding(requestor);
445 }
446
IpDisableForwarding(const std::string & requestor)447 int32_t NetsysControllerServiceImpl::IpDisableForwarding(const std::string &requestor)
448 {
449 NETMGR_LOG_D("IpDisableForwarding");
450 return netsysClient_.IpDisableForwarding(requestor);
451 }
452
EnableNat(const std::string & downstreamIface,const std::string & upstreamIface)453 int32_t NetsysControllerServiceImpl::EnableNat(const std::string &downstreamIface, const std::string &upstreamIface)
454 {
455 NETMGR_LOG_D("EnableNat");
456 return netsysClient_.EnableNat(downstreamIface, upstreamIface);
457 }
458
DisableNat(const std::string & downstreamIface,const std::string & upstreamIface)459 int32_t NetsysControllerServiceImpl::DisableNat(const std::string &downstreamIface, const std::string &upstreamIface)
460 {
461 NETMGR_LOG_D("DisableNat");
462 return netsysClient_.DisableNat(downstreamIface, upstreamIface);
463 }
464
IpfwdAddInterfaceForward(const std::string & fromIface,const std::string & toIface)465 int32_t NetsysControllerServiceImpl::IpfwdAddInterfaceForward(const std::string &fromIface, const std::string &toIface)
466 {
467 NETMGR_LOG_D("IpfwdAddInterfaceForward");
468 return netsysClient_.IpfwdAddInterfaceForward(fromIface, toIface);
469 }
470
IpfwdRemoveInterfaceForward(const std::string & fromIface,const std::string & toIface)471 int32_t NetsysControllerServiceImpl::IpfwdRemoveInterfaceForward(const std::string &fromIface,
472 const std::string &toIface)
473 {
474 NETMGR_LOG_D("IpfwdRemoveInterfaceForward");
475 return netsysClient_.IpfwdRemoveInterfaceForward(fromIface, toIface);
476 }
477
ShareDnsSet(uint16_t netId)478 int32_t NetsysControllerServiceImpl::ShareDnsSet(uint16_t netId)
479 {
480 NETMGR_LOG_D("IpfwdRemoveInterfaceForward");
481 if (mockNetsysClient_.CheckMockApi(MOCK_SHAREDNSSET_API)) {
482 return mockNetsysClient_.ShareDnsSet(netId);
483 }
484 return netsysClient_.ShareDnsSet(netId);
485 }
486
StartDnsProxyListen()487 int32_t NetsysControllerServiceImpl::StartDnsProxyListen()
488 {
489 NETMGR_LOG_D("StartDnsProxyListen");
490 return netsysClient_.StartDnsProxyListen();
491 }
492
StopDnsProxyListen()493 int32_t NetsysControllerServiceImpl::StopDnsProxyListen()
494 {
495 NETMGR_LOG_D("StopDnsProxyListen");
496 return netsysClient_.StopDnsProxyListen();
497 }
498
RegisterNetsysNotifyCallback(const NetsysNotifyCallback & callback)499 int32_t NetsysControllerServiceImpl::RegisterNetsysNotifyCallback(const NetsysNotifyCallback &callback)
500 {
501 NETMGR_LOG_D("IpfwdRemoveInterfaceForward");
502 if (mockNetsysClient_.CheckMockApi(MOCK_REGISTERNETSYSNOTIFYCALLBACK_API)) {
503 return mockNetsysClient_.RegisterNetsysNotifyCallback(callback);
504 }
505 return netsysClient_.RegisterNetsysNotifyCallback(callback);
506 }
507
BindNetworkServiceVpn(int32_t socketFd)508 int32_t NetsysControllerServiceImpl::BindNetworkServiceVpn(int32_t socketFd)
509 {
510 NETMGR_LOG_D("BindNetworkServiceVpn");
511 if (mockNetsysClient_.CheckMockApi(MOCK_BINDNETWORKSERVICEVPN_API)) {
512 return mockNetsysClient_.BindNetworkServiceVpn(socketFd);
513 }
514 return netsysClient_.BindNetworkServiceVpn(socketFd);
515 }
516
EnableVirtualNetIfaceCard(int32_t socketFd,struct ifreq & ifRequest,int32_t & ifaceFd)517 int32_t NetsysControllerServiceImpl::EnableVirtualNetIfaceCard(int32_t socketFd, struct ifreq &ifRequest,
518 int32_t &ifaceFd)
519 {
520 NETMGR_LOG_D("EnableVirtualNetIfaceCard");
521 if (mockNetsysClient_.CheckMockApi(MOCK_ENABLEVIRTUALNETIFACECARD_API)) {
522 return mockNetsysClient_.EnableVirtualNetIfaceCard(socketFd, ifRequest, ifaceFd);
523 }
524 return netsysClient_.EnableVirtualNetIfaceCard(socketFd, ifRequest, ifaceFd);
525 }
526
SetIpAddress(int32_t socketFd,const std::string & ipAddress,int32_t prefixLen,struct ifreq & ifRequest)527 int32_t NetsysControllerServiceImpl::SetIpAddress(int32_t socketFd, const std::string &ipAddress, int32_t prefixLen,
528 struct ifreq &ifRequest)
529 {
530 NETMGR_LOG_D("SetIpAddress");
531 if (mockNetsysClient_.CheckMockApi(MOCK_SETIPADDRESS_API)) {
532 return mockNetsysClient_.SetIpAddress(socketFd, ipAddress, prefixLen, ifRequest);
533 }
534 return netsysClient_.SetIpAddress(socketFd, ipAddress, prefixLen, ifRequest);
535 }
536
SetBlocking(int32_t ifaceFd,bool isBlock)537 int32_t NetsysControllerServiceImpl::SetBlocking(int32_t ifaceFd, bool isBlock)
538 {
539 NETMGR_LOG_D("SetBlocking");
540 if (mockNetsysClient_.CheckMockApi(MOCK_SETBLOCKING_API)) {
541 return mockNetsysClient_.SetBlocking(ifaceFd, isBlock);
542 }
543 return netsysClient_.SetBlocking(ifaceFd, isBlock);
544 }
545
StartDhcpClient(const std::string & iface,bool bIpv6)546 int32_t NetsysControllerServiceImpl::StartDhcpClient(const std::string &iface, bool bIpv6)
547 {
548 NETMGR_LOG_D("StartDhcpClient");
549 if (mockNetsysClient_.CheckMockApi(MOCK_STARTDHCPCLIENT_API)) {
550 return mockNetsysClient_.StartDhcpClient(iface, bIpv6);
551 }
552 return netsysClient_.StartDhcpClient(iface, bIpv6);
553 }
554
StopDhcpClient(const std::string & iface,bool bIpv6)555 int32_t NetsysControllerServiceImpl::StopDhcpClient(const std::string &iface, bool bIpv6)
556 {
557 NETMGR_LOG_D("StopDhcpClient");
558 if (mockNetsysClient_.CheckMockApi(MOCK_STOPDHCPCLIENT_API)) {
559 return mockNetsysClient_.StopDhcpClient(iface, bIpv6);
560 }
561 return netsysClient_.StopDhcpClient(iface, bIpv6);
562 }
563
RegisterCallback(sptr<NetsysControllerCallback> callback)564 int32_t NetsysControllerServiceImpl::RegisterCallback(sptr<NetsysControllerCallback> callback)
565 {
566 NETMGR_LOG_D("RegisterCallback");
567 if (mockNetsysClient_.CheckMockApi(MOCK_REGISTERNOTIFYCALLBACK_API)) {
568 return mockNetsysClient_.RegisterCallback(callback);
569 }
570 return netsysClient_.RegisterCallback(callback);
571 }
572
StartDhcpService(const std::string & iface,const std::string & ipv4addr)573 int32_t NetsysControllerServiceImpl::StartDhcpService(const std::string &iface, const std::string &ipv4addr)
574 {
575 NETMGR_LOG_D("SetBlocking");
576 if (mockNetsysClient_.CheckMockApi(MOCK_STARTDHCPSERVICE_API)) {
577 return mockNetsysClient_.StartDhcpService(iface, ipv4addr);
578 }
579 return netsysClient_.StartDhcpService(iface, ipv4addr);
580 }
581
StopDhcpService(const std::string & iface)582 int32_t NetsysControllerServiceImpl::StopDhcpService(const std::string &iface)
583 {
584 NETMGR_LOG_D("StopDhcpService");
585 if (mockNetsysClient_.CheckMockApi(MOCK_STOPDHCPSERVICE_API)) {
586 return mockNetsysClient_.StopDhcpService(iface);
587 }
588 return netsysClient_.StopDhcpService(iface);
589 }
590
BandwidthEnableDataSaver(bool enable)591 int32_t NetsysControllerServiceImpl::BandwidthEnableDataSaver(bool enable)
592 {
593 NETMGR_LOG_D("BandwidthEnableDataSaver: enable=%{public}d", enable);
594 return netsysClient_.BandwidthEnableDataSaver(enable);
595 }
596
BandwidthSetIfaceQuota(const std::string & ifName,int64_t bytes)597 int32_t NetsysControllerServiceImpl::BandwidthSetIfaceQuota(const std::string &ifName, int64_t bytes)
598 {
599 NETMGR_LOG_D("BandwidthSetIfaceQuota: ifName=%{public}s", ifName.c_str());
600 return netsysClient_.BandwidthSetIfaceQuota(ifName, bytes);
601 }
602
BandwidthRemoveIfaceQuota(const std::string & ifName)603 int32_t NetsysControllerServiceImpl::BandwidthRemoveIfaceQuota(const std::string &ifName)
604 {
605 NETMGR_LOG_D("BandwidthRemoveIfaceQuota: ifName=%{public}s", ifName.c_str());
606 return netsysClient_.BandwidthRemoveIfaceQuota(ifName);
607 }
608
BandwidthAddDeniedList(uint32_t uid)609 int32_t NetsysControllerServiceImpl::BandwidthAddDeniedList(uint32_t uid)
610 {
611 NETMGR_LOG_D("BandwidthAddDeniedList: uid=%{public}d", uid);
612 return netsysClient_.BandwidthAddDeniedList(uid);
613 }
614
BandwidthRemoveDeniedList(uint32_t uid)615 int32_t NetsysControllerServiceImpl::BandwidthRemoveDeniedList(uint32_t uid)
616 {
617 NETMGR_LOG_D("BandwidthRemoveDeniedList: uid=%{public}d", uid);
618 return netsysClient_.BandwidthRemoveDeniedList(uid);
619 }
620
BandwidthAddAllowedList(uint32_t uid)621 int32_t NetsysControllerServiceImpl::BandwidthAddAllowedList(uint32_t uid)
622 {
623 NETMGR_LOG_D("BandwidthAddAllowedList: uid=%{public}d", uid);
624 return netsysClient_.BandwidthAddAllowedList(uid);
625 }
626
BandwidthRemoveAllowedList(uint32_t uid)627 int32_t NetsysControllerServiceImpl::BandwidthRemoveAllowedList(uint32_t uid)
628 {
629 NETMGR_LOG_D("BandwidthRemoveAllowedList: uid=%{public}d", uid);
630 return netsysClient_.BandwidthRemoveAllowedList(uid);
631 }
632
FirewallSetUidsAllowedListChain(uint32_t chain,const std::vector<uint32_t> & uids)633 int32_t NetsysControllerServiceImpl::FirewallSetUidsAllowedListChain(uint32_t chain, const std::vector<uint32_t> &uids)
634 {
635 NETMGR_LOG_D("FirewallSetUidsAllowedListChain: chain=%{public}d", chain);
636 return netsysClient_.FirewallSetUidsAllowedListChain(chain, uids);
637 }
638
FirewallSetUidsDeniedListChain(uint32_t chain,const std::vector<uint32_t> & uids)639 int32_t NetsysControllerServiceImpl::FirewallSetUidsDeniedListChain(uint32_t chain, const std::vector<uint32_t> &uids)
640 {
641 NETMGR_LOG_D("FirewallSetUidsDeniedListChain: chain=%{public}d", chain);
642 return netsysClient_.FirewallSetUidsDeniedListChain(chain, uids);
643 }
644
FirewallEnableChain(uint32_t chain,bool enable)645 int32_t NetsysControllerServiceImpl::FirewallEnableChain(uint32_t chain, bool enable)
646 {
647 NETMGR_LOG_D("FirewallEnableChain: chain=%{public}d, enable=%{public}d", chain, enable);
648 return netsysClient_.FirewallEnableChain(chain, enable);
649 }
650
FirewallSetUidRule(uint32_t chain,const std::vector<uint32_t> & uids,uint32_t firewallRule)651 int32_t NetsysControllerServiceImpl::FirewallSetUidRule(uint32_t chain, const std::vector<uint32_t> &uids,
652 uint32_t firewallRule)
653 {
654 return netsysClient_.FirewallSetUidRule(chain, uids, firewallRule);
655 }
656
GetTotalStats(uint64_t & stats,uint32_t type)657 int32_t NetsysControllerServiceImpl::GetTotalStats(uint64_t &stats, uint32_t type)
658 {
659 NETMGR_LOG_D("GetTotalStats: type=%{public}d", type);
660 return netsysClient_.GetTotalStats(stats, type);
661 }
662
GetUidStats(uint64_t & stats,uint32_t type,uint32_t uid)663 int32_t NetsysControllerServiceImpl::GetUidStats(uint64_t &stats, uint32_t type, uint32_t uid)
664 {
665 NETMGR_LOG_D("GetUidStats: type=%{public}d uid=%{public}d", type, uid);
666 return netsysClient_.GetUidStats(stats, type, uid);
667 }
668
GetIfaceStats(uint64_t & stats,uint32_t type,const std::string & interfaceName)669 int32_t NetsysControllerServiceImpl::GetIfaceStats(uint64_t &stats, uint32_t type, const std::string &interfaceName)
670 {
671 NETMGR_LOG_D("GetIfaceStats: type=%{public}d", type);
672 return netsysClient_.GetIfaceStats(stats, type, interfaceName);
673 }
674
GetAllSimStatsInfo(std::vector<OHOS::NetManagerStandard::NetStatsInfo> & stats)675 int32_t NetsysControllerServiceImpl::GetAllSimStatsInfo(
676 std::vector<OHOS::NetManagerStandard::NetStatsInfo> &stats)
677 {
678 NETMGR_LOG_D("GetAllSimStatsInfo");
679 return netsysClient_.GetAllSimStatsInfo(stats);
680 }
681
DeleteSimStatsInfo(uint32_t uid)682 int32_t NetsysControllerServiceImpl::DeleteSimStatsInfo(uint32_t uid)
683 {
684 NETMGR_LOG_D("DeleteSimStatsInfo");
685 return netsysClient_.DeleteSimStatsInfo(uid);
686 }
687
GetAllStatsInfo(std::vector<OHOS::NetManagerStandard::NetStatsInfo> & stats)688 int32_t NetsysControllerServiceImpl::GetAllStatsInfo(std::vector<OHOS::NetManagerStandard::NetStatsInfo> &stats)
689 {
690 NETMGR_LOG_D("GetAllStatsInfo");
691 return netsysClient_.GetAllStatsInfo(stats);
692 }
693
DeleteStatsInfo(uint32_t uid)694 int32_t NetsysControllerServiceImpl::DeleteStatsInfo(uint32_t uid)
695 {
696 NETMGR_LOG_D("DeleteStatsInfo");
697 return netsysClient_.DeleteStatsInfo(uid);
698 }
699
SetIptablesCommandForRes(const std::string & cmd,std::string & respond,NetsysNative::IptablesType ipType)700 int32_t NetsysControllerServiceImpl::SetIptablesCommandForRes(const std::string &cmd, std::string &respond,
701 NetsysNative::IptablesType ipType)
702 {
703 return netsysClient_.SetIptablesCommandForRes(cmd, respond, ipType);
704 }
705
NetDiagPingHost(const OHOS::NetsysNative::NetDiagPingOption & pingOption,const sptr<OHOS::NetsysNative::INetDiagCallback> & callback)706 int32_t NetsysControllerServiceImpl::NetDiagPingHost(const OHOS::NetsysNative::NetDiagPingOption &pingOption,
707 const sptr<OHOS::NetsysNative::INetDiagCallback> &callback)
708 {
709 NETMGR_LOG_D("NetDiagPingHost");
710 return netsysClient_.NetDiagPingHost(pingOption, callback);
711 }
712
NetDiagGetRouteTable(std::list<OHOS::NetsysNative::NetDiagRouteTable> & routeTables)713 int32_t NetsysControllerServiceImpl::NetDiagGetRouteTable(std::list<OHOS::NetsysNative::NetDiagRouteTable> &routeTables)
714 {
715 NETMGR_LOG_D("NetDiagGetRouteTable");
716 return netsysClient_.NetDiagGetRouteTable(routeTables);
717 }
718
NetDiagGetSocketsInfo(OHOS::NetsysNative::NetDiagProtocolType socketType,OHOS::NetsysNative::NetDiagSocketsInfo & socketsInfo)719 int32_t NetsysControllerServiceImpl::NetDiagGetSocketsInfo(OHOS::NetsysNative::NetDiagProtocolType socketType,
720 OHOS::NetsysNative::NetDiagSocketsInfo &socketsInfo)
721 {
722 NETMGR_LOG_D("NetDiagGetSocketsInfo");
723 return netsysClient_.NetDiagGetSocketsInfo(socketType, socketsInfo);
724 }
725
NetDiagGetInterfaceConfig(std::list<OHOS::NetsysNative::NetDiagIfaceConfig> & configs,const std::string & ifaceName)726 int32_t NetsysControllerServiceImpl::NetDiagGetInterfaceConfig(
727 std::list<OHOS::NetsysNative::NetDiagIfaceConfig> &configs, const std::string &ifaceName)
728 {
729 NETMGR_LOG_D("NetDiagGetInterfaceConfig");
730 return netsysClient_.NetDiagGetInterfaceConfig(configs, ifaceName);
731 }
732
NetDiagUpdateInterfaceConfig(const OHOS::NetsysNative::NetDiagIfaceConfig & config,const std::string & ifaceName,bool add)733 int32_t NetsysControllerServiceImpl::NetDiagUpdateInterfaceConfig(const OHOS::NetsysNative::NetDiagIfaceConfig &config,
734 const std::string &ifaceName, bool add)
735 {
736 NETMGR_LOG_D("NetDiagUpdateInterfaceConfig");
737 return netsysClient_.NetDiagUpdateInterfaceConfig(config, ifaceName, add);
738 }
739
NetDiagSetInterfaceActiveState(const std::string & ifaceName,bool up)740 int32_t NetsysControllerServiceImpl::NetDiagSetInterfaceActiveState(const std::string &ifaceName, bool up)
741 {
742 NETMGR_LOG_D("NetDiagSetInterfaceActiveState");
743 return netsysClient_.NetDiagSetInterfaceActiveState(ifaceName, up);
744 }
745
AddStaticArp(const std::string & ipAddr,const std::string & macAddr,const std::string & ifName)746 int32_t NetsysControllerServiceImpl::AddStaticArp(const std::string &ipAddr, const std::string &macAddr,
747 const std::string &ifName)
748 {
749 NETMGR_LOG_D("AddStaticArp");
750 return netsysClient_.AddStaticArp(ipAddr, macAddr, ifName);
751 }
752
DelStaticArp(const std::string & ipAddr,const std::string & macAddr,const std::string & ifName)753 int32_t NetsysControllerServiceImpl::DelStaticArp(const std::string &ipAddr, const std::string &macAddr,
754 const std::string &ifName)
755 {
756 NETMGR_LOG_D("DelStaticArp");
757 return netsysClient_.DelStaticArp(ipAddr, macAddr, ifName);
758 }
759
RegisterDnsResultCallback(const sptr<OHOS::NetManagerStandard::NetsysDnsReportCallback> & callback,uint32_t timeStep)760 int32_t NetsysControllerServiceImpl::RegisterDnsResultCallback(
761 const sptr<OHOS::NetManagerStandard::NetsysDnsReportCallback> &callback, uint32_t timeStep)
762 {
763 NETMGR_LOG_D("RegisterDnsResultListener");
764 return netsysClient_.RegisterDnsResultCallback(callback, timeStep);
765 }
766
UnregisterDnsResultCallback(const sptr<OHOS::NetManagerStandard::NetsysDnsReportCallback> & callback)767 int32_t NetsysControllerServiceImpl::UnregisterDnsResultCallback(
768 const sptr<OHOS::NetManagerStandard::NetsysDnsReportCallback> &callback)
769 {
770 NETMGR_LOG_D("UnregisterDnsResultListener");
771 return netsysClient_.UnregisterDnsResultCallback(callback);
772 }
773
RegisterDnsHealthCallback(const sptr<INetDnsHealthCallback> & callback)774 int32_t NetsysControllerServiceImpl::RegisterDnsHealthCallback(const sptr<INetDnsHealthCallback> &callback)
775 {
776 NETMGR_LOG_D("RegisterDnsResultListener");
777 return netsysClient_.RegisterDnsHealthCallback(callback);
778 }
779
UnregisterDnsHealthCallback(const sptr<INetDnsHealthCallback> & callback)780 int32_t NetsysControllerServiceImpl::UnregisterDnsHealthCallback(const sptr<INetDnsHealthCallback> &callback)
781 {
782 NETMGR_LOG_D("UnregisterDnsResultListener");
783 return netsysClient_.UnregisterDnsHealthCallback(callback);
784 }
785
GetCookieStats(uint64_t & stats,uint32_t type,uint64_t cookie)786 int32_t NetsysControllerServiceImpl::GetCookieStats(uint64_t &stats, uint32_t type, uint64_t cookie)
787 {
788 NETMGR_LOG_D("GetCookieStats: type=%{public}u", type);
789 return netsysClient_.GetCookieStats(stats, type, cookie);
790 }
791
GetNetworkSharingType(std::set<uint32_t> & sharingTypeIsOn)792 int32_t NetsysControllerServiceImpl::GetNetworkSharingType(std::set<uint32_t>& sharingTypeIsOn)
793 {
794 NETMGR_LOG_D("GetNetworkSharingType");
795 return netsysClient_.GetNetworkSharingType(sharingTypeIsOn);
796 }
797
UpdateNetworkSharingType(uint32_t type,bool isOpen)798 int32_t NetsysControllerServiceImpl::UpdateNetworkSharingType(uint32_t type, bool isOpen)
799 {
800 NETMGR_LOG_D("UpdateNetworkSharingType: type=%{public}d isOpen=%{public}d",
801 type, isOpen);
802 return netsysClient_.UpdateNetworkSharingType(type, isOpen);
803 }
804
805 #ifdef FEATURE_NET_FIREWALL_ENABLE
SetFirewallRules(NetFirewallRuleType type,const std::vector<sptr<NetFirewallBaseRule>> & ruleList,bool isFinish)806 int32_t NetsysControllerServiceImpl::SetFirewallRules(NetFirewallRuleType type,
807 const std::vector<sptr<NetFirewallBaseRule>> &ruleList,
808 bool isFinish)
809 {
810 NETMGR_LOG_D("NetsysControllerServiceImpl::SetFirewallRules");
811 return netsysClient_.SetFirewallRules(type, ruleList, isFinish);
812 }
813
SetFirewallDefaultAction(FirewallRuleAction inDefault,FirewallRuleAction outDefault)814 int32_t NetsysControllerServiceImpl::SetFirewallDefaultAction(FirewallRuleAction inDefault,
815 FirewallRuleAction outDefault)
816 {
817 NETMGR_LOG_D("NetsysControllerServiceImpl::SetFirewallDefaultAction");
818 return netsysClient_.SetFirewallDefaultAction(inDefault, outDefault);
819 }
820
SetFirewallCurrentUserId(int32_t userId)821 int32_t NetsysControllerServiceImpl::SetFirewallCurrentUserId(int32_t userId)
822 {
823 NETMGR_LOG_D("NetsysControllerServiceImpl::SetFirewallCurrentUserId");
824 return netsysClient_.SetFirewallCurrentUserId(userId);
825 }
826
ClearFirewallRules(NetFirewallRuleType type)827 int32_t NetsysControllerServiceImpl::ClearFirewallRules(NetFirewallRuleType type)
828 {
829 NETMGR_LOG_D("NetsysControllerServiceImpl::ClearFirewallRules");
830 return netsysClient_.ClearFirewallRules(type);
831 }
RegisterNetFirewallCallback(const sptr<NetsysNative::INetFirewallCallback> & callback)832 int32_t NetsysControllerServiceImpl::RegisterNetFirewallCallback(
833 const sptr<NetsysNative::INetFirewallCallback> &callback)
834 {
835 NETMGR_LOG_D("NetsysControllerServiceImpl::RegisterNetFirewallCallback");
836 return netsysClient_.RegisterNetFirewallCallback(callback);
837 }
838
UnRegisterNetFirewallCallback(const sptr<NetsysNative::INetFirewallCallback> & callback)839 int32_t NetsysControllerServiceImpl::UnRegisterNetFirewallCallback(
840 const sptr<NetsysNative::INetFirewallCallback> &callback)
841 {
842 NETMGR_LOG_D("NetsysControllerServiceImpl::UnRegisterNetFirewallCallback");
843 return netsysClient_.UnRegisterNetFirewallCallback(callback);
844 }
845 #endif
846
SetIpv6PrivacyExtensions(const std::string & interfaceName,const uint32_t on)847 int32_t NetsysControllerServiceImpl::SetIpv6PrivacyExtensions(const std::string &interfaceName, const uint32_t on)
848 {
849 NETMGR_LOG_I("SetIpv6PrivacyExtensions: interfaceName=%{public}s on=%{public}d", interfaceName.c_str(), on);
850 return netsysClient_.SetIpv6PrivacyExtensions(interfaceName, on);
851 }
852
SetEnableIpv6(const std::string & interfaceName,const uint32_t on)853 int32_t NetsysControllerServiceImpl::SetEnableIpv6(const std::string &interfaceName, const uint32_t on)
854 {
855 NETMGR_LOG_I("SetEnableIpv6: interfaceName=%{public}s on=%{public}d", interfaceName.c_str(), on);
856 return netsysClient_.SetEnableIpv6(interfaceName, on);
857 }
858
SetNetworkAccessPolicy(uint32_t uid,NetworkAccessPolicy policy,bool reconfirmFlag,bool isBroker)859 int32_t NetsysControllerServiceImpl::SetNetworkAccessPolicy(uint32_t uid, NetworkAccessPolicy policy,
860 bool reconfirmFlag, bool isBroker)
861 {
862 return netsysClient_.SetNetworkAccessPolicy(uid, policy, reconfirmFlag, isBroker);
863 }
864
DeleteNetworkAccessPolicy(uint32_t uid)865 int32_t NetsysControllerServiceImpl::DeleteNetworkAccessPolicy(uint32_t uid)
866 {
867 return netsysClient_.DeleteNetworkAccessPolicy(uid);
868 }
869
ClearFirewallAllRules()870 int32_t NetsysControllerServiceImpl::ClearFirewallAllRules()
871 {
872 return netsysClient_.ClearFirewallAllRules();
873 }
874
NotifyNetBearerTypeChange(std::set<NetBearType> bearerTypes)875 int32_t NetsysControllerServiceImpl::NotifyNetBearerTypeChange(std::set<NetBearType> bearerTypes)
876 {
877 return netsysClient_.NotifyNetBearerTypeChange(bearerTypes);
878 }
879
StartClat(const std::string & interfaceName,int32_t netId,const std::string & nat64PrefixStr)880 int32_t NetsysControllerServiceImpl::StartClat(const std::string &interfaceName, int32_t netId,
881 const std::string &nat64PrefixStr)
882 {
883 NETMGR_LOG_I("StartClat: interfaceName=%{public}s netId=%{public}d", interfaceName.c_str(), netId);
884 return netsysClient_.StartClat(interfaceName, netId, nat64PrefixStr);
885 }
886
StopClat(const std::string & interfaceName)887 int32_t NetsysControllerServiceImpl::StopClat(const std::string &interfaceName)
888 {
889 NETMGR_LOG_I("StopClat: interfaceName=%{public}s", interfaceName.c_str());
890 return netsysClient_.StopClat(interfaceName);
891 }
892
SetNicTrafficAllowed(const std::vector<std::string> & ifaceNames,bool status)893 int32_t NetsysControllerServiceImpl::SetNicTrafficAllowed(const std::vector<std::string> &ifaceNames, bool status)
894 {
895 NETMGR_LOG_D("SetNicTrafficAllowed: status = %{public}d", status);
896 return netsysClient_.SetNicTrafficAllowed(ifaceNames, status);
897 }
898 } // namespace NetManagerStandard
899 } // namespace OHOS
900