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.2/IWifiStaIface.h> 23 24 #include <wifi_system/interface_tool.h> 25 26 #include "hidl_callback_util.h" 27 #include "wifi_legacy_hal.h" 28 29 namespace android { 30 namespace hardware { 31 namespace wifi { 32 namespace V1_2 { 33 namespace implementation { 34 using namespace android::hardware::wifi::V1_0; 35 36 /** 37 * HIDL interface object used to control a STA Iface instance. 38 */ 39 class WifiStaIface : public V1_2::IWifiStaIface { 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(); 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> 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; 108 Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac, 109 setMacAddress_cb hidl_status_cb) override; 110 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); 122 std::pair<WifiStatus, std::vector<uint8_t>> 123 readApfPacketFilterDataInternal(); 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(); 153 WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac); 154 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_; 160 wifi_system::InterfaceTool iface_tool_; 161 162 DISALLOW_COPY_AND_ASSIGN(WifiStaIface); 163 }; 164 165 } // namespace implementation 166 } // namespace V1_2 167 } // namespace wifi 168 } // namespace hardware 169 } // namespace android 170 171 #endif // WIFI_STA_IFACE_H_ 172