blob: 71cd17d30c1f967b79779f245a86334e00b5cc6c [file] [log] [blame]
Roshan Pius3e2d6712016-10-06 13:16:23 -07001/*
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>
Roshan Piusa04ba3f2016-10-27 14:36:26 -070021#include <android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.h>
Bernie Innocenti7e6f71a2018-03-07 00:17:50 +090022#include <android/hardware/wifi/1.2/IWifiStaIface.h>
Roshan Pius3e2d6712016-10-06 13:16:23 -070023
Jong Wook Kimb9f0ff92018-03-16 16:21:49 -070024#include <wifi_system/interface_tool.h>
25
Roshan Piusd37341f2017-01-31 13:13:28 -080026#include "hidl_callback_util.h"
Roshan Pius3e2d6712016-10-06 13:16:23 -070027#include "wifi_legacy_hal.h"
28
29namespace android {
30namespace hardware {
31namespace wifi {
Etan Cohen6ce50902017-09-14 07:30:57 -070032namespace V1_2 {
Roshan Pius3e2d6712016-10-06 13:16:23 -070033namespace implementation {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070034using namespace android::hardware::wifi::V1_0;
Roshan Pius3e2d6712016-10-06 13:16:23 -070035
36/**
37 * HIDL interface object used to control a STA Iface instance.
38 */
Bernie Innocenti7e6f71a2018-03-07 00:17:50 +090039class WifiStaIface : public V1_2::IWifiStaIface {
Roshan Piusabcf78f2017-10-06 16:30:38 -070040 public:
41 WifiStaIface(const std::string& ifname,
42 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
43 // Refer to |WifiChip::invalidate()|.
44 void invalidate();
45 bool isValid();
46 std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks();
Roshan Pius675609b2017-10-31 14:24:58 -070047 std::string getName();
Roshan Pius3e2d6712016-10-06 13:16:23 -070048
Roshan Piusabcf78f2017-10-06 16:30:38 -070049 // 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(
53 const sp<IWifiStaIfaceEventCallback>& callback,
54 registerEventCallback_cb hidl_status_cb) override;
55 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
56 Return<void> getApfPacketFilterCapabilities(
57 getApfPacketFilterCapabilities_cb hidl_status_cb) override;
58 Return<void> installApfPacketFilter(
59 uint32_t cmd_id, const hidl_vec<uint8_t>& program,
60 installApfPacketFilter_cb hidl_status_cb) override;
Bernie Innocenti7e6f71a2018-03-07 00:17:50 +090061 Return<void> readApfPacketFilterData(
62 readApfPacketFilterData_cb hidl_status_cb) override;
Roshan Piusabcf78f2017-10-06 16:30:38 -070063 Return<void> getBackgroundScanCapabilities(
64 getBackgroundScanCapabilities_cb hidl_status_cb) override;
65 Return<void> getValidFrequenciesForBand(
66 WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
67 Return<void> startBackgroundScan(
68 uint32_t cmd_id, const StaBackgroundScanParameters& params,
69 startBackgroundScan_cb hidl_status_cb) override;
70 Return<void> stopBackgroundScan(
71 uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override;
72 Return<void> enableLinkLayerStatsCollection(
73 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override;
74 Return<void> disableLinkLayerStatsCollection(
75 disableLinkLayerStatsCollection_cb hidl_status_cb) override;
76 Return<void> getLinkLayerStats(
77 getLinkLayerStats_cb hidl_status_cb) override;
78 Return<void> startRssiMonitoring(
79 uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi,
80 startRssiMonitoring_cb hidl_status_cb) override;
81 Return<void> stopRssiMonitoring(
82 uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
83 Return<void> getRoamingCapabilities(
84 getRoamingCapabilities_cb hidl_status_cb) override;
85 Return<void> configureRoaming(const StaRoamingConfig& config,
86 configureRoaming_cb hidl_status_cb) override;
87 Return<void> setRoamingState(StaRoamingState state,
88 setRoamingState_cb hidl_status_cb) override;
89 Return<void> enableNdOffload(bool enable,
90 enableNdOffload_cb hidl_status_cb) override;
91 Return<void> startSendingKeepAlivePackets(
92 uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data,
93 uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address,
94 const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms,
95 startSendingKeepAlivePackets_cb hidl_status_cb) override;
96 Return<void> stopSendingKeepAlivePackets(
97 uint32_t cmd_id,
98 stopSendingKeepAlivePackets_cb hidl_status_cb) override;
99 Return<void> setScanningMacOui(
100 const hidl_array<uint8_t, 3>& oui,
101 setScanningMacOui_cb hidl_status_cb) override;
102 Return<void> startDebugPacketFateMonitoring(
103 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
104 Return<void> getDebugTxPacketFates(
105 getDebugTxPacketFates_cb hidl_status_cb) override;
106 Return<void> getDebugRxPacketFates(
107 getDebugRxPacketFates_cb hidl_status_cb) override;
Jong Wook Kimb9f0ff92018-03-16 16:21:49 -0700108 Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac,
109 setMacAddress_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700110
Roshan Piusabcf78f2017-10-06 16:30:38 -0700111 private:
112 // Corresponding worker functions for the HIDL methods.
113 std::pair<WifiStatus, std::string> getNameInternal();
114 std::pair<WifiStatus, IfaceType> getTypeInternal();
115 WifiStatus registerEventCallbackInternal(
116 const sp<IWifiStaIfaceEventCallback>& callback);
117 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
118 std::pair<WifiStatus, StaApfPacketFilterCapabilities>
119 getApfPacketFilterCapabilitiesInternal();
120 WifiStatus installApfPacketFilterInternal(
121 uint32_t cmd_id, const std::vector<uint8_t>& program);
Bernie Innocenti7e6f71a2018-03-07 00:17:50 +0900122 std::pair<WifiStatus, std::vector<uint8_t>>
123 readApfPacketFilterDataInternal();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700124 std::pair<WifiStatus, StaBackgroundScanCapabilities>
125 getBackgroundScanCapabilitiesInternal();
126 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
127 getValidFrequenciesForBandInternal(WifiBand band);
128 WifiStatus startBackgroundScanInternal(
129 uint32_t cmd_id, const StaBackgroundScanParameters& params);
130 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
131 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
132 WifiStatus disableLinkLayerStatsCollectionInternal();
133 std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
134 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi,
135 int32_t min_rssi);
136 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
137 std::pair<WifiStatus, StaRoamingCapabilities>
138 getRoamingCapabilitiesInternal();
139 WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
140 WifiStatus setRoamingStateInternal(StaRoamingState state);
141 WifiStatus enableNdOffloadInternal(bool enable);
142 WifiStatus startSendingKeepAlivePacketsInternal(
143 uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data,
144 uint16_t ether_type, const std::array<uint8_t, 6>& src_address,
145 const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms);
146 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
147 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
148 WifiStatus startDebugPacketFateMonitoringInternal();
149 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
150 getDebugTxPacketFatesInternal();
151 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
152 getDebugRxPacketFatesInternal();
Jong Wook Kimb9f0ff92018-03-16 16:21:49 -0700153 WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
Roshan Pius907d4a22016-10-27 12:48:12 -0700154
Roshan Piusabcf78f2017-10-06 16:30:38 -0700155 std::string ifname_;
156 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
157 bool is_valid_;
158 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback>
159 event_cb_handler_;
Jong Wook Kimb9f0ff92018-03-16 16:21:49 -0700160 wifi_system::InterfaceTool iface_tool_;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700161
Roshan Piusabcf78f2017-10-06 16:30:38 -0700162 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
Roshan Pius3e2d6712016-10-06 13:16:23 -0700163};
164
165} // namespace implementation
Etan Cohen6ce50902017-09-14 07:30:57 -0700166} // namespace V1_2
Roshan Pius3e2d6712016-10-06 13:16:23 -0700167} // namespace wifi
168} // namespace hardware
169} // namespace android
170
171#endif // WIFI_STA_IFACE_H_