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