• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * wpa_supplicant - Internal driver interface wrappers
3  * Copyright (c) 2003-2009, 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_scan(struct wpa_supplicant * wpa_s,struct wpa_driver_scan_params * params)68 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s,
69 			       struct wpa_driver_scan_params *params)
70 {
71 	if (wpa_s->driver->scan2)
72 		return wpa_s->driver->scan2(wpa_s->drv_priv, params);
73 	return -1;
74 }
75 
wpa_drv_sched_scan(struct wpa_supplicant * wpa_s,struct wpa_driver_scan_params * params,u32 interval)76 static inline int wpa_drv_sched_scan(struct wpa_supplicant *wpa_s,
77 				     struct wpa_driver_scan_params *params,
78 				     u32 interval)
79 {
80 	if (wpa_s->driver->sched_scan)
81 		return wpa_s->driver->sched_scan(wpa_s->drv_priv,
82 						 params, interval);
83 	return -1;
84 }
85 
wpa_drv_stop_sched_scan(struct wpa_supplicant * wpa_s)86 static inline int wpa_drv_stop_sched_scan(struct wpa_supplicant *wpa_s)
87 {
88 	if (wpa_s->driver->stop_sched_scan)
89 		return wpa_s->driver->stop_sched_scan(wpa_s->drv_priv);
90 	return -1;
91 }
92 
wpa_drv_get_scan_results2(struct wpa_supplicant * wpa_s)93 static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
94 	struct wpa_supplicant *wpa_s)
95 {
96 	if (wpa_s->driver->get_scan_results2)
97 		return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
98 	return NULL;
99 }
100 
wpa_drv_get_bssid(struct wpa_supplicant * wpa_s,u8 * bssid)101 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
102 {
103 	if (wpa_s->driver->get_bssid) {
104 		return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
105 	}
106 	return -1;
107 }
108 
wpa_drv_get_ssid(struct wpa_supplicant * wpa_s,u8 * ssid)109 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
110 {
111 	if (wpa_s->driver->get_ssid) {
112 		return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
113 	}
114 	return -1;
115 }
116 
wpa_drv_set_key(struct wpa_supplicant * wpa_s,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)117 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s,
118 				  enum wpa_alg alg, const u8 *addr,
119 				  int key_idx, int set_tx,
120 				  const u8 *seq, size_t seq_len,
121 				  const u8 *key, size_t key_len)
122 {
123 	if (alg != WPA_ALG_NONE) {
124 		if (key_idx >= 0 && key_idx <= 6)
125 			wpa_s->keys_cleared &= ~BIT(key_idx);
126 		else
127 			wpa_s->keys_cleared = 0;
128 	}
129 	if (wpa_s->driver->set_key) {
130 		return wpa_s->driver->set_key(wpa_s->ifname, wpa_s->drv_priv,
131 					      alg, addr, key_idx, set_tx,
132 					      seq, seq_len, key, key_len);
133 	}
134 	return -1;
135 }
136 
wpa_drv_sta_deauth(struct wpa_supplicant * wpa_s,const u8 * addr,int reason_code)137 static inline int wpa_drv_sta_deauth(struct wpa_supplicant *wpa_s,
138 				     const u8 *addr, int reason_code)
139 {
140 	if (wpa_s->driver->sta_deauth) {
141 		return wpa_s->driver->sta_deauth(wpa_s->drv_priv,
142 						 wpa_s->own_addr, addr,
143 						 reason_code);
144 	}
145 	return -1;
146 }
147 
wpa_drv_deauthenticate(struct wpa_supplicant * wpa_s,const u8 * addr,int reason_code)148 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
149 					 const u8 *addr, int reason_code)
150 {
151 	if (wpa_s->driver->deauthenticate) {
152 		return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
153 						     reason_code);
154 	}
155 	return -1;
156 }
157 
wpa_drv_add_pmkid(struct wpa_supplicant * wpa_s,const u8 * bssid,const u8 * pmkid)158 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
159 				    const u8 *bssid, const u8 *pmkid)
160 {
161 	if (wpa_s->driver->add_pmkid) {
162 		return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
163 	}
164 	return -1;
165 }
166 
wpa_drv_remove_pmkid(struct wpa_supplicant * wpa_s,const u8 * bssid,const u8 * pmkid)167 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
168 				       const u8 *bssid, const u8 *pmkid)
169 {
170 	if (wpa_s->driver->remove_pmkid) {
171 		return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
172 						   pmkid);
173 	}
174 	return -1;
175 }
176 
wpa_drv_flush_pmkid(struct wpa_supplicant * wpa_s)177 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
178 {
179 	if (wpa_s->driver->flush_pmkid) {
180 		return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
181 	}
182 	return -1;
183 }
184 
wpa_drv_get_capa(struct wpa_supplicant * wpa_s,struct wpa_driver_capa * capa)185 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
186 				   struct wpa_driver_capa *capa)
187 {
188 	if (wpa_s->driver->get_capa) {
189 		return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
190 	}
191 	return -1;
192 }
193 
wpa_drv_poll(struct wpa_supplicant * wpa_s)194 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
195 {
196 	if (wpa_s->driver->poll) {
197 		wpa_s->driver->poll(wpa_s->drv_priv);
198 	}
199 }
200 
wpa_drv_get_ifname(struct wpa_supplicant * wpa_s)201 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
202 {
203 	if (wpa_s->driver->get_ifname) {
204 		return wpa_s->driver->get_ifname(wpa_s->drv_priv);
205 	}
206 	return NULL;
207 }
208 
209 static inline const char *
wpa_driver_get_radio_name(struct wpa_supplicant * wpa_s)210 wpa_driver_get_radio_name(struct wpa_supplicant *wpa_s)
211 {
212 	if (wpa_s->driver->get_radio_name)
213 		return wpa_s->driver->get_radio_name(wpa_s->drv_priv);
214 	return NULL;
215 }
216 
wpa_drv_get_mac_addr(struct wpa_supplicant * wpa_s)217 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
218 {
219 	if (wpa_s->driver->get_mac_addr) {
220 		return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
221 	}
222 	return NULL;
223 }
224 
wpa_drv_send_eapol(struct wpa_supplicant * wpa_s,const u8 * dst,u16 proto,const u8 * data,size_t data_len)225 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
226 				     const u8 *dst, u16 proto,
227 				     const u8 *data, size_t data_len)
228 {
229 	if (wpa_s->driver->send_eapol)
230 		return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
231 						 data, data_len);
232 	return -1;
233 }
234 
wpa_drv_set_operstate(struct wpa_supplicant * wpa_s,int state)235 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
236 					int state)
237 {
238 	if (wpa_s->driver->set_operstate)
239 		return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
240 	return 0;
241 }
242 
wpa_drv_mlme_setprotection(struct wpa_supplicant * wpa_s,const u8 * addr,int protect_type,int key_type)243 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
244 					     const u8 *addr, int protect_type,
245 					     int key_type)
246 {
247 	if (wpa_s->driver->mlme_setprotection)
248 		return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
249 							 protect_type,
250 							 key_type);
251 	return 0;
252 }
253 
254 static inline struct hostapd_hw_modes *
wpa_drv_get_hw_feature_data(struct wpa_supplicant * wpa_s,u16 * num_modes,u16 * flags)255 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
256 			    u16 *flags)
257 {
258 	if (wpa_s->driver->get_hw_feature_data)
259 		return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
260 							  num_modes, flags);
261 	return NULL;
262 }
263 
wpa_drv_set_country(struct wpa_supplicant * wpa_s,const char * alpha2)264 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
265 				      const char *alpha2)
266 {
267 	if (wpa_s->driver->set_country)
268 		return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
269 	return 0;
270 }
271 
wpa_drv_send_mlme(struct wpa_supplicant * wpa_s,const u8 * data,size_t data_len,int noack)272 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
273 				    const u8 *data, size_t data_len, int noack)
274 {
275 	if (wpa_s->driver->send_mlme)
276 		return wpa_s->driver->send_mlme(wpa_s->drv_priv,
277 						data, data_len, noack);
278 	return -1;
279 }
280 
wpa_drv_update_ft_ies(struct wpa_supplicant * wpa_s,const u8 * md,const u8 * ies,size_t ies_len)281 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
282 					const u8 *md,
283 					const u8 *ies, size_t ies_len)
284 {
285 	if (wpa_s->driver->update_ft_ies)
286 		return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
287 						    ies, ies_len);
288 	return -1;
289 }
290 
wpa_drv_send_ft_action(struct wpa_supplicant * wpa_s,u8 action,const u8 * target_ap,const u8 * ies,size_t ies_len)291 static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
292 					 u8 action, const u8 *target_ap,
293 					 const u8 *ies, size_t ies_len)
294 {
295 	if (wpa_s->driver->send_ft_action)
296 		return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
297 						     target_ap, ies, ies_len);
298 	return -1;
299 }
300 
wpa_drv_set_ap(struct wpa_supplicant * wpa_s,struct wpa_driver_ap_params * params)301 static inline int wpa_drv_set_ap(struct wpa_supplicant *wpa_s,
302 				 struct wpa_driver_ap_params *params)
303 {
304 	if (wpa_s->driver->set_ap)
305 		return wpa_s->driver->set_ap(wpa_s->drv_priv, params);
306 	return -1;
307 }
308 
wpa_drv_sta_add(struct wpa_supplicant * wpa_s,struct hostapd_sta_add_params * params)309 static inline int wpa_drv_sta_add(struct wpa_supplicant *wpa_s,
310 				  struct hostapd_sta_add_params *params)
311 {
312 	if (wpa_s->driver->sta_add)
313 		return wpa_s->driver->sta_add(wpa_s->drv_priv, params);
314 	return -1;
315 }
316 
wpa_drv_sta_remove(struct wpa_supplicant * wpa_s,const u8 * addr)317 static inline int wpa_drv_sta_remove(struct wpa_supplicant *wpa_s,
318 				     const u8 *addr)
319 {
320 	if (wpa_s->driver->sta_remove)
321 		return wpa_s->driver->sta_remove(wpa_s->drv_priv, addr);
322 	return -1;
323 }
324 
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)325 static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s,
326 					  const u8 *addr, const u8 *data,
327 					  size_t data_len, int encrypt,
328 					  const u8 *own_addr, u32 flags)
329 {
330 	if (wpa_s->driver->hapd_send_eapol)
331 		return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr,
332 						      data, data_len, encrypt,
333 						      own_addr, flags);
334 	return -1;
335 }
336 
wpa_drv_sta_set_flags(struct wpa_supplicant * wpa_s,const u8 * addr,int total_flags,int flags_or,int flags_and)337 static inline int wpa_drv_sta_set_flags(struct wpa_supplicant *wpa_s,
338 					const u8 *addr, int total_flags,
339 					int flags_or, int flags_and)
340 {
341 	if (wpa_s->driver->sta_set_flags)
342 		return wpa_s->driver->sta_set_flags(wpa_s->drv_priv, addr,
343 						    total_flags, flags_or,
344 						    flags_and);
345 	return -1;
346 }
347 
wpa_drv_set_supp_port(struct wpa_supplicant * wpa_s,int authorized)348 static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s,
349 					int authorized)
350 {
351 	if (wpa_s->driver->set_supp_port) {
352 		return wpa_s->driver->set_supp_port(wpa_s->drv_priv,
353 						    authorized);
354 	}
355 	return 0;
356 }
357 
wpa_drv_send_action(struct wpa_supplicant * wpa_s,unsigned int freq,unsigned int wait,const u8 * dst,const u8 * src,const u8 * bssid,const u8 * data,size_t data_len,int no_cck)358 static inline int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
359 				      unsigned int freq,
360 				      unsigned int wait,
361 				      const u8 *dst, const u8 *src,
362 				      const u8 *bssid,
363 				      const u8 *data, size_t data_len,
364 				      int no_cck)
365 {
366 	if (wpa_s->driver->send_action)
367 		return wpa_s->driver->send_action(wpa_s->drv_priv, freq,
368 						  wait, dst, src, bssid,
369 						  data, data_len, no_cck);
370 	return -1;
371 }
372 
wpa_drv_send_action_cancel_wait(struct wpa_supplicant * wpa_s)373 static inline void wpa_drv_send_action_cancel_wait(struct wpa_supplicant *wpa_s)
374 {
375 	if (wpa_s->driver->send_action_cancel_wait)
376 		wpa_s->driver->send_action_cancel_wait(wpa_s->drv_priv);
377 }
378 
wpa_drv_set_freq(struct wpa_supplicant * wpa_s,struct hostapd_freq_params * freq)379 static inline int wpa_drv_set_freq(struct wpa_supplicant *wpa_s,
380 				   struct hostapd_freq_params *freq)
381 {
382 	if (wpa_s->driver->set_freq)
383 		return wpa_s->driver->set_freq(wpa_s->drv_priv, freq);
384 	return -1;
385 }
386 
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)387 static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s,
388 				 enum wpa_driver_if_type type,
389 				 const char *ifname, const u8 *addr,
390 				 void *bss_ctx, char *force_ifname,
391 				 u8 *if_addr, const char *bridge)
392 {
393 	if (wpa_s->driver->if_add)
394 		return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname,
395 					     addr, bss_ctx, NULL, force_ifname,
396 					     if_addr, bridge, 0);
397 	return -1;
398 }
399 
wpa_drv_if_remove(struct wpa_supplicant * wpa_s,enum wpa_driver_if_type type,const char * ifname)400 static inline int wpa_drv_if_remove(struct wpa_supplicant *wpa_s,
401 				    enum wpa_driver_if_type type,
402 				    const char *ifname)
403 {
404 	if (wpa_s->driver->if_remove)
405 		return wpa_s->driver->if_remove(wpa_s->drv_priv, type, ifname);
406 	return -1;
407 }
408 
wpa_drv_remain_on_channel(struct wpa_supplicant * wpa_s,unsigned int freq,unsigned int duration)409 static inline int wpa_drv_remain_on_channel(struct wpa_supplicant *wpa_s,
410 					    unsigned int freq,
411 					    unsigned int duration)
412 {
413 	if (wpa_s->driver->remain_on_channel)
414 		return wpa_s->driver->remain_on_channel(wpa_s->drv_priv, freq,
415 							duration);
416 	return -1;
417 }
418 
wpa_drv_cancel_remain_on_channel(struct wpa_supplicant * wpa_s)419 static inline int wpa_drv_cancel_remain_on_channel(
420 	struct wpa_supplicant *wpa_s)
421 {
422 	if (wpa_s->driver->cancel_remain_on_channel)
423 		return wpa_s->driver->cancel_remain_on_channel(
424 			wpa_s->drv_priv);
425 	return -1;
426 }
427 
wpa_drv_probe_req_report(struct wpa_supplicant * wpa_s,int report)428 static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s,
429 					   int report)
430 {
431 	if (wpa_s->driver->probe_req_report)
432 		return wpa_s->driver->probe_req_report(wpa_s->drv_priv,
433 						       report);
434 	return -1;
435 }
436 
wpa_drv_deinit_ap(struct wpa_supplicant * wpa_s)437 static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
438 {
439 	if (wpa_s->driver->deinit_ap)
440 		return wpa_s->driver->deinit_ap(wpa_s->drv_priv);
441 	return 0;
442 }
443 
wpa_drv_deinit_p2p_cli(struct wpa_supplicant * wpa_s)444 static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s)
445 {
446 	if (wpa_s->driver->deinit_p2p_cli)
447 		return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv);
448 	return 0;
449 }
450 
wpa_drv_suspend(struct wpa_supplicant * wpa_s)451 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
452 {
453 	if (wpa_s->driver->suspend)
454 		wpa_s->driver->suspend(wpa_s->drv_priv);
455 }
456 
wpa_drv_resume(struct wpa_supplicant * wpa_s)457 static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s)
458 {
459 	if (wpa_s->driver->resume)
460 		wpa_s->driver->resume(wpa_s->drv_priv);
461 }
462 
wpa_drv_signal_monitor(struct wpa_supplicant * wpa_s,int threshold,int hysteresis)463 static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s,
464 					 int threshold, int hysteresis)
465 {
466 	if (wpa_s->driver->signal_monitor)
467 		return wpa_s->driver->signal_monitor(wpa_s->drv_priv,
468 						     threshold, hysteresis);
469 	return -1;
470 }
471 
wpa_drv_signal_poll(struct wpa_supplicant * wpa_s,struct wpa_signal_info * si)472 static inline int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s,
473 				      struct wpa_signal_info *si)
474 {
475 	if (wpa_s->driver->signal_poll)
476 		return wpa_s->driver->signal_poll(wpa_s->drv_priv, si);
477 	return -1;
478 }
479 
wpa_drv_pktcnt_poll(struct wpa_supplicant * wpa_s,struct hostap_sta_driver_data * sta)480 static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s,
481 				      struct hostap_sta_driver_data *sta)
482 {
483 	if (wpa_s->driver->read_sta_data)
484 		return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta,
485 						    wpa_s->bssid);
486 	return -1;
487 }
488 
wpa_drv_set_ap_wps_ie(struct wpa_supplicant * wpa_s,const struct wpabuf * beacon,const struct wpabuf * proberesp,const struct wpabuf * assocresp)489 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
490 					const struct wpabuf *beacon,
491 					const struct wpabuf *proberesp,
492 					const struct wpabuf *assocresp)
493 {
494 	if (!wpa_s->driver->set_ap_wps_ie)
495 		return -1;
496 	return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
497 					    proberesp, assocresp);
498 }
499 
wpa_drv_shared_freq(struct wpa_supplicant * wpa_s)500 static inline int wpa_drv_shared_freq(struct wpa_supplicant *wpa_s)
501 {
502 	if (!wpa_s->driver->shared_freq)
503 		return -1;
504 	return wpa_s->driver->shared_freq(wpa_s->drv_priv);
505 }
506 
wpa_drv_get_noa(struct wpa_supplicant * wpa_s,u8 * buf,size_t buf_len)507 static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
508 				  u8 *buf, size_t buf_len)
509 {
510 	if (!wpa_s->driver->get_noa)
511 		return -1;
512 	return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
513 }
514 
wpa_drv_set_p2p_powersave(struct wpa_supplicant * wpa_s,int legacy_ps,int opp_ps,int ctwindow)515 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
516 					    int legacy_ps, int opp_ps,
517 					    int ctwindow)
518 {
519 	if (!wpa_s->driver->set_p2p_powersave)
520 		return -1;
521 	return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
522 						opp_ps, ctwindow);
523 }
524 
wpa_drv_ampdu(struct wpa_supplicant * wpa_s,int ampdu)525 static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
526 {
527 	if (!wpa_s->driver->ampdu)
528 		return -1;
529 	return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
530 }
531 
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)532 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
533 					 const u8 *dst, u8 action_code,
534 					 u8 dialog_token, u16 status_code,
535 					 u32 peer_capab, int initiator,
536 					 const u8 *buf, size_t len)
537 {
538 	if (wpa_s->driver->send_tdls_mgmt) {
539 		return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
540 						     action_code, dialog_token,
541 						     status_code, peer_capab,
542 						     initiator, buf, len);
543 	}
544 	return -1;
545 }
546 
wpa_drv_tdls_oper(struct wpa_supplicant * wpa_s,enum tdls_oper oper,const u8 * peer)547 static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
548 				    enum tdls_oper oper, const u8 *peer)
549 {
550 	if (!wpa_s->driver->tdls_oper)
551 		return -1;
552 	return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
553 }
554 
555 #ifdef ANDROID
wpa_drv_driver_cmd(struct wpa_supplicant * wpa_s,char * cmd,char * buf,size_t buf_len)556 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
557 				     char *cmd, char *buf, size_t buf_len)
558 {
559 	if (!wpa_s->driver->driver_cmd)
560 		return -1;
561 	return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
562 }
563 #endif /* ANDROID */
564 
wpa_drv_set_rekey_info(struct wpa_supplicant * wpa_s,const u8 * kek,const u8 * kck,const u8 * replay_ctr)565 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
566 					  const u8 *kek, const u8 *kck,
567 					  const u8 *replay_ctr)
568 {
569 	if (!wpa_s->driver->set_rekey_info)
570 		return;
571 	wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kck, replay_ctr);
572 }
573 
wpa_drv_radio_disable(struct wpa_supplicant * wpa_s,int disabled)574 static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s,
575 					int disabled)
576 {
577 	if (!wpa_s->driver->radio_disable)
578 		return -1;
579 	return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled);
580 }
581 
wpa_drv_switch_channel(struct wpa_supplicant * wpa_s,struct csa_settings * settings)582 static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
583 					 struct csa_settings *settings)
584 {
585 	if (!wpa_s->driver->switch_channel)
586 		return -1;
587 	return wpa_s->driver->switch_channel(wpa_s->drv_priv, settings);
588 }
589 
wpa_drv_wnm_oper(struct wpa_supplicant * wpa_s,enum wnm_oper oper,const u8 * peer,u8 * buf,u16 * buf_len)590 static inline int wpa_drv_wnm_oper(struct wpa_supplicant *wpa_s,
591 				   enum wnm_oper oper, const u8 *peer,
592 				   u8 *buf, u16 *buf_len)
593 {
594 	if (!wpa_s->driver->wnm_oper)
595 		return -1;
596 	return wpa_s->driver->wnm_oper(wpa_s->drv_priv, oper, peer, buf,
597 				       buf_len);
598 }
599 
wpa_drv_status(struct wpa_supplicant * wpa_s,char * buf,size_t buflen)600 static inline int wpa_drv_status(struct wpa_supplicant *wpa_s,
601 				 char *buf, size_t buflen)
602 {
603 	if (!wpa_s->driver->status)
604 		return -1;
605 	return wpa_s->driver->status(wpa_s->drv_priv, buf, buflen);
606 }
607 
wpa_drv_set_qos_map(struct wpa_supplicant * wpa_s,const u8 * qos_map_set,u8 qos_map_set_len)608 static inline int wpa_drv_set_qos_map(struct wpa_supplicant *wpa_s,
609 				      const u8 *qos_map_set, u8 qos_map_set_len)
610 {
611 	if (!wpa_s->driver->set_qos_map)
612 		return -1;
613 	return wpa_s->driver->set_qos_map(wpa_s->drv_priv, qos_map_set,
614 					  qos_map_set_len);
615 }
616 
wpa_drv_wowlan(struct wpa_supplicant * wpa_s,const struct wowlan_triggers * triggers)617 static inline int wpa_drv_wowlan(struct wpa_supplicant *wpa_s,
618 				 const struct wowlan_triggers *triggers)
619 {
620 	if (!wpa_s->driver->set_wowlan)
621 		return -1;
622 	return wpa_s->driver->set_wowlan(wpa_s->drv_priv, triggers);
623 }
624 
wpa_drv_vendor_cmd(struct wpa_supplicant * wpa_s,int vendor_id,int subcmd,const u8 * data,size_t data_len,struct wpabuf * buf)625 static inline int wpa_drv_vendor_cmd(struct wpa_supplicant *wpa_s,
626 				     int vendor_id, int subcmd, const u8 *data,
627 				     size_t data_len, struct wpabuf *buf)
628 {
629 	if (!wpa_s->driver->vendor_cmd)
630 		return -1;
631 	return wpa_s->driver->vendor_cmd(wpa_s->drv_priv, vendor_id, subcmd,
632 					 data, data_len, buf);
633 }
634 
wpa_drv_roaming(struct wpa_supplicant * wpa_s,int allowed,const u8 * bssid)635 static inline int wpa_drv_roaming(struct wpa_supplicant *wpa_s, int allowed,
636 				  const u8 *bssid)
637 {
638 	if (!wpa_s->driver->roaming)
639 		return -1;
640 	return wpa_s->driver->roaming(wpa_s->drv_priv, allowed, bssid);
641 }
642 
wpa_drv_set_mac_addr(struct wpa_supplicant * wpa_s,const u8 * addr)643 static inline int wpa_drv_set_mac_addr(struct wpa_supplicant *wpa_s,
644 				       const u8 *addr)
645 {
646 	if (!wpa_s->driver->set_mac_addr)
647 		return -1;
648 	return wpa_s->driver->set_mac_addr(wpa_s->drv_priv, addr);
649 }
650 
651 
652 #ifdef CONFIG_MACSEC
653 
wpa_drv_macsec_init(struct wpa_supplicant * wpa_s,struct macsec_init_params * params)654 static inline int wpa_drv_macsec_init(struct wpa_supplicant *wpa_s,
655 				      struct macsec_init_params *params)
656 {
657 	if (!wpa_s->driver->macsec_init)
658 		return -1;
659 	return wpa_s->driver->macsec_init(wpa_s->drv_priv, params);
660 }
661 
wpa_drv_macsec_deinit(struct wpa_supplicant * wpa_s)662 static inline int wpa_drv_macsec_deinit(struct wpa_supplicant *wpa_s)
663 {
664 	if (!wpa_s->driver->macsec_deinit)
665 		return -1;
666 	return wpa_s->driver->macsec_deinit(wpa_s->drv_priv);
667 }
668 
wpa_drv_enable_protect_frames(struct wpa_supplicant * wpa_s,Boolean enabled)669 static inline int wpa_drv_enable_protect_frames(struct wpa_supplicant *wpa_s,
670 						Boolean enabled)
671 {
672 	if (!wpa_s->driver->enable_protect_frames)
673 		return -1;
674 	return wpa_s->driver->enable_protect_frames(wpa_s->drv_priv, enabled);
675 }
676 
wpa_drv_set_replay_protect(struct wpa_supplicant * wpa_s,Boolean enabled,u32 window)677 static inline int wpa_drv_set_replay_protect(struct wpa_supplicant *wpa_s,
678 					     Boolean enabled, u32 window)
679 {
680 	if (!wpa_s->driver->set_replay_protect)
681 		return -1;
682 	return wpa_s->driver->set_replay_protect(wpa_s->drv_priv, enabled,
683 						 window);
684 }
685 
wpa_drv_set_current_cipher_suite(struct wpa_supplicant * wpa_s,const u8 * cs,size_t cs_len)686 static inline int wpa_drv_set_current_cipher_suite(struct wpa_supplicant *wpa_s,
687 						   const u8 *cs, size_t cs_len)
688 {
689 	if (!wpa_s->driver->set_current_cipher_suite)
690 		return -1;
691 	return wpa_s->driver->set_current_cipher_suite(wpa_s->drv_priv, cs,
692 						       cs_len);
693 }
694 
wpa_drv_enable_controlled_port(struct wpa_supplicant * wpa_s,Boolean enabled)695 static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
696 						 Boolean enabled)
697 {
698 	if (!wpa_s->driver->enable_controlled_port)
699 		return -1;
700 	return wpa_s->driver->enable_controlled_port(wpa_s->drv_priv, enabled);
701 }
702 
wpa_drv_get_receive_lowest_pn(struct wpa_supplicant * wpa_s,u32 channel,u8 an,u32 * lowest_pn)703 static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
704 						u32 channel, u8 an,
705 						u32 *lowest_pn)
706 {
707 	if (!wpa_s->driver->get_receive_lowest_pn)
708 		return -1;
709 	return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, channel,
710 						    an, lowest_pn);
711 }
712 
wpa_drv_get_transmit_next_pn(struct wpa_supplicant * wpa_s,u32 channel,u8 an,u32 * next_pn)713 static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
714 						u32 channel, u8 an,
715 						u32 *next_pn)
716 {
717 	if (!wpa_s->driver->get_transmit_next_pn)
718 		return -1;
719 	return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, channel,
720 						    an, next_pn);
721 }
722 
wpa_drv_set_transmit_next_pn(struct wpa_supplicant * wpa_s,u32 channel,u8 an,u32 next_pn)723 static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
724 						u32 channel, u8 an,
725 						u32 next_pn)
726 {
727 	if (!wpa_s->driver->set_transmit_next_pn)
728 		return -1;
729 	return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, channel,
730 						    an, next_pn);
731 }
732 
wpa_drv_get_available_receive_sc(struct wpa_supplicant * wpa_s,u32 * channel)733 static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s,
734 						   u32 *channel)
735 {
736 	if (!wpa_s->driver->get_available_receive_sc)
737 		return -1;
738 	return wpa_s->driver->get_available_receive_sc(wpa_s->drv_priv,
739 						       channel);
740 }
741 
742 static inline int
wpa_drv_create_receive_sc(struct wpa_supplicant * wpa_s,u32 channel,const u8 * sci_addr,u16 sci_port,unsigned int conf_offset,int validation)743 wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, u32 channel,
744 			  const u8 *sci_addr, u16 sci_port,
745 			  unsigned int conf_offset, int validation)
746 {
747 	if (!wpa_s->driver->create_receive_sc)
748 		return -1;
749 	return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, channel,
750 						sci_addr, sci_port, conf_offset,
751 						validation);
752 }
753 
wpa_drv_delete_receive_sc(struct wpa_supplicant * wpa_s,u32 channel)754 static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
755 					    u32 channel)
756 {
757 	if (!wpa_s->driver->delete_receive_sc)
758 		return -1;
759 	return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, channel);
760 }
761 
wpa_drv_create_receive_sa(struct wpa_supplicant * wpa_s,u32 channel,u8 an,u32 lowest_pn,const u8 * sak)762 static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
763 					    u32 channel, u8 an,
764 					    u32 lowest_pn, const u8 *sak)
765 {
766 	if (!wpa_s->driver->create_receive_sa)
767 		return -1;
768 	return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, channel, an,
769 						lowest_pn, sak);
770 }
771 
wpa_drv_enable_receive_sa(struct wpa_supplicant * wpa_s,u32 channel,u8 an)772 static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
773 					    u32 channel, u8 an)
774 {
775 	if (!wpa_s->driver->enable_receive_sa)
776 		return -1;
777 	return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, channel, an);
778 }
779 
wpa_drv_disable_receive_sa(struct wpa_supplicant * wpa_s,u32 channel,u8 an)780 static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
781 					     u32 channel, u8 an)
782 {
783 	if (!wpa_s->driver->disable_receive_sa)
784 		return -1;
785 	return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, channel, an);
786 }
787 
788 static inline int
wpa_drv_get_available_transmit_sc(struct wpa_supplicant * wpa_s,u32 * channel)789 wpa_drv_get_available_transmit_sc(struct wpa_supplicant *wpa_s, u32 *channel)
790 {
791 	if (!wpa_s->driver->get_available_transmit_sc)
792 		return -1;
793 	return wpa_s->driver->get_available_transmit_sc(wpa_s->drv_priv,
794 							channel);
795 }
796 
797 static inline int
wpa_drv_create_transmit_sc(struct wpa_supplicant * wpa_s,u32 channel,const u8 * sci_addr,u16 sci_port,unsigned int conf_offset)798 wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, u32 channel,
799 			   const u8 *sci_addr, u16 sci_port,
800 			   unsigned int conf_offset)
801 {
802 	if (!wpa_s->driver->create_transmit_sc)
803 		return -1;
804 	return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, channel,
805 						 sci_addr, sci_port,
806 						 conf_offset);
807 }
808 
wpa_drv_delete_transmit_sc(struct wpa_supplicant * wpa_s,u32 channel)809 static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s,
810 					     u32 channel)
811 {
812 	if (!wpa_s->driver->delete_transmit_sc)
813 		return -1;
814 	return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, channel);
815 }
816 
wpa_drv_create_transmit_sa(struct wpa_supplicant * wpa_s,u32 channel,u8 an,u32 next_pn,Boolean confidentiality,const u8 * sak)817 static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s,
818 					     u32 channel, u8 an,
819 					     u32 next_pn,
820 					     Boolean confidentiality,
821 					     const u8 *sak)
822 {
823 	if (!wpa_s->driver->create_transmit_sa)
824 		return -1;
825 	return wpa_s->driver->create_transmit_sa(wpa_s->drv_priv, channel, an,
826 						 next_pn, confidentiality, sak);
827 }
828 
wpa_drv_enable_transmit_sa(struct wpa_supplicant * wpa_s,u32 channel,u8 an)829 static inline int wpa_drv_enable_transmit_sa(struct wpa_supplicant *wpa_s,
830 					     u32 channel, u8 an)
831 {
832 	if (!wpa_s->driver->enable_transmit_sa)
833 		return -1;
834 	return wpa_s->driver->enable_transmit_sa(wpa_s->drv_priv, channel, an);
835 }
836 
wpa_drv_disable_transmit_sa(struct wpa_supplicant * wpa_s,u32 channel,u8 an)837 static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s,
838 					      u32 channel, u8 an)
839 {
840 	if (!wpa_s->driver->disable_transmit_sa)
841 		return -1;
842 	return wpa_s->driver->disable_transmit_sa(wpa_s->drv_priv, channel, an);
843 }
844 #endif /* CONFIG_MACSEC */
845 
846 #endif /* DRIVER_I_H */
847