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