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