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> |
| 21 | #include <android/hardware/wifi/1.0/IWifiStaIface.h> |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 22 | #include <android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.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 | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 25 | #include "wifi_legacy_hal.h" |
| 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace wifi { |
| 30 | namespace V1_0 { |
| 31 | namespace implementation { |
| 32 | |
| 33 | /** |
| 34 | * HIDL interface object used to control a STA Iface instance. |
| 35 | */ |
| 36 | class WifiStaIface : public IWifiStaIface { |
| 37 | public: |
| 38 | WifiStaIface(const std::string& ifname, |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 39 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 40 | // Refer to |WifiChip::invalidate()|. |
| 41 | void invalidate(); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 42 | bool isValid(); |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 43 | std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks(); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 44 | |
| 45 | // HIDL methods exposed. |
Roshan Pius | 734fea0 | 2016-10-11 08:30:28 -0700 | [diff] [blame] | 46 | Return<void> getName(getName_cb hidl_status_cb) override; |
| 47 | Return<void> getType(getType_cb hidl_status_cb) override; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 48 | 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; |
Roshan Pius | 7f4574d | 2017-02-22 09:48:03 -0800 | [diff] [blame^] | 60 | Return<void> getValidFrequenciesForBand( |
| 61 | WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 62 | Return<void> startBackgroundScan( |
| 63 | uint32_t cmd_id, |
| 64 | 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(getLinkLayerStats_cb hidl_status_cb) override; |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 73 | Return<void> startRssiMonitoring( |
| 74 | uint32_t cmd_id, |
| 75 | int32_t max_rssi, |
| 76 | int32_t min_rssi, |
| 77 | startRssiMonitoring_cb hidl_status_cb) override; |
| 78 | Return<void> stopRssiMonitoring( |
| 79 | uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override; |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 80 | Return<void> getRoamingCapabilities( |
| 81 | getRoamingCapabilities_cb hidl_status_cb) override; |
| 82 | Return<void> configureRoaming(const StaRoamingConfig& config, |
| 83 | configureRoaming_cb hidl_status_cb) override; |
| 84 | Return<void> setRoamingState(StaRoamingState state, |
| 85 | setRoamingState_cb hidl_status_cb) override; |
Roshan Pius | af727c0 | 2017-01-11 15:37:25 -0800 | [diff] [blame] | 86 | Return<void> enableNdOffload(bool enable, |
| 87 | enableNdOffload_cb hidl_status_cb) override; |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 88 | Return<void> startSendingKeepAlivePackets( |
| 89 | uint32_t cmd_id, |
| 90 | const hidl_vec<uint8_t>& ip_packet_data, |
| 91 | uint16_t ether_type, |
| 92 | const hidl_array<uint8_t, 6>& src_address, |
| 93 | const hidl_array<uint8_t, 6>& dst_address, |
| 94 | uint32_t period_in_ms, |
| 95 | startSendingKeepAlivePackets_cb hidl_status_cb) override; |
| 96 | Return<void> stopSendingKeepAlivePackets( |
| 97 | uint32_t cmd_id, stopSendingKeepAlivePackets_cb hidl_status_cb) override; |
Roshan Pius | 795bb81 | 2017-02-01 13:09:08 -0800 | [diff] [blame] | 98 | Return<void> setScanningMacOui(const hidl_array<uint8_t, 3>& oui, |
| 99 | setScanningMacOui_cb hidl_status_cb) override; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 100 | Return<void> startDebugPacketFateMonitoring( |
| 101 | startDebugPacketFateMonitoring_cb hidl_status_cb) override; |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 102 | Return<void> getDebugTxPacketFates( |
| 103 | getDebugTxPacketFates_cb hidl_status_cb) override; |
| 104 | Return<void> getDebugRxPacketFates( |
| 105 | getDebugRxPacketFates_cb hidl_status_cb) override; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 106 | |
| 107 | private: |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 108 | // Corresponding worker functions for the HIDL methods. |
| 109 | std::pair<WifiStatus, std::string> getNameInternal(); |
| 110 | std::pair<WifiStatus, IfaceType> getTypeInternal(); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 111 | WifiStatus registerEventCallbackInternal( |
| 112 | const sp<IWifiStaIfaceEventCallback>& callback); |
| 113 | std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); |
| 114 | std::pair<WifiStatus, StaApfPacketFilterCapabilities> |
| 115 | getApfPacketFilterCapabilitiesInternal(); |
| 116 | WifiStatus installApfPacketFilterInternal( |
| 117 | uint32_t cmd_id, const std::vector<uint8_t>& program); |
| 118 | std::pair<WifiStatus, StaBackgroundScanCapabilities> |
| 119 | getBackgroundScanCapabilitiesInternal(); |
| 120 | std::pair<WifiStatus, std::vector<WifiChannelInMhz>> |
Roshan Pius | 7f4574d | 2017-02-22 09:48:03 -0800 | [diff] [blame^] | 121 | getValidFrequenciesForBandInternal(WifiBand band); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 122 | WifiStatus startBackgroundScanInternal( |
| 123 | uint32_t cmd_id, const StaBackgroundScanParameters& params); |
| 124 | WifiStatus stopBackgroundScanInternal(uint32_t cmd_id); |
| 125 | WifiStatus enableLinkLayerStatsCollectionInternal(bool debug); |
| 126 | WifiStatus disableLinkLayerStatsCollectionInternal(); |
| 127 | std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal(); |
Roshan Pius | d476754 | 2016-12-06 10:04:05 -0800 | [diff] [blame] | 128 | WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, |
| 129 | int32_t max_rssi, |
| 130 | int32_t min_rssi); |
| 131 | WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id); |
Roshan Pius | 26801cb | 2016-12-13 14:25:45 -0800 | [diff] [blame] | 132 | std::pair<WifiStatus, StaRoamingCapabilities> |
| 133 | getRoamingCapabilitiesInternal(); |
| 134 | WifiStatus configureRoamingInternal(const StaRoamingConfig& config); |
| 135 | WifiStatus setRoamingStateInternal(StaRoamingState state); |
Roshan Pius | af727c0 | 2017-01-11 15:37:25 -0800 | [diff] [blame] | 136 | WifiStatus enableNdOffloadInternal(bool enable); |
Roshan Pius | 9a9869a | 2017-01-11 16:42:16 -0800 | [diff] [blame] | 137 | WifiStatus startSendingKeepAlivePacketsInternal( |
| 138 | uint32_t cmd_id, |
| 139 | const std::vector<uint8_t>& ip_packet_data, |
| 140 | uint16_t ether_type, |
| 141 | const std::array<uint8_t, 6>& src_address, |
| 142 | const std::array<uint8_t, 6>& dst_address, |
| 143 | uint32_t period_in_ms); |
| 144 | WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id); |
Roshan Pius | 795bb81 | 2017-02-01 13:09:08 -0800 | [diff] [blame] | 145 | WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 146 | WifiStatus startDebugPacketFateMonitoringInternal(); |
Roshan Pius | a04ba3f | 2016-10-27 14:36:26 -0700 | [diff] [blame] | 147 | std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> |
| 148 | getDebugTxPacketFatesInternal(); |
| 149 | std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> |
| 150 | getDebugRxPacketFatesInternal(); |
Roshan Pius | 907d4a2 | 2016-10-27 12:48:12 -0700 | [diff] [blame] | 151 | |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 152 | std::string ifname_; |
Roshan Pius | 6cedc97 | 2016-10-28 10:11:17 -0700 | [diff] [blame] | 153 | std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 154 | bool is_valid_; |
Roshan Pius | d37341f | 2017-01-31 13:13:28 -0800 | [diff] [blame] | 155 | hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback> |
| 156 | event_cb_handler_; |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 157 | |
| 158 | DISALLOW_COPY_AND_ASSIGN(WifiStaIface); |
| 159 | }; |
| 160 | |
| 161 | } // namespace implementation |
| 162 | } // namespace V1_0 |
| 163 | } // namespace wifi |
| 164 | } // namespace hardware |
| 165 | } // namespace android |
| 166 | |
| 167 | #endif // WIFI_STA_IFACE_H_ |