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