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