1 /* 2 * WPA Supplicant - Sta Iface Aidl interface 3 * Copyright (c) 2021, Google Inc. All rights reserved. 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #ifndef WPA_SUPPLICANT_AIDL_STA_IFACE_H 10 #define WPA_SUPPLICANT_AIDL_STA_IFACE_H 11 12 #include <array> 13 #include <vector> 14 15 #include <android-base/macros.h> 16 17 #include <aidl/android/hardware/wifi/supplicant/AnqpInfoId.h> 18 #include <aidl/android/hardware/wifi/supplicant/BnSupplicantStaIface.h> 19 #include <aidl/android/hardware/wifi/supplicant/BtCoexistenceMode.h> 20 #include <aidl/android/hardware/wifi/supplicant/Hs20AnqpSubtypes.h> 21 #include <aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.h> 22 #include <aidl/android/hardware/wifi/supplicant/ISupplicantStaNetwork.h> 23 #include <aidl/android/hardware/wifi/supplicant/MloLinksInfo.h> 24 #include <aidl/android/hardware/wifi/supplicant/QosPolicyStatus.h> 25 #include <aidl/android/hardware/wifi/supplicant/RxFilterType.h> 26 27 extern "C" 28 { 29 #include "utils/common.h" 30 #include "utils/includes.h" 31 #include "wpa_supplicant_i.h" 32 #include "config.h" 33 #include "driver_i.h" 34 #include "wpa.h" 35 } 36 37 namespace aidl { 38 namespace android { 39 namespace hardware { 40 namespace wifi { 41 namespace supplicant { 42 43 /** 44 * Implementation of StaIface aidl object. Each unique aidl 45 * object is used for control operations on a specific interface 46 * controlled by wpa_supplicant. 47 */ 48 class StaIface : public BnSupplicantStaIface 49 { 50 public: 51 StaIface(struct wpa_global* wpa_global, const char ifname[]); 52 ~StaIface() override = default; 53 // AIDL does not provide a built-in mechanism to let the server 54 // invalidate a AIDL interface object after creation. If any client 55 // process holds onto a reference to the object in their context, 56 // any method calls on that reference will continue to be directed to 57 // the server. 58 // However Supplicant HAL needs to control the lifetime of these 59 // objects. So, add a public |invalidate| method to all |Iface| and 60 // |Network| objects. 61 // This will be used to mark an object invalid when the corresponding 62 // iface or network is removed. 63 // All AIDL method implementations should check if the object is still 64 // marked valid before processing them. 65 void invalidate(); 66 bool isValid(); 67 68 // Aidl methods exposed. 69 ::ndk::ScopedAStatus getName(std::string* _aidl_return) override; 70 ::ndk::ScopedAStatus getType(IfaceType* _aidl_return) override; 71 ::ndk::ScopedAStatus addNetwork( 72 std::shared_ptr<ISupplicantStaNetwork>* _aidl_return) override; 73 ::ndk::ScopedAStatus removeNetwork(int32_t in_id) override; 74 ::ndk::ScopedAStatus filsHlpFlushRequest() override; 75 ::ndk::ScopedAStatus filsHlpAddRequest( 76 const std::vector<uint8_t>& in_dst_mac, 77 const std::vector<uint8_t>& in_pkt) override; 78 ::ndk::ScopedAStatus getNetwork( 79 int32_t in_id, std::shared_ptr<ISupplicantStaNetwork>* _aidl_return) override; 80 ::ndk::ScopedAStatus listNetworks(std::vector<int32_t>* _aidl_return) override; 81 ::ndk::ScopedAStatus registerCallback( 82 const std::shared_ptr<ISupplicantStaIfaceCallback>& in_callback) override; 83 ::ndk::ScopedAStatus reassociate() override; 84 ::ndk::ScopedAStatus reconnect() override; 85 ::ndk::ScopedAStatus disconnect() override; 86 ::ndk::ScopedAStatus setPowerSave(bool in_enable) override; 87 ::ndk::ScopedAStatus initiateTdlsDiscover( 88 const std::vector<uint8_t>& in_macAddress) override; 89 ::ndk::ScopedAStatus initiateTdlsSetup( 90 const std::vector<uint8_t>& in_macAddress) override; 91 ::ndk::ScopedAStatus initiateTdlsTeardown( 92 const std::vector<uint8_t>& in_macAddress) override; 93 ::ndk::ScopedAStatus initiateAnqpQuery( 94 const std::vector<uint8_t>& in_macAddress, 95 const std::vector<AnqpInfoId>& in_infoElements, 96 const std::vector<Hs20AnqpSubtypes>& in_subTypes) override; 97 ::ndk::ScopedAStatus initiateVenueUrlAnqpQuery( 98 const std::vector<uint8_t>& in_macAddress) override; 99 ::ndk::ScopedAStatus initiateHs20IconQuery( 100 const std::vector<uint8_t>& in_macAddress, const std::string& in_fileName) override; 101 ::ndk::ScopedAStatus getMacAddress(std::vector<uint8_t>* _aidl_return) override; 102 ::ndk::ScopedAStatus startRxFilter() override; 103 ::ndk::ScopedAStatus stopRxFilter() override; 104 ::ndk::ScopedAStatus addRxFilter(RxFilterType in_type) override; 105 ::ndk::ScopedAStatus removeRxFilter(RxFilterType in_type) override; 106 ::ndk::ScopedAStatus setBtCoexistenceMode(BtCoexistenceMode in_mode) override; 107 ::ndk::ScopedAStatus setBtCoexistenceScanModeEnabled(bool in_enable) override; 108 ::ndk::ScopedAStatus setSuspendModeEnabled(bool in_enable) override; 109 ::ndk::ScopedAStatus setCountryCode(const std::vector<uint8_t>& in_code) override; 110 ::ndk::ScopedAStatus startWpsRegistrar( 111 const std::vector<uint8_t>& in_bssid, const std::string& in_pin) override; 112 ::ndk::ScopedAStatus startWpsPbc(const std::vector<uint8_t>& in_bssid) override; 113 ::ndk::ScopedAStatus startWpsPinDisplay( 114 const std::vector<uint8_t>& in_bssid, std::string* _aidl_return) override; 115 ::ndk::ScopedAStatus startWpsPinKeypad(const std::string& in_pin) override; 116 ::ndk::ScopedAStatus cancelWps() override; 117 ::ndk::ScopedAStatus setWpsDeviceName(const std::string& in_name) override; 118 ::ndk::ScopedAStatus setWpsDeviceType(const std::vector<uint8_t>& in_type) override; 119 ::ndk::ScopedAStatus setWpsManufacturer(const std::string& in_manufacturer) override; 120 ::ndk::ScopedAStatus setWpsModelName(const std::string& in_modelName) override; 121 ::ndk::ScopedAStatus setWpsModelNumber(const std::string& in_modelNumber) override; 122 ::ndk::ScopedAStatus setWpsSerialNumber(const std::string& in_serialNumber) override; 123 ::ndk::ScopedAStatus setWpsConfigMethods(WpsConfigMethods in_configMethods) override; 124 ::ndk::ScopedAStatus setExternalSim(bool in_useExternalSim) override; 125 ::ndk::ScopedAStatus addExtRadioWork( 126 const std::string& in_name, int32_t in_freqInMhz, 127 int32_t in_timeoutInSec, int32_t* _aidl_return) override; 128 ::ndk::ScopedAStatus removeExtRadioWork(int32_t in_id) override; 129 ::ndk::ScopedAStatus enableAutoReconnect(bool in_enable) override; 130 ::ndk::ScopedAStatus getKeyMgmtCapabilities(KeyMgmtMask* _aidl_return) override; 131 ::ndk::ScopedAStatus addDppPeerUri( 132 const std::string& in_uri, int32_t* _aidl_return) override; 133 ::ndk::ScopedAStatus removeDppUri(int32_t in_id) override; 134 ::ndk::ScopedAStatus startDppConfiguratorInitiator( 135 int32_t in_peerBootstrapId, int32_t in_ownBootstrapId, 136 const std::string& in_ssid, const std::string& in_password, 137 const std::string& in_psk, DppNetRole in_netRole, DppAkm in_securityAkm, 138 const std::vector<uint8_t>& in_privEcKey, 139 std::vector<uint8_t>* _aidl_return) override; 140 ::ndk::ScopedAStatus startDppEnrolleeInitiator( 141 int32_t in_peerBootstrapId, int32_t in_ownBootstrapId) override; 142 ::ndk::ScopedAStatus stopDppInitiator() override; 143 ::ndk::ScopedAStatus getConnectionCapabilities(ConnectionCapabilities* _aidl_return) override; 144 ::ndk::ScopedAStatus getWpaDriverCapabilities(WpaDriverCapabilitiesMask* _aidl_return) override; 145 ::ndk::ScopedAStatus setMboCellularDataStatus(bool in_available) override; 146 ::ndk::ScopedAStatus generateDppBootstrapInfoForResponder( 147 const std::vector<uint8_t>& in_macAddress, 148 const std::string& in_deviceInfo, DppCurve in_curve, 149 DppResponderBootstrapInfo* _aidl_return) override; 150 ::ndk::ScopedAStatus startDppEnrolleeResponder(int32_t in_listenChannel) override; 151 ::ndk::ScopedAStatus stopDppResponder(int32_t in_ownBootstrapId) override; 152 ::ndk::ScopedAStatus generateSelfDppConfiguration( 153 const std::string& in_ssid, const std::vector<uint8_t>& in_privEcKey) override; 154 ::ndk::ScopedAStatus setQosPolicyFeatureEnabled(bool in_enable) override; 155 ::ndk::ScopedAStatus sendQosPolicyResponse( 156 int32_t in_qosPolicyRequestId, bool in_morePolicies, 157 const std::vector<QosPolicyStatus>& in_qosPolicyStatusList) override; 158 ::ndk::ScopedAStatus removeAllQosPolicies() override; 159 ::ndk::ScopedAStatus getConnectionMloLinksInfo(MloLinksInfo* _aidl_return) override; 160 161 private: 162 // Corresponding worker functions for the AIDL methods. 163 std::pair<std::string, ndk::ScopedAStatus> getNameInternal(); 164 std::pair<IfaceType, ndk::ScopedAStatus> getTypeInternal(); 165 std::pair<std::shared_ptr<ISupplicantStaNetwork>, ndk::ScopedAStatus> 166 addNetworkInternal(); 167 ndk::ScopedAStatus filsHlpFlushRequestInternal(); 168 ndk::ScopedAStatus filsHlpAddRequestInternal( 169 const std::vector<uint8_t>& dst_mac, 170 const std::vector<uint8_t>& pkt); 171 ndk::ScopedAStatus removeNetworkInternal(int32_t id); 172 std::pair<std::shared_ptr<ISupplicantStaNetwork>, ndk::ScopedAStatus> 173 getNetworkInternal(int32_t id); 174 std::pair<std::vector<int32_t>, ndk::ScopedAStatus> 175 listNetworksInternal(); 176 ndk::ScopedAStatus registerCallbackInternal( 177 const std::shared_ptr<ISupplicantStaIfaceCallback>& callback); 178 ndk::ScopedAStatus reassociateInternal(); 179 ndk::ScopedAStatus reconnectInternal(); 180 ndk::ScopedAStatus disconnectInternal(); 181 ndk::ScopedAStatus setPowerSaveInternal(bool enable); 182 ndk::ScopedAStatus initiateTdlsDiscoverInternal( 183 const std::vector<uint8_t>& mac_address); 184 ndk::ScopedAStatus initiateTdlsSetupInternal( 185 const std::vector<uint8_t>& mac_address); 186 ndk::ScopedAStatus initiateTdlsTeardownInternal( 187 const std::vector<uint8_t>& mac_address); 188 ndk::ScopedAStatus initiateAnqpQueryInternal( 189 const std::vector<uint8_t>& mac_address, 190 const std::vector<AnqpInfoId>& info_elements, 191 const std::vector<Hs20AnqpSubtypes>& 192 sub_types); 193 ndk::ScopedAStatus initiateVenueUrlAnqpQueryInternal( 194 const std::vector<uint8_t>& mac_address); 195 ndk::ScopedAStatus initiateHs20IconQueryInternal( 196 const std::vector<uint8_t>& mac_address, 197 const std::string& file_name); 198 std::pair<std::vector<uint8_t>, ndk::ScopedAStatus> 199 getMacAddressInternal(); 200 ndk::ScopedAStatus startRxFilterInternal(); 201 ndk::ScopedAStatus stopRxFilterInternal(); 202 ndk::ScopedAStatus addRxFilterInternal( 203 RxFilterType type); 204 ndk::ScopedAStatus removeRxFilterInternal( 205 RxFilterType type); 206 ndk::ScopedAStatus setBtCoexistenceModeInternal( 207 BtCoexistenceMode mode); 208 ndk::ScopedAStatus setBtCoexistenceScanModeEnabledInternal(bool enable); 209 ndk::ScopedAStatus setSuspendModeEnabledInternal(bool enable); 210 ndk::ScopedAStatus setCountryCodeInternal( 211 const std::vector<uint8_t>& code); 212 ndk::ScopedAStatus startWpsRegistrarInternal( 213 const std::vector<uint8_t>& bssid, const std::string& pin); 214 ndk::ScopedAStatus startWpsPbcInternal( 215 const std::vector<uint8_t>& bssid); 216 ndk::ScopedAStatus startWpsPinKeypadInternal(const std::string& pin); 217 std::pair<std::string, ndk::ScopedAStatus> startWpsPinDisplayInternal( 218 const std::vector<uint8_t>& bssid); 219 ndk::ScopedAStatus cancelWpsInternal(); 220 ndk::ScopedAStatus setWpsDeviceNameInternal(const std::string& name); 221 ndk::ScopedAStatus setWpsDeviceTypeInternal( 222 const std::vector<uint8_t>& type); 223 ndk::ScopedAStatus setWpsManufacturerInternal( 224 const std::string& manufacturer); 225 ndk::ScopedAStatus setWpsModelNameInternal(const std::string& model_name); 226 ndk::ScopedAStatus setWpsModelNumberInternal( 227 const std::string& model_number); 228 ndk::ScopedAStatus setWpsSerialNumberInternal( 229 const std::string& serial_number); 230 ndk::ScopedAStatus setWpsConfigMethodsInternal(WpsConfigMethods config_methods); 231 ndk::ScopedAStatus setExternalSimInternal(bool useExternalSim); 232 std::pair<uint32_t, ndk::ScopedAStatus> addExtRadioWorkInternal( 233 const std::string& name, uint32_t freq_in_mhz, 234 uint32_t timeout_in_sec); 235 ndk::ScopedAStatus removeExtRadioWorkInternal(uint32_t id); 236 ndk::ScopedAStatus enableAutoReconnectInternal(bool enable); 237 std::pair<KeyMgmtMask, ndk::ScopedAStatus> getKeyMgmtCapabilitiesInternal(); 238 std::pair<uint32_t, ndk::ScopedAStatus> addDppPeerUriInternal(const std::string& uri); 239 ndk::ScopedAStatus removeDppUriInternal(uint32_t bootstrap_id); 240 std::pair<std::vector<uint8_t>, ndk::ScopedAStatus> startDppConfiguratorInitiatorInternal( 241 uint32_t peer_bootstrap_id, uint32_t own_bootstrap_id, const std::string& ssid, 242 const std::string& password, const std::string& psk, DppNetRole net_role, 243 DppAkm security_akm, const std::vector<uint8_t> &privEcKey); 244 ndk::ScopedAStatus startDppEnrolleeInitiatorInternal(uint32_t peer_bootstrap_id, 245 uint32_t own_bootstrap_id); 246 ndk::ScopedAStatus stopDppInitiatorInternal(); 247 std::pair<ConnectionCapabilities, ndk::ScopedAStatus> getConnectionCapabilitiesInternal(); 248 std::pair<WpaDriverCapabilitiesMask, ndk::ScopedAStatus> getWpaDriverCapabilitiesInternal(); 249 ndk::ScopedAStatus setMboCellularDataStatusInternal(bool available); 250 std::pair<DppResponderBootstrapInfo, ndk::ScopedAStatus> 251 generateDppBootstrapInfoForResponderInternal( 252 const std::vector<uint8_t>& mac_address, const std::string& device_info, 253 DppCurve curve); 254 ndk::ScopedAStatus startDppEnrolleeResponderInternal(uint32_t listen_channel); 255 ndk::ScopedAStatus stopDppResponderInternal(uint32_t own_bootstrap_id); 256 ndk::ScopedAStatus generateSelfDppConfigurationInternal( 257 const std::string& ssid, const std::vector<uint8_t> &privEcKey); 258 ndk::ScopedAStatus setQosPolicyFeatureEnabledInternal(bool enable); 259 ndk::ScopedAStatus sendQosPolicyResponseInternal( 260 int32_t qos_policy_request_id, bool more_policies, 261 const std::vector<QosPolicyStatus>& qos_policy_status_list); 262 ndk::ScopedAStatus removeAllQosPoliciesInternal(); 263 std::pair<MloLinksInfo, ndk::ScopedAStatus> getConnectionMloLinksInfoInternal(); 264 struct wpa_supplicant* retrieveIfacePtr(); 265 266 // Reference to the global wpa_struct. This is assumed to be valid for 267 // the lifetime of the process. 268 struct wpa_global* wpa_global_; 269 // Name of the iface this aidl object controls 270 const std::string ifname_; 271 bool is_valid_; 272 273 DISALLOW_COPY_AND_ASSIGN(StaIface); 274 }; 275 276 } // namespace supplicant 277 } // namespace wifi 278 } // namespace hardware 279 } // namespace android 280 } // namespace aidl 281 282 #endif // WPA_SUPPLICANT_AIDL_STA_IFACE_H 283