blob: 5f0ffe9a2c18e4d7e4c0793ce662487cc1833e48 [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>
21#include <android/hardware/wifi/1.0/IWifiStaIface.h>
Roshan Piusa04ba3f2016-10-27 14:36:26 -070022#include <android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.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 {
30namespace V1_0 {
31namespace implementation {
32
33/**
34 * HIDL interface object used to control a STA Iface instance.
35 */
36class WifiStaIface : public IWifiStaIface {
37 public:
38 WifiStaIface(const std::string& ifname,
Roshan Pius6cedc972016-10-28 10:11:17 -070039 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
Roshan Pius3e2d6712016-10-06 13:16:23 -070040 // Refer to |WifiChip::invalidate()|.
41 void invalidate();
Roshan Pius907d4a22016-10-27 12:48:12 -070042 bool isValid();
Roshan Piusd37341f2017-01-31 13:13:28 -080043 std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks();
Roshan Pius3e2d6712016-10-06 13:16:23 -070044
45 // HIDL methods exposed.
Roshan Pius734fea02016-10-11 08:30:28 -070046 Return<void> getName(getName_cb hidl_status_cb) override;
47 Return<void> getType(getType_cb hidl_status_cb) override;
Roshan Piusa04ba3f2016-10-27 14:36:26 -070048 Return<void> registerEventCallback(
49 const sp<IWifiStaIfaceEventCallback>& callback,
50 registerEventCallback_cb hidl_status_cb) override;
51 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
52 Return<void> getApfPacketFilterCapabilities(
53 getApfPacketFilterCapabilities_cb hidl_status_cb) override;
54 Return<void> installApfPacketFilter(
55 uint32_t cmd_id,
56 const hidl_vec<uint8_t>& program,
57 installApfPacketFilter_cb hidl_status_cb) override;
58 Return<void> getBackgroundScanCapabilities(
59 getBackgroundScanCapabilities_cb hidl_status_cb) override;
60 Return<void> getValidFrequenciesForBackgroundScan(
61 StaBackgroundScanBand band,
62 getValidFrequenciesForBackgroundScan_cb hidl_status_cb) override;
63 Return<void> startBackgroundScan(
64 uint32_t cmd_id,
65 const StaBackgroundScanParameters& params,
66 startBackgroundScan_cb hidl_status_cb) override;
67 Return<void> stopBackgroundScan(
68 uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override;
69 Return<void> enableLinkLayerStatsCollection(
70 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override;
71 Return<void> disableLinkLayerStatsCollection(
72 disableLinkLayerStatsCollection_cb hidl_status_cb) override;
73 Return<void> getLinkLayerStats(getLinkLayerStats_cb hidl_status_cb) override;
Roshan Piusd4767542016-12-06 10:04:05 -080074 Return<void> startRssiMonitoring(
75 uint32_t cmd_id,
76 int32_t max_rssi,
77 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;
Roshan Pius26801cb2016-12-13 14:25:45 -080081 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;
Roshan Piusaf727c02017-01-11 15:37:25 -080087 Return<void> enableNdOffload(bool enable,
88 enableNdOffload_cb hidl_status_cb) override;
Roshan Pius9a9869a2017-01-11 16:42:16 -080089 Return<void> startSendingKeepAlivePackets(
90 uint32_t cmd_id,
91 const hidl_vec<uint8_t>& ip_packet_data,
92 uint16_t ether_type,
93 const hidl_array<uint8_t, 6>& src_address,
94 const hidl_array<uint8_t, 6>& dst_address,
95 uint32_t period_in_ms,
96 startSendingKeepAlivePackets_cb hidl_status_cb) override;
97 Return<void> stopSendingKeepAlivePackets(
98 uint32_t cmd_id, stopSendingKeepAlivePackets_cb hidl_status_cb) override;
Roshan Pius795bb812017-02-01 13:09:08 -080099 Return<void> setScanningMacOui(const hidl_array<uint8_t, 3>& oui,
100 setScanningMacOui_cb hidl_status_cb) override;
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700101 Return<void> startDebugPacketFateMonitoring(
102 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700103 Return<void> getDebugTxPacketFates(
104 getDebugTxPacketFates_cb hidl_status_cb) override;
105 Return<void> getDebugRxPacketFates(
106 getDebugRxPacketFates_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700107
108 private:
Roshan Pius907d4a22016-10-27 12:48:12 -0700109 // Corresponding worker functions for the HIDL methods.
110 std::pair<WifiStatus, std::string> getNameInternal();
111 std::pair<WifiStatus, IfaceType> getTypeInternal();
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700112 WifiStatus registerEventCallbackInternal(
113 const sp<IWifiStaIfaceEventCallback>& callback);
114 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
115 std::pair<WifiStatus, StaApfPacketFilterCapabilities>
116 getApfPacketFilterCapabilitiesInternal();
117 WifiStatus installApfPacketFilterInternal(
118 uint32_t cmd_id, const std::vector<uint8_t>& program);
119 std::pair<WifiStatus, StaBackgroundScanCapabilities>
120 getBackgroundScanCapabilitiesInternal();
121 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
122 getValidFrequenciesForBackgroundScanInternal(StaBackgroundScanBand band);
123 WifiStatus startBackgroundScanInternal(
124 uint32_t cmd_id, const StaBackgroundScanParameters& params);
125 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
126 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
127 WifiStatus disableLinkLayerStatsCollectionInternal();
128 std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
Roshan Piusd4767542016-12-06 10:04:05 -0800129 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id,
130 int32_t max_rssi,
131 int32_t min_rssi);
132 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
Roshan Pius26801cb2016-12-13 14:25:45 -0800133 std::pair<WifiStatus, StaRoamingCapabilities>
134 getRoamingCapabilitiesInternal();
135 WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
136 WifiStatus setRoamingStateInternal(StaRoamingState state);
Roshan Piusaf727c02017-01-11 15:37:25 -0800137 WifiStatus enableNdOffloadInternal(bool enable);
Roshan Pius9a9869a2017-01-11 16:42:16 -0800138 WifiStatus startSendingKeepAlivePacketsInternal(
139 uint32_t cmd_id,
140 const std::vector<uint8_t>& ip_packet_data,
141 uint16_t ether_type,
142 const std::array<uint8_t, 6>& src_address,
143 const std::array<uint8_t, 6>& dst_address,
144 uint32_t period_in_ms);
145 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
Roshan Pius795bb812017-02-01 13:09:08 -0800146 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700147 WifiStatus startDebugPacketFateMonitoringInternal();
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700148 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
149 getDebugTxPacketFatesInternal();
150 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
151 getDebugRxPacketFatesInternal();
Roshan Pius907d4a22016-10-27 12:48:12 -0700152
Roshan Pius3e2d6712016-10-06 13:16:23 -0700153 std::string ifname_;
Roshan Pius6cedc972016-10-28 10:11:17 -0700154 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700155 bool is_valid_;
Roshan Piusd37341f2017-01-31 13:13:28 -0800156 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback>
157 event_cb_handler_;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700158
159 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
160};
161
162} // namespace implementation
163} // namespace V1_0
164} // namespace wifi
165} // namespace hardware
166} // namespace android
167
168#endif // WIFI_STA_IFACE_H_