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 
526 int wpa_drv_get_conn_info(struct wpa_supplicant *wpa_s,
527 			struct wpa_conn_info *conn_info);
528 
wpa_drv_channel_info(struct wpa_supplicant * wpa_s,struct wpa_channel_info * ci)529 static inline int wpa_drv_channel_info(struct wpa_supplicant *wpa_s,
530 				       struct wpa_channel_info *ci)
531 {
532 	if (wpa_s->driver->channel_info)
533 		return wpa_s->driver->channel_info(wpa_s->drv_priv, ci);
534 	return -1;
535 }
536 
wpa_drv_pktcnt_poll(struct wpa_supplicant * wpa_s,struct hostap_sta_driver_data * sta)537 static inline int wpa_drv_pktcnt_poll(struct wpa_supplicant *wpa_s,
538 				      struct hostap_sta_driver_data *sta)
539 {
540 	if (wpa_s->driver->read_sta_data)
541 		return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta,
542 						    wpa_s->bssid);
543 	return -1;
544 }
545 
wpa_drv_set_ap_wps_ie(struct wpa_supplicant * wpa_s,const struct wpabuf * beacon,const struct wpabuf * proberesp,const struct wpabuf * assocresp)546 static inline int wpa_drv_set_ap_wps_ie(struct wpa_supplicant *wpa_s,
547 					const struct wpabuf *beacon,
548 					const struct wpabuf *proberesp,
549 					const struct wpabuf *assocresp)
550 {
551 	if (!wpa_s->driver->set_ap_wps_ie)
552 		return -1;
553 	return wpa_s->driver->set_ap_wps_ie(wpa_s->drv_priv, beacon,
554 					    proberesp, assocresp);
555 }
556 
wpa_drv_get_noa(struct wpa_supplicant * wpa_s,u8 * buf,size_t buf_len)557 static inline int wpa_drv_get_noa(struct wpa_supplicant *wpa_s,
558 				  u8 *buf, size_t buf_len)
559 {
560 	if (!wpa_s->driver->get_noa)
561 		return -1;
562 	return wpa_s->driver->get_noa(wpa_s->drv_priv, buf, buf_len);
563 }
564 
wpa_drv_set_p2p_powersave(struct wpa_supplicant * wpa_s,int legacy_ps,int opp_ps,int ctwindow)565 static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,
566 					    int legacy_ps, int opp_ps,
567 					    int ctwindow)
568 {
569 	if (!wpa_s->driver->set_p2p_powersave)
570 		return -1;
571 	return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,
572 						opp_ps, ctwindow);
573 }
574 
wpa_drv_ampdu(struct wpa_supplicant * wpa_s,int ampdu)575 static inline int wpa_drv_ampdu(struct wpa_supplicant *wpa_s, int ampdu)
576 {
577 	if (!wpa_s->driver->ampdu)
578 		return -1;
579 	return wpa_s->driver->ampdu(wpa_s->drv_priv, ampdu);
580 }
581 
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)582 static inline int wpa_drv_send_tdls_mgmt(struct wpa_supplicant *wpa_s,
583 					 const u8 *dst, u8 action_code,
584 					 u8 dialog_token, u16 status_code,
585 					 u32 peer_capab, int initiator,
586 					 const u8 *buf, size_t len)
587 {
588 	if (wpa_s->driver->send_tdls_mgmt) {
589 		return wpa_s->driver->send_tdls_mgmt(wpa_s->drv_priv, dst,
590 						     action_code, dialog_token,
591 						     status_code, peer_capab,
592 						     initiator, buf, len);
593 	}
594 	return -1;
595 }
596 
wpa_drv_tdls_oper(struct wpa_supplicant * wpa_s,enum tdls_oper oper,const u8 * peer)597 static inline int wpa_drv_tdls_oper(struct wpa_supplicant *wpa_s,
598 				    enum tdls_oper oper, const u8 *peer)
599 {
600 	if (!wpa_s->driver->tdls_oper)
601 		return -1;
602 	return wpa_s->driver->tdls_oper(wpa_s->drv_priv, oper, peer);
603 }
604 
605 #ifdef ANDROID
wpa_drv_driver_cmd(struct wpa_supplicant * wpa_s,char * cmd,char * buf,size_t buf_len)606 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
607 				     char *cmd, char *buf, size_t buf_len)
608 {
609 	if (!wpa_s->driver->driver_cmd)
610 		return -1;
611 	return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
612 }
613 #endif /* ANDROID */
614 
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)615 static inline void wpa_drv_set_rekey_info(struct wpa_supplicant *wpa_s,
616 					  const u8 *kek, size_t kek_len,
617 					  const u8 *kck, size_t kck_len,
618 					  const u8 *replay_ctr)
619 {
620 	if (!wpa_s->driver->set_rekey_info)
621 		return;
622 	wpa_s->driver->set_rekey_info(wpa_s->drv_priv, kek, kek_len,
623 				      kck, kck_len, replay_ctr);
624 }
625 
wpa_drv_radio_disable(struct wpa_supplicant * wpa_s,int disabled)626 static inline int wpa_drv_radio_disable(struct wpa_supplicant *wpa_s,
627 					int disabled)
628 {
629 	if (!wpa_s->driver->radio_disable)
630 		return -1;
631 	return wpa_s->driver->radio_disable(wpa_s->drv_priv, disabled);
632 }
633 
wpa_drv_switch_channel(struct wpa_supplicant * wpa_s,struct csa_settings * settings)634 static inline int wpa_drv_switch_channel(struct wpa_supplicant *wpa_s,
635 					 struct csa_settings *settings)
636 {
637 	if (!wpa_s->driver->switch_channel)
638 		return -1;
639 	return wpa_s->driver->switch_channel(wpa_s->drv_priv, settings);
640 }
641 
wpa_drv_add_ts(struct wpa_supplicant * wpa_s,u8 tsid,const u8 * address,u8 user_priority,u16 admitted_time)642 static inline int wpa_drv_add_ts(struct wpa_supplicant *wpa_s, u8 tsid,
643 				 const u8 *address, u8 user_priority,
644 				 u16 admitted_time)
645 {
646 	if (!wpa_s->driver->add_tx_ts)
647 		return -1;
648 	return wpa_s->driver->add_tx_ts(wpa_s->drv_priv, tsid, address,
649 					user_priority, admitted_time);
650 }
651 
wpa_drv_del_ts(struct wpa_supplicant * wpa_s,u8 tid,const u8 * address)652 static inline int wpa_drv_del_ts(struct wpa_supplicant *wpa_s, u8 tid,
653 				 const u8 *address)
654 {
655 	if (!wpa_s->driver->del_tx_ts)
656 		return -1;
657 	return wpa_s->driver->del_tx_ts(wpa_s->drv_priv, tid, address);
658 }
659 
wpa_drv_tdls_enable_channel_switch(struct wpa_supplicant * wpa_s,const u8 * addr,u8 oper_class,const struct hostapd_freq_params * freq_params)660 static inline int wpa_drv_tdls_enable_channel_switch(
661 	struct wpa_supplicant *wpa_s, const u8 *addr, u8 oper_class,
662 	const struct hostapd_freq_params *freq_params)
663 {
664 	if (!wpa_s->driver->tdls_enable_channel_switch)
665 		return -1;
666 	return wpa_s->driver->tdls_enable_channel_switch(wpa_s->drv_priv, addr,
667 							 oper_class,
668 							 freq_params);
669 }
670 
671 static inline int
wpa_drv_tdls_disable_channel_switch(struct wpa_supplicant * wpa_s,const u8 * addr)672 wpa_drv_tdls_disable_channel_switch(struct wpa_supplicant *wpa_s,
673 				    const u8 *addr)
674 {
675 	if (!wpa_s->driver->tdls_disable_channel_switch)
676 		return -1;
677 	return wpa_s->driver->tdls_disable_channel_switch(wpa_s->drv_priv,
678 							  addr);
679 }
680 
wpa_drv_wnm_oper(struct wpa_supplicant * wpa_s,enum wnm_oper oper,const u8 * peer,u8 * buf,u16 * buf_len)681 static inline int wpa_drv_wnm_oper(struct wpa_supplicant *wpa_s,
682 				   enum wnm_oper oper, const u8 *peer,
683 				   u8 *buf, u16 *buf_len)
684 {
685 	if (!wpa_s->driver->wnm_oper)
686 		return -1;
687 	return wpa_s->driver->wnm_oper(wpa_s->drv_priv, oper, peer, buf,
688 				       buf_len);
689 }
690 
wpa_drv_status(struct wpa_supplicant * wpa_s,char * buf,size_t buflen)691 static inline int wpa_drv_status(struct wpa_supplicant *wpa_s,
692 				 char *buf, size_t buflen)
693 {
694 	if (!wpa_s->driver->status)
695 		return -1;
696 	return wpa_s->driver->status(wpa_s->drv_priv, buf, buflen);
697 }
698 
wpa_drv_set_qos_map(struct wpa_supplicant * wpa_s,const u8 * qos_map_set,u8 qos_map_set_len)699 static inline int wpa_drv_set_qos_map(struct wpa_supplicant *wpa_s,
700 				      const u8 *qos_map_set, u8 qos_map_set_len)
701 {
702 	if (!wpa_s->driver->set_qos_map)
703 		return -1;
704 	return wpa_s->driver->set_qos_map(wpa_s->drv_priv, qos_map_set,
705 					  qos_map_set_len);
706 }
707 
wpa_drv_get_wowlan(struct wpa_supplicant * wpa_s)708 static inline int wpa_drv_get_wowlan(struct wpa_supplicant *wpa_s)
709 {
710 	if (!wpa_s->driver->get_wowlan)
711 		return 0;
712 	return wpa_s->driver->get_wowlan(wpa_s->drv_priv);
713 }
714 
wpa_drv_wowlan(struct wpa_supplicant * wpa_s,const struct wowlan_triggers * triggers)715 static inline int wpa_drv_wowlan(struct wpa_supplicant *wpa_s,
716 				 const struct wowlan_triggers *triggers)
717 {
718 	if (!wpa_s->driver->set_wowlan)
719 		return -1;
720 	return wpa_s->driver->set_wowlan(wpa_s->drv_priv, triggers);
721 }
722 
wpa_drv_vendor_cmd(struct wpa_supplicant * wpa_s,int vendor_id,int subcmd,const u8 * data,size_t data_len,enum nested_attr nested_attr_flag,struct wpabuf * buf)723 static inline int wpa_drv_vendor_cmd(struct wpa_supplicant *wpa_s,
724 				     int vendor_id, int subcmd, const u8 *data,
725 				     size_t data_len,
726 				     enum nested_attr nested_attr_flag,
727 				     struct wpabuf *buf)
728 {
729 	if (!wpa_s->driver->vendor_cmd)
730 		return -1;
731 	return wpa_s->driver->vendor_cmd(wpa_s->drv_priv, vendor_id, subcmd,
732 					 data, data_len, nested_attr_flag, buf);
733 }
734 
wpa_drv_roaming(struct wpa_supplicant * wpa_s,int allowed,const u8 * bssid)735 static inline int wpa_drv_roaming(struct wpa_supplicant *wpa_s, int allowed,
736 				  const u8 *bssid)
737 {
738 	if (!wpa_s->driver->roaming)
739 		return -1;
740 	return wpa_s->driver->roaming(wpa_s->drv_priv, allowed, bssid);
741 }
742 
wpa_drv_disable_fils(struct wpa_supplicant * wpa_s,int disable)743 static inline int wpa_drv_disable_fils(struct wpa_supplicant *wpa_s,
744 				       int disable)
745 {
746 	if (!wpa_s->driver->disable_fils)
747 		return -1;
748 	return wpa_s->driver->disable_fils(wpa_s->drv_priv, disable);
749 }
750 
wpa_drv_set_mac_addr(struct wpa_supplicant * wpa_s,const u8 * addr)751 static inline int wpa_drv_set_mac_addr(struct wpa_supplicant *wpa_s,
752 				       const u8 *addr)
753 {
754 	if (!wpa_s->driver->set_mac_addr)
755 		return -1;
756 	return wpa_s->driver->set_mac_addr(wpa_s->drv_priv, addr);
757 }
758 
759 
760 #ifdef CONFIG_MACSEC
761 
wpa_drv_macsec_init(struct wpa_supplicant * wpa_s,struct macsec_init_params * params)762 static inline int wpa_drv_macsec_init(struct wpa_supplicant *wpa_s,
763 				      struct macsec_init_params *params)
764 {
765 	if (!wpa_s->driver->macsec_init)
766 		return -1;
767 	return wpa_s->driver->macsec_init(wpa_s->drv_priv, params);
768 }
769 
wpa_drv_macsec_deinit(struct wpa_supplicant * wpa_s)770 static inline int wpa_drv_macsec_deinit(struct wpa_supplicant *wpa_s)
771 {
772 	if (!wpa_s->driver->macsec_deinit)
773 		return -1;
774 	return wpa_s->driver->macsec_deinit(wpa_s->drv_priv);
775 }
776 
wpa_drv_macsec_get_capability(struct wpa_supplicant * wpa_s,enum macsec_cap * cap)777 static inline int wpa_drv_macsec_get_capability(struct wpa_supplicant *wpa_s,
778 						enum macsec_cap *cap)
779 {
780 	if (!wpa_s->driver->macsec_get_capability)
781 		return -1;
782 	return wpa_s->driver->macsec_get_capability(wpa_s->drv_priv, cap);
783 }
784 
wpa_drv_enable_protect_frames(struct wpa_supplicant * wpa_s,bool enabled)785 static inline int wpa_drv_enable_protect_frames(struct wpa_supplicant *wpa_s,
786 						bool enabled)
787 {
788 	if (!wpa_s->driver->enable_protect_frames)
789 		return -1;
790 	return wpa_s->driver->enable_protect_frames(wpa_s->drv_priv, enabled);
791 }
792 
wpa_drv_enable_encrypt(struct wpa_supplicant * wpa_s,bool enabled)793 static inline int wpa_drv_enable_encrypt(struct wpa_supplicant *wpa_s,
794 						bool enabled)
795 {
796 	if (!wpa_s->driver->enable_encrypt)
797 		return -1;
798 	return wpa_s->driver->enable_encrypt(wpa_s->drv_priv, enabled);
799 }
800 
wpa_drv_set_replay_protect(struct wpa_supplicant * wpa_s,bool enabled,u32 window)801 static inline int wpa_drv_set_replay_protect(struct wpa_supplicant *wpa_s,
802 					     bool enabled, u32 window)
803 {
804 	if (!wpa_s->driver->set_replay_protect)
805 		return -1;
806 	return wpa_s->driver->set_replay_protect(wpa_s->drv_priv, enabled,
807 						 window);
808 }
809 
wpa_drv_set_current_cipher_suite(struct wpa_supplicant * wpa_s,u64 cs)810 static inline int wpa_drv_set_current_cipher_suite(struct wpa_supplicant *wpa_s,
811 						   u64 cs)
812 {
813 	if (!wpa_s->driver->set_current_cipher_suite)
814 		return -1;
815 	return wpa_s->driver->set_current_cipher_suite(wpa_s->drv_priv, cs);
816 }
817 
wpa_drv_enable_controlled_port(struct wpa_supplicant * wpa_s,bool enabled)818 static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
819 						 bool enabled)
820 {
821 	if (!wpa_s->driver->enable_controlled_port)
822 		return -1;
823 	return wpa_s->driver->enable_controlled_port(wpa_s->drv_priv, enabled);
824 }
825 
wpa_drv_get_receive_lowest_pn(struct wpa_supplicant * wpa_s,struct receive_sa * sa)826 static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
827 						struct receive_sa *sa)
828 {
829 	if (!wpa_s->driver->get_receive_lowest_pn)
830 		return -1;
831 	return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, sa);
832 }
833 
wpa_drv_get_transmit_next_pn(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)834 static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
835 						struct transmit_sa *sa)
836 {
837 	if (!wpa_s->driver->get_transmit_next_pn)
838 		return -1;
839 	return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, sa);
840 }
841 
wpa_drv_set_transmit_next_pn(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)842 static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
843 						struct transmit_sa *sa)
844 {
845 	if (!wpa_s->driver->set_transmit_next_pn)
846 		return -1;
847 	return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, sa);
848 }
849 
wpa_drv_set_receive_lowest_pn(struct wpa_supplicant * wpa_s,struct receive_sa * sa)850 static inline int wpa_drv_set_receive_lowest_pn(struct wpa_supplicant *wpa_s,
851 						struct receive_sa *sa)
852 {
853 	if (!wpa_s->driver->set_receive_lowest_pn)
854 		return -1;
855 	return wpa_s->driver->set_receive_lowest_pn(wpa_s->drv_priv, sa);
856 }
857 
858 static inline int
wpa_drv_create_receive_sc(struct wpa_supplicant * wpa_s,struct receive_sc * sc,unsigned int conf_offset,int validation)859 wpa_drv_create_receive_sc(struct wpa_supplicant *wpa_s, struct receive_sc *sc,
860 			  unsigned int conf_offset, int validation)
861 {
862 	if (!wpa_s->driver->create_receive_sc)
863 		return -1;
864 	return wpa_s->driver->create_receive_sc(wpa_s->drv_priv, sc,
865 						conf_offset, validation);
866 }
867 
wpa_drv_delete_receive_sc(struct wpa_supplicant * wpa_s,struct receive_sc * sc)868 static inline int wpa_drv_delete_receive_sc(struct wpa_supplicant *wpa_s,
869 					    struct receive_sc *sc)
870 {
871 	if (!wpa_s->driver->delete_receive_sc)
872 		return -1;
873 	return wpa_s->driver->delete_receive_sc(wpa_s->drv_priv, sc);
874 }
875 
wpa_drv_create_receive_sa(struct wpa_supplicant * wpa_s,struct receive_sa * sa)876 static inline int wpa_drv_create_receive_sa(struct wpa_supplicant *wpa_s,
877 					    struct receive_sa *sa)
878 {
879 	if (!wpa_s->driver->create_receive_sa)
880 		return -1;
881 	return wpa_s->driver->create_receive_sa(wpa_s->drv_priv, sa);
882 }
883 
wpa_drv_delete_receive_sa(struct wpa_supplicant * wpa_s,struct receive_sa * sa)884 static inline int wpa_drv_delete_receive_sa(struct wpa_supplicant *wpa_s,
885 					    struct receive_sa *sa)
886 {
887 	if (!wpa_s->driver->delete_receive_sa)
888 		return -1;
889 	return wpa_s->driver->delete_receive_sa(wpa_s->drv_priv, sa);
890 }
891 
wpa_drv_enable_receive_sa(struct wpa_supplicant * wpa_s,struct receive_sa * sa)892 static inline int wpa_drv_enable_receive_sa(struct wpa_supplicant *wpa_s,
893 					    struct receive_sa *sa)
894 {
895 	if (!wpa_s->driver->enable_receive_sa)
896 		return -1;
897 	return wpa_s->driver->enable_receive_sa(wpa_s->drv_priv, sa);
898 }
899 
wpa_drv_disable_receive_sa(struct wpa_supplicant * wpa_s,struct receive_sa * sa)900 static inline int wpa_drv_disable_receive_sa(struct wpa_supplicant *wpa_s,
901 					     struct receive_sa *sa)
902 {
903 	if (!wpa_s->driver->disable_receive_sa)
904 		return -1;
905 	return wpa_s->driver->disable_receive_sa(wpa_s->drv_priv, sa);
906 }
907 
908 static inline int
wpa_drv_create_transmit_sc(struct wpa_supplicant * wpa_s,struct transmit_sc * sc,unsigned int conf_offset)909 wpa_drv_create_transmit_sc(struct wpa_supplicant *wpa_s, struct transmit_sc *sc,
910 			   unsigned int conf_offset)
911 {
912 	if (!wpa_s->driver->create_transmit_sc)
913 		return -1;
914 	return wpa_s->driver->create_transmit_sc(wpa_s->drv_priv, sc,
915 						 conf_offset);
916 }
917 
wpa_drv_delete_transmit_sc(struct wpa_supplicant * wpa_s,struct transmit_sc * sc)918 static inline int wpa_drv_delete_transmit_sc(struct wpa_supplicant *wpa_s,
919 					     struct transmit_sc *sc)
920 {
921 	if (!wpa_s->driver->delete_transmit_sc)
922 		return -1;
923 	return wpa_s->driver->delete_transmit_sc(wpa_s->drv_priv, sc);
924 }
925 
wpa_drv_create_transmit_sa(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)926 static inline int wpa_drv_create_transmit_sa(struct wpa_supplicant *wpa_s,
927 					     struct transmit_sa *sa)
928 {
929 	if (!wpa_s->driver->create_transmit_sa)
930 		return -1;
931 	return wpa_s->driver->create_transmit_sa(wpa_s->drv_priv, sa);
932 }
933 
wpa_drv_delete_transmit_sa(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)934 static inline int wpa_drv_delete_transmit_sa(struct wpa_supplicant *wpa_s,
935 					     struct transmit_sa *sa)
936 {
937 	if (!wpa_s->driver->delete_transmit_sa)
938 		return -1;
939 	return wpa_s->driver->delete_transmit_sa(wpa_s->drv_priv, sa);
940 }
941 
wpa_drv_enable_transmit_sa(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)942 static inline int wpa_drv_enable_transmit_sa(struct wpa_supplicant *wpa_s,
943 					     struct transmit_sa *sa)
944 {
945 	if (!wpa_s->driver->enable_transmit_sa)
946 		return -1;
947 	return wpa_s->driver->enable_transmit_sa(wpa_s->drv_priv, sa);
948 }
949 
wpa_drv_disable_transmit_sa(struct wpa_supplicant * wpa_s,struct transmit_sa * sa)950 static inline int wpa_drv_disable_transmit_sa(struct wpa_supplicant *wpa_s,
951 					      struct transmit_sa *sa)
952 {
953 	if (!wpa_s->driver->disable_transmit_sa)
954 		return -1;
955 	return wpa_s->driver->disable_transmit_sa(wpa_s->drv_priv, sa);
956 }
957 #endif /* CONFIG_MACSEC */
958 
wpa_drv_setband(struct wpa_supplicant * wpa_s,u32 band_mask)959 static inline int wpa_drv_setband(struct wpa_supplicant *wpa_s,
960 				  u32 band_mask)
961 {
962 	if (!wpa_s->driver->set_band)
963 		return -1;
964 	return wpa_s->driver->set_band(wpa_s->drv_priv, band_mask);
965 }
966 
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)967 static inline int wpa_drv_get_pref_freq_list(struct wpa_supplicant *wpa_s,
968 					     enum wpa_driver_if_type if_type,
969 					     unsigned int *num,
970 					     unsigned int *freq_list)
971 {
972 #ifdef CONFIG_TESTING_OPTIONS
973 	if (wpa_s->get_pref_freq_list_override)
974 		return wpas_ctrl_iface_get_pref_freq_list_override(
975 			wpa_s, if_type, num, freq_list);
976 #endif /* CONFIG_TESTING_OPTIONS */
977 	if (!wpa_s->driver->get_pref_freq_list)
978 		return -1;
979 	return wpa_s->driver->get_pref_freq_list(wpa_s->drv_priv, if_type,
980 						 num, freq_list);
981 }
982 
wpa_drv_set_prob_oper_freq(struct wpa_supplicant * wpa_s,unsigned int freq)983 static inline int wpa_drv_set_prob_oper_freq(struct wpa_supplicant *wpa_s,
984 					     unsigned int freq)
985 {
986 	if (!wpa_s->driver->set_prob_oper_freq)
987 		return 0;
988 	return wpa_s->driver->set_prob_oper_freq(wpa_s->drv_priv, freq);
989 }
990 
wpa_drv_abort_scan(struct wpa_supplicant * wpa_s,u64 scan_cookie)991 static inline int wpa_drv_abort_scan(struct wpa_supplicant *wpa_s,
992 				     u64 scan_cookie)
993 {
994 	if (!wpa_s->driver->abort_scan)
995 		return -1;
996 	return wpa_s->driver->abort_scan(wpa_s->drv_priv, scan_cookie);
997 }
998 
wpa_drv_configure_frame_filters(struct wpa_supplicant * wpa_s,u32 filters)999 static inline int wpa_drv_configure_frame_filters(struct wpa_supplicant *wpa_s,
1000 						  u32 filters)
1001 {
1002 	if (!wpa_s->driver->configure_data_frame_filters)
1003 		return -1;
1004 	return wpa_s->driver->configure_data_frame_filters(wpa_s->drv_priv,
1005 							   filters);
1006 }
1007 
wpa_drv_get_ext_capa(struct wpa_supplicant * wpa_s,enum wpa_driver_if_type type)1008 static inline int wpa_drv_get_ext_capa(struct wpa_supplicant *wpa_s,
1009 				       enum wpa_driver_if_type type)
1010 {
1011 	if (!wpa_s->driver->get_ext_capab)
1012 		return -1;
1013 	return wpa_s->driver->get_ext_capab(wpa_s->drv_priv, type,
1014 					    &wpa_s->extended_capa,
1015 					    &wpa_s->extended_capa_mask,
1016 					    &wpa_s->extended_capa_len);
1017 }
1018 
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)1019 static inline int wpa_drv_p2p_lo_start(struct wpa_supplicant *wpa_s,
1020 				       unsigned int channel,
1021 				       unsigned int period,
1022 				       unsigned int interval,
1023 				       unsigned int count,
1024 				       const u8 *device_types,
1025 				       size_t dev_types_len,
1026 				       const u8 *ies, size_t ies_len)
1027 {
1028 	if (!wpa_s->driver->p2p_lo_start)
1029 		return -1;
1030 	return wpa_s->driver->p2p_lo_start(wpa_s->drv_priv, channel, period,
1031 					   interval, count, device_types,
1032 					   dev_types_len, ies, ies_len);
1033 }
1034 
wpa_drv_p2p_lo_stop(struct wpa_supplicant * wpa_s)1035 static inline int wpa_drv_p2p_lo_stop(struct wpa_supplicant *wpa_s)
1036 {
1037 	if (!wpa_s->driver->p2p_lo_stop)
1038 		return -1;
1039 	return wpa_s->driver->p2p_lo_stop(wpa_s->drv_priv);
1040 }
1041 
wpa_drv_set_default_scan_ies(struct wpa_supplicant * wpa_s,const u8 * ies,size_t len)1042 static inline int wpa_drv_set_default_scan_ies(struct wpa_supplicant *wpa_s,
1043 					       const u8 *ies, size_t len)
1044 {
1045 	if (!wpa_s->driver->set_default_scan_ies)
1046 		return -1;
1047 	return wpa_s->driver->set_default_scan_ies(wpa_s->drv_priv, ies, len);
1048 }
1049 
wpa_drv_set_tdls_mode(struct wpa_supplicant * wpa_s,int tdls_external_control)1050 static inline int wpa_drv_set_tdls_mode(struct wpa_supplicant *wpa_s,
1051 					int tdls_external_control)
1052 {
1053 	if (!wpa_s->driver->set_tdls_mode)
1054 		return -1;
1055 	return wpa_s->driver->set_tdls_mode(wpa_s->drv_priv,
1056 					    tdls_external_control);
1057 }
1058 
1059 static inline struct wpa_bss_candidate_info *
wpa_drv_get_bss_trans_status(struct wpa_supplicant * wpa_s,struct wpa_bss_trans_info * params)1060 wpa_drv_get_bss_trans_status(struct wpa_supplicant *wpa_s,
1061 			     struct wpa_bss_trans_info *params)
1062 {
1063 	if (!wpa_s->driver->get_bss_transition_status)
1064 		return NULL;
1065 	return wpa_s->driver->get_bss_transition_status(wpa_s->drv_priv,
1066 							params);
1067 }
1068 
wpa_drv_ignore_assoc_disallow(struct wpa_supplicant * wpa_s,int val)1069 static inline int wpa_drv_ignore_assoc_disallow(struct wpa_supplicant *wpa_s,
1070 						int val)
1071 {
1072 	if (!wpa_s->driver->ignore_assoc_disallow)
1073 		return -1;
1074 	return wpa_s->driver->ignore_assoc_disallow(wpa_s->drv_priv, val);
1075 }
1076 
wpa_drv_set_bssid_tmp_disallow(struct wpa_supplicant * wpa_s,unsigned int num_bssid,const u8 * bssids)1077 static inline int wpa_drv_set_bssid_tmp_disallow(struct wpa_supplicant *wpa_s,
1078 						 unsigned int num_bssid,
1079 						 const u8 *bssids)
1080 {
1081 	if (!wpa_s->driver->set_bssid_tmp_disallow)
1082 		return -1;
1083 	return wpa_s->driver->set_bssid_tmp_disallow(wpa_s->drv_priv, num_bssid,
1084 						     bssids);
1085 }
1086 
wpa_drv_update_connect_params(struct wpa_supplicant * wpa_s,struct wpa_driver_associate_params * params,enum wpa_drv_update_connect_params_mask mask)1087 static inline int wpa_drv_update_connect_params(
1088 	struct wpa_supplicant *wpa_s,
1089 	struct wpa_driver_associate_params *params,
1090 	enum wpa_drv_update_connect_params_mask mask)
1091 {
1092 	if (!wpa_s->driver->update_connect_params)
1093 		return -1;
1094 	return wpa_s->driver->update_connect_params(wpa_s->drv_priv, params,
1095 						    mask);
1096 }
1097 
1098 static inline int
wpa_drv_send_external_auth_status(struct wpa_supplicant * wpa_s,struct external_auth * params)1099 wpa_drv_send_external_auth_status(struct wpa_supplicant *wpa_s,
1100 				  struct external_auth *params)
1101 {
1102 	if (!wpa_s->driver->send_external_auth_status)
1103 		return -1;
1104 	return wpa_s->driver->send_external_auth_status(wpa_s->drv_priv,
1105 							params);
1106 }
1107 
wpa_drv_set_4addr_mode(struct wpa_supplicant * wpa_s,int val)1108 static inline int wpa_drv_set_4addr_mode(struct wpa_supplicant *wpa_s, int val)
1109 {
1110 	if (!wpa_s->driver->set_4addr_mode)
1111 		return -1;
1112 	return wpa_s->driver->set_4addr_mode(wpa_s->drv_priv,
1113 					     wpa_s->bridge_ifname, val);
1114 }
1115 
wpa_drv_dpp_listen(struct wpa_supplicant * wpa_s,bool enable)1116 static inline int wpa_drv_dpp_listen(struct wpa_supplicant *wpa_s, bool enable)
1117 {
1118 	if (!wpa_s->driver->dpp_listen)
1119 		return 0;
1120 	return wpa_s->driver->dpp_listen(wpa_s->drv_priv, enable);
1121 }
1122 
1123 #endif /* DRIVER_I_H */
1124