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> 22 #include <android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.h> 23 24 #include "hidl_callback_util.h" 25 #include "wifi_legacy_hal.h" 26 27 namespace android { 28 namespace hardware { 29 namespace wifi { 30 namespace V1_1 { 31 namespace implementation { 32 using namespace android::hardware::wifi::V1_0; 33 34 /** 35 * HIDL interface object used to control a STA Iface instance. 36 */ 37 class WifiStaIface : public V1_0::IWifiStaIface { 38 public: 39 WifiStaIface(const std::string& ifname, 40 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal); 41 // Refer to |WifiChip::invalidate()|. 42 void invalidate(); 43 bool isValid(); 44 std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks(); 45 46 // HIDL methods exposed. 47 Return<void> getName(getName_cb hidl_status_cb) override; 48 Return<void> getType(getType_cb hidl_status_cb) override; 49 Return<void> registerEventCallback( 50 const sp<IWifiStaIfaceEventCallback>& callback, 51 registerEventCallback_cb hidl_status_cb) override; 52 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override; 53 Return<void> getApfPacketFilterCapabilities( 54 getApfPacketFilterCapabilities_cb hidl_status_cb) override; 55 Return<void> installApfPacketFilter( 56 uint32_t cmd_id, 57 const hidl_vec<uint8_t>& program, 58 installApfPacketFilter_cb hidl_status_cb) override; 59 Return<void> getBackgroundScanCapabilities( 60 getBackgroundScanCapabilities_cb hidl_status_cb) override; 61 Return<void> getValidFrequenciesForBand( 62 WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override; 63 Return<void> startBackgroundScan( 64 uint32_t cmd_id, 65 const StaBackgroundScanParameters& params, 66 startBackgroundScan_cb hidl_status_cb) override; 67 Return<void> stopBackgroundScan( 68 uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override; 69 Return<void> enableLinkLayerStatsCollection( 70 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override; 71 Return<void> disableLinkLayerStatsCollection( 72 disableLinkLayerStatsCollection_cb hidl_status_cb) override; 73 Return<void> getLinkLayerStats(getLinkLayerStats_cb hidl_status_cb) override; 74 Return<void> startRssiMonitoring( 75 uint32_t cmd_id, 76 int32_t max_rssi, 77 int32_t min_rssi, 78 startRssiMonitoring_cb hidl_status_cb) override; 79 Return<void> stopRssiMonitoring( 80 uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override; 81 Return<void> getRoamingCapabilities( 82 getRoamingCapabilities_cb hidl_status_cb) override; 83 Return<void> configureRoaming(const StaRoamingConfig& config, 84 configureRoaming_cb hidl_status_cb) override; 85 Return<void> setRoamingState(StaRoamingState state, 86 setRoamingState_cb hidl_status_cb) override; 87 Return<void> enableNdOffload(bool enable, 88 enableNdOffload_cb hidl_status_cb) override; 89 Return<void> startSendingKeepAlivePackets( 90 uint32_t cmd_id, 91 const hidl_vec<uint8_t>& ip_packet_data, 92 uint16_t ether_type, 93 const hidl_array<uint8_t, 6>& src_address, 94 const hidl_array<uint8_t, 6>& dst_address, 95 uint32_t period_in_ms, 96 startSendingKeepAlivePackets_cb hidl_status_cb) override; 97 Return<void> stopSendingKeepAlivePackets( 98 uint32_t cmd_id, stopSendingKeepAlivePackets_cb hidl_status_cb) override; 99 Return<void> setScanningMacOui(const hidl_array<uint8_t, 3>& oui, 100 setScanningMacOui_cb hidl_status_cb) override; 101 Return<void> startDebugPacketFateMonitoring( 102 startDebugPacketFateMonitoring_cb hidl_status_cb) override; 103 Return<void> getDebugTxPacketFates( 104 getDebugTxPacketFates_cb hidl_status_cb) override; 105 Return<void> getDebugRxPacketFates( 106 getDebugRxPacketFates_cb hidl_status_cb) override; 107 108 private: 109 // Corresponding worker functions for the HIDL methods. 110 std::pair<WifiStatus, std::string> getNameInternal(); 111 std::pair<WifiStatus, IfaceType> getTypeInternal(); 112 WifiStatus registerEventCallbackInternal( 113 const sp<IWifiStaIfaceEventCallback>& callback); 114 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); 115 std::pair<WifiStatus, StaApfPacketFilterCapabilities> 116 getApfPacketFilterCapabilitiesInternal(); 117 WifiStatus installApfPacketFilterInternal( 118 uint32_t cmd_id, const std::vector<uint8_t>& program); 119 std::pair<WifiStatus, StaBackgroundScanCapabilities> 120 getBackgroundScanCapabilitiesInternal(); 121 std::pair<WifiStatus, std::vector<WifiChannelInMhz>> 122 getValidFrequenciesForBandInternal(WifiBand band); 123 WifiStatus startBackgroundScanInternal( 124 uint32_t cmd_id, const StaBackgroundScanParameters& params); 125 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id); 126 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug); 127 WifiStatus disableLinkLayerStatsCollectionInternal(); 128 std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal(); 129 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, 130 int32_t max_rssi, 131 int32_t min_rssi); 132 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id); 133 std::pair<WifiStatus, StaRoamingCapabilities> 134 getRoamingCapabilitiesInternal(); 135 WifiStatus configureRoamingInternal(const StaRoamingConfig& config); 136 WifiStatus setRoamingStateInternal(StaRoamingState state); 137 WifiStatus enableNdOffloadInternal(bool enable); 138 WifiStatus startSendingKeepAlivePacketsInternal( 139 uint32_t cmd_id, 140 const std::vector<uint8_t>& ip_packet_data, 141 uint16_t ether_type, 142 const std::array<uint8_t, 6>& src_address, 143 const std::array<uint8_t, 6>& dst_address, 144 uint32_t period_in_ms); 145 WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id); 146 WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui); 147 WifiStatus startDebugPacketFateMonitoringInternal(); 148 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>> 149 getDebugTxPacketFatesInternal(); 150 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>> 151 getDebugRxPacketFatesInternal(); 152 153 std::string ifname_; 154 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_; 155 bool is_valid_; 156 hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback> 157 event_cb_handler_; 158 159 DISALLOW_COPY_AND_ASSIGN(WifiStaIface); 160 }; 161 162 } // namespace implementation 163 } // namespace V1_1 164 } // namespace wifi 165 } // namespace hardware 166 } // namespace android 167 168 #endif // WIFI_STA_IFACE_H_ 169