xref: /aosp_15_r20/external/wpa_supplicant_8/wpa_supplicant/aidl/vendor/sta_iface.h (revision 03f9172ca588f91df233974f4258bab95191f931)
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 	::ndk::ScopedAStatus getSignalPollResults(
161 		std::vector<SignalPollResult>* results) override;
162 	::ndk::ScopedAStatus addQosPolicyRequestForScs(
163 		const std::vector<QosPolicyScsData>& in_qosPolicyData,
164 		std::vector<QosPolicyScsRequestStatus>* _aidl_return) override;
165 	::ndk::ScopedAStatus removeQosPolicyForScs(
166 		const std::vector<uint8_t>& in_scsPolicyIds,
167 		std::vector<QosPolicyScsRequestStatus>* _aidl_return) override;
168 	::ndk::ScopedAStatus configureMscs(const MscsParams& in_params) override;
169 	::ndk::ScopedAStatus disableMscs() override;
170 	::ndk::ScopedAStatus getUsdCapabilities(UsdCapabilities* _aidl_return);
171 	::ndk::ScopedAStatus startUsdPublish(int32_t in_cmdId,
172 		const UsdPublishConfig& in_usdPublishConfig);
173 	::ndk::ScopedAStatus startUsdSubscribe(int32_t in_cmdId,
174 		const UsdSubscribeConfig& in_usdSubscribeConfig);
175 	::ndk::ScopedAStatus updateUsdPublish(int32_t in_publishId,
176 		const std::vector<uint8_t>& in_serviceSpecificInfo);
177 	::ndk::ScopedAStatus cancelUsdPublish(int32_t in_publishId);
178 	::ndk::ScopedAStatus cancelUsdSubscribe(int32_t in_subscribeId);
179 	::ndk::ScopedAStatus sendUsdMessage(const UsdMessageInfo& in_messageInfo);
180 
181 private:
182 	// Corresponding worker functions for the AIDL methods.
183 	std::pair<std::string, ndk::ScopedAStatus> getNameInternal();
184 	std::pair<IfaceType, ndk::ScopedAStatus> getTypeInternal();
185 	std::pair<std::shared_ptr<ISupplicantStaNetwork>, ndk::ScopedAStatus>
186 		addNetworkInternal();
187 	ndk::ScopedAStatus filsHlpFlushRequestInternal();
188 	ndk::ScopedAStatus filsHlpAddRequestInternal(
189 		const std::vector<uint8_t>& dst_mac,
190 		const std::vector<uint8_t>& pkt);
191 	ndk::ScopedAStatus removeNetworkInternal(int32_t id);
192 	std::pair<std::shared_ptr<ISupplicantStaNetwork>, ndk::ScopedAStatus>
193 		getNetworkInternal(int32_t id);
194 	std::pair<std::vector<int32_t>, ndk::ScopedAStatus>
195 		listNetworksInternal();
196 	ndk::ScopedAStatus registerCallbackInternal(
197 		const std::shared_ptr<ISupplicantStaIfaceCallback>& callback);
198 	ndk::ScopedAStatus reassociateInternal();
199 	ndk::ScopedAStatus reconnectInternal();
200 	ndk::ScopedAStatus disconnectInternal();
201 	ndk::ScopedAStatus setPowerSaveInternal(bool enable);
202 	ndk::ScopedAStatus initiateTdlsDiscoverInternal(
203 		const std::vector<uint8_t>& mac_address);
204 	ndk::ScopedAStatus initiateTdlsSetupInternal(
205 		const std::vector<uint8_t>& mac_address);
206 	ndk::ScopedAStatus initiateTdlsTeardownInternal(
207 		const std::vector<uint8_t>& mac_address);
208 	ndk::ScopedAStatus initiateAnqpQueryInternal(
209 		const std::vector<uint8_t>& mac_address,
210 		const std::vector<AnqpInfoId>& info_elements,
211 		const std::vector<Hs20AnqpSubtypes>&
212 		sub_types);
213 	ndk::ScopedAStatus initiateVenueUrlAnqpQueryInternal(
214 		const std::vector<uint8_t>& mac_address);
215 	ndk::ScopedAStatus initiateHs20IconQueryInternal(
216 		const std::vector<uint8_t>& mac_address,
217 		const std::string& file_name);
218 	std::pair<std::vector<uint8_t>, ndk::ScopedAStatus>
219 		getMacAddressInternal();
220 	ndk::ScopedAStatus startRxFilterInternal();
221 	ndk::ScopedAStatus stopRxFilterInternal();
222 	ndk::ScopedAStatus addRxFilterInternal(
223 		RxFilterType type);
224 	ndk::ScopedAStatus removeRxFilterInternal(
225 		RxFilterType type);
226 	ndk::ScopedAStatus setBtCoexistenceModeInternal(
227 		BtCoexistenceMode mode);
228 	ndk::ScopedAStatus setBtCoexistenceScanModeEnabledInternal(bool enable);
229 	ndk::ScopedAStatus setSuspendModeEnabledInternal(bool enable);
230 	ndk::ScopedAStatus setCountryCodeInternal(
231 		const std::vector<uint8_t>& code);
232 	ndk::ScopedAStatus startWpsRegistrarInternal(
233 		const std::vector<uint8_t>& bssid, const std::string& pin);
234 	ndk::ScopedAStatus startWpsPbcInternal(
235 		const std::vector<uint8_t>& bssid);
236 	ndk::ScopedAStatus startWpsPinKeypadInternal(const std::string& pin);
237 	std::pair<std::string, ndk::ScopedAStatus> startWpsPinDisplayInternal(
238 		const std::vector<uint8_t>& bssid);
239 	ndk::ScopedAStatus cancelWpsInternal();
240 	ndk::ScopedAStatus setWpsDeviceNameInternal(const std::string& name);
241 	ndk::ScopedAStatus setWpsDeviceTypeInternal(
242 		const std::vector<uint8_t>& type);
243 	ndk::ScopedAStatus setWpsManufacturerInternal(
244 		const std::string& manufacturer);
245 	ndk::ScopedAStatus setWpsModelNameInternal(const std::string& model_name);
246 	ndk::ScopedAStatus setWpsModelNumberInternal(
247 		const std::string& model_number);
248 	ndk::ScopedAStatus setWpsSerialNumberInternal(
249 		const std::string& serial_number);
250 	ndk::ScopedAStatus setWpsConfigMethodsInternal(WpsConfigMethods config_methods);
251 	ndk::ScopedAStatus setExternalSimInternal(bool useExternalSim);
252 	std::pair<uint32_t, ndk::ScopedAStatus> addExtRadioWorkInternal(
253 		const std::string& name, uint32_t freq_in_mhz,
254 		uint32_t timeout_in_sec);
255 	ndk::ScopedAStatus removeExtRadioWorkInternal(uint32_t id);
256 	ndk::ScopedAStatus enableAutoReconnectInternal(bool enable);
257 	std::pair<KeyMgmtMask, ndk::ScopedAStatus> getKeyMgmtCapabilitiesInternal();
258 	std::pair<uint32_t, ndk::ScopedAStatus> addDppPeerUriInternal(const std::string& uri);
259 	ndk::ScopedAStatus removeDppUriInternal(uint32_t bootstrap_id);
260 	std::pair<std::vector<uint8_t>, ndk::ScopedAStatus> startDppConfiguratorInitiatorInternal(
261 		uint32_t peer_bootstrap_id, uint32_t own_bootstrap_id, const std::string& ssid,
262 		const std::string& password, const std::string& psk, DppNetRole net_role,
263 		DppAkm security_akm, const std::vector<uint8_t> &privEcKey);
264 	ndk::ScopedAStatus startDppEnrolleeInitiatorInternal(uint32_t peer_bootstrap_id,
265 			uint32_t own_bootstrap_id);
266 	ndk::ScopedAStatus stopDppInitiatorInternal();
267 	std::pair<ConnectionCapabilities, ndk::ScopedAStatus> getConnectionCapabilitiesInternal();
268 	std::pair<WpaDriverCapabilitiesMask, ndk::ScopedAStatus> getWpaDriverCapabilitiesInternal();
269 	ndk::ScopedAStatus setMboCellularDataStatusInternal(bool available);
270 	std::pair<DppResponderBootstrapInfo, ndk::ScopedAStatus>
271 			generateDppBootstrapInfoForResponderInternal(
272 			const std::vector<uint8_t>& mac_address, const std::string& device_info,
273 			DppCurve curve);
274 	ndk::ScopedAStatus startDppEnrolleeResponderInternal(uint32_t listen_channel);
275 	ndk::ScopedAStatus stopDppResponderInternal(uint32_t own_bootstrap_id);
276 	ndk::ScopedAStatus generateSelfDppConfigurationInternal(
277 		const std::string& ssid, const std::vector<uint8_t> &privEcKey);
278 	ndk::ScopedAStatus setQosPolicyFeatureEnabledInternal(bool enable);
279 	ndk::ScopedAStatus sendQosPolicyResponseInternal(
280 		int32_t qos_policy_request_id, bool more_policies,
281 		const std::vector<QosPolicyStatus>& qos_policy_status_list);
282 	ndk::ScopedAStatus removeAllQosPoliciesInternal();
283 	std::pair<MloLinksInfo, ndk::ScopedAStatus> getConnectionMloLinksInfoInternal();
284 	std::pair<std::vector<SignalPollResult>, ndk::ScopedAStatus>
285 		getSignalPollResultsInternal();
286 	std::pair<std::vector<QosPolicyScsRequestStatus>, ndk::ScopedAStatus>
287 		addQosPolicyRequestForScsInternal(
288 		const std::vector<QosPolicyScsData>& qosPolicyData);
289 	std::pair<std::vector<QosPolicyScsRequestStatus>, ndk::ScopedAStatus>
290 		removeQosPolicyForScsInternal(
291 		const std::vector<uint8_t>& scsPolicyIds);
292 	::ndk::ScopedAStatus configureMscsInternal(const MscsParams& params);
293 	::ndk::ScopedAStatus disableMscsInternal();
294 	std::pair<UsdCapabilities, ndk::ScopedAStatus> getUsdCapabilitiesInternal();
295 	::ndk::ScopedAStatus startUsdPublishInternal(const UsdPublishConfig& usdPublishConfig);
296 	::ndk::ScopedAStatus startUsdSubscribeInternal(const UsdSubscribeConfig& usdSubscribeConfig);
297 	::ndk::ScopedAStatus updateUsdPublishInternal(int32_t publishId,
298 		const std::vector<uint8_t>& serviceSpecificInfo);
299 	::ndk::ScopedAStatus cancelUsdPublishInternal(int32_t publishId);
300 	::ndk::ScopedAStatus cancelUsdSubscribeInternal(int32_t subscribeId);
301 	::ndk::ScopedAStatus sendUsdMessageInternal(const UsdMessageInfo& messageInfo);
302 
303 	struct wpa_supplicant* retrieveIfacePtr();
304 
305 	// Reference to the global wpa_struct. This is assumed to be valid for
306 	// the lifetime of the process.
307 	struct wpa_global* wpa_global_;
308 	// Name of the iface this aidl object controls
309 	const std::string ifname_;
310 	bool is_valid_;
311 
312 	DISALLOW_COPY_AND_ASSIGN(StaIface);
313 };
314 
315 }  // namespace supplicant
316 }  // namespace wifi
317 }  // namespace hardware
318 }  // namespace android
319 }  // namespace aidl
320 
321 #endif  // WPA_SUPPLICANT_AIDL_STA_IFACE_H
322