• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
169 private:
170 	// Corresponding worker functions for the AIDL methods.
171 	std::pair<std::string, ndk::ScopedAStatus> getNameInternal();
172 	std::pair<IfaceType, ndk::ScopedAStatus> getTypeInternal();
173 	std::pair<std::shared_ptr<ISupplicantStaNetwork>, ndk::ScopedAStatus>
174 		addNetworkInternal();
175 	ndk::ScopedAStatus filsHlpFlushRequestInternal();
176 	ndk::ScopedAStatus filsHlpAddRequestInternal(
177 		const std::vector<uint8_t>& dst_mac,
178 		const std::vector<uint8_t>& pkt);
179 	ndk::ScopedAStatus removeNetworkInternal(int32_t id);
180 	std::pair<std::shared_ptr<ISupplicantStaNetwork>, ndk::ScopedAStatus>
181 		getNetworkInternal(int32_t id);
182 	std::pair<std::vector<int32_t>, ndk::ScopedAStatus>
183 		listNetworksInternal();
184 	ndk::ScopedAStatus registerCallbackInternal(
185 		const std::shared_ptr<ISupplicantStaIfaceCallback>& callback);
186 	ndk::ScopedAStatus reassociateInternal();
187 	ndk::ScopedAStatus reconnectInternal();
188 	ndk::ScopedAStatus disconnectInternal();
189 	ndk::ScopedAStatus setPowerSaveInternal(bool enable);
190 	ndk::ScopedAStatus initiateTdlsDiscoverInternal(
191 		const std::vector<uint8_t>& mac_address);
192 	ndk::ScopedAStatus initiateTdlsSetupInternal(
193 		const std::vector<uint8_t>& mac_address);
194 	ndk::ScopedAStatus initiateTdlsTeardownInternal(
195 		const std::vector<uint8_t>& mac_address);
196 	ndk::ScopedAStatus initiateAnqpQueryInternal(
197 		const std::vector<uint8_t>& mac_address,
198 		const std::vector<AnqpInfoId>& info_elements,
199 		const std::vector<Hs20AnqpSubtypes>&
200 		sub_types);
201 	ndk::ScopedAStatus initiateVenueUrlAnqpQueryInternal(
202 		const std::vector<uint8_t>& mac_address);
203 	ndk::ScopedAStatus initiateHs20IconQueryInternal(
204 		const std::vector<uint8_t>& mac_address,
205 		const std::string& file_name);
206 	std::pair<std::vector<uint8_t>, ndk::ScopedAStatus>
207 		getMacAddressInternal();
208 	ndk::ScopedAStatus startRxFilterInternal();
209 	ndk::ScopedAStatus stopRxFilterInternal();
210 	ndk::ScopedAStatus addRxFilterInternal(
211 		RxFilterType type);
212 	ndk::ScopedAStatus removeRxFilterInternal(
213 		RxFilterType type);
214 	ndk::ScopedAStatus setBtCoexistenceModeInternal(
215 		BtCoexistenceMode mode);
216 	ndk::ScopedAStatus setBtCoexistenceScanModeEnabledInternal(bool enable);
217 	ndk::ScopedAStatus setSuspendModeEnabledInternal(bool enable);
218 	ndk::ScopedAStatus setCountryCodeInternal(
219 		const std::vector<uint8_t>& code);
220 	ndk::ScopedAStatus startWpsRegistrarInternal(
221 		const std::vector<uint8_t>& bssid, const std::string& pin);
222 	ndk::ScopedAStatus startWpsPbcInternal(
223 		const std::vector<uint8_t>& bssid);
224 	ndk::ScopedAStatus startWpsPinKeypadInternal(const std::string& pin);
225 	std::pair<std::string, ndk::ScopedAStatus> startWpsPinDisplayInternal(
226 		const std::vector<uint8_t>& bssid);
227 	ndk::ScopedAStatus cancelWpsInternal();
228 	ndk::ScopedAStatus setWpsDeviceNameInternal(const std::string& name);
229 	ndk::ScopedAStatus setWpsDeviceTypeInternal(
230 		const std::vector<uint8_t>& type);
231 	ndk::ScopedAStatus setWpsManufacturerInternal(
232 		const std::string& manufacturer);
233 	ndk::ScopedAStatus setWpsModelNameInternal(const std::string& model_name);
234 	ndk::ScopedAStatus setWpsModelNumberInternal(
235 		const std::string& model_number);
236 	ndk::ScopedAStatus setWpsSerialNumberInternal(
237 		const std::string& serial_number);
238 	ndk::ScopedAStatus setWpsConfigMethodsInternal(WpsConfigMethods config_methods);
239 	ndk::ScopedAStatus setExternalSimInternal(bool useExternalSim);
240 	std::pair<uint32_t, ndk::ScopedAStatus> addExtRadioWorkInternal(
241 		const std::string& name, uint32_t freq_in_mhz,
242 		uint32_t timeout_in_sec);
243 	ndk::ScopedAStatus removeExtRadioWorkInternal(uint32_t id);
244 	ndk::ScopedAStatus enableAutoReconnectInternal(bool enable);
245 	std::pair<KeyMgmtMask, ndk::ScopedAStatus> getKeyMgmtCapabilitiesInternal();
246 	std::pair<uint32_t, ndk::ScopedAStatus> addDppPeerUriInternal(const std::string& uri);
247 	ndk::ScopedAStatus removeDppUriInternal(uint32_t bootstrap_id);
248 	std::pair<std::vector<uint8_t>, ndk::ScopedAStatus> startDppConfiguratorInitiatorInternal(
249 		uint32_t peer_bootstrap_id, uint32_t own_bootstrap_id, const std::string& ssid,
250 		const std::string& password, const std::string& psk, DppNetRole net_role,
251 		DppAkm security_akm, const std::vector<uint8_t> &privEcKey);
252 	ndk::ScopedAStatus startDppEnrolleeInitiatorInternal(uint32_t peer_bootstrap_id,
253 			uint32_t own_bootstrap_id);
254 	ndk::ScopedAStatus stopDppInitiatorInternal();
255 	std::pair<ConnectionCapabilities, ndk::ScopedAStatus> getConnectionCapabilitiesInternal();
256 	std::pair<WpaDriverCapabilitiesMask, ndk::ScopedAStatus> getWpaDriverCapabilitiesInternal();
257 	ndk::ScopedAStatus setMboCellularDataStatusInternal(bool available);
258 	std::pair<DppResponderBootstrapInfo, ndk::ScopedAStatus>
259 			generateDppBootstrapInfoForResponderInternal(
260 			const std::vector<uint8_t>& mac_address, const std::string& device_info,
261 			DppCurve curve);
262 	ndk::ScopedAStatus startDppEnrolleeResponderInternal(uint32_t listen_channel);
263 	ndk::ScopedAStatus stopDppResponderInternal(uint32_t own_bootstrap_id);
264 	ndk::ScopedAStatus generateSelfDppConfigurationInternal(
265 		const std::string& ssid, const std::vector<uint8_t> &privEcKey);
266 	ndk::ScopedAStatus setQosPolicyFeatureEnabledInternal(bool enable);
267 	ndk::ScopedAStatus sendQosPolicyResponseInternal(
268 		int32_t qos_policy_request_id, bool more_policies,
269 		const std::vector<QosPolicyStatus>& qos_policy_status_list);
270 	ndk::ScopedAStatus removeAllQosPoliciesInternal();
271 	std::pair<MloLinksInfo, ndk::ScopedAStatus> getConnectionMloLinksInfoInternal();
272 	std::pair<std::vector<SignalPollResult>, ndk::ScopedAStatus>
273 		getSignalPollResultsInternal();
274 	std::pair<std::vector<QosPolicyScsRequestStatus>, ndk::ScopedAStatus>
275 		addQosPolicyRequestForScsInternal(
276 		const std::vector<QosPolicyScsData>& qosPolicyData);
277 	std::pair<std::vector<QosPolicyScsRequestStatus>, ndk::ScopedAStatus>
278 		removeQosPolicyForScsInternal(
279 		const std::vector<uint8_t>& scsPolicyIds);
280 
281 	struct wpa_supplicant* retrieveIfacePtr();
282 
283 	// Reference to the global wpa_struct. This is assumed to be valid for
284 	// the lifetime of the process.
285 	struct wpa_global* wpa_global_;
286 	// Name of the iface this aidl object controls
287 	const std::string ifname_;
288 	bool is_valid_;
289 
290 	DISALLOW_COPY_AND_ASSIGN(StaIface);
291 };
292 
293 }  // namespace supplicant
294 }  // namespace wifi
295 }  // namespace hardware
296 }  // namespace android
297 }  // namespace aidl
298 
299 #endif  // WPA_SUPPLICANT_AIDL_STA_IFACE_H
300