blob: c01c50b61242e5ea81af001a5383504242d5ecc5 [file] [log] [blame]
Ahmed ElArabawy687ce132022-01-11 16:42:48 -08001/*
2 * Copyright (C) 2016 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 <android-base/macros.h>
21#include <android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.h>
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080022#include <android/hardware/wifi/1.6/IWifiStaIface.h>
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080023
24#include "hidl_callback_util.h"
25#include "wifi_iface_util.h"
26#include "wifi_legacy_hal.h"
27
28namespace android {
29namespace hardware {
30namespace wifi {
31namespace V1_6 {
32namespace implementation {
33using namespace android::hardware::wifi::V1_0;
34
35/**
36 * HIDL interface object used to control a STA Iface instance.
37 */
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080038class WifiStaIface : public V1_6::IWifiStaIface {
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080039 public:
40 WifiStaIface(const std::string& ifname,
41 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
42 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util);
43 // Refer to |WifiChip::invalidate()|.
44 void invalidate();
45 bool isValid();
46 std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks();
47 std::string getName();
48
49 // HIDL methods exposed.
50 Return<void> getName(getName_cb hidl_status_cb) override;
51 Return<void> getType(getType_cb hidl_status_cb) override;
52 Return<void> registerEventCallback(const sp<IWifiStaIfaceEventCallback>& callback,
53 registerEventCallback_cb hidl_status_cb) override;
54 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
55 Return<void> getApfPacketFilterCapabilities(
56 getApfPacketFilterCapabilities_cb hidl_status_cb) override;
57 Return<void> installApfPacketFilter(uint32_t cmd_id, const hidl_vec<uint8_t>& program,
58 installApfPacketFilter_cb hidl_status_cb) override;
59 Return<void> readApfPacketFilterData(readApfPacketFilterData_cb hidl_status_cb) override;
60 Return<void> getBackgroundScanCapabilities(
61 getBackgroundScanCapabilities_cb hidl_status_cb) override;
62 Return<void> getValidFrequenciesForBand(V1_0::WifiBand band,
63 getValidFrequenciesForBand_cb hidl_status_cb) override;
64 Return<void> startBackgroundScan(uint32_t cmd_id, const StaBackgroundScanParameters& params,
65 startBackgroundScan_cb hidl_status_cb) override;
66 Return<void> stopBackgroundScan(uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override;
67 Return<void> enableLinkLayerStatsCollection(
68 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override;
69 Return<void> disableLinkLayerStatsCollection(
70 disableLinkLayerStatsCollection_cb hidl_status_cb) override;
71 Return<void> getLinkLayerStats(getLinkLayerStats_cb hidl_status_cb) override;
72 Return<void> getLinkLayerStats_1_3(getLinkLayerStats_1_3_cb hidl_status_cb) override;
73 Return<void> getLinkLayerStats_1_5(getLinkLayerStats_1_5_cb hidl_status_cb) override;
Ahmed ElArabawy05571e42022-01-19 11:54:11 -080074 Return<void> getLinkLayerStats_1_6(getLinkLayerStats_1_6_cb hidl_status_cb) override;
Ahmed ElArabawy687ce132022-01-11 16:42:48 -080075 Return<void> startRssiMonitoring(uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi,
76 startRssiMonitoring_cb hidl_status_cb) override;
77 Return<void> stopRssiMonitoring(uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
78 Return<void> getRoamingCapabilities(getRoamingCapabilities_cb hidl_status_cb) override;
79 Return<void> configureRoaming(const StaRoamingConfig& config,
80 configureRoaming_cb hidl_status_cb) override;
81 Return<void> setRoamingState(StaRoamingState state, setRoamingState_cb hidl_status_cb) override;
82 Return<void> enableNdOffload(bool enable, enableNdOffload_cb hidl_status_cb) override;
83 Return<void> startSendingKeepAlivePackets(
84 uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data, uint16_t ether_type,
85 const hidl_array<uint8_t, 6>& src_address, const hidl_array<uint8_t, 6>& dst_address,
86 uint32_t period_in_ms, startSendingKeepAlivePackets_cb hidl_status_cb) override;
87 Return<void> stopSendingKeepAlivePackets(
88 uint32_t cmd_id, stopSendingKeepAlivePackets_cb hidl_status_cb) override;
89 Return<void> setScanningMacOui(const hidl_array<uint8_t, 3>& oui,
90 setScanningMacOui_cb hidl_status_cb) override;
91 Return<void> startDebugPacketFateMonitoring(
92 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
93 Return<void> getDebugTxPacketFates(getDebugTxPacketFates_cb hidl_status_cb) override;
94 Return<void> getDebugRxPacketFates(getDebugRxPacketFates_cb hidl_status_cb) override;
95 Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac,
96 setMacAddress_cb hidl_status_cb) override;
97 Return<void> getFactoryMacAddress(getFactoryMacAddress_cb hidl_status_cb) override;
98 Return<void> setScanMode(bool enable, setScanMode_cb hidl_status_cb) override;
99
100 private:
101 // Corresponding worker functions for the HIDL methods.
102 std::pair<WifiStatus, std::string> getNameInternal();
103 std::pair<WifiStatus, IfaceType> getTypeInternal();
104 WifiStatus registerEventCallbackInternal(const sp<IWifiStaIfaceEventCallback>& callback);
105 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
106 std::pair<WifiStatus, StaApfPacketFilterCapabilities> getApfPacketFilterCapabilitiesInternal();
107 WifiStatus installApfPacketFilterInternal(uint32_t cmd_id, const std::vector<uint8_t>& program);
108 std::pair<WifiStatus, std::vector<uint8_t>> readApfPacketFilterDataInternal();
109 std::pair<WifiStatus, StaBackgroundScanCapabilities> getBackgroundScanCapabilitiesInternal();
110 std::pair<WifiStatus, std::vector<WifiChannelInMhz>> getValidFrequenciesForBandInternal(
111 V1_0::WifiBand band);
112 WifiStatus startBackgroundScanInternal(uint32_t cmd_id,
113 const StaBackgroundScanParameters& params);
114 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
115 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
116 WifiStatus disableLinkLayerStatsCollectionInternal();
117 std::pair<WifiStatus, V1_0::StaLinkLayerStats> getLinkLayerStatsInternal();
118 std::pair<WifiStatus, V1_3::StaLinkLayerStats> getLinkLayerStatsInternal_1_3();
119 std::pair<WifiStatus, V1_5::StaLinkLayerStats> getLinkLayerStatsInternal_1_5();
Ahmed ElArabawy05571e42022-01-19 11:54:11 -0800120 std::pair<WifiStatus, V1_6::StaLinkLayerStats> getLinkLayerStatsInternal_1_6();
Ahmed ElArabawy687ce132022-01-11 16:42:48 -0800121 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi);
122 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
123 std::pair<WifiStatus, StaRoamingCapabilities> getRoamingCapabilitiesInternal();
124 WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
125 WifiStatus setRoamingStateInternal(StaRoamingState state);
126 WifiStatus enableNdOffloadInternal(bool enable);
127 WifiStatus startSendingKeepAlivePacketsInternal(uint32_t cmd_id,
128 const std::vector<uint8_t>& ip_packet_data,
129 uint16_t ether_type,
130 const std::array<uint8_t, 6>& src_address,
131 const std::array<uint8_t, 6>& dst_address,
132 uint32_t period_in_ms);
133 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
134 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
135 WifiStatus startDebugPacketFateMonitoringInternal();
136 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> getDebugTxPacketFatesInternal();
137 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> getDebugRxPacketFatesInternal();
138 WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
139 std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal();
140 WifiStatus setScanModeInternal(bool enable);
141
142 std::string ifname_;
143 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
144 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
145 bool is_valid_;
146 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback> event_cb_handler_;
147
148 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
149};
150
151} // namespace implementation
152} // namespace V1_6
153} // namespace wifi
154} // namespace hardware
155} // namespace android
156
157#endif // WIFI_STA_IFACE_H_