blob: a2128882f541704368e331a06d6775b80c9cc837 [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
Roshan Piusd37341f2017-01-31 13:13:28 -080024#include "hidl_callback_util.h"
Roshan Pius3e2d6712016-10-06 13:16:23 -070025#include "wifi_legacy_hal.h"
26
27namespace android {
28namespace hardware {
29namespace wifi {
Etan Cohen6ce50902017-09-14 07:30:57 -070030namespace V1_2 {
Roshan Pius3e2d6712016-10-06 13:16:23 -070031namespace implementation {
Roshan Piusdbd83ef2017-06-20 12:05:40 -070032using namespace android::hardware::wifi::V1_0;
Roshan Pius3e2d6712016-10-06 13:16:23 -070033
34/**
35 * HIDL interface object used to control a STA Iface instance.
36 */
Bernie Innocenti7e6f71a2018-03-07 00:17:50 +090037class WifiStaIface : public V1_2::IWifiStaIface {
Roshan Piusabcf78f2017-10-06 16:30:38 -070038 public:
39 WifiStaIface(const std::string& ifname,
40 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
41 // Refer to |WifiChip::invalidate()|.
42 void invalidate();
43 bool isValid();
44 std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks();
Roshan Pius675609b2017-10-31 14:24:58 -070045 std::string getName();
Roshan Pius3e2d6712016-10-06 13:16:23 -070046
Roshan Piusabcf78f2017-10-06 16:30:38 -070047 // HIDL methods exposed.
48 Return<void> getName(getName_cb hidl_status_cb) override;
49 Return<void> getType(getType_cb hidl_status_cb) override;
50 Return<void> registerEventCallback(
51 const sp<IWifiStaIfaceEventCallback>& callback,
52 registerEventCallback_cb hidl_status_cb) override;
53 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
54 Return<void> getApfPacketFilterCapabilities(
55 getApfPacketFilterCapabilities_cb hidl_status_cb) override;
56 Return<void> installApfPacketFilter(
57 uint32_t cmd_id, const hidl_vec<uint8_t>& program,
58 installApfPacketFilter_cb hidl_status_cb) override;
Bernie Innocenti7e6f71a2018-03-07 00:17:50 +090059 Return<void> readApfPacketFilterData(
60 readApfPacketFilterData_cb hidl_status_cb) override;
Roshan Piusabcf78f2017-10-06 16:30:38 -070061 Return<void> getBackgroundScanCapabilities(
62 getBackgroundScanCapabilities_cb hidl_status_cb) override;
63 Return<void> getValidFrequenciesForBand(
64 WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
65 Return<void> startBackgroundScan(
66 uint32_t cmd_id, const StaBackgroundScanParameters& params,
67 startBackgroundScan_cb hidl_status_cb) override;
68 Return<void> stopBackgroundScan(
69 uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override;
70 Return<void> enableLinkLayerStatsCollection(
71 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override;
72 Return<void> disableLinkLayerStatsCollection(
73 disableLinkLayerStatsCollection_cb hidl_status_cb) override;
74 Return<void> getLinkLayerStats(
75 getLinkLayerStats_cb hidl_status_cb) override;
76 Return<void> startRssiMonitoring(
77 uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi,
78 startRssiMonitoring_cb hidl_status_cb) override;
79 Return<void> stopRssiMonitoring(
80 uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
81 Return<void> getRoamingCapabilities(
82 getRoamingCapabilities_cb hidl_status_cb) override;
83 Return<void> configureRoaming(const StaRoamingConfig& config,
84 configureRoaming_cb hidl_status_cb) override;
85 Return<void> setRoamingState(StaRoamingState state,
86 setRoamingState_cb hidl_status_cb) override;
87 Return<void> enableNdOffload(bool enable,
88 enableNdOffload_cb hidl_status_cb) override;
89 Return<void> startSendingKeepAlivePackets(
90 uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data,
91 uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address,
92 const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms,
93 startSendingKeepAlivePackets_cb hidl_status_cb) override;
94 Return<void> stopSendingKeepAlivePackets(
95 uint32_t cmd_id,
96 stopSendingKeepAlivePackets_cb hidl_status_cb) override;
97 Return<void> setScanningMacOui(
98 const hidl_array<uint8_t, 3>& oui,
99 setScanningMacOui_cb hidl_status_cb) override;
100 Return<void> startDebugPacketFateMonitoring(
101 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
102 Return<void> getDebugTxPacketFates(
103 getDebugTxPacketFates_cb hidl_status_cb) override;
104 Return<void> getDebugRxPacketFates(
105 getDebugRxPacketFates_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700106
Roshan Piusabcf78f2017-10-06 16:30:38 -0700107 private:
108 // Corresponding worker functions for the HIDL methods.
109 std::pair<WifiStatus, std::string> getNameInternal();
110 std::pair<WifiStatus, IfaceType> getTypeInternal();
111 WifiStatus registerEventCallbackInternal(
112 const sp<IWifiStaIfaceEventCallback>& callback);
113 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
114 std::pair<WifiStatus, StaApfPacketFilterCapabilities>
115 getApfPacketFilterCapabilitiesInternal();
116 WifiStatus installApfPacketFilterInternal(
117 uint32_t cmd_id, const std::vector<uint8_t>& program);
Bernie Innocenti7e6f71a2018-03-07 00:17:50 +0900118 std::pair<WifiStatus, std::vector<uint8_t>>
119 readApfPacketFilterDataInternal();
Roshan Piusabcf78f2017-10-06 16:30:38 -0700120 std::pair<WifiStatus, StaBackgroundScanCapabilities>
121 getBackgroundScanCapabilitiesInternal();
122 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
123 getValidFrequenciesForBandInternal(WifiBand band);
124 WifiStatus startBackgroundScanInternal(
125 uint32_t cmd_id, const StaBackgroundScanParameters& params);
126 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
127 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
128 WifiStatus disableLinkLayerStatsCollectionInternal();
129 std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
130 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi,
131 int32_t min_rssi);
132 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
133 std::pair<WifiStatus, StaRoamingCapabilities>
134 getRoamingCapabilitiesInternal();
135 WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
136 WifiStatus setRoamingStateInternal(StaRoamingState state);
137 WifiStatus enableNdOffloadInternal(bool enable);
138 WifiStatus startSendingKeepAlivePacketsInternal(
139 uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data,
140 uint16_t ether_type, const std::array<uint8_t, 6>& src_address,
141 const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms);
142 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
143 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
144 WifiStatus startDebugPacketFateMonitoringInternal();
145 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
146 getDebugTxPacketFatesInternal();
147 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
148 getDebugRxPacketFatesInternal();
Roshan Pius907d4a22016-10-27 12:48:12 -0700149
Roshan Piusabcf78f2017-10-06 16:30:38 -0700150 std::string ifname_;
151 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
152 bool is_valid_;
153 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback>
154 event_cb_handler_;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700155
Roshan Piusabcf78f2017-10-06 16:30:38 -0700156 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
Roshan Pius3e2d6712016-10-06 13:16:23 -0700157};
158
159} // namespace implementation
Etan Cohen6ce50902017-09-14 07:30:57 -0700160} // namespace V1_2
Roshan Pius3e2d6712016-10-06 13:16:23 -0700161} // namespace wifi
162} // namespace hardware
163} // namespace android
164
165#endif // WIFI_STA_IFACE_H_