1 /*
2  * Copyright (c) 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 <hdf_log.h>
17 #include "iface_util.h"
18 
19 namespace OHOS {
20 namespace HDI {
21 namespace Wlan {
22 namespace Chip {
23 namespace V1_0 {
IfaceUtil(const std::weak_ptr<IfaceTool> ifaceTool)24 IfaceUtil::IfaceUtil(const std::weak_ptr<IfaceTool> ifaceTool)
25     : ifaceTool_(ifaceTool)
26 {}
27 
SetMacAddress(const std::string & ifaceName,const std::string & mac)28 bool IfaceUtil::SetMacAddress(const std::string& ifaceName, const std::string& mac)
29 {
30     bool success = ifaceTool_.lock()->SetMacAddress(ifaceName.c_str(), mac.c_str());
31     if (!success) {
32         HDF_LOGE("SetMacAddress failed on %{public}s", ifaceName.c_str());
33     } else {
34         HDF_LOGD("SetMacAddress successed on %{public}s", ifaceName.c_str());
35     }
36     return success;
37 }
38 
SetUpState(const std::string & ifaceName,bool requestUp)39 bool IfaceUtil::SetUpState(const std::string& ifaceName, bool requestUp)
40 {
41     return ifaceTool_.lock()->SetUpState(ifaceName.c_str(), requestUp);
42 }
43 
GetUpState(const std::string & ifaceName)44 bool IfaceUtil::GetUpState(const std::string& ifaceName)
45 {
46     return ifaceTool_.lock()->GetUpState(ifaceName.c_str());
47 }
48 }
49 }
50 }
51 }
52 }