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> |
Bernie Innocenti | 7e6f71a | 2018-03-07 00:17:50 +0900 | [diff] [blame] | 22 | #include <android/hardware/wifi/1.2/IWifiStaIface.h> |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 23 | |
Jong Wook Kim | b9f0ff9 | 2018-03-16 16:21:49 -0700 | [diff] [blame] | 24 | #include <wifi_system/interface_tool.h> |
| 25 | |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 26 | #include "hidl_callback_util.h" |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 27 | #include "wifi_legacy_hal.h" |
| 28 | |
| 29 | namespace android { |
| 30 | namespace hardware { |
| 31 | namespace wifi { |
Etan Cohen | 6ce5090 | 2017-09-14 07:30:57 -0700 | [diff] [blame] | 32 | namespace V1_2 { |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 33 | namespace implementation { |
Roshan Pius | dbd83ef | 2017-06-20 12:05:40 -0700 | [diff] [blame] | 34 | using namespace android::hardware::wifi::V1_0; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * HIDL interface object used to control a STA Iface instance. |
| 38 | */ |
Bernie Innocenti | 7e6f71a | 2018-03-07 00:17:50 +0900 | [diff] [blame] | 39 | class WifiStaIface : public V1_2::IWifiStaIface { |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 40 | public: |
| 41 | WifiStaIface(const std::string& ifname, |
| 42 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal); |
| 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( |
| 66 | WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override; |
| 67 | Return<void> startBackgroundScan( |
| 68 | uint32_t cmd_id, const StaBackgroundScanParameters& params, |
| 69 | startBackgroundScan_cb hidl_status_cb) override; |
| 70 | Return<void> stopBackgroundScan( |
| 71 | uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override; |
| 72 | Return<void> enableLinkLayerStatsCollection( |
| 73 | bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override; |
| 74 | Return<void> disableLinkLayerStatsCollection( |
| 75 | disableLinkLayerStatsCollection_cb hidl_status_cb) override; |
| 76 | Return<void> getLinkLayerStats( |
| 77 | getLinkLayerStats_cb hidl_status_cb) override; |
| 78 | Return<void> startRssiMonitoring( |
| 79 | uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi, |
| 80 | startRssiMonitoring_cb hidl_status_cb) override; |
| 81 | Return<void> stopRssiMonitoring( |
| 82 | uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override; |
| 83 | Return<void> getRoamingCapabilities( |
| 84 | getRoamingCapabilities_cb hidl_status_cb) override; |
| 85 | Return<void> configureRoaming(const StaRoamingConfig& config, |
| 86 | configureRoaming_cb hidl_status_cb) override; |
| 87 | Return<void> setRoamingState(StaRoamingState state, |
| 88 | setRoamingState_cb hidl_status_cb) override; |
| 89 | Return<void> enableNdOffload(bool enable, |
| 90 | enableNdOffload_cb hidl_status_cb) override; |
| 91 | Return<void> startSendingKeepAlivePackets( |
| 92 | uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data, |
| 93 | uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address, |
| 94 | const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms, |
| 95 | startSendingKeepAlivePackets_cb hidl_status_cb) override; |
| 96 | Return<void> stopSendingKeepAlivePackets( |
| 97 | uint32_t cmd_id, |
| 98 | stopSendingKeepAlivePackets_cb hidl_status_cb) override; |
| 99 | Return<void> setScanningMacOui( |
| 100 | const hidl_array<uint8_t, 3>& oui, |
| 101 | setScanningMacOui_cb hidl_status_cb) override; |
| 102 | Return<void> startDebugPacketFateMonitoring( |
| 103 | startDebugPacketFateMonitoring_cb hidl_status_cb) override; |
| 104 | Return<void> getDebugTxPacketFates( |
| 105 | getDebugTxPacketFates_cb hidl_status_cb) override; |
| 106 | Return<void> getDebugRxPacketFates( |
| 107 | getDebugRxPacketFates_cb hidl_status_cb) override; |
Jong Wook Kim | b9f0ff9 | 2018-03-16 16:21:49 -0700 | [diff] [blame] | 108 | Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, |
| 109 | setMacAddress_cb hidl_status_cb) override; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 110 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 111 | private: |
| 112 | // Corresponding worker functions for the HIDL methods. |
| 113 | std::pair<WifiStatus, std::string> getNameInternal(); |
| 114 | std::pair<WifiStatus, IfaceType> getTypeInternal(); |
| 115 | WifiStatus registerEventCallbackInternal( |
| 116 | const sp<IWifiStaIfaceEventCallback>& callback); |
| 117 | std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); |
| 118 | std::pair<WifiStatus, StaApfPacketFilterCapabilities> |
| 119 | getApfPacketFilterCapabilitiesInternal(); |
| 120 | WifiStatus installApfPacketFilterInternal( |
| 121 | uint32_t cmd_id, const std::vector<uint8_t>& program); |
Bernie Innocenti | 7e6f71a | 2018-03-07 00:17:50 +0900 | [diff] [blame] | 122 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 123 | readApfPacketFilterDataInternal(); |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 124 | std::pair<WifiStatus, StaBackgroundScanCapabilities> |
| 125 | getBackgroundScanCapabilitiesInternal(); |
| 126 | std::pair<WifiStatus, std::vector<WifiChannelInMhz>> |
| 127 | getValidFrequenciesForBandInternal(WifiBand band); |
| 128 | WifiStatus startBackgroundScanInternal( |
| 129 | uint32_t cmd_id, const StaBackgroundScanParameters& params); |
| 130 | WifiStatus stopBackgroundScanInternal(uint32_t cmd_id); |
| 131 | WifiStatus enableLinkLayerStatsCollectionInternal(bool debug); |
| 132 | WifiStatus disableLinkLayerStatsCollectionInternal(); |
| 133 | std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal(); |
| 134 | WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi, |
| 135 | int32_t min_rssi); |
| 136 | WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id); |
| 137 | std::pair<WifiStatus, StaRoamingCapabilities> |
| 138 | getRoamingCapabilitiesInternal(); |
| 139 | WifiStatus configureRoamingInternal(const StaRoamingConfig& config); |
| 140 | WifiStatus setRoamingStateInternal(StaRoamingState state); |
| 141 | WifiStatus enableNdOffloadInternal(bool enable); |
| 142 | WifiStatus startSendingKeepAlivePacketsInternal( |
| 143 | uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data, |
| 144 | uint16_t ether_type, const std::array<uint8_t, 6>& src_address, |
| 145 | const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms); |
| 146 | WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id); |
| 147 | WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui); |
| 148 | WifiStatus startDebugPacketFateMonitoringInternal(); |
| 149 | std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> |
| 150 | getDebugTxPacketFatesInternal(); |
| 151 | std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> |
| 152 | getDebugRxPacketFatesInternal(); |
Jong Wook Kim | b9f0ff9 | 2018-03-16 16:21:49 -0700 | [diff] [blame] | 153 | WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 154 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 155 | std::string ifname_; |
| 156 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; |
| 157 | bool is_valid_; |
| 158 | hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback> |
| 159 | event_cb_handler_; |
Jong Wook Kim | b9f0ff9 | 2018-03-16 16:21:49 -0700 | [diff] [blame] | 160 | wifi_system::InterfaceTool iface_tool_; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 161 | |
Roshan Pius | abcf78f | 2017-10-06 16:30:38 -0700 | [diff] [blame] | 162 | DISALLOW_COPY_AND_ASSIGN(WifiStaIface); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | } // namespace implementation |
Etan Cohen | 6ce5090 | 2017-09-14 07:30:57 -0700 | [diff] [blame] | 166 | } // namespace V1_2 |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 167 | } // namespace wifi |
| 168 | } // namespace hardware |
| 169 | } // namespace android |
| 170 | |
| 171 | #endif // WIFI_STA_IFACE_H_ |