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