blob: 39fa1e8b6dc3e59b9b4f0b417797769c3ed23e01 [file] [log] [blame]
Roshan Pius99dab382019-02-14 07:57:10 -08001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <android-base/logging.h>
18#include <android-base/macros.h>
19#include <private/android_filesystem_config.h>
20
21#include "wifi_iface_util.h"
22
23namespace android {
24namespace hardware {
25namespace wifi {
26namespace V1_3 {
27namespace implementation {
28namespace iface_util {
29
30WifiIfaceUtil::WifiIfaceUtil() {}
31
32std::array<uint8_t, 6> WifiIfaceUtil::getFactoryMacAddress(
33 const std::string& iface_name) {
34 return iface_tool_.GetFactoryMacAddress(iface_name.c_str());
35}
36
37bool WifiIfaceUtil::setMacAddress(const std::string& iface_name,
38 const std::array<uint8_t, 6>& mac) {
39 if (!iface_tool_.SetUpState(iface_name.c_str(), false)) {
40 LOG(ERROR) << "SetUpState(false) failed.";
41 return false;
42 }
43 if (!iface_tool_.SetMacAddress(iface_name.c_str(), mac)) {
44 LOG(ERROR) << "SetMacAddress failed.";
45 return false;
46 }
47 if (!iface_tool_.SetUpState(iface_name.c_str(), true)) {
48 LOG(ERROR) << "SetUpState(true) failed.";
49 return false;
50 }
51 LOG(DEBUG) << "Successfully SetMacAddress.";
52 return true;
53}
54
55} // namespace iface_util
56} // namespace implementation
57} // namespace V1_3
58} // namespace wifi
59} // namespace hardware
60} // namespace android