blob: 423365cfbdc78b6999e1359a89e0b3c3294fc4d0 [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 {
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 */
Roshan Piusdbd83ef2017-06-20 12:05:40 -070037class WifiStaIface : public V1_0::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;
59 Return<void> getBackgroundScanCapabilities(
60 getBackgroundScanCapabilities_cb hidl_status_cb) override;
61 Return<void> getValidFrequenciesForBand(
62 WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
63 Return<void> startBackgroundScan(
64 uint32_t cmd_id, const StaBackgroundScanParameters& params,
65 startBackgroundScan_cb hidl_status_cb) override;
66 Return<void> stopBackgroundScan(
67 uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override;
68 Return<void> enableLinkLayerStatsCollection(
69 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override;
70 Return<void> disableLinkLayerStatsCollection(
71 disableLinkLayerStatsCollection_cb hidl_status_cb) override;
72 Return<void> getLinkLayerStats(
73 getLinkLayerStats_cb hidl_status_cb) override;
74 Return<void> startRssiMonitoring(
75 uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi,
76 startRssiMonitoring_cb hidl_status_cb) override;
77 Return<void> stopRssiMonitoring(
78 uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
79 Return<void> getRoamingCapabilities(
80 getRoamingCapabilities_cb hidl_status_cb) override;
81 Return<void> configureRoaming(const StaRoamingConfig& config,
82 configureRoaming_cb hidl_status_cb) override;
83 Return<void> setRoamingState(StaRoamingState state,
84 setRoamingState_cb hidl_status_cb) override;
85 Return<void> enableNdOffload(bool enable,
86 enableNdOffload_cb hidl_status_cb) override;
87 Return<void> startSendingKeepAlivePackets(
88 uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data,
89 uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address,
90 const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms,
91 startSendingKeepAlivePackets_cb hidl_status_cb) override;
92 Return<void> stopSendingKeepAlivePackets(
93 uint32_t cmd_id,
94 stopSendingKeepAlivePackets_cb hidl_status_cb) override;
95 Return<void> setScanningMacOui(
96 const hidl_array<uint8_t, 3>& oui,
97 setScanningMacOui_cb hidl_status_cb) override;
98 Return<void> startDebugPacketFateMonitoring(
99 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
100 Return<void> getDebugTxPacketFates(
101 getDebugTxPacketFates_cb hidl_status_cb) override;
102 Return<void> getDebugRxPacketFates(
103 getDebugRxPacketFates_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700104
Roshan Piusabcf78f2017-10-06 16:30:38 -0700105 private:
106 // Corresponding worker functions for the HIDL methods.
107 std::pair<WifiStatus, std::string> getNameInternal();
108 std::pair<WifiStatus, IfaceType> getTypeInternal();
109 WifiStatus registerEventCallbackInternal(
110 const sp<IWifiStaIfaceEventCallback>& callback);
111 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
112 std::pair<WifiStatus, StaApfPacketFilterCapabilities>
113 getApfPacketFilterCapabilitiesInternal();
114 WifiStatus installApfPacketFilterInternal(
115 uint32_t cmd_id, const std::vector<uint8_t>& program);
116 std::pair<WifiStatus, StaBackgroundScanCapabilities>
117 getBackgroundScanCapabilitiesInternal();
118 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
119 getValidFrequenciesForBandInternal(WifiBand band);
120 WifiStatus startBackgroundScanInternal(
121 uint32_t cmd_id, const StaBackgroundScanParameters& params);
122 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
123 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
124 WifiStatus disableLinkLayerStatsCollectionInternal();
125 std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
126 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi,
127 int32_t min_rssi);
128 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
129 std::pair<WifiStatus, StaRoamingCapabilities>
130 getRoamingCapabilitiesInternal();
131 WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
132 WifiStatus setRoamingStateInternal(StaRoamingState state);
133 WifiStatus enableNdOffloadInternal(bool enable);
134 WifiStatus startSendingKeepAlivePacketsInternal(
135 uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data,
136 uint16_t ether_type, const std::array<uint8_t, 6>& src_address,
137 const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms);
138 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
139 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
140 WifiStatus startDebugPacketFateMonitoringInternal();
141 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
142 getDebugTxPacketFatesInternal();
143 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
144 getDebugRxPacketFatesInternal();
Roshan Pius907d4a22016-10-27 12:48:12 -0700145
Roshan Piusabcf78f2017-10-06 16:30:38 -0700146 std::string ifname_;
147 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
148 bool is_valid_;
149 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback>
150 event_cb_handler_;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700151
Roshan Piusabcf78f2017-10-06 16:30:38 -0700152 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
Roshan Pius3e2d6712016-10-06 13:16:23 -0700153};
154
155} // namespace implementation
Etan Cohen6ce50902017-09-14 07:30:57 -0700156} // namespace V1_2
Roshan Pius3e2d6712016-10-06 13:16:23 -0700157} // namespace wifi
158} // namespace hardware
159} // namespace android
160
161#endif // WIFI_STA_IFACE_H_