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/IWifiStaIfaceEventCallback.h> 22 #include <android/hardware/wifi/1.5/IWifiStaIface.h> 23 24 #include "hidl_callback_util.h" 25 #include "wifi_iface_util.h" 26 #include "wifi_legacy_hal.h" 27 28 namespace android { 29 namespace hardware { 30 namespace wifi { 31 namespace V1_5 { 32 namespace implementation { 33 using namespace android::hardware::wifi::V1_0; 34 35 /** 36 * HIDL interface object used to control a STA Iface instance. 37 */ 38 class WifiStaIface : public V1_5::IWifiStaIface { 39 public: 40 WifiStaIface(const std::string& ifname, 41 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, 42 const std::weak_ptr<iface_util::WifiIfaceUtil> iface_util); 43 // Refer to |WifiChip::invalidate()|. 44 void invalidate(); 45 bool isValid(); 46 std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks(); 47 std::string getName(); 48 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; 61 Return<void> readApfPacketFilterData( 62 readApfPacketFilterData_cb hidl_status_cb) override; 63 Return<void> getBackgroundScanCapabilities( 64 getBackgroundScanCapabilities_cb hidl_status_cb) override; 65 Return<void> getValidFrequenciesForBand( 66 V1_0::WifiBand band, 67 getValidFrequenciesForBand_cb hidl_status_cb) override; 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; 79 Return<void> getLinkLayerStats_1_3( 80 getLinkLayerStats_1_3_cb hidl_status_cb) override; 81 Return<void> getLinkLayerStats_1_5( 82 getLinkLayerStats_1_5_cb hidl_status_cb) override; 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; 113 Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, 114 setMacAddress_cb hidl_status_cb) override; 115 Return<void> getFactoryMacAddress( 116 getFactoryMacAddress_cb hidl_status_cb) override; 117 Return<void> setScanMode(bool enable, 118 setScanMode_cb hidl_status_cb) override; 119 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); 131 std::pair<WifiStatus, std::vector<uint8_t>> 132 readApfPacketFilterDataInternal(); 133 std::pair<WifiStatus, StaBackgroundScanCapabilities> 134 getBackgroundScanCapabilitiesInternal(); 135 std::pair<WifiStatus, std::vector<WifiChannelInMhz>> 136 getValidFrequenciesForBandInternal(V1_0::WifiBand band); 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(); 142 std::pair<WifiStatus, V1_0::StaLinkLayerStats> getLinkLayerStatsInternal(); 143 std::pair<WifiStatus, V1_3::StaLinkLayerStats> 144 getLinkLayerStatsInternal_1_3(); 145 std::pair<WifiStatus, V1_5::StaLinkLayerStats> 146 getLinkLayerStatsInternal_1_5(); 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(); 166 WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); 167 std::pair<WifiStatus, std::array<uint8_t, 6>> 168 getFactoryMacAddressInternal(); 169 WifiStatus setScanModeInternal(bool enable); 170 171 std::string ifname_; 172 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; 173 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; 174 bool is_valid_; 175 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback> 176 event_cb_handler_; 177 178 DISALLOW_COPY_AND_ASSIGN(WifiStaIface); 179 }; 180 181 } // namespace implementation 182 } // namespace V1_5 183 } // namespace wifi 184 } // namespace hardware 185 } // namespace android 186 187 #endif // WIFI_STA_IFACE_H_ 188