blob: 6731864dec47852efedea15e26d23da4bd277dbb [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 Pius3e2d6712016-10-06 13:16:23 -070045
Roshan Piusabcf78f2017-10-06 16:30:38 -070046 // HIDL methods exposed.
47 Return<void> getName(getName_cb hidl_status_cb) override;
48 Return<void> getType(getType_cb hidl_status_cb) override;
49 Return<void> registerEventCallback(
50 const sp<IWifiStaIfaceEventCallback>& callback,
51 registerEventCallback_cb hidl_status_cb) override;
52 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
53 Return<void> getApfPacketFilterCapabilities(
54 getApfPacketFilterCapabilities_cb hidl_status_cb) override;
55 Return<void> installApfPacketFilter(
56 uint32_t cmd_id, 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> getValidFrequenciesForBand(
61 WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
62 Return<void> startBackgroundScan(
63 uint32_t cmd_id, const StaBackgroundScanParameters& params,
64 startBackgroundScan_cb hidl_status_cb) override;
65 Return<void> stopBackgroundScan(
66 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(
72 getLinkLayerStats_cb hidl_status_cb) override;
73 Return<void> startRssiMonitoring(
74 uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi,
75 startRssiMonitoring_cb hidl_status_cb) override;
76 Return<void> stopRssiMonitoring(
77 uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
78 Return<void> getRoamingCapabilities(
79 getRoamingCapabilities_cb hidl_status_cb) override;
80 Return<void> configureRoaming(const StaRoamingConfig& config,
81 configureRoaming_cb hidl_status_cb) override;
82 Return<void> setRoamingState(StaRoamingState state,
83 setRoamingState_cb hidl_status_cb) override;
84 Return<void> enableNdOffload(bool enable,
85 enableNdOffload_cb hidl_status_cb) override;
86 Return<void> startSendingKeepAlivePackets(
87 uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data,
88 uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address,
89 const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms,
90 startSendingKeepAlivePackets_cb hidl_status_cb) override;
91 Return<void> stopSendingKeepAlivePackets(
92 uint32_t cmd_id,
93 stopSendingKeepAlivePackets_cb hidl_status_cb) override;
94 Return<void> setScanningMacOui(
95 const hidl_array<uint8_t, 3>& oui,
96 setScanningMacOui_cb hidl_status_cb) override;
97 Return<void> startDebugPacketFateMonitoring(
98 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
99 Return<void> getDebugTxPacketFates(
100 getDebugTxPacketFates_cb hidl_status_cb) override;
101 Return<void> getDebugRxPacketFates(
102 getDebugRxPacketFates_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700103
Roshan Piusabcf78f2017-10-06 16:30:38 -0700104 private:
105 // Corresponding worker functions for the HIDL methods.
106 std::pair<WifiStatus, std::string> getNameInternal();
107 std::pair<WifiStatus, IfaceType> getTypeInternal();
108 WifiStatus registerEventCallbackInternal(
109 const sp<IWifiStaIfaceEventCallback>& callback);
110 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
111 std::pair<WifiStatus, StaApfPacketFilterCapabilities>
112 getApfPacketFilterCapabilitiesInternal();
113 WifiStatus installApfPacketFilterInternal(
114 uint32_t cmd_id, const std::vector<uint8_t>& program);
115 std::pair<WifiStatus, StaBackgroundScanCapabilities>
116 getBackgroundScanCapabilitiesInternal();
117 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
118 getValidFrequenciesForBandInternal(WifiBand band);
119 WifiStatus startBackgroundScanInternal(
120 uint32_t cmd_id, const StaBackgroundScanParameters& params);
121 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
122 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
123 WifiStatus disableLinkLayerStatsCollectionInternal();
124 std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
125 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi,
126 int32_t min_rssi);
127 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
128 std::pair<WifiStatus, StaRoamingCapabilities>
129 getRoamingCapabilitiesInternal();
130 WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
131 WifiStatus setRoamingStateInternal(StaRoamingState state);
132 WifiStatus enableNdOffloadInternal(bool enable);
133 WifiStatus startSendingKeepAlivePacketsInternal(
134 uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data,
135 uint16_t ether_type, const std::array<uint8_t, 6>& src_address,
136 const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms);
137 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
138 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
139 WifiStatus startDebugPacketFateMonitoringInternal();
140 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
141 getDebugTxPacketFatesInternal();
142 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
143 getDebugRxPacketFatesInternal();
Roshan Pius907d4a22016-10-27 12:48:12 -0700144
Roshan Piusabcf78f2017-10-06 16:30:38 -0700145 std::string ifname_;
146 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
147 bool is_valid_;
148 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback>
149 event_cb_handler_;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700150
Roshan Piusabcf78f2017-10-06 16:30:38 -0700151 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
Roshan Pius3e2d6712016-10-06 13:16:23 -0700152};
153
154} // namespace implementation
Etan Cohen6ce50902017-09-14 07:30:57 -0700155} // namespace V1_2
Roshan Pius3e2d6712016-10-06 13:16:23 -0700156} // namespace wifi
157} // namespace hardware
158} // namespace android
159
160#endif // WIFI_STA_IFACE_H_