blob: fe05c2148325b7f059bd951fe676c58a3df248aa [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_STA_IFACE_H_
18#define WIFI_STA_IFACE_H_
19
20#include <aidl/android/hardware/wifi/BnWifiStaIface.h>
21#include <aidl/android/hardware/wifi/IWifiStaIfaceEventCallback.h>
22#include <android-base/macros.h>
23
24#include "aidl_callback_util.h"
25#include "wifi_iface_util.h"
26#include "wifi_legacy_hal.h"
27
28namespace aidl {
29namespace android {
30namespace hardware {
31namespace wifi {
32
33/**
34 * AIDL interface object used to control a STA Iface instance.
35 */
36class WifiStaIface : public BnWifiStaIface {
37 public:
38 WifiStaIface(const std::string& ifname,
39 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
40 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util);
41
42 // Factory method - use instead of default constructor.
43 static std::shared_ptr<WifiStaIface> create(
44 const std::string& ifname, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
45 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util);
46
47 // Refer to |WifiChip::invalidate()|.
48 void invalidate();
49 bool isValid();
50 std::set<std::shared_ptr<IWifiStaIfaceEventCallback>> getEventCallbacks();
51 std::string getName();
52
53 // AIDL methods exposed.
54 ndk::ScopedAStatus getName(std::string* _aidl_return) override;
55 ndk::ScopedAStatus registerEventCallback(
56 const std::shared_ptr<IWifiStaIfaceEventCallback>& in_callback) override;
Gabriel Biren2f862492023-03-09 19:13:07 +000057 ndk::ScopedAStatus getFeatureSet(int32_t* _aidl_return) override;
Gabriel Birenf3262f92022-07-15 23:25:39 +000058 ndk::ScopedAStatus getApfPacketFilterCapabilities(
59 StaApfPacketFilterCapabilities* _aidl_return) override;
60 ndk::ScopedAStatus installApfPacketFilter(const std::vector<uint8_t>& in_program) override;
61 ndk::ScopedAStatus readApfPacketFilterData(std::vector<uint8_t>* _aidl_return) override;
62 ndk::ScopedAStatus getBackgroundScanCapabilities(
63 StaBackgroundScanCapabilities* _aidl_return) override;
Gabriel Birenf3262f92022-07-15 23:25:39 +000064 ndk::ScopedAStatus startBackgroundScan(int32_t in_cmdId,
65 const StaBackgroundScanParameters& in_params) override;
66 ndk::ScopedAStatus stopBackgroundScan(int32_t in_cmdId) override;
67 ndk::ScopedAStatus enableLinkLayerStatsCollection(bool in_debug) override;
68 ndk::ScopedAStatus disableLinkLayerStatsCollection() override;
69 ndk::ScopedAStatus getLinkLayerStats(StaLinkLayerStats* _aidl_return) override;
70 ndk::ScopedAStatus startRssiMonitoring(int32_t in_cmdId, int32_t in_maxRssi,
71 int32_t in_minRssi) override;
72 ndk::ScopedAStatus stopRssiMonitoring(int32_t in_cmdId) override;
73 ndk::ScopedAStatus getRoamingCapabilities(StaRoamingCapabilities* _aidl_return) override;
74 ndk::ScopedAStatus configureRoaming(const StaRoamingConfig& in_config) override;
75 ndk::ScopedAStatus setRoamingState(StaRoamingState in_state) override;
76 ndk::ScopedAStatus enableNdOffload(bool in_enable) override;
77 ndk::ScopedAStatus startSendingKeepAlivePackets(int32_t in_cmdId,
78 const std::vector<uint8_t>& in_ipPacketData,
79 char16_t in_etherType,
80 const std::array<uint8_t, 6>& in_srcAddress,
81 const std::array<uint8_t, 6>& in_dstAddress,
82 int32_t in_periodInMs) override;
83 ndk::ScopedAStatus stopSendingKeepAlivePackets(int32_t in_cmdId) override;
84 ndk::ScopedAStatus startDebugPacketFateMonitoring() override;
85 ndk::ScopedAStatus getDebugTxPacketFates(
86 std::vector<WifiDebugTxPacketFateReport>* _aidl_return) override;
87 ndk::ScopedAStatus getDebugRxPacketFates(
88 std::vector<WifiDebugRxPacketFateReport>* _aidl_return) override;
89 ndk::ScopedAStatus setMacAddress(const std::array<uint8_t, 6>& in_mac) override;
90 ndk::ScopedAStatus getFactoryMacAddress(std::array<uint8_t, 6>* _aidl_return) override;
91 ndk::ScopedAStatus setScanMode(bool in_enable) override;
Kai Shi6d02d402022-11-17 16:34:05 -080092 ndk::ScopedAStatus setDtimMultiplier(int32_t in_multiplier) override;
Kai Shi7d0e5e92023-11-20 19:23:36 -080093 ndk::ScopedAStatus getCachedScanData(CachedScanData* _aidl_return) override;
Gabriel Birenf3262f92022-07-15 23:25:39 +000094
95 private:
96 // Corresponding worker functions for the AIDL methods.
97 std::pair<std::string, ndk::ScopedAStatus> getNameInternal();
98 ndk::ScopedAStatus registerEventCallbackInternal(
99 const std::shared_ptr<IWifiStaIfaceEventCallback>& callback);
Gabriel Biren2f862492023-03-09 19:13:07 +0000100 std::pair<int32_t, ndk::ScopedAStatus> getFeatureSetInternal();
Gabriel Birenf3262f92022-07-15 23:25:39 +0000101 std::pair<StaApfPacketFilterCapabilities, ndk::ScopedAStatus>
102 getApfPacketFilterCapabilitiesInternal();
103 ndk::ScopedAStatus installApfPacketFilterInternal(const std::vector<uint8_t>& program);
104 std::pair<std::vector<uint8_t>, ndk::ScopedAStatus> readApfPacketFilterDataInternal();
105 std::pair<StaBackgroundScanCapabilities, ndk::ScopedAStatus>
106 getBackgroundScanCapabilitiesInternal();
Gabriel Birenf3262f92022-07-15 23:25:39 +0000107 ndk::ScopedAStatus startBackgroundScanInternal(int32_t cmd_id,
108 const StaBackgroundScanParameters& params);
109 ndk::ScopedAStatus stopBackgroundScanInternal(int32_t cmd_id);
110 ndk::ScopedAStatus enableLinkLayerStatsCollectionInternal(bool debug);
111 ndk::ScopedAStatus disableLinkLayerStatsCollectionInternal();
112 std::pair<StaLinkLayerStats, ndk::ScopedAStatus> getLinkLayerStatsInternal();
113 ndk::ScopedAStatus startRssiMonitoringInternal(int32_t cmd_id, int32_t max_rssi,
114 int32_t min_rssi);
115 ndk::ScopedAStatus stopRssiMonitoringInternal(int32_t cmd_id);
116 std::pair<StaRoamingCapabilities, ndk::ScopedAStatus> getRoamingCapabilitiesInternal();
117 ndk::ScopedAStatus configureRoamingInternal(const StaRoamingConfig& config);
118 ndk::ScopedAStatus setRoamingStateInternal(StaRoamingState state);
119 ndk::ScopedAStatus enableNdOffloadInternal(bool enable);
120 ndk::ScopedAStatus startSendingKeepAlivePacketsInternal(
121 int32_t cmd_id, const std::vector<uint8_t>& ip_packet_data, char16_t ether_type,
122 const std::array<uint8_t, 6>& src_address, const std::array<uint8_t, 6>& dst_address,
123 int32_t period_in_ms);
124 ndk::ScopedAStatus stopSendingKeepAlivePacketsInternal(int32_t cmd_id);
125 ndk::ScopedAStatus startDebugPacketFateMonitoringInternal();
126 std::pair<std::vector<WifiDebugTxPacketFateReport>, ndk::ScopedAStatus>
127 getDebugTxPacketFatesInternal();
128 std::pair<std::vector<WifiDebugRxPacketFateReport>, ndk::ScopedAStatus>
129 getDebugRxPacketFatesInternal();
130 ndk::ScopedAStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
131 std::pair<std::array<uint8_t, 6>, ndk::ScopedAStatus> getFactoryMacAddressInternal();
132 ndk::ScopedAStatus setScanModeInternal(bool enable);
Kai Shi6d02d402022-11-17 16:34:05 -0800133 ndk::ScopedAStatus setDtimMultiplierInternal(const int multiplier);
Kai Shi7d0e5e92023-11-20 19:23:36 -0800134 std::pair<CachedScanData, ndk::ScopedAStatus> getCachedScanDataInternal();
Gabriel Birenf3262f92022-07-15 23:25:39 +0000135
136 void setWeakPtr(std::weak_ptr<WifiStaIface> ptr);
137
138 std::string ifname_;
139 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
140 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
141 std::weak_ptr<WifiStaIface> weak_ptr_this_;
142 bool is_valid_;
143 aidl_callback_util::AidlCallbackHandler<IWifiStaIfaceEventCallback> event_cb_handler_;
144
145 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
146};
147
148} // namespace wifi
149} // namespace hardware
150} // namespace android
151} // namespace aidl
152
153#endif // WIFI_STA_IFACE_H_