blob: e07154db14fc527559dd3159820b002b80e80281 [file] [log] [blame]
Gabriel Birenf3262f92022-07-15 23:25:39 +00001/*
2 * Copyright (C) 2022 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_AP_IFACE_H_
18#define WIFI_AP_IFACE_H_
19
20#include <aidl/android/hardware/wifi/BnWifiApIface.h>
21#include <android-base/macros.h>
22
23#include "wifi_iface_util.h"
24#include "wifi_legacy_hal.h"
25
26namespace aidl {
27namespace android {
28namespace hardware {
29namespace wifi {
30
31/**
32 * AIDL interface object used to control an AP Iface instance.
33 */
34class WifiApIface : public BnWifiApIface {
35 public:
Les Leeea2d2352024-09-04 17:55:27 +000036 WifiApIface(const std::string& ifname, const bool usesMlo,
37 const std::vector<std::string>& instances,
Gabriel Birenf3262f92022-07-15 23:25:39 +000038 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
39 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util);
40 // Refer to |WifiChip::invalidate()|.
41 void invalidate();
42 bool isValid();
43 std::string getName();
Les Leeea2d2352024-09-04 17:55:27 +000044 bool usesMlo();
Gabriel Birenf3262f92022-07-15 23:25:39 +000045 void removeInstance(std::string instance);
46
47 // AIDL methods exposed.
48 ndk::ScopedAStatus getName(std::string* _aidl_return) override;
49 ndk::ScopedAStatus setCountryCode(const std::array<uint8_t, 2>& in_code) override;
Gabriel Birenf3262f92022-07-15 23:25:39 +000050 ndk::ScopedAStatus setMacAddress(const std::array<uint8_t, 6>& in_mac) override;
51 ndk::ScopedAStatus getFactoryMacAddress(std::array<uint8_t, 6>* _aidl_return) override;
52 ndk::ScopedAStatus resetToFactoryMacAddress() override;
53 ndk::ScopedAStatus getBridgedInstances(std::vector<std::string>* _aidl_return) override;
Les Leeea2d2352024-09-04 17:55:27 +000054 ndk::ScopedAStatus usesMlo(bool* _aidl_return) override;
Gabriel Birenf3262f92022-07-15 23:25:39 +000055
56 private:
57 // Corresponding worker functions for the AIDL methods.
58 std::pair<std::string, ndk::ScopedAStatus> getNameInternal();
59 ndk::ScopedAStatus setCountryCodeInternal(const std::array<uint8_t, 2>& code);
Gabriel Birenf3262f92022-07-15 23:25:39 +000060 ndk::ScopedAStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
61 std::pair<std::array<uint8_t, 6>, ndk::ScopedAStatus> getFactoryMacAddressInternal(
62 const std::string& ifaceName);
63 ndk::ScopedAStatus resetToFactoryMacAddressInternal();
64 std::pair<std::vector<std::string>, ndk::ScopedAStatus> getBridgedInstancesInternal();
65
66 std::string ifname_;
Les Leeea2d2352024-09-04 17:55:27 +000067 bool uses_mlo_;
Gabriel Birenf3262f92022-07-15 23:25:39 +000068 std::vector<std::string> instances_;
69 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
70 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
71 bool is_valid_;
72
Les Leeea2d2352024-09-04 17:55:27 +000073 // The mlo is using one interface but owning two link instances.
74 // The operating should be based on interface.
75 inline std::string getOperatingInstanceName() {
76 return (instances_.size() > 0 && !uses_mlo_) ? instances_[0] : ifname_;
77 };
78
Gabriel Birenf3262f92022-07-15 23:25:39 +000079 DISALLOW_COPY_AND_ASSIGN(WifiApIface);
80};
81
82} // namespace wifi
83} // namespace hardware
84} // namespace android
85} // namespace aidl
86
87#endif // WIFI_AP_IFACE_H_