• 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 (wpa_s->driver->set_key) {
124 		wpa_s->keys_cleared = 0;
125 		return wpa_s->driver->set_key(wpa_s->ifname, wpa_s->drv_priv,
126 					      alg, addr, key_idx, set_tx,
127 					      seq, seq_len, key, key_len);
128 	}
129 	return -1;
130 }
131 
wpa_drv_deauthenticate(struct wpa_supplicant * wpa_s,const u8 * addr,int reason_code)132 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
133 					 const u8 *addr, int reason_code)
134 {
135 	if (wpa_s->driver->deauthenticate) {
136 		return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
137 						     reason_code);
138 	}
139 	return -1;
140 }
141 
wpa_drv_disassociate(struct wpa_supplicant * wpa_s,const u8 * addr,int reason_code)142 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
143 				       const u8 *addr, int reason_code)
144 {
145 	if (wpa_s->driver->disassociate) {
146 		return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
147 						   reason_code);
148 	}
149 	return -1;
150 }
151 
wpa_drv_add_pmkid(struct wpa_supplicant * wpa_s,const u8 * bssid,const u8 * pmkid)152 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
153 				    const u8 *bssid, const u8 *pmkid)
154 {
155 	if (wpa_s->driver->add_pmkid) {
156 		return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
157 	}
158 	return -1;
159 }
160 
wpa_drv_remove_pmkid(struct wpa_supplicant * wpa_s,const u8 * bssid,const u8 * pmkid)161 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
162 				       const u8 *bssid, const u8 *pmkid)
163 {
164 	if (wpa_s->driver->remove_pmkid) {
165 		return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
166 						   pmkid);
167 	}
168 	return -1;
169 }
170 
wpa_drv_flush_pmkid(struct wpa_supplicant * wpa_s)171 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
172 {
173 	if (wpa_s->driver->flush_pmkid) {
174 		return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
175 	}
176 	return -1;
177 }
178 
wpa_drv_get_capa(struct wpa_supplicant * wpa_s,struct wpa_driver_capa * capa)179 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
180 				   struct wpa_driver_capa *capa)
181 {
182 	if (wpa_s->driver->get_capa) {
183 		return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
184 	}
185 	return -1;
186 }
187 
wpa_drv_poll(struct wpa_supplicant * wpa_s)188 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
189 {
190 	if (wpa_s->driver->poll) {
191 		wpa_s->driver->poll(wpa_s->drv_priv);
192 	}
193 }
194 
wpa_drv_get_ifname(struct wpa_supplicant * wpa_s)195 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
196 {
197 	if (wpa_s->driver->get_ifname) {
198 		return wpa_s->driver->get_ifname(wpa_s->drv_priv);
199 	}
200 	return NULL;
201 }
202 
wpa_drv_get_mac_addr(struct wpa_supplicant * wpa_s)203 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
204 {
205 	if (wpa_s->driver->get_mac_addr) {
206 		return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
207 	}
208 	return NULL;
209 }
210 
wpa_drv_send_eapol(struct wpa_supplicant * wpa_s,const u8 * dst,u16 proto,const u8 * data,size_t data_len)211 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
212 				     const u8 *dst, u16 proto,
213 				     const u8 *data, size_t data_len)
214 {
215 	if (wpa_s->driver->send_eapol)
216 		return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
217 						 data, data_len);
218 	return -1;
219 }
220 
wpa_drv_set_operstate(struct wpa_supplicant * wpa_s,int state)221 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
222 					int state)
223 {
224 	if (wpa_s->driver->set_operstate)
225 		return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
226 	return 0;
227 }
228 
wpa_drv_mlme_setprotection(struct wpa_supplicant * wpa_s,const u8 * addr,int protect_type,int key_type)229 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
230 					     const u8 *addr, int protect_type,
231 					     int key_type)
232 {
233 	if (wpa_s->driver->mlme_setprotection)
234 		return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
235 							 protect_type,
236 							 key_type);
237 	return 0;
238 }
239 
240 static inline struct hostapd_hw_modes *
wpa_drv_get_hw_feature_data(struct wpa_supplicant * wpa_s,u16 * num_modes,u16 * flags)241 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
242 			    u16 *flags)
243 {
244 	if (wpa_s->driver->get_hw_feature_data)
245 		return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
246 							  num_modes, flags);
247 	return NULL;
248 }
249 
wpa_drv_set_country(struct wpa_supplicant * wpa_s,const char * alpha2)250 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
251 				      const char *alpha2)
252 {
253 	if (wpa_s->driver->set_country)
254 		return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
255 	return 0;
256 }
257 
wpa_drv_send_mlme(struct wpa_supplicant * wpa_s,const u8 * data,size_t data_len,int noack)258 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
259 				    const u8 *data, size_t data_len, int noack)
260 {
261 	if (wpa_s->driver->send_mlme)
262 		return wpa_s->driver->send_mlme(wpa_s->drv_priv,
263 						data, data_len, noack);
264 	return -1;
265 }
266 
wpa_drv_update_ft_ies(struct wpa_supplicant * wpa_s,const u8 * md,const u8 * ies,size_t ies_len)267 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
268 					const u8 *md,
269 					const u8 *ies, size_t ies_len)
270 {
271 	if (wpa_s->driver->update_ft_ies)
272 		return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
273 						    ies, ies_len);
274 	return -1;
275 }
276 
wpa_drv_send_ft_action(struct wpa_supplicant * wpa_s,u8 action,const u8 * target_ap,const u8 * ies,size_t ies_len)277 static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
278 					 u8 action, const u8 *target_ap,
279 					 const u8 *ies, size_t ies_len)
280 {
281 	if (wpa_s->driver->send_ft_action)
282 		return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
283 						     target_ap, ies, ies_len);
284 	return -1;
285 }
286 
wpa_drv_set_ap(struct wpa_supplicant * wpa_s,struct wpa_driver_ap_params * params)287 static inline int wpa_drv_set_ap(struct wpa_supplicant *wpa_s,
288 				 struct wpa_driver_ap_params *params)
289 {
290 	if (wpa_s->driver->set_ap)
291 		return wpa_s->driver->set_ap(wpa_s->drv_priv, params);
292 	return -1;
293 }
294 
wpa_drv_sta_add(struct wpa_supplicant * wpa_s,struct hostapd_sta_add_params * params)295 static inline int wpa_drv_sta_add(struct wpa_supplicant *wpa_s,
296 				  struct hostapd_sta_add_params *params)
297 {
298 	if (wpa_s->driver->sta_add)
299 		return wpa_s->driver->sta_add(wpa_s->drv_priv, params);
300 	return -1;
301 }
302 
wpa_drv_sta_remove(struct wpa_supplicant * wpa_s,const u8 * addr)303 static inline int wpa_drv_sta_remove(struct wpa_supplicant *wpa_s,
304 				     const u8 *addr)
305 {
306 	if (wpa_s->driver->sta_remove)
307 		return wpa_s->driver->sta_remove(wpa_s->drv_priv, addr);
308 	return -1;
309 }
310 
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)311 static inline int wpa_drv_hapd_send_eapol(struct wpa_supplicant *wpa_s,
312 					  const u8 *addr, const u8 *data,
313 					  size_t data_len, int encrypt,
314 					  const u8 *own_addr, u32 flags)
315 {
316 	if (wpa_s->driver->hapd_send_eapol)
317 		return wpa_s->driver->hapd_send_eapol(wpa_s->drv_priv, addr,
318 						      data, data_len, encrypt,
319 						      own_addr, flags);
320 	return -1;
321 }
322 
wpa_drv_sta_set_flags(struct wpa_supplicant * wpa_s,const u8 * addr,int total_flags,int flags_or,int flags_and)323 static inline int wpa_drv_sta_set_flags(struct wpa_supplicant *wpa_s,
324 					const u8 *addr, int total_flags,
325 					int flags_or, int flags_and)
326 {
327 	if (wpa_s->driver->sta_set_flags)
328 		return wpa_s->driver->sta_set_flags(wpa_s->drv_priv, addr,
329 						    total_flags, flags_or,
330 						    flags_and);
331 	return -1;
332 }
333 
wpa_drv_set_supp_port(struct wpa_supplicant * wpa_s,int authorized)334 static inline int wpa_drv_set_supp_port(struct wpa_supplicant *wpa_s,
335 					int authorized)
336 {
337 	if (wpa_s->driver->set_supp_port) {
338 		return wpa_s->driver->set_supp_port(wpa_s->drv_priv,
339 						    authorized);
340 	}
341 	return 0;
342 }
343 
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)344 static inline int wpa_drv_send_action(struct wpa_supplicant *wpa_s,
345 				      unsigned int freq,
346 				      unsigned int wait,
347 				      const u8 *dst, const u8 *src,
348 				      const u8 *bssid,
349 				      const u8 *data, size_t data_len,
350 				      int no_cck)
351 {
352 	if (wpa_s->driver->send_action)
353 		return wpa_s->driver->send_action(wpa_s->drv_priv, freq,
354 						  wait, dst, src, bssid,
355 						  data, data_len, no_cck);
356 	return -1;
357 }
358 
wpa_drv_send_action_cancel_wait(struct wpa_supplicant * wpa_s)359 static inline void wpa_drv_send_action_cancel_wait(struct wpa_supplicant *wpa_s)
360 {
361 	if (wpa_s->driver->send_action_cancel_wait)
362 		wpa_s->driver->send_action_cancel_wait(wpa_s->drv_priv);
363 }
364 
wpa_drv_set_freq(struct wpa_supplicant * wpa_s,struct hostapd_freq_params * freq)365 static inline int wpa_drv_set_freq(struct wpa_supplicant *wpa_s,
366 				   struct hostapd_freq_params *freq)
367 {
368 	if (wpa_s->driver->set_freq)
369 		return wpa_s->driver->set_freq(wpa_s->drv_priv, freq);
370 	return -1;
371 }
372 
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)373 static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s,
374 				 enum wpa_driver_if_type type,
375 				 const char *ifname, const u8 *addr,
376 				 void *bss_ctx, char *force_ifname,
377 				 u8 *if_addr, const char *bridge)
378 {
379 	if (wpa_s->driver->if_add)
380 		return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname,
381 					     addr, bss_ctx, NULL, force_ifname,
382 					     if_addr, bridge);
383 	return -1;
384 }
385 
wpa_drv_if_remove(struct wpa_supplicant * wpa_s,enum wpa_driver_if_type type,const char * ifname)386 static inline int wpa_drv_if_remove(struct wpa_supplicant *wpa_s,
387 				    enum wpa_driver_if_type type,
388 				    const char *ifname)
389 {
390 	if (wpa_s->driver->if_remove)
391 		return wpa_s->driver->if_remove(wpa_s->drv_priv, type, ifname);
392 	return -1;
393 }
394 
wpa_drv_remain_on_channel(struct wpa_supplicant * wpa_s,unsigned int freq,unsigned int duration)395 static inline int wpa_drv_remain_on_channel(struct wpa_supplicant *wpa_s,
396 					    unsigned int freq,
397 					    unsigned int duration)
398 {
399 	if (wpa_s->driver->remain_on_channel)
400 		return wpa_s->driver->remain_on_channel(wpa_s->drv_priv, freq,
401 							duration);
402 	return -1;
403 }
404 
wpa_drv_cancel_remain_on_channel(struct wpa_supplicant * wpa_s)405 static inline int wpa_drv_cancel_remain_on_channel(
406 	struct wpa_supplicant *wpa_s)
407 {
408 	if (wpa_s->driver->cancel_remain_on_channel)
409 		return wpa_s->driver->cancel_remain_on_channel(
410 			wpa_s->drv_priv);
411 	return -1;
412 }
413 
wpa_drv_probe_req_report(struct wpa_supplicant * wpa_s,int report)414 static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s,
415 					   int report)
416 {
417 	if (wpa_s->driver->probe_req_report)
418 		return wpa_s->driver->probe_req_report(wpa_s->drv_priv,
419 						       report);
420 	return -1;
421 }
422 
wpa_drv_deinit_ap(struct wpa_supplicant * wpa_s)423 static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
424 {
425 	if (wpa_s->driver->deinit_ap)
426 		return wpa_s->driver->deinit_ap(wpa_s->drv_priv);
427 	return 0;
428 }
429 
wpa_drv_deinit_p2p_cli(struct wpa_supplicant * wpa_s)430 static inline int wpa_drv_deinit_p2p_cli(struct wpa_supplicant *wpa_s)
431 {
432 	if (wpa_s->driver->deinit_p2p_cli)
433 		return wpa_s->driver->deinit_p2p_cli(wpa_s->drv_priv);
434 	return 0;
435 }
436 
wpa_drv_suspend(struct wpa_supplicant * wpa_s)437 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
438 {
439 	if (wpa_s->driver->suspend)
440 		wpa_s->driver->suspend(wpa_s->drv_priv);
441 }
442 
wpa_drv_resume(struct wpa_supplicant * wpa_s)443 static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s)
444 {
445 	if (wpa_s->driver->resume)
446 		wpa_s->driver->resume(wpa_s->drv_priv);
447 }
448 
wpa_drv_signal_monitor(struct wpa_supplicant * wpa_s,int threshold,int hysteresis)449 static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s,
450 					 int threshold, int hysteresis)
451 {
452 	if (wpa_s->driver->signal_monitor)
453 		return wpa_s->driver->signal_monitor(wpa_s->drv_priv,
454 						     threshold, hysteresis);
455 	return -1;
456 }
457 
wpa_drv_signal_poll(struct wpa_supplicant * wpa_s,struct wpa_signal_info * si)458 static inline int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s,
459 				      struct wpa_signal_info *si)
460 {
461 	if (wpa_s->driver->signal_poll)
462 		return wpa_s->driver->signal_poll(wpa_s->drv_priv, si);
463 	return -1;
464 }
465 
wpa_drv_pktcnt_poll(struct wpa_supplicant * wpa_s,struct hostap_sta_driver_data * sta)466 static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s,
467 				      struct hostap_sta_driver_data *sta)
468 {
469 	if (wpa_s->driver->read_sta_data)
470 		return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta,
471 						    wpa_s->bssid);
472 	return -1;
473 }
474 
wpa_drv_set_ap_wps_ie(struct wpa_supplicant * wpa_s,const struct wpabuf * beacon,const struct wpabuf * proberesp,const struct wpabuf * assocresp)475 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
476 					const struct wpabuf *beacon,
477 					const struct wpabuf *proberesp,
478 					const struct wpabuf *assocresp)
479 {
480 	if (!wpa_s->driver->set_ap_wps_ie)
481 		return -1;
482 	return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
483 					    proberesp, assocresp);
484 }
485 
wpa_drv_shared_freq(struct wpa_supplicant * wpa_s)486 static inline int wpa_drv_shared_freq(struct wpa_supplicant *wpa_s)
487 {
488 	if (!wpa_s->driver->shared_freq)
489 		return -1;
490 	return wpa_s->driver->shared_freq(wpa_s->drv_priv);
491 }
492 
wpa_drv_get_noa(struct wpa_supplicant * wpa_s,u8 * buf,size_t buf_len)493 static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
494 				  u8 *buf, size_t buf_len)
495 {
496 	if (!wpa_s->driver->get_noa)
497 		return -1;
498 	return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
499 }
500 
wpa_drv_set_p2p_powersave(struct wpa_supplicant * wpa_s,int legacy_ps,int opp_ps,int ctwindow)501 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
502 					    int legacy_ps, int opp_ps,
503 					    int ctwindow)
504 {
505 	if (!wpa_s->driver->set_p2p_powersave)
506 		return -1;
507 	return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
508 						opp_ps, ctwindow);
509 }
510 
wpa_drv_ampdu(struct wpa_supplicant * wpa_s,int ampdu)511 static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
512 {
513 	if (!wpa_s->driver->ampdu)
514 		return -1;
515 	return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
516 }
517 
wpa_drv_p2p_find(struct wpa_supplicant * wpa_s,unsigned int timeout,int type)518 static inline int wpa_drv_p2p_find(struct wpa_supplicant *wpa_s,
519 				   unsigned int timeout, int type)
520 {
521 	if (!wpa_s->driver->p2p_find)
522 		return -1;
523 	return wpa_s->driver->p2p_find(wpa_s->drv_priv, timeout, type);
524 }
525 
wpa_drv_p2p_stop_find(struct wpa_supplicant * wpa_s)526 static inline int wpa_drv_p2p_stop_find(struct wpa_supplicant *wpa_s)
527 {
528 	if (!wpa_s->driver->p2p_stop_find)
529 		return -1;
530 	return wpa_s->driver->p2p_stop_find(wpa_s->drv_priv);
531 }
532 
wpa_drv_p2p_listen(struct wpa_supplicant * wpa_s,unsigned int timeout)533 static inline int wpa_drv_p2p_listen(struct wpa_supplicant *wpa_s,
534 				     unsigned int timeout)
535 {
536 	if (!wpa_s->driver->p2p_listen)
537 		return -1;
538 	return wpa_s->driver->p2p_listen(wpa_s->drv_priv, timeout);
539 }
540 
wpa_drv_p2p_connect(struct wpa_supplicant * wpa_s,const u8 * peer_addr,int wps_method,int go_intent,const u8 * own_interface_addr,unsigned int force_freq,int persistent_group)541 static inline int wpa_drv_p2p_connect(struct wpa_supplicant *wpa_s,
542 				      const u8 *peer_addr, int wps_method,
543 				      int go_intent,
544 				      const u8 *own_interface_addr,
545 				      unsigned int force_freq,
546 				      int persistent_group)
547 {
548 	if (!wpa_s->driver->p2p_connect)
549 		return -1;
550 	return wpa_s->driver->p2p_connect(wpa_s->drv_priv, peer_addr,
551 					  wps_method, go_intent,
552 					  own_interface_addr, force_freq,
553 					  persistent_group);
554 }
555 
wpa_drv_wps_success_cb(struct wpa_supplicant * wpa_s,const u8 * peer_addr)556 static inline int wpa_drv_wps_success_cb(struct wpa_supplicant *wpa_s,
557 					 const u8 *peer_addr)
558 {
559 	if (!wpa_s->driver->wps_success_cb)
560 		return -1;
561 	return wpa_s->driver->wps_success_cb(wpa_s->drv_priv, peer_addr);
562 }
563 
564 static inline int
wpa_drv_p2p_group_formation_failed(struct wpa_supplicant * wpa_s)565 wpa_drv_p2p_group_formation_failed(struct wpa_supplicant *wpa_s)
566 {
567 	if (!wpa_s->driver->p2p_group_formation_failed)
568 		return -1;
569 	return wpa_s->driver->p2p_group_formation_failed(wpa_s->drv_priv);
570 }
571 
wpa_drv_p2p_set_params(struct wpa_supplicant * wpa_s,const struct p2p_params * params)572 static inline int wpa_drv_p2p_set_params(struct wpa_supplicant *wpa_s,
573 					 const struct p2p_params *params)
574 {
575 	if (!wpa_s->driver->p2p_set_params)
576 		return -1;
577 	return wpa_s->driver->p2p_set_params(wpa_s->drv_priv, params);
578 }
579 
wpa_drv_p2p_prov_disc_req(struct wpa_supplicant * wpa_s,const u8 * peer_addr,u16 config_methods,int join)580 static inline int wpa_drv_p2p_prov_disc_req(struct wpa_supplicant *wpa_s,
581 					    const u8 *peer_addr,
582 					    u16 config_methods, int join)
583 {
584 	if (!wpa_s->driver->p2p_prov_disc_req)
585 		return -1;
586 	return wpa_s->driver->p2p_prov_disc_req(wpa_s->drv_priv, peer_addr,
587 						config_methods, join);
588 }
589 
wpa_drv_p2p_sd_request(struct wpa_supplicant * wpa_s,const u8 * dst,const struct wpabuf * tlvs)590 static inline u64 wpa_drv_p2p_sd_request(struct wpa_supplicant *wpa_s,
591 					 const u8 *dst,
592 					 const struct wpabuf *tlvs)
593 {
594 	if (!wpa_s->driver->p2p_sd_request)
595 		return 0;
596 	return wpa_s->driver->p2p_sd_request(wpa_s->drv_priv, dst, tlvs);
597 }
598 
wpa_drv_p2p_sd_cancel_request(struct wpa_supplicant * wpa_s,u64 req)599 static inline int wpa_drv_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s,
600 						u64 req)
601 {
602 	if (!wpa_s->driver->p2p_sd_cancel_request)
603 		return -1;
604 	return wpa_s->driver->p2p_sd_cancel_request(wpa_s->drv_priv, req);
605 }
606 
wpa_drv_p2p_sd_response(struct wpa_supplicant * wpa_s,int freq,const u8 * dst,u8 dialog_token,const struct wpabuf * resp_tlvs)607 static inline int wpa_drv_p2p_sd_response(struct wpa_supplicant *wpa_s,
608 					  int freq, const u8 *dst,
609 					  u8 dialog_token,
610 					  const struct wpabuf *resp_tlvs)
611 {
612 	if (!wpa_s->driver->p2p_sd_response)
613 		return -1;
614 	return wpa_s->driver->p2p_sd_response(wpa_s->drv_priv, freq, dst,
615 					      dialog_token, resp_tlvs);
616 }
617 
wpa_drv_p2p_service_update(struct wpa_supplicant * wpa_s)618 static inline int wpa_drv_p2p_service_update(struct wpa_supplicant *wpa_s)
619 {
620 	if (!wpa_s->driver->p2p_service_update)
621 		return -1;
622 	return wpa_s->driver->p2p_service_update(wpa_s->drv_priv);
623 }
624 
wpa_drv_p2p_reject(struct wpa_supplicant * wpa_s,const u8 * addr)625 static inline int wpa_drv_p2p_reject(struct wpa_supplicant *wpa_s,
626 				     const u8 *addr)
627 {
628 	if (!wpa_s->driver->p2p_reject)
629 		return -1;
630 	return wpa_s->driver->p2p_reject(wpa_s->drv_priv, addr);
631 }
632 
wpa_drv_p2p_invite(struct wpa_supplicant * wpa_s,const u8 * peer,int role,const u8 * bssid,const u8 * ssid,size_t ssid_len,const u8 * go_dev_addr,int persistent_group)633 static inline int wpa_drv_p2p_invite(struct wpa_supplicant *wpa_s,
634 				     const u8 *peer, int role, const u8 *bssid,
635 				     const u8 *ssid, size_t ssid_len,
636 				     const u8 *go_dev_addr,
637 				     int persistent_group)
638 {
639 	if (!wpa_s->driver->p2p_invite)
640 		return -1;
641 	return wpa_s->driver->p2p_invite(wpa_s->drv_priv, peer, role, bssid,
642 					 ssid, ssid_len, go_dev_addr,
643 					 persistent_group);
644 }
645 
wpa_drv_send_tdls_mgmt(struct wpa_supplicant * wpa_s,const u8 * dst,u8 action_code,u8 dialog_token,u16 status_code,const u8 * buf,size_t len)646 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
647 					 const u8 *dst, u8 action_code,
648 					 u8 dialog_token, u16 status_code,
649 					 const u8 *buf, size_t len)
650 {
651 	if (wpa_s->driver->send_tdls_mgmt) {
652 		return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
653 						     action_code, dialog_token,
654 						     status_code, buf, len);
655 	}
656 	return -1;
657 }
658 
wpa_drv_tdls_oper(struct wpa_supplicant * wpa_s,enum tdls_oper oper,const u8 * peer)659 static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
660 				    enum tdls_oper oper, const u8 *peer)
661 {
662 	if (!wpa_s->driver->tdls_oper)
663 		return -1;
664 	return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
665 }
666 
667 #ifdef ANDROID
wpa_drv_driver_cmd(struct wpa_supplicant * wpa_s,char * cmd,char * buf,size_t buf_len)668 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
669 				     char *cmd, char *buf, size_t buf_len)
670 {
671 	if (!wpa_s->driver->driver_cmd)
672 		return -1;
673 	return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
674 }
675 #endif
676 
wpa_drv_set_rekey_info(struct wpa_supplicant * wpa_s,const u8 * kek,const u8 * kck,const u8 * replay_ctr)677 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
678 					  const u8 *kek, const u8 *kck,
679 					  const u8 *replay_ctr)
680 {
681 	if (!wpa_s->driver->set_rekey_info)
682 		return;
683 	wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kck, replay_ctr);
684 }
685 
wpa_drv_radio_disable(struct wpa_supplicant * wpa_s,int disabled)686 static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s,
687 					int disabled)
688 {
689 	if (!wpa_s->driver->radio_disable)
690 		return -1;
691 	return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled);
692 }
693 
wpa_drv_switch_channel(struct wpa_supplicant * wpa_s,unsigned int freq)694 static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
695 					 unsigned int freq)
696 {
697 	if (!wpa_s->driver->switch_channel)
698 		return -1;
699 	return wpa_s->driver->switch_channel(wpa_s->drv_priv, freq);
700 }
701 
wpa_drv_wnm_oper(struct wpa_supplicant * wpa_s,enum wnm_oper oper,const u8 * peer,u8 * buf,u16 * buf_len)702 static inline int wpa_drv_wnm_oper(struct wpa_supplicant *wpa_s,
703 				   enum wnm_oper oper, const u8 *peer,
704 				   u8 *buf, u16 *buf_len)
705 {
706 	if (!wpa_s->driver->wnm_oper)
707 		return -1;
708 	return wpa_s->driver->wnm_oper(wpa_s->drv_priv, oper, peer, buf,
709 				       buf_len);
710 }
711 
712 #endif /* DRIVER_I_H */
713