blob: 37358a5fb0901bcc20b9487343952380ae8bf6f3 [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>
22#include <android/hardware/wifi/1.5/IWifiStaIface.h>
23
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 */
38class WifiStaIface : public V1_5::IWifiStaIface {
39 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;
74 Return<void> startRssiMonitoring(uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi,
75 startRssiMonitoring_cb hidl_status_cb) override;
76 Return<void> stopRssiMonitoring(uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
77 Return<void> getRoamingCapabilities(getRoamingCapabilities_cb hidl_status_cb) override;
78 Return<void> configureRoaming(const StaRoamingConfig& config,
79 configureRoaming_cb hidl_status_cb) override;
80 Return<void> setRoamingState(StaRoamingState state, setRoamingState_cb hidl_status_cb) override;
81 Return<void> enableNdOffload(bool enable, enableNdOffload_cb hidl_status_cb) override;
82 Return<void> startSendingKeepAlivePackets(
83 uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data, uint16_t ether_type,
84 const hidl_array<uint8_t, 6>& src_address, const hidl_array<uint8_t, 6>& dst_address,
85 uint32_t period_in_ms, startSendingKeepAlivePackets_cb hidl_status_cb) override;
86 Return<void> stopSendingKeepAlivePackets(
87 uint32_t cmd_id, stopSendingKeepAlivePackets_cb hidl_status_cb) override;
88 Return<void> setScanningMacOui(const hidl_array<uint8_t, 3>& oui,
89 setScanningMacOui_cb hidl_status_cb) override;
90 Return<void> startDebugPacketFateMonitoring(
91 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
92 Return<void> getDebugTxPacketFates(getDebugTxPacketFates_cb hidl_status_cb) override;
93 Return<void> getDebugRxPacketFates(getDebugRxPacketFates_cb hidl_status_cb) override;
94 Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac,
95 setMacAddress_cb hidl_status_cb) override;
96 Return<void> getFactoryMacAddress(getFactoryMacAddress_cb hidl_status_cb) override;
97 Return<void> setScanMode(bool enable, setScanMode_cb hidl_status_cb) override;
98
99 private:
100 // Corresponding worker functions for the HIDL methods.
101 std::pair<WifiStatus, std::string> getNameInternal();
102 std::pair<WifiStatus, IfaceType> getTypeInternal();
103 WifiStatus registerEventCallbackInternal(const sp<IWifiStaIfaceEventCallback>& callback);
104 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
105 std::pair<WifiStatus, StaApfPacketFilterCapabilities> getApfPacketFilterCapabilitiesInternal();
106 WifiStatus installApfPacketFilterInternal(uint32_t cmd_id, const std::vector<uint8_t>& program);
107 std::pair<WifiStatus, std::vector<uint8_t>> readApfPacketFilterDataInternal();
108 std::pair<WifiStatus, StaBackgroundScanCapabilities> getBackgroundScanCapabilitiesInternal();
109 std::pair<WifiStatus, std::vector<WifiChannelInMhz>> getValidFrequenciesForBandInternal(
110 V1_0::WifiBand band);
111 WifiStatus startBackgroundScanInternal(uint32_t cmd_id,
112 const StaBackgroundScanParameters& params);
113 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
114 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
115 WifiStatus disableLinkLayerStatsCollectionInternal();
116 std::pair<WifiStatus, V1_0::StaLinkLayerStats> getLinkLayerStatsInternal();
117 std::pair<WifiStatus, V1_3::StaLinkLayerStats> getLinkLayerStatsInternal_1_3();
118 std::pair<WifiStatus, V1_5::StaLinkLayerStats> getLinkLayerStatsInternal_1_5();
119 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi);
120 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
121 std::pair<WifiStatus, StaRoamingCapabilities> getRoamingCapabilitiesInternal();
122 WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
123 WifiStatus setRoamingStateInternal(StaRoamingState state);
124 WifiStatus enableNdOffloadInternal(bool enable);
125 WifiStatus startSendingKeepAlivePacketsInternal(uint32_t cmd_id,
126 const std::vector<uint8_t>& ip_packet_data,
127 uint16_t ether_type,
128 const std::array<uint8_t, 6>& src_address,
129 const std::array<uint8_t, 6>& dst_address,
130 uint32_t period_in_ms);
131 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
132 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
133 WifiStatus startDebugPacketFateMonitoringInternal();
134 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> getDebugTxPacketFatesInternal();
135 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> getDebugRxPacketFatesInternal();
136 WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
137 std::pair<WifiStatus, std::array<uint8_t, 6>> getFactoryMacAddressInternal();
138 WifiStatus setScanModeInternal(bool enable);
139
140 std::string ifname_;
141 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
142 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_;
143 bool is_valid_;
144 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback> event_cb_handler_;
145
146 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
147};
148
149} // namespace implementation
150} // namespace V1_6
151} // namespace wifi
152} // namespace hardware
153} // namespace android
154
155#endif // WIFI_STA_IFACE_H_