• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * wpa_supplicant - Internal driver interface wrappers
3  * Copyright (c) 2003-2015, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef DRIVER_I_H
10 #define DRIVER_I_H
11 
12 #include "drivers/driver.h"
13 
14 /* driver_ops */
wpa_drv_init(struct wpa_supplicant * wpa_s,const char * ifname)15 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
16 				  const char *ifname)
17 {
18 	if (wpa_s->driver->init2)
19 		return wpa_s->driver->init2(wpa_s, ifname,
20 					    wpa_s->global_drv_priv);
21 	if (wpa_s->driver->init) {
22 		return wpa_s->driver->init(wpa_s, ifname);
23 	}
24 	return NULL;
25 }
26 
wpa_drv_deinit(struct wpa_supplicant * wpa_s)27 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
28 {
29 	if (wpa_s->driver->deinit)
30 		wpa_s->driver->deinit(wpa_s->drv_priv);
31 }
32 
wpa_drv_set_param(struct wpa_supplicant * wpa_s,const char * param)33 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
34 				    const char *param)
35 {
36 	if (wpa_s->driver->set_param)
37 		return wpa_s->driver->set_param(wpa_s->drv_priv, param);
38 	return 0;
39 }
40 
wpa_drv_set_countermeasures(struct wpa_supplicant * wpa_s,int enabled)41 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
42 					      int enabled)
43 {
44 	if (wpa_s->driver->set_countermeasures) {
45 		return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
46 							  enabled);
47 	}
48 	return -1;
49 }
50 
wpa_drv_authenticate(struct wpa_supplicant * wpa_s,struct wpa_driver_auth_params * params)51 static inline int wpa_drv_authenticate(struct wpa_supplicant *wpa_s,
52 				       struct wpa_driver_auth_params *params)
53 {
54 	if (wpa_s->driver->authenticate)
55 		return wpa_s->driver->authenticate(wpa_s->drv_priv, params);
56 	return -1;
57 }
58 
wpa_drv_associate(struct wpa_supplicant * wpa_s,struct wpa_driver_associate_params * params)59 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
60 				    struct wpa_driver_associate_params *params)
61 {
62 	if (wpa_s->driver->associate) {
63 		return wpa_s->driver->associate(wpa_s->drv_priv, params);
64 	}
65 	return -1;
66 }
67 
wpa_drv_init_mesh(struct wpa_supplicant * wpa_s)68 static inline int wpa_drv_init_mesh(struct wpa_supplicant *wpa_s)
69 {
70 	if (wpa_s->driver->init_mesh)
71 		return wpa_s->driver->init_mesh(wpa_s->drv_priv);
72 	return -1;
73 }
74 
wpa_drv_join_mesh(struct wpa_supplicant * wpa_s,struct wpa_driver_mesh_join_params * params)75 static inline int wpa_drv_join_mesh(struct wpa_supplicant *wpa_s,
76 				    struct wpa_driver_mesh_join_params *params)
77 {
78 	if (wpa_s->driver->join_mesh)
79 		return wpa_s->driver->join_mesh(wpa_s->drv_priv, params);
80 	return -1;
81 }
82 
wpa_drv_leave_mesh(struct wpa_supplicant * wpa_s)83 static inline int wpa_drv_leave_mesh(struct wpa_supplicant *wpa_s)
84 {
85 	if (wpa_s->driver->leave_mesh)
86 		return wpa_s->driver->leave_mesh(wpa_s->drv_priv);
87 	return -1;
88 }
89 
wpa_drv_mesh_link_probe(struct wpa_supplicant * wpa_s,const u8 * addr,const u8 * eth,size_t len)90 static inline int wpa_drv_mesh_link_probe(struct wpa_supplicant *wpa_s,
91 					  const u8 *addr,
92 					  const u8 *eth, size_t len)
93 {
94 	if (wpa_s->driver->probe_mesh_link)
95 		return wpa_s->driver->probe_mesh_link(wpa_s->drv_priv, addr,
96 						      eth, len);
97 	return -1;
98 }
99 
wpa_drv_scan(struct wpa_supplicant * wpa_s,struct wpa_driver_scan_params * params)100 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s,
101 			       struct wpa_driver_scan_params *params)
102 {
103 #ifdef CONFIG_TESTING_OPTIONS
104 	if (wpa_s->test_failure == WPAS_TEST_FAILURE_SCAN_TRIGGER)
105 		return -EBUSY;
106 #endif /* CONFIG_TESTING_OPTIONS */
107 	if (wpa_s->driver->scan2)
108 		return wpa_s->driver->scan2(wpa_s->drv_priv, params);
109 	return -1;
110 }
111 
wpa_drv_sched_scan(struct wpa_supplicant * wpa_s,struct wpa_driver_scan_params * params)112 static inline int wpa_drv_sched_scan(struct wpa_supplicant *wpa_s,
113 				     struct wpa_driver_scan_params *params)
114 {
115 	if (wpa_s->driver->sched_scan)
116 		return wpa_s->driver->sched_scan(wpa_s->drv_priv, params);
117 	return -1;
118 }
119 
wpa_drv_stop_sched_scan(struct wpa_supplicant * wpa_s)120 static inline int wpa_drv_stop_sched_scan(struct wpa_supplicant *wpa_s)
121 {
122 	if (wpa_s->driver->stop_sched_scan)
123 		return wpa_s->driver->stop_sched_scan(wpa_s->drv_priv);
124 	return -1;
125 }
126 
127 struct wpa_scan_results *
128 wpa_drv_get_scan_results2(struct wpa_supplicant *wpa_s);
129 
wpa_drv_get_bssid(struct wpa_supplicant * wpa_s,u8 * bssid)130 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
131 {
132 	if (wpa_s->driver->get_bssid) {
133 		return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
134 	}
135 	return -1;
136 }
137 
wpa_drv_get_ssid(struct wpa_supplicant * wpa_s,u8 * ssid)138 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
139 {
140 	if (wpa_s->driver->get_ssid) {
141 		return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
142 	}
143 	return -1;
144 }
145 
wpa_drv_set_key(struct wpa_supplicant * wpa_s,int link_id,enum wpa_alg alg,const u8 * addr,int key_idx,int set_tx,const u8 * seq,size_t seq_len,const u8 * key,size_t key_len,enum key_flag key_flag)146 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, int link_id,
147 				  enum wpa_alg alg, const u8 *addr,
148 				  int key_idx, int set_tx,
149 				  const u8 *seq, size_t seq_len,
150 				  const u8 *key, size_t key_len,
151 				  enum key_flag key_flag)
152 {
153 	struct wpa_driver_set_key_params params;
154 
155 	os_memset(&params, 0, sizeof(params));
156 	params.ifname = wpa_s->ifname;
157 	params.alg = alg;
158 	params.addr = addr;
159 	params.key_idx = key_idx;
160 	params.set_tx = set_tx;
161 	params.seq = seq;
162 	params.seq_len = seq_len;
163 	params.key = key;
164 	params.key_len = key_len;
165 	params.key_flag = key_flag;
166 	params.link_id = link_id;
167 
168 	if (alg != WPA_ALG_NONE) {
169 		/* keyidx = 1 can be either a broadcast or--with
170 		 * Extended Key ID--a unicast key. Use bit 15 for
171 		 * the pairwise keyidx 1 which is hopefully high enough
172 		 * to not clash with future extensions.
173 		 */
174 		if (key_idx == 1 && (key_flag & KEY_FLAG_PAIRWISE))
175 			wpa_s->keys_cleared &= ~BIT(15);
176 		else if (key_idx >= 0 && key_idx <= 5)
177 			wpa_s->keys_cleared &= ~BIT(key_idx);
178 		else
179 			wpa_s->keys_cleared = 0;
180 	}
181 	if (wpa_s->driver->set_key) {
182 		return wpa_s->driver->set_key(wpa_s->drv_priv, &params);
183 	}
184 	return -1;
185 }
186 
wpa_drv_get_seqnum(struct wpa_supplicant * wpa_s,const u8 * addr,int idx,u8 * seq)187 static inline int wpa_drv_get_seqnum(struct wpa_supplicant *wpa_s,
188 				     const u8 *addr, int idx, u8 *seq)
189 {
190 	if (wpa_s->driver->get_seqnum)
191 		return wpa_s->driver->get_seqnum(wpa_s->ifname, wpa_s->drv_priv,
192 						 addr, idx, seq);
193 	return -1;
194 }
195 
wpa_drv_sta_deauth(struct wpa_supplicant * wpa_s,const u8 * addr,u16 reason_code)196 static inline int wpa_drv_sta_deauth(struct wpa_supplicant *wpa_s,
197 				     const u8 *addr, u16 reason_code)
198 {
199 	if (wpa_s->driver->sta_deauth) {
200 		return wpa_s->driver->sta_deauth(wpa_s->drv_priv,
201 						 wpa_s->own_addr, addr,
202 						 reason_code);
203 	}
204 	return -1;
205 }
206 
wpa_drv_deauthenticate(struct wpa_supplicant * wpa_s,const u8 * addr,u16 reason_code)207 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
208 					 const u8 *addr, u16 reason_code)
209 {
210 	if (wpa_s->driver->deauthenticate) {
211 		return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
212 						     reason_code);
213 	}
214 	return -1;
215 }
216 
wpa_drv_add_pmkid(struct wpa_supplicant * wpa_s,struct wpa_pmkid_params * params)217 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
218 				    struct wpa_pmkid_params *params)
219 {
220 	if (wpa_s->driver->add_pmkid) {
221 		return wpa_s->driver->add_pmkid(wpa_s->drv_priv, params);
222 	}
223 	return -1;
224 }
225 
wpa_drv_remove_pmkid(struct wpa_supplicant * wpa_s,struct wpa_pmkid_params * params)226 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
227 				       struct wpa_pmkid_params *params)
228 {
229 	if (wpa_s->driver->remove_pmkid) {
230 		return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, params);
231 	}
232 	return -1;
233 }
234 
wpa_drv_flush_pmkid(struct wpa_supplicant * wpa_s)235 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
236 {
237 	if (wpa_s->driver->flush_pmkid) {
238 		return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
239 	}
240 	return -1;
241 }
242 
wpa_drv_get_capa(struct wpa_supplicant * wpa_s,struct wpa_driver_capa * capa)243 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
244 				   struct wpa_driver_capa *capa)
245 {
246 	if (wpa_s->driver->get_capa) {
247 		return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
248 	}
249 	return -1;
250 }
251 
wpa_drv_poll(struct wpa_supplicant * wpa_s)252 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
253 {
254 	if (wpa_s->driver->poll) {
255 		wpa_s->driver->poll(wpa_s->drv_priv);
256 	}
257 }
258 
wpa_drv_get_ifname(struct wpa_supplicant * wpa_s)259 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
260 {
261 	if (wpa_s->driver->get_ifname) {
262 		return wpa_s->driver->get_ifname(wpa_s->drv_priv);
263 	}
264 	return NULL;
265 }
266 
267 static inline const char *
wpa_driver_get_radio_name(struct wpa_supplicant * wpa_s)268 wpa_driver_get_radio_name(struct wpa_supplicant *wpa_s)
269 {
270 	if (wpa_s->driver->get_radio_name)
271 		return wpa_s->driver->get_radio_name(wpa_s->drv_priv);
272 	return NULL;
273 }
274 
wpa_drv_get_mac_addr(struct wpa_supplicant * wpa_s)275 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
276 {
277 	if (wpa_s->driver->get_mac_addr) {
278 		return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
279 	}
280 	return NULL;
281 }
282 
wpa_drv_set_operstate(struct wpa_supplicant * wpa_s,int state)283 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
284 					int state)
285 {
286 	if (wpa_s->driver->set_operstate)
287 		return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
288 	return 0;
289 }
290 
wpa_drv_mlme_setprotection(struct wpa_supplicant * wpa_s,const u8 * addr,int protect_type,int key_type)291 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
292 					     const u8 *addr, int protect_type,
293 					     int key_type)
294 {
295 	if (wpa_s->driver->mlme_setprotection)
296 		return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
297 							 protect_type,
298 							 key_type);
299 	return 0;
300 }
301 
302 static inline struct hostapd_hw_modes *
wpa_drv_get_hw_feature_data(struct wpa_supplicant * wpa_s,u16 * num_modes,u16 * flags,u8 * dfs_domain)303 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
304 			    u16 *flags, u8 *dfs_domain)
305 {
306 	if (wpa_s->driver->get_hw_feature_data)
307 		return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
308 							  num_modes, flags,
309 							  dfs_domain);
310 	return NULL;
311 }
312 
wpa_drv_set_country(struct wpa_supplicant * wpa_s,const char * alpha2)313 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
314 				      const char *alpha2)
315 {
316 	if (wpa_s->driver->set_country)
317 		return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
318 	return 0;
319 }
320 
wpa_drv_send_mlme(struct wpa_supplicant * wpa_s,const u8 * data,size_t data_len,int noack,unsigned int freq,unsigned int wait)321 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
322 				    const u8 *data, size_t data_len, int noack,
323 				    unsigned int freq, unsigned int wait)
324 {
325 	if (wpa_s->driver->send_mlme)
326 		return wpa_s->driver->send_mlme(wpa_s->drv_priv,
327 						data, data_len, noack,
328 						freq, NULL, 0, 0, wait);
329 	return -1;
330 }
331 
wpa_drv_update_ft_ies(struct wpa_supplicant * wpa_s,const u8 * md,const u8 * ies,size_t ies_len)332 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
333 					const u8 *md,
334 					const u8 *ies, size_t ies_len)
335 {
336 	if (wpa_s->driver->update_ft_ies)
337 		return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
338 						    ies, ies_len);
339 	return -1;
340 }
341 
wpa_drv_set_ap(struct wpa_supplicant * wpa_s,struct wpa_driver_ap_params * params)342 static inline int wpa_drv_set_ap(struct wpa_supplicant *wpa_s,
343 				 struct wpa_driver_ap_params *params)
344 {
345 	if (wpa_s->driver->set_ap)
346 		return wpa_s->driver->set_ap(wpa_s->drv_priv, params);
347 	return -1;
348 }
349 
wpa_drv_sta_add(struct wpa_supplicant * wpa_s,struct hostapd_sta_add_params * params)350 static inline int wpa_drv_sta_add(struct wpa_supplicant *wpa_s,
351 				  struct hostapd_sta_add_params *params)
352 {
353 	if (wpa_s->driver->sta_add) {
354 		/* Set link_id to -1 as it's needed for AP only */
355 		params->mld_link_id = -1;
356 		return wpa_s->driver->sta_add(wpa_s->drv_priv, params);
357 	}
358 	return -1;
359 }
360 
wpa_drv_sta_remove(struct wpa_supplicant * wpa_s,const u8 * addr)361 static inline int wpa_drv_sta_remove(struct wpa_supplicant *wpa_s,
362 				     const u8 *addr)
363 {
364 	if (wpa_s->driver->sta_remove)
365 		return wpa_s->driver->sta_remove(wpa_s->drv_priv, addr);
366 	return -1;
367 }
368 
wpa_drv_tx_control_port(struct wpa_supplicant * wpa_s,const u8 * dest,u16 proto,const u8 * buf,size_t len,int no_encrypt)369 static inline int wpa_drv_tx_control_port(struct wpa_supplicant *wpa_s,
370 					  const u8 *dest, u16 proto,
371 					  const u8 *buf, size_t len,
372 					  int no_encrypt)
373 {
374 	if (!wpa_s->driver->tx_control_port)
375 		return -1;
376 	return wpa_s->driver->tx_control_port(wpa_s->drv_priv, dest, proto,
377 					      buf, len, no_encrypt);
378 }
379 
wpa_drv_hapd_send_eapol(struct wpa_supplicant * wpa_s,const u8 * addr,const u8 * data,size_t data_len,int encrypt,const u8 * own_addr,u32 flags)380 static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s,
381 					  const u8 *addr, const u8 *data,
382 					  size_t data_len, int encrypt,
383 					  const u8 *own_addr, u32 flags)
384 {
385 	if (wpa_s->driver->hapd_send_eapol)
386 		return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr,
387 						      data, data_len, encrypt,
388 						      own_addr, flags);
389 	return -1;
390 }
391 
wpa_drv_sta_set_flags(struct wpa_supplicant * wpa_s,const u8 * addr,int total_flags,int flags_or,int flags_and)392 static inline int wpa_drv_sta_set_flags(struct wpa_supplicant *wpa_s,
393 					const u8 *addr, int total_flags,
394 					int flags_or, int flags_and)
395 {
396 	if (wpa_s->driver->sta_set_flags)
397 		return wpa_s->driver->sta_set_flags(wpa_s->drv_priv, addr,
398 						    total_flags, flags_or,
399 						    flags_and);
400 	return -1;
401 }
402 
wpa_drv_set_supp_port(struct wpa_supplicant * wpa_s,int authorized)403 static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s,
404 					int authorized)
405 {
406 	if (wpa_s->driver->set_supp_port) {
407 		return wpa_s->driver->set_supp_port(wpa_s->drv_priv,
408 						    authorized);
409 	}
410 	return 0;
411 }
412 
413 int wpa_drv_send_action(struct wpa_supplicant *wpa_s, unsigned int freq,
414 			unsigned int wait, const u8 *dst, const u8 *src,
415 			const u8 *bssid, const u8 *data, size_t data_len,
416 			int no_cck);
417 
wpa_drv_send_action_cancel_wait(struct wpa_supplicant * wpa_s)418 static inline void wpa_drv_send_action_cancel_wait(struct wpa_supplicant *wpa_s)
419 {
420 	if (wpa_s->driver->send_action_cancel_wait)
421 		wpa_s->driver->send_action_cancel_wait(wpa_s->drv_priv);
422 }
423 
wpa_drv_set_freq(struct wpa_supplicant * wpa_s,struct hostapd_freq_params * freq)424 static inline int wpa_drv_set_freq(struct wpa_supplicant *wpa_s,
425 				   struct hostapd_freq_params *freq)
426 {
427 	if (wpa_s->driver->set_freq)
428 		return wpa_s->driver->set_freq(wpa_s->drv_priv, freq);
429 	return -1;
430 }
431 
wpa_drv_if_add(struct wpa_supplicant * wpa_s,enum wpa_driver_if_type type,const char * ifname,const u8 * addr,void * bss_ctx,char * force_ifname,u8 * if_addr,const char * bridge)432 static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s,
433 				 enum wpa_driver_if_type type,
434 				 const char *ifname, const u8 *addr,
435 				 void *bss_ctx, char *force_ifname,
436 				 u8 *if_addr, const char *bridge)
437 {
438 	if (wpa_s->driver->if_add)
439 		return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname,
440 					     addr, bss_ctx, NULL, force_ifname,
441 					     if_addr, bridge, 0, 0);
442 	return -1;
443 }
444 
wpa_drv_if_remove(struct wpa_supplicant * wpa_s,enum wpa_driver_if_type type,const char * ifname)445 static inline int wpa_drv_if_remove(struct wpa_supplicant *wpa_s,
446 				    enum wpa_driver_if_type type,
447 				    const char *ifname)
448 {
449 	if (wpa_s->driver->if_remove)
450 		return wpa_s->driver->if_remove(wpa_s->drv_priv, type, ifname);
451 	return -1;
452 }
453 
wpa_drv_remain_on_channel(struct wpa_supplicant * wpa_s,unsigned int freq,unsigned int duration)454 static inline int wpa_drv_remain_on_channel(struct wpa_supplicant *wpa_s,
455 					    unsigned int freq,
456 					    unsigned int duration)
457 {
458 	if (wpa_s->driver->remain_on_channel)
459 		return wpa_s->driver->remain_on_channel(wpa_s->drv_priv, freq,
460 							duration);
461 	return -1;
462 }
463 
wpa_drv_cancel_remain_on_channel(struct wpa_supplicant * wpa_s)464 static inline int wpa_drv_cancel_remain_on_channel(
465 	struct wpa_supplicant *wpa_s)
466 {
467 	if (wpa_s->driver->cancel_remain_on_channel)
468 		return wpa_s->driver->cancel_remain_on_channel(
469 			wpa_s->drv_priv);
470 	return -1;
471 }
472 
wpa_drv_probe_req_report(struct wpa_supplicant * wpa_s,int report)473 static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s,
474 					   int report)
475 {
476 	if (wpa_s->driver->probe_req_report)
477 		return wpa_s->driver->probe_req_report(wpa_s->drv_priv,
478 						       report);
479 	return -1;
480 }
481 
wpa_drv_deinit_ap(struct wpa_supplicant * wpa_s)482 static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
483 {
484 	if (wpa_s->driver->deinit_ap)
485 		return wpa_s->driver->deinit_ap(wpa_s->drv_priv);
486 	return 0;
487 }
488 
wpa_drv_deinit_p2p_cli(struct wpa_supplicant * wpa_s)489 static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s)
490 {
491 	if (wpa_s->driver->deinit_p2p_cli)
492 		return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv);
493 	return 0;
494 }
495 
wpa_drv_suspend(struct wpa_supplicant * wpa_s)496 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
497 {
498 	if (wpa_s->driver->suspend)
499 		wpa_s->driver->suspend(wpa_s->drv_priv);
500 }
501 
wpa_drv_resume(struct wpa_supplicant * wpa_s)502 static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s)
503 {
504 	if (wpa_s->driver->resume)
505 		wpa_s->driver->resume(wpa_s->drv_priv);
506 }
507 
wpa_drv_signal_monitor(struct wpa_supplicant * wpa_s,int threshold,int hysteresis)508 static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s,
509 					 int threshold, int hysteresis)
510 {
511 	if (wpa_s->driver->signal_monitor)
512 		return wpa_s->driver->signal_monitor(wpa_s->drv_priv,
513 						     threshold, hysteresis);
514 	return -1;
515 }
516 
517 int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s,
518 			struct wpa_signal_info *si);
519 
wpa_drv_mlo_signal_poll(struct wpa_supplicant * wpa_s,struct wpa_mlo_signal_info * mlo_si)520 static inline int wpa_drv_mlo_signal_poll(struct wpa_supplicant *wpa_s,
521 					  struct wpa_mlo_signal_info *mlo_si)
522 {
523 	if (wpa_s->driver->mlo_signal_poll)
524 		return wpa_s->driver->mlo_signal_poll(wpa_s->drv_priv, mlo_si);
525 	return -1;
526 }
527 
wpa_drv_channel_info(struct wpa_supplicant * wpa_s,struct wpa_channel_info * ci)528 static inline int wpa_drv_channel_info(struct wpa_supplicant *wpa_s,
529 				       struct wpa_channel_info *ci)
530 {
531 	if (wpa_s->driver->channel_info)
532 		return wpa_s->driver->channel_info(wpa_s->drv_priv, ci);
533 	return -1;
534 }
535 
wpa_drv_pktcnt_poll(struct wpa_supplicant * wpa_s,struct hostap_sta_driver_data * sta)536 static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s,
537 				      struct hostap_sta_driver_data *sta)
538 {
539 	if (wpa_s->driver->read_sta_data)
540 		return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta,
541 						    wpa_s->bssid);
542 	return -1;
543 }
544 
wpa_drv_set_ap_wps_ie(struct wpa_supplicant * wpa_s,const struct wpabuf * beacon,const struct wpabuf * proberesp,const struct wpabuf * assocresp)545 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
546 					const struct wpabuf *beacon,
547 					const struct wpabuf *proberesp,
548 					const struct wpabuf *assocresp)
549 {
550 	if (!wpa_s->driver->set_ap_wps_ie)
551 		return -1;
552 	return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
553 					    proberesp, assocresp);
554 }
555 
wpa_drv_get_noa(struct wpa_supplicant * wpa_s,u8 * buf,size_t buf_len)556 static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
557 				  u8 *buf, size_t buf_len)
558 {
559 	if (!wpa_s->driver->get_noa)
560 		return -1;
561 	return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
562 }
563 
wpa_drv_set_p2p_powersave(struct wpa_supplicant * wpa_s,int legacy_ps,int opp_ps,int ctwindow)564 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
565 					    int legacy_ps, int opp_ps,
566 					    int ctwindow)
567 {
568 	if (!wpa_s->driver->set_p2p_powersave)
569 		return -1;
570 	return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
571 						opp_ps, ctwindow);
572 }
573 
wpa_drv_ampdu(struct wpa_supplicant * wpa_s,int ampdu)574 static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
575 {
576 	if (!wpa_s->driver->ampdu)
577 		return -1;
578 	return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
579 }
580 
wpa_drv_send_tdls_mgmt(struct wpa_supplicant * wpa_s,const u8 * dst,u8 action_code,u8 dialog_token,u16 status_code,u32 peer_capab,int initiator,const u8 * buf,size_t len)581 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
582 					 const u8 *dst, u8 action_code,
583 					 u8 dialog_token, u16 status_code,
584 					 u32 peer_capab, int initiator,
585 					 const u8 *buf, size_t len)
586 {
587 	if (wpa_s->driver->send_tdls_mgmt) {
588 		return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
589 						     action_code, dialog_token,
590 						     status_code, peer_capab,
591 						     initiator, buf, len);
592 	}
593 	return -1;
594 }
595 
wpa_drv_tdls_oper(struct wpa_supplicant * wpa_s,enum tdls_oper oper,const u8 * peer)596 static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
597 				    enum tdls_oper oper, const u8 *peer)
598 {
599 	if (!wpa_s->driver->tdls_oper)
600 		return -1;
601 	return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
602 }
603 
604 #ifdef ANDROID
wpa_drv_driver_cmd(struct wpa_supplicant * wpa_s,char * cmd,char * buf,size_t buf_len)605 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
606 				     char *cmd, char *buf, size_t buf_len)
607 {
608 	if (!wpa_s->driver->driver_cmd)
609 		return -1;
610 	return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
611 }
612 #endif /* ANDROID */
613 
wpa_drv_set_rekey_info(struct wpa_supplicant * wpa_s,const u8 * kek,size_t kek_len,const u8 * kck,size_t kck_len,const u8 * replay_ctr)614 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
615 					  const u8 *kek, size_t kek_len,
616 					  const u8 *kck, size_t kck_len,
617 					  const u8 *replay_ctr)
618 {
619 	if (!wpa_s->driver->set_rekey_info)
620 		return;
621 	wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kek_len,
622 				      kck, kck_len, replay_ctr);
623 }
624 
wpa_drv_radio_disable(struct wpa_supplicant * wpa_s,int disabled)625 static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s,
626 					int disabled)
627 {
628 	if (!wpa_s->driver->radio_disable)
629 		return -1;
630 	return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled);
631 }
632 
wpa_drv_switch_channel(struct wpa_supplicant * wpa_s,struct csa_settings * settings)633 static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
634 					 struct csa_settings *settings)
635 {
636 	if (!wpa_s->driver->switch_channel)
637 		return -1;
638 	return wpa_s->driver->switch_channel(wpa_s->drv_priv, settings);
639 }
640 
wpa_drv_add_ts(struct wpa_supplicant * wpa_s,u8 tsid,const u8 * address,u8 user_priority,u16 admitted_time)641 static inline int wpa_drv_add_ts(struct wpa_supplicant *wpa_s, u8 tsid,
642 				 const u8 *address, u8 user_priority,
643 				 u16 admitted_time)
644 {
645 	if (!wpa_s->driver->add_tx_ts)
646 		return -1;
647 	return wpa_s->driver->add_tx_ts(wpa_s->drv_priv, tsid, address,
648 					user_priority, admitted_time);
649 }
650 
wpa_drv_del_ts(struct wpa_supplicant * wpa_s,u8 tid,const u8 * address)651 static inline int wpa_drv_del_ts(struct wpa_supplicant *wpa_s, u8 tid,
652 				 const u8 *address)
653 {
654 	if (!wpa_s->driver->del_tx_ts)
655 		return -1;
656 	return wpa_s->driver->del_tx_ts(wpa_s->drv_priv, tid, address);
657 }
658 
wpa_drv_tdls_enable_channel_switch(struct wpa_supplicant * wpa_s,const u8 * addr,u8 oper_class,const struct hostapd_freq_params * freq_params)659 static inline int wpa_drv_tdls_enable_channel_switch(
660 	struct wpa_supplicant *wpa_s, const u8 *addr, u8 oper_class,
661 	const struct hostapd_freq_params *freq_params)
662 {
663 	if (!wpa_s->driver->tdls_enable_channel_switch)
664 		return -1;
665 	return wpa_s->driver->tdls_enable_channel_switch(wpa_s->drv_priv, addr,
666 							 oper_class,
667 							 freq_params);
668 }
669 
670 static inline int
wpa_drv_tdls_disable_channel_switch(struct wpa_supplicant * wpa_s,const u8 * addr)671 wpa_drv_tdls_disable_channel_switch(struct wpa_supplicant *wpa_s,
672 				    const u8 *addr)
673 {
674 	if (!wpa_s->driver->tdls_disable_channel_switch)
675 		return -1;
676 	return wpa_s->driver->tdls_disable_channel_switch(wpa_s->drv_priv,
677 							  addr);
678 }
679 
wpa_drv_wnm_oper(struct wpa_supplicant * wpa_s,enum wnm_oper oper,const u8 * peer,u8 * buf,u16 * buf_len)680 static inline int wpa_drv_wnm_oper(struct wpa_supplicant *wpa_s,
681 				   enum wnm_oper oper, const u8 *peer,
682 				   u8 *buf, u16 *buf_len)
683 {
684 	if (!wpa_s->driver->wnm_oper)
685 		return -1;
686 	return wpa_s->driver->wnm_oper(wpa_s->drv_priv, oper, peer, buf,
687 				       buf_len);
688 }
689 
wpa_drv_status(struct wpa_supplicant * wpa_s,char * buf,size_t buflen)690 static inline int wpa_drv_status(struct wpa_supplicant *wpa_s,
691 				 char *buf, size_t buflen)
692 {
693 	if (!wpa_s->driver->status)
694 		return -1;
695 	return wpa_s->driver->status(wpa_s->drv_priv, buf, buflen);
696 }
697 
wpa_drv_set_qos_map(struct wpa_supplicant * wpa_s,const u8 * qos_map_set,u8 qos_map_set_len)698 static inline int wpa_drv_set_qos_map(struct wpa_supplicant *wpa_s,
699 				      const u8 *qos_map_set, u8 qos_map_set_len)
700 {
701 	if (!wpa_s->driver->set_qos_map)
702 		return -1;
703 	return wpa_s->driver->set_qos_map(wpa_s->drv_priv, qos_map_set,
704 					  qos_map_set_len);
705 }
706 
wpa_drv_get_wowlan(struct wpa_supplicant * wpa_s)707 static inline int wpa_drv_get_wowlan(struct wpa_supplicant *wpa_s)
708 {
709 	if (!wpa_s->driver->get_wowlan)
710 		return 0;
711 	return wpa_s->driver->get_wowlan(wpa_s->drv_priv);
712 }
713 
wpa_drv_wowlan(struct wpa_supplicant * wpa_s,const struct wowlan_triggers * triggers)714 static inline int wpa_drv_wowlan(struct wpa_supplicant *wpa_s,
715 				 const struct wowlan_triggers *triggers)
716 {
717 	if (!wpa_s->driver->set_wowlan)
718 		return -1;
719 	return wpa_s->driver->set_wowlan(wpa_s->drv_priv, triggers);
720 }
721 
wpa_drv_vendor_cmd(struct wpa_supplicant * wpa_s,int vendor_id,int subcmd,const u8 * data,size_t data_len,enum nested_attr nested_attr_flag,struct wpabuf * buf)722 static inline int wpa_drv_vendor_cmd(struct wpa_supplicant *wpa_s,
723 				     int vendor_id, int subcmd, const u8 *data,
724 				     size_t data_len,
725 				     enum nested_attr nested_attr_flag,
726 				     struct wpabuf *buf)
727 {
728 	if (!wpa_s->driver->vendor_cmd)
729 		return -1;
730 	return wpa_s->driver->vendor_cmd(wpa_s->drv_priv, vendor_id, subcmd,
731 					 data, data_len, nested_attr_flag, buf);
732 }
733 
wpa_drv_roaming(struct wpa_supplicant * wpa_s,int allowed,const u8 * bssid)734 static inline int wpa_drv_roaming(struct wpa_supplicant *wpa_s, int allowed,
735 				  const u8 *bssid)
736 {
737 	if (!wpa_s->driver->roaming)
738 		return -1;
739 	return wpa_s->driver->roaming(wpa_s->drv_priv, allowed, bssid);
740 }
741 
wpa_drv_disable_fils(struct wpa_supplicant * wpa_s,int disable)742 static inline int wpa_drv_disable_fils(struct wpa_supplicant *wpa_s,
743 				       int disable)
744 {
745 	if (!wpa_s->driver->disable_fils)
746 		return -1;
747 	return wpa_s->driver->disable_fils(wpa_s->drv_priv, disable);
748 }
749 
wpa_drv_set_mac_addr(struct wpa_supplicant * wpa_s,const u8 * addr)750 static inline int wpa_drv_set_mac_addr(struct wpa_supplicant *wpa_s,
751 				       const u8 *addr)
752 {
753 	if (!wpa_s->driver->set_mac_addr)
754 		return -1;
755 	return wpa_s->driver->set_mac_addr(wpa_s->drv_priv, addr);
756 }
757 
758 
759 #ifdef CONFIG_MACSEC
760 
wpa_drv_macsec_init(struct wpa_supplicant * wpa_s,struct macsec_init_params * params)761 static inline int wpa_drv_macsec_init(struct wpa_supplicant *wpa_s,
762 				      struct macsec_init_params *params)
763 {
764 	if (!wpa_s->driver->macsec_init)
765 		return -1;
766 	return wpa_s->driver->macsec_init(wpa_s->drv_priv, params);
767 }
768 
wpa_drv_macsec_deinit(struct wpa_supplicant * wpa_s)769 static inline int wpa_drv_macsec_deinit(struct wpa_supplicant *wpa_s)
770 {
771 	if (!wpa_s->driver->macsec_deinit)
772 		return -1;
773 	return wpa_s->driver->macsec_deinit(wpa_s->drv_priv);
774 }
775 
wpa_drv_macsec_get_capability(struct wpa_supplicant * wpa_s,enum macsec_cap * cap)776 static inline int wpa_drv_macsec_get_capability(struct wpa_supplicant *wpa_s,
777 						enum macsec_cap *cap)
778 {
779 	if (!wpa_s->driver->macsec_get_capability)
780 		return -1;
781 	return wpa_s->driver->macsec_get_capability(wpa_s->drv_priv, cap);
782 }
783 
wpa_drv_enable_protect_frames(struct wpa_supplicant * wpa_s,bool enabled)784 static inline int wpa_drv_enable_protect_frames(struct wpa_supplicant *wpa_s,
785 						bool enabled)
786 {
787 	if (!wpa_s->driver->enable_protect_frames)
788 		return -1;
789 	return wpa_s->driver->enable_protect_frames(wpa_s->drv_priv, enabled);
790 }
791 
wpa_drv_enable_encrypt(struct wpa_supplicant * wpa_s,bool enabled)792 static inline int wpa_drv_enable_encrypt(struct wpa_supplicant *wpa_s,
793 						bool enabled)
794 {
795 	if (!wpa_s->driver->enable_encrypt)
796 		return -1;
797 	return wpa_s->driver->enable_encrypt(wpa_s->drv_priv, enabled);
798 }
799 
wpa_drv_set_replay_protect(struct wpa_supplicant * wpa_s,bool enabled,u32 window)800 static inline int wpa_drv_set_replay_protect(struct wpa_supplicant *wpa_s,
801 					     bool enabled, u32 window)
802 {
803 	if (!wpa_s->driver->set_replay_protect)
804 		return -1;
805 	return wpa_s->driver->set_replay_protect(wpa_s->drv_priv, enabled,
806 						 window);
807 }
808 
wpa_drv_set_offload(struct wpa_supplicant * wpa_s,u8 offload)809 static inline int wpa_drv_set_offload(struct wpa_supplicant *wpa_s, u8 offload)
810 {
811 	if (!wpa_s->driver->set_offload)
812 		return -1;
813 	return wpa_s->driver->set_offload(wpa_s->drv_priv, offload);
814 
815 }
816 
wpa_drv_set_current_cipher_suite(struct wpa_supplicant * wpa_s,u64 cs)817 static inline int wpa_drv_set_current_cipher_suite(struct wpa_supplicant *wpa_s,
818 						   u64 cs)
819 {
820 	if (!wpa_s->driver->set_current_cipher_suite)
821 		return -1;
822 	return wpa_s->driver->set_current_cipher_suite(wpa_s->drv_priv, cs);
823 }
824 
wpa_drv_enable_controlled_port(struct wpa_supplicant * wpa_s,bool enabled)825 static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
826 						 bool enabled)
827 {
828 	if (!wpa_s->driver->enable_controlled_port)
829 		return -1;
830 	return wpa_s->driver->enable_controlled_port(wpa_s->drv_priv, enabled);
831 }
832 
wpa_drv_get_receive_lowest_pn(struct wpa_supplicant * wpa_s,struct receive_sa * sa)833 static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
834 						struct receive_sa *sa)
835 {
836 	if (!wpa_s->driver->get_receive_lowest_pn)
837 		return -1;
838 	return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, sa);
839 }
840 
wpa_drv_get_transmit_next_pn(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)841 static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
842 						struct transmit_sa *sa)
843 {
844 	if (!wpa_s->driver->get_transmit_next_pn)
845 		return -1;
846 	return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, sa);
847 }
848 
wpa_drv_set_transmit_next_pn(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)849 static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
850 						struct transmit_sa *sa)
851 {
852 	if (!wpa_s->driver->set_transmit_next_pn)
853 		return -1;
854 	return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, sa);
855 }
856 
wpa_drv_set_receive_lowest_pn(struct wpa_supplicant * wpa_s,struct receive_sa * sa)857 static inline int wpa_drv_set_receive_lowest_pn(struct wpa_supplicant *wpa_s,
858 						struct receive_sa *sa)
859 {
860 	if (!wpa_s->driver->set_receive_lowest_pn)
861 		return -1;
862 	return wpa_s->driver->set_receive_lowest_pn(wpa_s->drv_priv, sa);
863 }
864 
865 static inline int
wpa_drv_create_receive_sc(struct wpa_supplicant * wpa_s,struct receive_sc * sc,unsigned int conf_offset,int validation)866 wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, struct receive_sc *sc,
867 			  unsigned int conf_offset, int validation)
868 {
869 	if (!wpa_s->driver->create_receive_sc)
870 		return -1;
871 	return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, sc,
872 						conf_offset, validation);
873 }
874 
wpa_drv_delete_receive_sc(struct wpa_supplicant * wpa_s,struct receive_sc * sc)875 static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
876 					    struct receive_sc *sc)
877 {
878 	if (!wpa_s->driver->delete_receive_sc)
879 		return -1;
880 	return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, sc);
881 }
882 
wpa_drv_create_receive_sa(struct wpa_supplicant * wpa_s,struct receive_sa * sa)883 static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
884 					    struct receive_sa *sa)
885 {
886 	if (!wpa_s->driver->create_receive_sa)
887 		return -1;
888 	return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, sa);
889 }
890 
wpa_drv_delete_receive_sa(struct wpa_supplicant * wpa_s,struct receive_sa * sa)891 static inline int wpa_drv_delete_receive_sa(struct wpa_supplicant *wpa_s,
892 					    struct receive_sa *sa)
893 {
894 	if (!wpa_s->driver->delete_receive_sa)
895 		return -1;
896 	return wpa_s->driver->delete_receive_sa(wpa_s->drv_priv, sa);
897 }
898 
wpa_drv_enable_receive_sa(struct wpa_supplicant * wpa_s,struct receive_sa * sa)899 static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
900 					    struct receive_sa *sa)
901 {
902 	if (!wpa_s->driver->enable_receive_sa)
903 		return -1;
904 	return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, sa);
905 }
906 
wpa_drv_disable_receive_sa(struct wpa_supplicant * wpa_s,struct receive_sa * sa)907 static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
908 					     struct receive_sa *sa)
909 {
910 	if (!wpa_s->driver->disable_receive_sa)
911 		return -1;
912 	return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, sa);
913 }
914 
915 static inline int
wpa_drv_create_transmit_sc(struct wpa_supplicant * wpa_s,struct transmit_sc * sc,unsigned int conf_offset)916 wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, struct transmit_sc *sc,
917 			   unsigned int conf_offset)
918 {
919 	if (!wpa_s->driver->create_transmit_sc)
920 		return -1;
921 	return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, sc,
922 						 conf_offset);
923 }
924 
wpa_drv_delete_transmit_sc(struct wpa_supplicant * wpa_s,struct transmit_sc * sc)925 static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s,
926 					     struct transmit_sc *sc)
927 {
928 	if (!wpa_s->driver->delete_transmit_sc)
929 		return -1;
930 	return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, sc);
931 }
932 
wpa_drv_create_transmit_sa(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)933 static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s,
934 					     struct transmit_sa *sa)
935 {
936 	if (!wpa_s->driver->create_transmit_sa)
937 		return -1;
938 	return wpa_s->driver->create_transmit_sa(wpa_s->drv_priv, sa);
939 }
940 
wpa_drv_delete_transmit_sa(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)941 static inline int wpa_drv_delete_transmit_sa(struct wpa_supplicant *wpa_s,
942 					     struct transmit_sa *sa)
943 {
944 	if (!wpa_s->driver->delete_transmit_sa)
945 		return -1;
946 	return wpa_s->driver->delete_transmit_sa(wpa_s->drv_priv, sa);
947 }
948 
wpa_drv_enable_transmit_sa(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)949 static inline int wpa_drv_enable_transmit_sa(struct wpa_supplicant *wpa_s,
950 					     struct transmit_sa *sa)
951 {
952 	if (!wpa_s->driver->enable_transmit_sa)
953 		return -1;
954 	return wpa_s->driver->enable_transmit_sa(wpa_s->drv_priv, sa);
955 }
956 
wpa_drv_disable_transmit_sa(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)957 static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s,
958 					      struct transmit_sa *sa)
959 {
960 	if (!wpa_s->driver->disable_transmit_sa)
961 		return -1;
962 	return wpa_s->driver->disable_transmit_sa(wpa_s->drv_priv, sa);
963 }
964 #endif /* CONFIG_MACSEC */
965 
wpa_drv_setband(struct wpa_supplicant * wpa_s,u32 band_mask)966 static inline int wpa_drv_setband(struct wpa_supplicant *wpa_s,
967 				  u32 band_mask)
968 {
969 	if (!wpa_s->driver->set_band)
970 		return -1;
971 	return wpa_s->driver->set_band(wpa_s->drv_priv, band_mask);
972 }
973 
wpa_drv_get_pref_freq_list(struct wpa_supplicant * wpa_s,enum wpa_driver_if_type if_type,unsigned int * num,struct weighted_pcl * freq_list)974 static inline int wpa_drv_get_pref_freq_list(struct wpa_supplicant *wpa_s,
975 					     enum wpa_driver_if_type if_type,
976 					     unsigned int *num,
977 					     struct weighted_pcl *freq_list)
978 {
979 #ifdef CONFIG_TESTING_OPTIONS
980 	if (wpa_s->get_pref_freq_list_override)
981 		return wpas_ctrl_iface_get_pref_freq_list_override(
982 			wpa_s, if_type, num, freq_list);
983 #endif /* CONFIG_TESTING_OPTIONS */
984 	if (!wpa_s->driver->get_pref_freq_list)
985 		return -1;
986 	return wpa_s->driver->get_pref_freq_list(wpa_s->drv_priv, if_type,
987 						 num, freq_list);
988 }
989 
wpa_drv_set_prob_oper_freq(struct wpa_supplicant * wpa_s,unsigned int freq)990 static inline int wpa_drv_set_prob_oper_freq(struct wpa_supplicant *wpa_s,
991 					     unsigned int freq)
992 {
993 	if (!wpa_s->driver->set_prob_oper_freq)
994 		return 0;
995 	return wpa_s->driver->set_prob_oper_freq(wpa_s->drv_priv, freq);
996 }
997 
wpa_drv_abort_scan(struct wpa_supplicant * wpa_s,u64 scan_cookie)998 static inline int wpa_drv_abort_scan(struct wpa_supplicant *wpa_s,
999 				     u64 scan_cookie)
1000 {
1001 	if (!wpa_s->driver->abort_scan)
1002 		return -1;
1003 	return wpa_s->driver->abort_scan(wpa_s->drv_priv, scan_cookie);
1004 }
1005 
wpa_drv_configure_frame_filters(struct wpa_supplicant * wpa_s,u32 filters)1006 static inline int wpa_drv_configure_frame_filters(struct wpa_supplicant *wpa_s,
1007 						  u32 filters)
1008 {
1009 	if (!wpa_s->driver->configure_data_frame_filters)
1010 		return -1;
1011 	return wpa_s->driver->configure_data_frame_filters(wpa_s->drv_priv,
1012 							   filters);
1013 }
1014 
wpa_drv_get_ext_capa(struct wpa_supplicant * wpa_s,enum wpa_driver_if_type type)1015 static inline int wpa_drv_get_ext_capa(struct wpa_supplicant *wpa_s,
1016 				       enum wpa_driver_if_type type)
1017 {
1018 	if (!wpa_s->driver->get_ext_capab)
1019 		return -1;
1020 	return wpa_s->driver->get_ext_capab(wpa_s->drv_priv, type,
1021 					    &wpa_s->extended_capa,
1022 					    &wpa_s->extended_capa_mask,
1023 					    &wpa_s->extended_capa_len);
1024 }
1025 
wpa_drv_p2p_lo_start(struct wpa_supplicant * wpa_s,unsigned int channel,unsigned int period,unsigned int interval,unsigned int count,const u8 * device_types,size_t dev_types_len,const u8 * ies,size_t ies_len)1026 static inline int wpa_drv_p2p_lo_start(struct wpa_supplicant *wpa_s,
1027 				       unsigned int channel,
1028 				       unsigned int period,
1029 				       unsigned int interval,
1030 				       unsigned int count,
1031 				       const u8 *device_types,
1032 				       size_t dev_types_len,
1033 				       const u8 *ies, size_t ies_len)
1034 {
1035 	if (!wpa_s->driver->p2p_lo_start)
1036 		return -1;
1037 	return wpa_s->driver->p2p_lo_start(wpa_s->drv_priv, channel, period,
1038 					   interval, count, device_types,
1039 					   dev_types_len, ies, ies_len);
1040 }
1041 
wpa_drv_p2p_lo_stop(struct wpa_supplicant * wpa_s)1042 static inline int wpa_drv_p2p_lo_stop(struct wpa_supplicant *wpa_s)
1043 {
1044 	if (!wpa_s->driver->p2p_lo_stop)
1045 		return -1;
1046 	return wpa_s->driver->p2p_lo_stop(wpa_s->drv_priv);
1047 }
1048 
wpa_drv_set_default_scan_ies(struct wpa_supplicant * wpa_s,const u8 * ies,size_t len)1049 static inline int wpa_drv_set_default_scan_ies(struct wpa_supplicant *wpa_s,
1050 					       const u8 *ies, size_t len)
1051 {
1052 	if (!wpa_s->driver->set_default_scan_ies)
1053 		return -1;
1054 	return wpa_s->driver->set_default_scan_ies(wpa_s->drv_priv, ies, len);
1055 }
1056 
wpa_drv_set_tdls_mode(struct wpa_supplicant * wpa_s,int tdls_external_control)1057 static inline int wpa_drv_set_tdls_mode(struct wpa_supplicant *wpa_s,
1058 					int tdls_external_control)
1059 {
1060 	if (!wpa_s->driver->set_tdls_mode)
1061 		return -1;
1062 	return wpa_s->driver->set_tdls_mode(wpa_s->drv_priv,
1063 					    tdls_external_control);
1064 }
1065 
1066 static inline struct wpa_bss_candidate_info *
wpa_drv_get_bss_trans_status(struct wpa_supplicant * wpa_s,struct wpa_bss_trans_info * params)1067 wpa_drv_get_bss_trans_status(struct wpa_supplicant *wpa_s,
1068 			     struct wpa_bss_trans_info *params)
1069 {
1070 	if (!wpa_s->driver->get_bss_transition_status)
1071 		return NULL;
1072 	return wpa_s->driver->get_bss_transition_status(wpa_s->drv_priv,
1073 							params);
1074 }
1075 
wpa_drv_ignore_assoc_disallow(struct wpa_supplicant * wpa_s,int val)1076 static inline int wpa_drv_ignore_assoc_disallow(struct wpa_supplicant *wpa_s,
1077 						int val)
1078 {
1079 	if (!wpa_s->driver->ignore_assoc_disallow)
1080 		return -1;
1081 	return wpa_s->driver->ignore_assoc_disallow(wpa_s->drv_priv, val);
1082 }
1083 
wpa_drv_set_bssid_tmp_disallow(struct wpa_supplicant * wpa_s,unsigned int num_bssid,const u8 * bssids)1084 static inline int wpa_drv_set_bssid_tmp_disallow(struct wpa_supplicant *wpa_s,
1085 						 unsigned int num_bssid,
1086 						 const u8 *bssids)
1087 {
1088 	if (!wpa_s->driver->set_bssid_tmp_disallow)
1089 		return -1;
1090 	return wpa_s->driver->set_bssid_tmp_disallow(wpa_s->drv_priv, num_bssid,
1091 						     bssids);
1092 }
1093 
wpa_drv_update_connect_params(struct wpa_supplicant * wpa_s,struct wpa_driver_associate_params * params,enum wpa_drv_update_connect_params_mask mask)1094 static inline int wpa_drv_update_connect_params(
1095 	struct wpa_supplicant *wpa_s,
1096 	struct wpa_driver_associate_params *params,
1097 	enum wpa_drv_update_connect_params_mask mask)
1098 {
1099 	if (!wpa_s->driver->update_connect_params)
1100 		return -1;
1101 	return wpa_s->driver->update_connect_params(wpa_s->drv_priv, params,
1102 						    mask);
1103 }
1104 
1105 static inline int
wpa_drv_send_external_auth_status(struct wpa_supplicant * wpa_s,struct external_auth * params)1106 wpa_drv_send_external_auth_status(struct wpa_supplicant *wpa_s,
1107 				  struct external_auth *params)
1108 {
1109 	if (!wpa_s->driver->send_external_auth_status)
1110 		return -1;
1111 	return wpa_s->driver->send_external_auth_status(wpa_s->drv_priv,
1112 							params);
1113 }
1114 
wpa_drv_set_4addr_mode(struct wpa_supplicant * wpa_s,int val)1115 static inline int wpa_drv_set_4addr_mode(struct wpa_supplicant *wpa_s, int val)
1116 {
1117 	if (!wpa_s->driver->set_4addr_mode)
1118 		return -1;
1119 	return wpa_s->driver->set_4addr_mode(wpa_s->drv_priv,
1120 					     wpa_s->bridge_ifname, val);
1121 }
1122 
wpa_drv_dpp_listen(struct wpa_supplicant * wpa_s,bool enable)1123 static inline int wpa_drv_dpp_listen(struct wpa_supplicant *wpa_s, bool enable)
1124 {
1125 	if (!wpa_s->driver->dpp_listen)
1126 		return 0;
1127 	return wpa_s->driver->dpp_listen(wpa_s->drv_priv, enable);
1128 }
1129 
wpa_drv_send_pasn_resp(struct wpa_supplicant * wpa_s,struct pasn_auth * params)1130 static inline int wpa_drv_send_pasn_resp(struct wpa_supplicant *wpa_s,
1131 					 struct pasn_auth *params)
1132 {
1133 	if (!wpa_s->driver->send_pasn_resp)
1134 		return -1;
1135 	return wpa_s->driver->send_pasn_resp(wpa_s->drv_priv, params);
1136 }
1137 
wpa_drv_set_secure_ranging_ctx(struct wpa_supplicant * wpa_s,const u8 * own_addr,const u8 * peer_addr,u32 cipher,u8 tk_len,const u8 * tk,u8 ltf_keyseed_len,const u8 * ltf_keyseed,u32 action)1138 static inline int wpa_drv_set_secure_ranging_ctx(struct wpa_supplicant *wpa_s,
1139 						 const u8 *own_addr,
1140 						 const u8 *peer_addr,
1141 						 u32 cipher, u8 tk_len,
1142 						 const u8 *tk,
1143 						 u8 ltf_keyseed_len,
1144 						 const u8 *ltf_keyseed,
1145 						 u32 action)
1146 {
1147 	struct secure_ranging_params params;
1148 
1149 	if (!wpa_s->driver->set_secure_ranging_ctx)
1150 		return -1;
1151 
1152 	os_memset(&params, 0, sizeof(params));
1153 	params.action = action;
1154 	params.own_addr = own_addr;
1155 	params.peer_addr = peer_addr;
1156 	params.cipher = cipher;
1157 	params.tk_len = tk_len;
1158 	params.tk = tk;
1159 	params.ltf_keyseed_len = ltf_keyseed_len;
1160 	params.ltf_keyseed = ltf_keyseed;
1161 
1162 	return wpa_s->driver->set_secure_ranging_ctx(wpa_s->drv_priv, &params);
1163 }
1164 
1165 static inline int
wpas_drv_get_sta_mlo_info(struct wpa_supplicant * wpa_s,struct driver_sta_mlo_info * mlo_info)1166 wpas_drv_get_sta_mlo_info(struct wpa_supplicant *wpa_s,
1167 			  struct driver_sta_mlo_info *mlo_info)
1168 {
1169 	if (!wpa_s->driver->get_sta_mlo_info)
1170 		return 0;
1171 
1172 	return wpa_s->driver->get_sta_mlo_info(wpa_s->drv_priv, mlo_info);
1173 }
1174 
1175 #endif /* DRIVER_I_H */
1176