Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 1 | /* |
| 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 Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 21 | #include <android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.h> |
Roshan Pius | e9d1e7d | 2020-11-04 11:44:16 -0800 | [diff] [blame] | 22 | #include <android/hardware/wifi/1.5/IWifiStaIface.h> |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 23 | |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 24 | #include "hidl_callback_util.h" |
Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 25 | #include "wifi_iface_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 26 | #include "wifi_legacy_hal.h" |
| 27 | |
| 28 | namespace android { |
| 29 | namespace hardware { |
| 30 | namespace wifi { |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 31 | namespace V1_5 { |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 32 | namespace implementation { |
Roshan Pius | dbd83ef | 2017-06-20 12:05:40 -0700 | [diff] [blame] | 33 | using namespace android::hardware::wifi::V1_0; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * HIDL interface object used to control a STA Iface instance. |
| 37 | */ |
Roshan Pius | e9d1e7d | 2020-11-04 11:44:16 -0800 | [diff] [blame] | 38 | class WifiStaIface : public V1_5::IWifiStaIface { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 39 | public: |
| 40 | WifiStaIface(const std::string& ifname, |
Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 41 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, |
| 42 | const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 43 | // Refer to |WifiChip::invalidate()|. |
| 44 | void invalidate(); |
| 45 | bool isValid(); |
| 46 | std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks(); |
Roshan Pius | 675609b | 2017-10-31 14:24:58 -0700 | [diff] [blame] | 47 | std::string getName(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 48 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 49 | // 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 Innocenti | 7e6f71a | 2018-03-07 00:17:50 +0900 | [diff] [blame] | 61 | Return<void> readApfPacketFilterData( |
| 62 | readApfPacketFilterData_cb hidl_status_cb) override; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 63 | Return<void> getBackgroundScanCapabilities( |
| 64 | getBackgroundScanCapabilities_cb hidl_status_cb) override; |
| 65 | Return<void> getValidFrequenciesForBand( |
Ahmed ElArabawy | fd809fc | 2019-11-15 18:19:15 -0800 | [diff] [blame] | 66 | V1_0::WifiBand band, |
| 67 | getValidFrequenciesForBand_cb hidl_status_cb) override; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 68 | Return<void> startBackgroundScan( |
| 69 | uint32_t cmd_id, const StaBackgroundScanParameters& params, |
| 70 | startBackgroundScan_cb hidl_status_cb) override; |
| 71 | Return<void> stopBackgroundScan( |
| 72 | uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override; |
| 73 | Return<void> enableLinkLayerStatsCollection( |
| 74 | bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override; |
| 75 | Return<void> disableLinkLayerStatsCollection( |
| 76 | disableLinkLayerStatsCollection_cb hidl_status_cb) override; |
| 77 | Return<void> getLinkLayerStats( |
| 78 | getLinkLayerStats_cb hidl_status_cb) override; |
xshu | e987325 | 2018-08-07 11:04:34 -0700 | [diff] [blame] | 79 | Return<void> getLinkLayerStats_1_3( |
| 80 | getLinkLayerStats_1_3_cb hidl_status_cb) override; |
Roshan Pius | e9d1e7d | 2020-11-04 11:44:16 -0800 | [diff] [blame] | 81 | Return<void> getLinkLayerStats_1_5( |
| 82 | getLinkLayerStats_1_5_cb hidl_status_cb) override; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 83 | Return<void> startRssiMonitoring( |
| 84 | uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi, |
| 85 | startRssiMonitoring_cb hidl_status_cb) override; |
| 86 | Return<void> stopRssiMonitoring( |
| 87 | uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override; |
| 88 | Return<void> getRoamingCapabilities( |
| 89 | getRoamingCapabilities_cb hidl_status_cb) override; |
| 90 | Return<void> configureRoaming(const StaRoamingConfig& config, |
| 91 | configureRoaming_cb hidl_status_cb) override; |
| 92 | Return<void> setRoamingState(StaRoamingState state, |
| 93 | setRoamingState_cb hidl_status_cb) override; |
| 94 | Return<void> enableNdOffload(bool enable, |
| 95 | enableNdOffload_cb hidl_status_cb) override; |
| 96 | Return<void> startSendingKeepAlivePackets( |
| 97 | uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data, |
| 98 | uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address, |
| 99 | const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms, |
| 100 | startSendingKeepAlivePackets_cb hidl_status_cb) override; |
| 101 | Return<void> stopSendingKeepAlivePackets( |
| 102 | uint32_t cmd_id, |
| 103 | stopSendingKeepAlivePackets_cb hidl_status_cb) override; |
| 104 | Return<void> setScanningMacOui( |
| 105 | const hidl_array<uint8_t, 3>& oui, |
| 106 | setScanningMacOui_cb hidl_status_cb) override; |
| 107 | Return<void> startDebugPacketFateMonitoring( |
| 108 | startDebugPacketFateMonitoring_cb hidl_status_cb) override; |
| 109 | Return<void> getDebugTxPacketFates( |
| 110 | getDebugTxPacketFates_cb hidl_status_cb) override; |
| 111 | Return<void> getDebugRxPacketFates( |
| 112 | getDebugRxPacketFates_cb hidl_status_cb) override; |
Jong Wook Kim | b9f0ff9 | 2018-03-16 16:21:49 -0700 | [diff] [blame] | 113 | Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, |
| 114 | setMacAddress_cb hidl_status_cb) override; |
Jong Wook Kim | 0ee7743 | 2018-08-08 18:57:26 -0700 | [diff] [blame] | 115 | Return<void> getFactoryMacAddress( |
| 116 | getFactoryMacAddress_cb hidl_status_cb) override; |
Ye Jiao | c6b5f89 | 2021-01-15 15:42:09 +0800 | [diff] [blame] | 117 | Return<void> setScanMode(bool enable, |
| 118 | setScanMode_cb hidl_status_cb) override; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 119 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 120 | private: |
| 121 | // Corresponding worker functions for the HIDL methods. |
| 122 | std::pair<WifiStatus, std::string> getNameInternal(); |
| 123 | std::pair<WifiStatus, IfaceType> getTypeInternal(); |
| 124 | WifiStatus registerEventCallbackInternal( |
| 125 | const sp<IWifiStaIfaceEventCallback>& callback); |
| 126 | std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); |
| 127 | std::pair<WifiStatus, StaApfPacketFilterCapabilities> |
| 128 | getApfPacketFilterCapabilitiesInternal(); |
| 129 | WifiStatus installApfPacketFilterInternal( |
| 130 | uint32_t cmd_id, const std::vector<uint8_t>& program); |
Bernie Innocenti | 7e6f71a | 2018-03-07 00:17:50 +0900 | [diff] [blame] | 131 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 132 | readApfPacketFilterDataInternal(); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 133 | std::pair<WifiStatus, StaBackgroundScanCapabilities> |
| 134 | getBackgroundScanCapabilitiesInternal(); |
| 135 | std::pair<WifiStatus, std::vector<WifiChannelInMhz>> |
Ahmed ElArabawy | fd809fc | 2019-11-15 18:19:15 -0800 | [diff] [blame] | 136 | getValidFrequenciesForBandInternal(V1_0::WifiBand band); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 137 | WifiStatus startBackgroundScanInternal( |
| 138 | uint32_t cmd_id, const StaBackgroundScanParameters& params); |
| 139 | WifiStatus stopBackgroundScanInternal(uint32_t cmd_id); |
| 140 | WifiStatus enableLinkLayerStatsCollectionInternal(bool debug); |
| 141 | WifiStatus disableLinkLayerStatsCollectionInternal(); |
xshu | e987325 | 2018-08-07 11:04:34 -0700 | [diff] [blame] | 142 | std::pair<WifiStatus, V1_0::StaLinkLayerStats> getLinkLayerStatsInternal(); |
| 143 | std::pair<WifiStatus, V1_3::StaLinkLayerStats> |
| 144 | getLinkLayerStatsInternal_1_3(); |
Roshan Pius | e9d1e7d | 2020-11-04 11:44:16 -0800 | [diff] [blame] | 145 | std::pair<WifiStatus, V1_5::StaLinkLayerStats> |
| 146 | getLinkLayerStatsInternal_1_5(); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 147 | WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi, |
| 148 | int32_t min_rssi); |
| 149 | WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id); |
| 150 | std::pair<WifiStatus, StaRoamingCapabilities> |
| 151 | getRoamingCapabilitiesInternal(); |
| 152 | WifiStatus configureRoamingInternal(const StaRoamingConfig& config); |
| 153 | WifiStatus setRoamingStateInternal(StaRoamingState state); |
| 154 | WifiStatus enableNdOffloadInternal(bool enable); |
| 155 | WifiStatus startSendingKeepAlivePacketsInternal( |
| 156 | uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data, |
| 157 | uint16_t ether_type, const std::array<uint8_t, 6>& src_address, |
| 158 | const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms); |
| 159 | WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id); |
| 160 | WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui); |
| 161 | WifiStatus startDebugPacketFateMonitoringInternal(); |
| 162 | std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> |
| 163 | getDebugTxPacketFatesInternal(); |
| 164 | std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> |
| 165 | getDebugRxPacketFatesInternal(); |
Jong Wook Kim | b9f0ff9 | 2018-03-16 16:21:49 -0700 | [diff] [blame] | 166 | WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); |
Jong Wook Kim | 0ee7743 | 2018-08-08 18:57:26 -0700 | [diff] [blame] | 167 | std::pair<WifiStatus, std::array<uint8_t, 6>> |
| 168 | getFactoryMacAddressInternal(); |
Ye Jiao | c6b5f89 | 2021-01-15 15:42:09 +0800 | [diff] [blame] | 169 | WifiStatus setScanModeInternal(bool enable); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 170 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 171 | std::string ifname_; |
| 172 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; |
Roshan Pius | 99dab38 | 2019-02-14 07:57:10 -0800 | [diff] [blame] | 173 | std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 174 | bool is_valid_; |
| 175 | hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback> |
| 176 | event_cb_handler_; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 177 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 178 | DISALLOW_COPY_AND_ASSIGN(WifiStaIface); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | } // namespace implementation |
Jimmy Chen | d460df3 | 2019-11-29 17:31:22 +0200 | [diff] [blame] | 182 | } // namespace V1_5 |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 183 | } // namespace wifi |
| 184 | } // namespace hardware |
| 185 | } // namespace android |
| 186 | |
| 187 | #endif // WIFI_STA_IFACE_H_ |