xref: /freebsd/contrib/wpa/wpa_supplicant/driver_i.h (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
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 */
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
146 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s,
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 
167 	if (alg != WPA_ALG_NONE) {
168 		/* keyidx = 1 can be either a broadcast or--with
169 		 * Extended Key ID--a unicast key. Use bit 15 for
170 		 * the pairwise keyidx 1 which is hopefully high enough
171 		 * to not clash with future extensions.
172 		 */
173 		if (key_idx == 1 && (key_flag & KEY_FLAG_PAIRWISE))
174 			wpa_s->keys_cleared &= ~BIT(15);
175 		else if (key_idx >= 0 && key_idx <= 5)
176 			wpa_s->keys_cleared &= ~BIT(key_idx);
177 		else
178 			wpa_s->keys_cleared = 0;
179 	}
180 	if (wpa_s->driver->set_key) {
181 		return wpa_s->driver->set_key(wpa_s->drv_priv, &params);
182 	}
183 	return -1;
184 }
185 
186 static inline int wpa_drv_get_seqnum(struct wpa_supplicant *wpa_s,
187 				     const u8 *addr, int idx, u8 *seq)
188 {
189 	if (wpa_s->driver->get_seqnum)
190 		return wpa_s->driver->get_seqnum(wpa_s->ifname, wpa_s->drv_priv,
191 						 addr, idx, seq);
192 	return -1;
193 }
194 
195 static inline int wpa_drv_sta_deauth(struct wpa_supplicant *wpa_s,
196 				     const u8 *addr, u16 reason_code)
197 {
198 	if (wpa_s->driver->sta_deauth) {
199 		return wpa_s->driver->sta_deauth(wpa_s->drv_priv,
200 						 wpa_s->own_addr, addr,
201 						 reason_code);
202 	}
203 	return -1;
204 }
205 
206 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
207 					 const u8 *addr, u16 reason_code)
208 {
209 	if (wpa_s->driver->deauthenticate) {
210 		return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
211 						     reason_code);
212 	}
213 	return -1;
214 }
215 
216 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
217 				    struct wpa_pmkid_params *params)
218 {
219 	if (wpa_s->driver->add_pmkid) {
220 		return wpa_s->driver->add_pmkid(wpa_s->drv_priv, params);
221 	}
222 	return -1;
223 }
224 
225 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
226 				       struct wpa_pmkid_params *params)
227 {
228 	if (wpa_s->driver->remove_pmkid) {
229 		return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, params);
230 	}
231 	return -1;
232 }
233 
234 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
235 {
236 	if (wpa_s->driver->flush_pmkid) {
237 		return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
238 	}
239 	return -1;
240 }
241 
242 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
243 				   struct wpa_driver_capa *capa)
244 {
245 	if (wpa_s->driver->get_capa) {
246 		return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
247 	}
248 	return -1;
249 }
250 
251 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
252 {
253 	if (wpa_s->driver->poll) {
254 		wpa_s->driver->poll(wpa_s->drv_priv);
255 	}
256 }
257 
258 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
259 {
260 	if (wpa_s->driver->get_ifname) {
261 		return wpa_s->driver->get_ifname(wpa_s->drv_priv);
262 	}
263 	return NULL;
264 }
265 
266 static inline const char *
267 wpa_driver_get_radio_name(struct wpa_supplicant *wpa_s)
268 {
269 	if (wpa_s->driver->get_radio_name)
270 		return wpa_s->driver->get_radio_name(wpa_s->drv_priv);
271 	return NULL;
272 }
273 
274 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
275 {
276 	if (wpa_s->driver->get_mac_addr) {
277 		return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
278 	}
279 	return NULL;
280 }
281 
282 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
283 					int state)
284 {
285 	if (wpa_s->driver->set_operstate)
286 		return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
287 	return 0;
288 }
289 
290 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
291 					     const u8 *addr, int protect_type,
292 					     int key_type)
293 {
294 	if (wpa_s->driver->mlme_setprotection)
295 		return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
296 							 protect_type,
297 							 key_type);
298 	return 0;
299 }
300 
301 static inline struct hostapd_hw_modes *
302 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
303 			    u16 *flags, u8 *dfs_domain)
304 {
305 	if (wpa_s->driver->get_hw_feature_data)
306 		return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
307 							  num_modes, flags,
308 							  dfs_domain);
309 	return NULL;
310 }
311 
312 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
313 				      const char *alpha2)
314 {
315 	if (wpa_s->driver->set_country)
316 		return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
317 	return 0;
318 }
319 
320 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
321 				    const u8 *data, size_t data_len, int noack,
322 				    unsigned int freq, unsigned int wait)
323 {
324 	if (wpa_s->driver->send_mlme)
325 		return wpa_s->driver->send_mlme(wpa_s->drv_priv,
326 						data, data_len, noack,
327 						freq, NULL, 0, 0, wait);
328 	return -1;
329 }
330 
331 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
332 					const u8 *md,
333 					const u8 *ies, size_t ies_len)
334 {
335 	if (wpa_s->driver->update_ft_ies)
336 		return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
337 						    ies, ies_len);
338 	return -1;
339 }
340 
341 static inline int wpa_drv_set_ap(struct wpa_supplicant *wpa_s,
342 				 struct wpa_driver_ap_params *params)
343 {
344 	if (wpa_s->driver->set_ap)
345 		return wpa_s->driver->set_ap(wpa_s->drv_priv, params);
346 	return -1;
347 }
348 
349 static inline int wpa_drv_sta_add(struct wpa_supplicant *wpa_s,
350 				  struct hostapd_sta_add_params *params)
351 {
352 	if (wpa_s->driver->sta_add)
353 		return wpa_s->driver->sta_add(wpa_s->drv_priv, params);
354 	return -1;
355 }
356 
357 static inline int wpa_drv_sta_remove(struct wpa_supplicant *wpa_s,
358 				     const u8 *addr)
359 {
360 	if (wpa_s->driver->sta_remove)
361 		return wpa_s->driver->sta_remove(wpa_s->drv_priv, addr);
362 	return -1;
363 }
364 
365 static inline int wpa_drv_tx_control_port(struct wpa_supplicant *wpa_s,
366 					  const u8 *dest, u16 proto,
367 					  const u8 *buf, size_t len,
368 					  int no_encrypt)
369 {
370 	if (!wpa_s->driver->tx_control_port)
371 		return -1;
372 	return wpa_s->driver->tx_control_port(wpa_s->drv_priv, dest, proto,
373 					      buf, len, no_encrypt);
374 }
375 
376 static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s,
377 					  const u8 *addr, const u8 *data,
378 					  size_t data_len, int encrypt,
379 					  const u8 *own_addr, u32 flags)
380 {
381 	if (wpa_s->driver->hapd_send_eapol)
382 		return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr,
383 						      data, data_len, encrypt,
384 						      own_addr, flags);
385 	return -1;
386 }
387 
388 static inline int wpa_drv_sta_set_flags(struct wpa_supplicant *wpa_s,
389 					const u8 *addr, int total_flags,
390 					int flags_or, int flags_and)
391 {
392 	if (wpa_s->driver->sta_set_flags)
393 		return wpa_s->driver->sta_set_flags(wpa_s->drv_priv, addr,
394 						    total_flags, flags_or,
395 						    flags_and);
396 	return -1;
397 }
398 
399 static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s,
400 					int authorized)
401 {
402 	if (wpa_s->driver->set_supp_port) {
403 		return wpa_s->driver->set_supp_port(wpa_s->drv_priv,
404 						    authorized);
405 	}
406 	return 0;
407 }
408 
409 static inline int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
410 				      unsigned int freq,
411 				      unsigned int wait,
412 				      const u8 *dst, const u8 *src,
413 				      const u8 *bssid,
414 				      const u8 *data, size_t data_len,
415 				      int no_cck)
416 {
417 	if (wpa_s->driver->send_action)
418 		return wpa_s->driver->send_action(wpa_s->drv_priv, freq,
419 						  wait, dst, src, bssid,
420 						  data, data_len, no_cck);
421 	return -1;
422 }
423 
424 static inline void wpa_drv_send_action_cancel_wait(struct wpa_supplicant *wpa_s)
425 {
426 	if (wpa_s->driver->send_action_cancel_wait)
427 		wpa_s->driver->send_action_cancel_wait(wpa_s->drv_priv);
428 }
429 
430 static inline int wpa_drv_set_freq(struct wpa_supplicant *wpa_s,
431 				   struct hostapd_freq_params *freq)
432 {
433 	if (wpa_s->driver->set_freq)
434 		return wpa_s->driver->set_freq(wpa_s->drv_priv, freq);
435 	return -1;
436 }
437 
438 static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s,
439 				 enum wpa_driver_if_type type,
440 				 const char *ifname, const u8 *addr,
441 				 void *bss_ctx, char *force_ifname,
442 				 u8 *if_addr, const char *bridge)
443 {
444 	if (wpa_s->driver->if_add)
445 		return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname,
446 					     addr, bss_ctx, NULL, force_ifname,
447 					     if_addr, bridge, 0, 0);
448 	return -1;
449 }
450 
451 static inline int wpa_drv_if_remove(struct wpa_supplicant *wpa_s,
452 				    enum wpa_driver_if_type type,
453 				    const char *ifname)
454 {
455 	if (wpa_s->driver->if_remove)
456 		return wpa_s->driver->if_remove(wpa_s->drv_priv, type, ifname);
457 	return -1;
458 }
459 
460 static inline int wpa_drv_remain_on_channel(struct wpa_supplicant *wpa_s,
461 					    unsigned int freq,
462 					    unsigned int duration)
463 {
464 	if (wpa_s->driver->remain_on_channel)
465 		return wpa_s->driver->remain_on_channel(wpa_s->drv_priv, freq,
466 							duration);
467 	return -1;
468 }
469 
470 static inline int wpa_drv_cancel_remain_on_channel(
471 	struct wpa_supplicant *wpa_s)
472 {
473 	if (wpa_s->driver->cancel_remain_on_channel)
474 		return wpa_s->driver->cancel_remain_on_channel(
475 			wpa_s->drv_priv);
476 	return -1;
477 }
478 
479 static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s,
480 					   int report)
481 {
482 	if (wpa_s->driver->probe_req_report)
483 		return wpa_s->driver->probe_req_report(wpa_s->drv_priv,
484 						       report);
485 	return -1;
486 }
487 
488 static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
489 {
490 	if (wpa_s->driver->deinit_ap)
491 		return wpa_s->driver->deinit_ap(wpa_s->drv_priv);
492 	return 0;
493 }
494 
495 static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s)
496 {
497 	if (wpa_s->driver->deinit_p2p_cli)
498 		return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv);
499 	return 0;
500 }
501 
502 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
503 {
504 	if (wpa_s->driver->suspend)
505 		wpa_s->driver->suspend(wpa_s->drv_priv);
506 }
507 
508 static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s)
509 {
510 	if (wpa_s->driver->resume)
511 		wpa_s->driver->resume(wpa_s->drv_priv);
512 }
513 
514 static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s,
515 					 int threshold, int hysteresis)
516 {
517 	if (wpa_s->driver->signal_monitor)
518 		return wpa_s->driver->signal_monitor(wpa_s->drv_priv,
519 						     threshold, hysteresis);
520 	return -1;
521 }
522 
523 int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s,
524 			struct wpa_signal_info *si);
525 
526 static inline int wpa_drv_channel_info(struct wpa_supplicant *wpa_s,
527 				       struct wpa_channel_info *ci)
528 {
529 	if (wpa_s->driver->channel_info)
530 		return wpa_s->driver->channel_info(wpa_s->drv_priv, ci);
531 	return -1;
532 }
533 
534 static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s,
535 				      struct hostap_sta_driver_data *sta)
536 {
537 	if (wpa_s->driver->read_sta_data)
538 		return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta,
539 						    wpa_s->bssid);
540 	return -1;
541 }
542 
543 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
544 					const struct wpabuf *beacon,
545 					const struct wpabuf *proberesp,
546 					const struct wpabuf *assocresp)
547 {
548 	if (!wpa_s->driver->set_ap_wps_ie)
549 		return -1;
550 	return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
551 					    proberesp, assocresp);
552 }
553 
554 static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
555 				  u8 *buf, size_t buf_len)
556 {
557 	if (!wpa_s->driver->get_noa)
558 		return -1;
559 	return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
560 }
561 
562 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
563 					    int legacy_ps, int opp_ps,
564 					    int ctwindow)
565 {
566 	if (!wpa_s->driver->set_p2p_powersave)
567 		return -1;
568 	return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
569 						opp_ps, ctwindow);
570 }
571 
572 static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
573 {
574 	if (!wpa_s->driver->ampdu)
575 		return -1;
576 	return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
577 }
578 
579 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
580 					 const u8 *dst, u8 action_code,
581 					 u8 dialog_token, u16 status_code,
582 					 u32 peer_capab, int initiator,
583 					 const u8 *buf, size_t len)
584 {
585 	if (wpa_s->driver->send_tdls_mgmt) {
586 		return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
587 						     action_code, dialog_token,
588 						     status_code, peer_capab,
589 						     initiator, buf, len);
590 	}
591 	return -1;
592 }
593 
594 static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
595 				    enum tdls_oper oper, const u8 *peer)
596 {
597 	if (!wpa_s->driver->tdls_oper)
598 		return -1;
599 	return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
600 }
601 
602 #ifdef ANDROID
603 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
604 				     char *cmd, char *buf, size_t buf_len)
605 {
606 	if (!wpa_s->driver->driver_cmd)
607 		return -1;
608 	return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
609 }
610 #endif /* ANDROID */
611 
612 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
613 					  const u8 *kek, size_t kek_len,
614 					  const u8 *kck, size_t kck_len,
615 					  const u8 *replay_ctr)
616 {
617 	if (!wpa_s->driver->set_rekey_info)
618 		return;
619 	wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kek_len,
620 				      kck, kck_len, replay_ctr);
621 }
622 
623 static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s,
624 					int disabled)
625 {
626 	if (!wpa_s->driver->radio_disable)
627 		return -1;
628 	return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled);
629 }
630 
631 static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
632 					 struct csa_settings *settings)
633 {
634 	if (!wpa_s->driver->switch_channel)
635 		return -1;
636 	return wpa_s->driver->switch_channel(wpa_s->drv_priv, settings);
637 }
638 
639 static inline int wpa_drv_add_ts(struct wpa_supplicant *wpa_s, u8 tsid,
640 				 const u8 *address, u8 user_priority,
641 				 u16 admitted_time)
642 {
643 	if (!wpa_s->driver->add_tx_ts)
644 		return -1;
645 	return wpa_s->driver->add_tx_ts(wpa_s->drv_priv, tsid, address,
646 					user_priority, admitted_time);
647 }
648 
649 static inline int wpa_drv_del_ts(struct wpa_supplicant *wpa_s, u8 tid,
650 				 const u8 *address)
651 {
652 	if (!wpa_s->driver->del_tx_ts)
653 		return -1;
654 	return wpa_s->driver->del_tx_ts(wpa_s->drv_priv, tid, address);
655 }
656 
657 static inline int wpa_drv_tdls_enable_channel_switch(
658 	struct wpa_supplicant *wpa_s, const u8 *addr, u8 oper_class,
659 	const struct hostapd_freq_params *freq_params)
660 {
661 	if (!wpa_s->driver->tdls_enable_channel_switch)
662 		return -1;
663 	return wpa_s->driver->tdls_enable_channel_switch(wpa_s->drv_priv, addr,
664 							 oper_class,
665 							 freq_params);
666 }
667 
668 static inline int
669 wpa_drv_tdls_disable_channel_switch(struct wpa_supplicant *wpa_s,
670 				    const u8 *addr)
671 {
672 	if (!wpa_s->driver->tdls_disable_channel_switch)
673 		return -1;
674 	return wpa_s->driver->tdls_disable_channel_switch(wpa_s->drv_priv,
675 							  addr);
676 }
677 
678 static inline int wpa_drv_wnm_oper(struct wpa_supplicant *wpa_s,
679 				   enum wnm_oper oper, const u8 *peer,
680 				   u8 *buf, u16 *buf_len)
681 {
682 	if (!wpa_s->driver->wnm_oper)
683 		return -1;
684 	return wpa_s->driver->wnm_oper(wpa_s->drv_priv, oper, peer, buf,
685 				       buf_len);
686 }
687 
688 static inline int wpa_drv_status(struct wpa_supplicant *wpa_s,
689 				 char *buf, size_t buflen)
690 {
691 	if (!wpa_s->driver->status)
692 		return -1;
693 	return wpa_s->driver->status(wpa_s->drv_priv, buf, buflen);
694 }
695 
696 static inline int wpa_drv_set_qos_map(struct wpa_supplicant *wpa_s,
697 				      const u8 *qos_map_set, u8 qos_map_set_len)
698 {
699 	if (!wpa_s->driver->set_qos_map)
700 		return -1;
701 	return wpa_s->driver->set_qos_map(wpa_s->drv_priv, qos_map_set,
702 					  qos_map_set_len);
703 }
704 
705 static inline int wpa_drv_get_wowlan(struct wpa_supplicant *wpa_s)
706 {
707 	if (!wpa_s->driver->get_wowlan)
708 		return 0;
709 	return wpa_s->driver->get_wowlan(wpa_s->drv_priv);
710 }
711 
712 static inline int wpa_drv_wowlan(struct wpa_supplicant *wpa_s,
713 				 const struct wowlan_triggers *triggers)
714 {
715 	if (!wpa_s->driver->set_wowlan)
716 		return -1;
717 	return wpa_s->driver->set_wowlan(wpa_s->drv_priv, triggers);
718 }
719 
720 static inline int wpa_drv_vendor_cmd(struct wpa_supplicant *wpa_s,
721 				     int vendor_id, int subcmd, const u8 *data,
722 				     size_t data_len,
723 				     enum nested_attr nested_attr_flag,
724 				     struct wpabuf *buf)
725 {
726 	if (!wpa_s->driver->vendor_cmd)
727 		return -1;
728 	return wpa_s->driver->vendor_cmd(wpa_s->drv_priv, vendor_id, subcmd,
729 					 data, data_len, nested_attr_flag, buf);
730 }
731 
732 static inline int wpa_drv_roaming(struct wpa_supplicant *wpa_s, int allowed,
733 				  const u8 *bssid)
734 {
735 	if (!wpa_s->driver->roaming)
736 		return -1;
737 	return wpa_s->driver->roaming(wpa_s->drv_priv, allowed, bssid);
738 }
739 
740 static inline int wpa_drv_disable_fils(struct wpa_supplicant *wpa_s,
741 				       int disable)
742 {
743 	if (!wpa_s->driver->disable_fils)
744 		return -1;
745 	return wpa_s->driver->disable_fils(wpa_s->drv_priv, disable);
746 }
747 
748 static inline int wpa_drv_set_mac_addr(struct wpa_supplicant *wpa_s,
749 				       const u8 *addr)
750 {
751 	if (!wpa_s->driver->set_mac_addr)
752 		return -1;
753 	return wpa_s->driver->set_mac_addr(wpa_s->drv_priv, addr);
754 }
755 
756 
757 #ifdef CONFIG_MACSEC
758 
759 static inline int wpa_drv_macsec_init(struct wpa_supplicant *wpa_s,
760 				      struct macsec_init_params *params)
761 {
762 	if (!wpa_s->driver->macsec_init)
763 		return -1;
764 	return wpa_s->driver->macsec_init(wpa_s->drv_priv, params);
765 }
766 
767 static inline int wpa_drv_macsec_deinit(struct wpa_supplicant *wpa_s)
768 {
769 	if (!wpa_s->driver->macsec_deinit)
770 		return -1;
771 	return wpa_s->driver->macsec_deinit(wpa_s->drv_priv);
772 }
773 
774 static inline int wpa_drv_macsec_get_capability(struct wpa_supplicant *wpa_s,
775 						enum macsec_cap *cap)
776 {
777 	if (!wpa_s->driver->macsec_get_capability)
778 		return -1;
779 	return wpa_s->driver->macsec_get_capability(wpa_s->drv_priv, cap);
780 }
781 
782 static inline int wpa_drv_enable_protect_frames(struct wpa_supplicant *wpa_s,
783 						bool enabled)
784 {
785 	if (!wpa_s->driver->enable_protect_frames)
786 		return -1;
787 	return wpa_s->driver->enable_protect_frames(wpa_s->drv_priv, enabled);
788 }
789 
790 static inline int wpa_drv_enable_encrypt(struct wpa_supplicant *wpa_s,
791 						bool enabled)
792 {
793 	if (!wpa_s->driver->enable_encrypt)
794 		return -1;
795 	return wpa_s->driver->enable_encrypt(wpa_s->drv_priv, enabled);
796 }
797 
798 static inline int wpa_drv_set_replay_protect(struct wpa_supplicant *wpa_s,
799 					     bool enabled, u32 window)
800 {
801 	if (!wpa_s->driver->set_replay_protect)
802 		return -1;
803 	return wpa_s->driver->set_replay_protect(wpa_s->drv_priv, enabled,
804 						 window);
805 }
806 
807 static inline int wpa_drv_set_current_cipher_suite(struct wpa_supplicant *wpa_s,
808 						   u64 cs)
809 {
810 	if (!wpa_s->driver->set_current_cipher_suite)
811 		return -1;
812 	return wpa_s->driver->set_current_cipher_suite(wpa_s->drv_priv, cs);
813 }
814 
815 static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
816 						 bool enabled)
817 {
818 	if (!wpa_s->driver->enable_controlled_port)
819 		return -1;
820 	return wpa_s->driver->enable_controlled_port(wpa_s->drv_priv, enabled);
821 }
822 
823 static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
824 						struct receive_sa *sa)
825 {
826 	if (!wpa_s->driver->get_receive_lowest_pn)
827 		return -1;
828 	return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, sa);
829 }
830 
831 static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
832 						struct transmit_sa *sa)
833 {
834 	if (!wpa_s->driver->get_transmit_next_pn)
835 		return -1;
836 	return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, sa);
837 }
838 
839 static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
840 						struct transmit_sa *sa)
841 {
842 	if (!wpa_s->driver->set_transmit_next_pn)
843 		return -1;
844 	return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, sa);
845 }
846 
847 static inline int wpa_drv_set_receive_lowest_pn(struct wpa_supplicant *wpa_s,
848 						struct receive_sa *sa)
849 {
850 	if (!wpa_s->driver->set_receive_lowest_pn)
851 		return -1;
852 	return wpa_s->driver->set_receive_lowest_pn(wpa_s->drv_priv, sa);
853 }
854 
855 static inline int
856 wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, struct receive_sc *sc,
857 			  unsigned int conf_offset, int validation)
858 {
859 	if (!wpa_s->driver->create_receive_sc)
860 		return -1;
861 	return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, sc,
862 						conf_offset, validation);
863 }
864 
865 static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
866 					    struct receive_sc *sc)
867 {
868 	if (!wpa_s->driver->delete_receive_sc)
869 		return -1;
870 	return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, sc);
871 }
872 
873 static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
874 					    struct receive_sa *sa)
875 {
876 	if (!wpa_s->driver->create_receive_sa)
877 		return -1;
878 	return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, sa);
879 }
880 
881 static inline int wpa_drv_delete_receive_sa(struct wpa_supplicant *wpa_s,
882 					    struct receive_sa *sa)
883 {
884 	if (!wpa_s->driver->delete_receive_sa)
885 		return -1;
886 	return wpa_s->driver->delete_receive_sa(wpa_s->drv_priv, sa);
887 }
888 
889 static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
890 					    struct receive_sa *sa)
891 {
892 	if (!wpa_s->driver->enable_receive_sa)
893 		return -1;
894 	return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, sa);
895 }
896 
897 static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
898 					     struct receive_sa *sa)
899 {
900 	if (!wpa_s->driver->disable_receive_sa)
901 		return -1;
902 	return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, sa);
903 }
904 
905 static inline int
906 wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, struct transmit_sc *sc,
907 			   unsigned int conf_offset)
908 {
909 	if (!wpa_s->driver->create_transmit_sc)
910 		return -1;
911 	return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, sc,
912 						 conf_offset);
913 }
914 
915 static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s,
916 					     struct transmit_sc *sc)
917 {
918 	if (!wpa_s->driver->delete_transmit_sc)
919 		return -1;
920 	return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, sc);
921 }
922 
923 static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s,
924 					     struct transmit_sa *sa)
925 {
926 	if (!wpa_s->driver->create_transmit_sa)
927 		return -1;
928 	return wpa_s->driver->create_transmit_sa(wpa_s->drv_priv, sa);
929 }
930 
931 static inline int wpa_drv_delete_transmit_sa(struct wpa_supplicant *wpa_s,
932 					     struct transmit_sa *sa)
933 {
934 	if (!wpa_s->driver->delete_transmit_sa)
935 		return -1;
936 	return wpa_s->driver->delete_transmit_sa(wpa_s->drv_priv, sa);
937 }
938 
939 static inline int wpa_drv_enable_transmit_sa(struct wpa_supplicant *wpa_s,
940 					     struct transmit_sa *sa)
941 {
942 	if (!wpa_s->driver->enable_transmit_sa)
943 		return -1;
944 	return wpa_s->driver->enable_transmit_sa(wpa_s->drv_priv, sa);
945 }
946 
947 static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s,
948 					      struct transmit_sa *sa)
949 {
950 	if (!wpa_s->driver->disable_transmit_sa)
951 		return -1;
952 	return wpa_s->driver->disable_transmit_sa(wpa_s->drv_priv, sa);
953 }
954 #endif /* CONFIG_MACSEC */
955 
956 static inline int wpa_drv_setband(struct wpa_supplicant *wpa_s,
957 				  u32 band_mask)
958 {
959 	if (!wpa_s->driver->set_band)
960 		return -1;
961 	return wpa_s->driver->set_band(wpa_s->drv_priv, band_mask);
962 }
963 
964 static inline int wpa_drv_get_pref_freq_list(struct wpa_supplicant *wpa_s,
965 					     enum wpa_driver_if_type if_type,
966 					     unsigned int *num,
967 					     unsigned int *freq_list)
968 {
969 #ifdef CONFIG_TESTING_OPTIONS
970 	if (wpa_s->get_pref_freq_list_override)
971 		return wpas_ctrl_iface_get_pref_freq_list_override(
972 			wpa_s, if_type, num, freq_list);
973 #endif /* CONFIG_TESTING_OPTIONS */
974 	if (!wpa_s->driver->get_pref_freq_list)
975 		return -1;
976 	return wpa_s->driver->get_pref_freq_list(wpa_s->drv_priv, if_type,
977 						 num, freq_list);
978 }
979 
980 static inline int wpa_drv_set_prob_oper_freq(struct wpa_supplicant *wpa_s,
981 					     unsigned int freq)
982 {
983 	if (!wpa_s->driver->set_prob_oper_freq)
984 		return 0;
985 	return wpa_s->driver->set_prob_oper_freq(wpa_s->drv_priv, freq);
986 }
987 
988 static inline int wpa_drv_abort_scan(struct wpa_supplicant *wpa_s,
989 				     u64 scan_cookie)
990 {
991 	if (!wpa_s->driver->abort_scan)
992 		return -1;
993 	return wpa_s->driver->abort_scan(wpa_s->drv_priv, scan_cookie);
994 }
995 
996 static inline int wpa_drv_configure_frame_filters(struct wpa_supplicant *wpa_s,
997 						  u32 filters)
998 {
999 	if (!wpa_s->driver->configure_data_frame_filters)
1000 		return -1;
1001 	return wpa_s->driver->configure_data_frame_filters(wpa_s->drv_priv,
1002 							   filters);
1003 }
1004 
1005 static inline int wpa_drv_get_ext_capa(struct wpa_supplicant *wpa_s,
1006 				       enum wpa_driver_if_type type)
1007 {
1008 	if (!wpa_s->driver->get_ext_capab)
1009 		return -1;
1010 	return wpa_s->driver->get_ext_capab(wpa_s->drv_priv, type,
1011 					    &wpa_s->extended_capa,
1012 					    &wpa_s->extended_capa_mask,
1013 					    &wpa_s->extended_capa_len);
1014 }
1015 
1016 static inline int wpa_drv_p2p_lo_start(struct wpa_supplicant *wpa_s,
1017 				       unsigned int channel,
1018 				       unsigned int period,
1019 				       unsigned int interval,
1020 				       unsigned int count,
1021 				       const u8 *device_types,
1022 				       size_t dev_types_len,
1023 				       const u8 *ies, size_t ies_len)
1024 {
1025 	if (!wpa_s->driver->p2p_lo_start)
1026 		return -1;
1027 	return wpa_s->driver->p2p_lo_start(wpa_s->drv_priv, channel, period,
1028 					   interval, count, device_types,
1029 					   dev_types_len, ies, ies_len);
1030 }
1031 
1032 static inline int wpa_drv_p2p_lo_stop(struct wpa_supplicant *wpa_s)
1033 {
1034 	if (!wpa_s->driver->p2p_lo_stop)
1035 		return -1;
1036 	return wpa_s->driver->p2p_lo_stop(wpa_s->drv_priv);
1037 }
1038 
1039 static inline int wpa_drv_set_default_scan_ies(struct wpa_supplicant *wpa_s,
1040 					       const u8 *ies, size_t len)
1041 {
1042 	if (!wpa_s->driver->set_default_scan_ies)
1043 		return -1;
1044 	return wpa_s->driver->set_default_scan_ies(wpa_s->drv_priv, ies, len);
1045 }
1046 
1047 static inline int wpa_drv_set_tdls_mode(struct wpa_supplicant *wpa_s,
1048 					int tdls_external_control)
1049 {
1050 	if (!wpa_s->driver->set_tdls_mode)
1051 		return -1;
1052 	return wpa_s->driver->set_tdls_mode(wpa_s->drv_priv,
1053 					    tdls_external_control);
1054 }
1055 
1056 static inline struct wpa_bss_candidate_info *
1057 wpa_drv_get_bss_trans_status(struct wpa_supplicant *wpa_s,
1058 			     struct wpa_bss_trans_info *params)
1059 {
1060 	if (!wpa_s->driver->get_bss_transition_status)
1061 		return NULL;
1062 	return wpa_s->driver->get_bss_transition_status(wpa_s->drv_priv,
1063 							params);
1064 }
1065 
1066 static inline int wpa_drv_ignore_assoc_disallow(struct wpa_supplicant *wpa_s,
1067 						int val)
1068 {
1069 	if (!wpa_s->driver->ignore_assoc_disallow)
1070 		return -1;
1071 	return wpa_s->driver->ignore_assoc_disallow(wpa_s->drv_priv, val);
1072 }
1073 
1074 static inline int wpa_drv_set_bssid_tmp_disallow(struct wpa_supplicant *wpa_s,
1075 						 unsigned int num_bssid,
1076 						 const u8 *bssids)
1077 {
1078 	if (!wpa_s->driver->set_bssid_tmp_disallow)
1079 		return -1;
1080 	return wpa_s->driver->set_bssid_tmp_disallow(wpa_s->drv_priv, num_bssid,
1081 						     bssids);
1082 }
1083 
1084 static inline int wpa_drv_update_connect_params(
1085 	struct wpa_supplicant *wpa_s,
1086 	struct wpa_driver_associate_params *params,
1087 	enum wpa_drv_update_connect_params_mask mask)
1088 {
1089 	if (!wpa_s->driver->update_connect_params)
1090 		return -1;
1091 	return wpa_s->driver->update_connect_params(wpa_s->drv_priv, params,
1092 						    mask);
1093 }
1094 
1095 static inline int
1096 wpa_drv_send_external_auth_status(struct wpa_supplicant *wpa_s,
1097 				  struct external_auth *params)
1098 {
1099 	if (!wpa_s->driver->send_external_auth_status)
1100 		return -1;
1101 	return wpa_s->driver->send_external_auth_status(wpa_s->drv_priv,
1102 							params);
1103 }
1104 
1105 static inline int wpa_drv_set_4addr_mode(struct wpa_supplicant *wpa_s, int val)
1106 {
1107 	if (!wpa_s->driver->set_4addr_mode)
1108 		return -1;
1109 	return wpa_s->driver->set_4addr_mode(wpa_s->drv_priv,
1110 					     wpa_s->bridge_ifname, val);
1111 }
1112 
1113 static inline int wpa_drv_dpp_listen(struct wpa_supplicant *wpa_s, bool enable)
1114 {
1115 	if (!wpa_s->driver->dpp_listen)
1116 		return 0;
1117 	return wpa_s->driver->dpp_listen(wpa_s->drv_priv, enable);
1118 }
1119 
1120 #endif /* DRIVER_I_H */
1121