• 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_suspend(struct wpa_supplicant * wpa_s)430 static inline void wpa_drv_suspend(struct wpa_supplicant *wpa_s)
431 {
432 	if (wpa_s->driver->suspend)
433 		wpa_s->driver->suspend(wpa_s->drv_priv);
434 }
435 
wpa_drv_resume(struct wpa_supplicant * wpa_s)436 static inline void wpa_drv_resume(struct wpa_supplicant *wpa_s)
437 {
438 	if (wpa_s->driver->resume)
439 		wpa_s->driver->resume(wpa_s->drv_priv);
440 }
441 
wpa_drv_signal_monitor(struct wpa_supplicant * wpa_s,int threshold,int hysteresis)442 static inline int wpa_drv_signal_monitor(struct wpa_supplicant *wpa_s,
443 					 int threshold, int hysteresis)
444 {
445 	if (wpa_s->driver->signal_monitor)
446 		return wpa_s->driver->signal_monitor(wpa_s->drv_priv,
447 						     threshold, hysteresis);
448 	return -1;
449 }
450 
wpa_drv_signal_poll(struct wpa_supplicant * wpa_s,struct wpa_signal_info * si)451 static inline int wpa_drv_signal_poll(struct wpa_supplicant *wpa_s,
452 				      struct wpa_signal_info *si)
453 {
454 	if (wpa_s->driver->signal_poll)
455 		return wpa_s->driver->signal_poll(wpa_s->drv_priv, si);
456 	return -1;
457 }
458 
wpa_drv_set_ap_wps_ie(struct wpa_supplicant * wpa_s,const struct wpabuf * beacon,const struct wpabuf * proberesp,const struct wpabuf * assocresp)459 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
460 					const struct wpabuf *beacon,
461 					const struct wpabuf *proberesp,
462 					const struct wpabuf *assocresp)
463 {
464 	if (!wpa_s->driver->set_ap_wps_ie)
465 		return -1;
466 	return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
467 					    proberesp, assocresp);
468 }
469 
wpa_drv_shared_freq(struct wpa_supplicant * wpa_s)470 static inline int wpa_drv_shared_freq(struct wpa_supplicant *wpa_s)
471 {
472 	if (!wpa_s->driver->shared_freq)
473 		return -1;
474 	return wpa_s->driver->shared_freq(wpa_s->drv_priv);
475 }
476 
wpa_drv_get_noa(struct wpa_supplicant * wpa_s,u8 * buf,size_t buf_len)477 static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
478 				  u8 *buf, size_t buf_len)
479 {
480 	if (!wpa_s->driver->get_noa)
481 		return -1;
482 	return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
483 }
484 
wpa_drv_set_p2p_powersave(struct wpa_supplicant * wpa_s,int legacy_ps,int opp_ps,int ctwindow)485 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
486 					    int legacy_ps, int opp_ps,
487 					    int ctwindow)
488 {
489 	if (!wpa_s->driver->set_p2p_powersave)
490 		return -1;
491 	return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
492 						opp_ps, ctwindow);
493 }
494 
wpa_drv_ampdu(struct wpa_supplicant * wpa_s,int ampdu)495 static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
496 {
497 	if (!wpa_s->driver->ampdu)
498 		return -1;
499 	return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
500 }
501 
wpa_drv_p2p_find(struct wpa_supplicant * wpa_s,unsigned int timeout,int type)502 static inline int wpa_drv_p2p_find(struct wpa_supplicant *wpa_s,
503 				   unsigned int timeout, int type)
504 {
505 	if (!wpa_s->driver->p2p_find)
506 		return -1;
507 	return wpa_s->driver->p2p_find(wpa_s->drv_priv, timeout, type);
508 }
509 
wpa_drv_p2p_stop_find(struct wpa_supplicant * wpa_s)510 static inline int wpa_drv_p2p_stop_find(struct wpa_supplicant *wpa_s)
511 {
512 	if (!wpa_s->driver->p2p_stop_find)
513 		return -1;
514 	return wpa_s->driver->p2p_stop_find(wpa_s->drv_priv);
515 }
516 
wpa_drv_p2p_listen(struct wpa_supplicant * wpa_s,unsigned int timeout)517 static inline int wpa_drv_p2p_listen(struct wpa_supplicant *wpa_s,
518 				     unsigned int timeout)
519 {
520 	if (!wpa_s->driver->p2p_listen)
521 		return -1;
522 	return wpa_s->driver->p2p_listen(wpa_s->drv_priv, timeout);
523 }
524 
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)525 static inline int wpa_drv_p2p_connect(struct wpa_supplicant *wpa_s,
526 				      const u8 *peer_addr, int wps_method,
527 				      int go_intent,
528 				      const u8 *own_interface_addr,
529 				      unsigned int force_freq,
530 				      int persistent_group)
531 {
532 	if (!wpa_s->driver->p2p_connect)
533 		return -1;
534 	return wpa_s->driver->p2p_connect(wpa_s->drv_priv, peer_addr,
535 					  wps_method, go_intent,
536 					  own_interface_addr, force_freq,
537 					  persistent_group);
538 }
539 
wpa_drv_wps_success_cb(struct wpa_supplicant * wpa_s,const u8 * peer_addr)540 static inline int wpa_drv_wps_success_cb(struct wpa_supplicant *wpa_s,
541 					 const u8 *peer_addr)
542 {
543 	if (!wpa_s->driver->wps_success_cb)
544 		return -1;
545 	return wpa_s->driver->wps_success_cb(wpa_s->drv_priv, peer_addr);
546 }
547 
548 static inline int
wpa_drv_p2p_group_formation_failed(struct wpa_supplicant * wpa_s)549 wpa_drv_p2p_group_formation_failed(struct wpa_supplicant *wpa_s)
550 {
551 	if (!wpa_s->driver->p2p_group_formation_failed)
552 		return -1;
553 	return wpa_s->driver->p2p_group_formation_failed(wpa_s->drv_priv);
554 }
555 
wpa_drv_p2p_set_params(struct wpa_supplicant * wpa_s,const struct p2p_params * params)556 static inline int wpa_drv_p2p_set_params(struct wpa_supplicant *wpa_s,
557 					 const struct p2p_params *params)
558 {
559 	if (!wpa_s->driver->p2p_set_params)
560 		return -1;
561 	return wpa_s->driver->p2p_set_params(wpa_s->drv_priv, params);
562 }
563 
wpa_drv_p2p_prov_disc_req(struct wpa_supplicant * wpa_s,const u8 * peer_addr,u16 config_methods,int join)564 static inline int wpa_drv_p2p_prov_disc_req(struct wpa_supplicant *wpa_s,
565 					    const u8 *peer_addr,
566 					    u16 config_methods, int join)
567 {
568 	if (!wpa_s->driver->p2p_prov_disc_req)
569 		return -1;
570 	return wpa_s->driver->p2p_prov_disc_req(wpa_s->drv_priv, peer_addr,
571 						config_methods, join);
572 }
573 
wpa_drv_p2p_sd_request(struct wpa_supplicant * wpa_s,const u8 * dst,const struct wpabuf * tlvs)574 static inline u64 wpa_drv_p2p_sd_request(struct wpa_supplicant *wpa_s,
575 					 const u8 *dst,
576 					 const struct wpabuf *tlvs)
577 {
578 	if (!wpa_s->driver->p2p_sd_request)
579 		return 0;
580 	return wpa_s->driver->p2p_sd_request(wpa_s->drv_priv, dst, tlvs);
581 }
582 
wpa_drv_p2p_sd_cancel_request(struct wpa_supplicant * wpa_s,u64 req)583 static inline int wpa_drv_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s,
584 						u64 req)
585 {
586 	if (!wpa_s->driver->p2p_sd_cancel_request)
587 		return -1;
588 	return wpa_s->driver->p2p_sd_cancel_request(wpa_s->drv_priv, req);
589 }
590 
wpa_drv_p2p_sd_response(struct wpa_supplicant * wpa_s,int freq,const u8 * dst,u8 dialog_token,const struct wpabuf * resp_tlvs)591 static inline int wpa_drv_p2p_sd_response(struct wpa_supplicant *wpa_s,
592 					  int freq, const u8 *dst,
593 					  u8 dialog_token,
594 					  const struct wpabuf *resp_tlvs)
595 {
596 	if (!wpa_s->driver->p2p_sd_response)
597 		return -1;
598 	return wpa_s->driver->p2p_sd_response(wpa_s->drv_priv, freq, dst,
599 					      dialog_token, resp_tlvs);
600 }
601 
wpa_drv_p2p_service_update(struct wpa_supplicant * wpa_s)602 static inline int wpa_drv_p2p_service_update(struct wpa_supplicant *wpa_s)
603 {
604 	if (!wpa_s->driver->p2p_service_update)
605 		return -1;
606 	return wpa_s->driver->p2p_service_update(wpa_s->drv_priv);
607 }
608 
wpa_drv_p2p_reject(struct wpa_supplicant * wpa_s,const u8 * addr)609 static inline int wpa_drv_p2p_reject(struct wpa_supplicant *wpa_s,
610 				     const u8 *addr)
611 {
612 	if (!wpa_s->driver->p2p_reject)
613 		return -1;
614 	return wpa_s->driver->p2p_reject(wpa_s->drv_priv, addr);
615 }
616 
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)617 static inline int wpa_drv_p2p_invite(struct wpa_supplicant *wpa_s,
618 				     const u8 *peer, int role, const u8 *bssid,
619 				     const u8 *ssid, size_t ssid_len,
620 				     const u8 *go_dev_addr,
621 				     int persistent_group)
622 {
623 	if (!wpa_s->driver->p2p_invite)
624 		return -1;
625 	return wpa_s->driver->p2p_invite(wpa_s->drv_priv, peer, role, bssid,
626 					 ssid, ssid_len, go_dev_addr,
627 					 persistent_group);
628 }
629 
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)630 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
631 					 const u8 *dst, u8 action_code,
632 					 u8 dialog_token, u16 status_code,
633 					 const u8 *buf, size_t len)
634 {
635 	if (wpa_s->driver->send_tdls_mgmt) {
636 		return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
637 						     action_code, dialog_token,
638 						     status_code, buf, len);
639 	}
640 	return -1;
641 }
642 
wpa_drv_tdls_oper(struct wpa_supplicant * wpa_s,enum tdls_oper oper,const u8 * peer)643 static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
644 				    enum tdls_oper oper, const u8 *peer)
645 {
646 	if (!wpa_s->driver->tdls_oper)
647 		return -1;
648 	return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
649 }
650 
651 #ifdef ANDROID
wpa_drv_driver_cmd(struct wpa_supplicant * wpa_s,char * cmd,char * buf,size_t buf_len)652 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
653 				     char *cmd, char *buf, size_t buf_len)
654 {
655 	if (!wpa_s->driver->driver_cmd)
656 		return -1;
657 	return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
658 }
659 #endif
660 
wpa_drv_set_rekey_info(struct wpa_supplicant * wpa_s,const u8 * kek,const u8 * kck,const u8 * replay_ctr)661 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
662 					  const u8 *kek, const u8 *kck,
663 					  const u8 *replay_ctr)
664 {
665 	if (!wpa_s->driver->set_rekey_info)
666 		return;
667 	wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kck, replay_ctr);
668 }
669 
670 #ifdef ANDROID_P2P
wpa_drv_switch_channel(struct wpa_supplicant * wpa_s,int freq)671 static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
672 					  int freq)
673 {
674 	if (!wpa_s->driver->switch_channel)
675 		return -1;
676 	return wpa_s->driver->switch_channel(wpa_s->drv_priv, freq);
677 }
678 #endif
679 #endif /* DRIVER_I_H */
680