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