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.3/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_3 { 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_3::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 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> getLinkLayerStats_1_3( 79 getLinkLayerStats_1_3_cb hidl_status_cb) override; 80 Return<void> startRssiMonitoring( 81 uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi, 82 startRssiMonitoring_cb hidl_status_cb) override; 83 Return<void> stopRssiMonitoring( 84 uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override; 85 Return<void> getRoamingCapabilities( 86 getRoamingCapabilities_cb hidl_status_cb) override; 87 Return<void> configureRoaming(const StaRoamingConfig& config, 88 configureRoaming_cb hidl_status_cb) override; 89 Return<void> setRoamingState(StaRoamingState state, 90 setRoamingState_cb hidl_status_cb) override; 91 Return<void> enableNdOffload(bool enable, 92 enableNdOffload_cb hidl_status_cb) override; 93 Return<void> startSendingKeepAlivePackets( 94 uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data, 95 uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address, 96 const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms, 97 startSendingKeepAlivePackets_cb hidl_status_cb) override; 98 Return<void> stopSendingKeepAlivePackets( 99 uint32_t cmd_id, 100 stopSendingKeepAlivePackets_cb hidl_status_cb) override; 101 Return<void> setScanningMacOui( 102 const hidl_array<uint8_t, 3>& oui, 103 setScanningMacOui_cb hidl_status_cb) override; 104 Return<void> startDebugPacketFateMonitoring( 105 startDebugPacketFateMonitoring_cb hidl_status_cb) override; 106 Return<void> getDebugTxPacketFates( 107 getDebugTxPacketFates_cb hidl_status_cb) override; 108 Return<void> getDebugRxPacketFates( 109 getDebugRxPacketFates_cb hidl_status_cb) override; 110 Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, 111 setMacAddress_cb hidl_status_cb) override; 112 Return<void> getFactoryMacAddress( 113 getFactoryMacAddress_cb hidl_status_cb) override; 114 115 private: 116 // Corresponding worker functions for the HIDL methods. 117 std::pair<WifiStatus, std::string> getNameInternal(); 118 std::pair<WifiStatus, IfaceType> getTypeInternal(); 119 WifiStatus registerEventCallbackInternal( 120 const sp<IWifiStaIfaceEventCallback>& callback); 121 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); 122 std::pair<WifiStatus, StaApfPacketFilterCapabilities> 123 getApfPacketFilterCapabilitiesInternal(); 124 WifiStatus installApfPacketFilterInternal( 125 uint32_t cmd_id, const std::vector<uint8_t>& program); 126 std::pair<WifiStatus, std::vector<uint8_t>> 127 readApfPacketFilterDataInternal(); 128 std::pair<WifiStatus, StaBackgroundScanCapabilities> 129 getBackgroundScanCapabilitiesInternal(); 130 std::pair<WifiStatus, std::vector<WifiChannelInMhz>> 131 getValidFrequenciesForBandInternal(WifiBand band); 132 WifiStatus startBackgroundScanInternal( 133 uint32_t cmd_id, const StaBackgroundScanParameters& params); 134 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id); 135 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug); 136 WifiStatus disableLinkLayerStatsCollectionInternal(); 137 std::pair<WifiStatus, V1_0::StaLinkLayerStats> getLinkLayerStatsInternal(); 138 std::pair<WifiStatus, V1_3::StaLinkLayerStats> 139 getLinkLayerStatsInternal_1_3(); 140 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi, 141 int32_t min_rssi); 142 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id); 143 std::pair<WifiStatus, StaRoamingCapabilities> 144 getRoamingCapabilitiesInternal(); 145 WifiStatus configureRoamingInternal(const StaRoamingConfig& config); 146 WifiStatus setRoamingStateInternal(StaRoamingState state); 147 WifiStatus enableNdOffloadInternal(bool enable); 148 WifiStatus startSendingKeepAlivePacketsInternal( 149 uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data, 150 uint16_t ether_type, const std::array<uint8_t, 6>& src_address, 151 const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms); 152 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id); 153 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui); 154 WifiStatus startDebugPacketFateMonitoringInternal(); 155 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> 156 getDebugTxPacketFatesInternal(); 157 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> 158 getDebugRxPacketFatesInternal(); 159 WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); 160 std::pair<WifiStatus, std::array<uint8_t, 6>> 161 getFactoryMacAddressInternal(); 162 163 std::string ifname_; 164 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; 165 std::weak_ptr<iface_util::WifiIfaceUtil> iface_util_; 166 bool is_valid_; 167 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback> 168 event_cb_handler_; 169 170 DISALLOW_COPY_AND_ASSIGN(WifiStaIface); 171 }; 172 173 } // namespace implementation 174 } // namespace V1_3 175 } // namespace wifi 176 } // namespace hardware 177 } // namespace android 178 179 #endif // WIFI_STA_IFACE_H_ 180