Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 1 | /* |
| 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 | #ifndef WIFI_IFACE_UTIL_H_ |
| 18 | #define WIFI_IFACE_UTIL_H_ |
| 19 | |
| 20 | #include <wifi_system/interface_tool.h> |
| 21 | |
| 22 | #include <android/hardware/wifi/1.0/IWifi.h> |
| 23 | |
| 24 | namespace android { |
| 25 | namespace hardware { |
| 26 | namespace wifi { |
| 27 | namespace V1_3 { |
| 28 | namespace implementation { |
| 29 | namespace iface_util { |
| 30 | |
| 31 | /** |
| 32 | * Util class for common iface operations. |
| 33 | */ |
| 34 | class WifiIfaceUtil { |
| 35 | public: |
| 36 | WifiIfaceUtil(); |
| 37 | virtual ~WifiIfaceUtil() = default; |
| 38 | |
| 39 | virtual std::array<uint8_t, 6> getFactoryMacAddress( |
| 40 | const std::string& iface_name); |
| 41 | virtual bool setMacAddress(const std::string& iface_name, |
| 42 | const std::array<uint8_t, 6>& mac); |
Roshan Pius | 3b6705f | 2019-02-14 09:43:43 -0800 | [diff] [blame^] | 43 | // Get or create a random MAC address. The MAC address returned from |
| 44 | // this method will remain the same throughout the lifetime of the HAL |
| 45 | // daemon. (So, changes on every reboot) |
| 46 | virtual std::array<uint8_t, 6> getOrCreateRandomMacAddress(); |
Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 47 | |
| 48 | private: |
Roshan Pius | 3b6705f | 2019-02-14 09:43:43 -0800 | [diff] [blame^] | 49 | std::array<uint8_t, 6> createRandomMacAddress(); |
| 50 | |
Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 51 | wifi_system::InterfaceTool iface_tool_; |
Roshan Pius | 3b6705f | 2019-02-14 09:43:43 -0800 | [diff] [blame^] | 52 | std::unique_ptr<std::array<uint8_t, 6>> random_mac_address_; |
Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | } // namespace iface_util |
| 56 | } // namespace implementation |
| 57 | } // namespace V1_3 |
| 58 | } // namespace wifi |
| 59 | } // namespace hardware |
| 60 | } // namespace android |
| 61 | |
| 62 | #endif // WIFI_IFACE_UTIL_H_ |