The Android Open Source Project | 845e012 | 2009-03-03 19:31:34 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * wpa_supplicant - Internal definitions |
| 3 | * Copyright (c) 2003-2006, Jouni Malinen <j@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 WPA_SUPPLICANT_I_H |
| 16 | #define WPA_SUPPLICANT_I_H |
| 17 | |
| 18 | #include "driver.h" |
| 19 | |
| 20 | struct wpa_blacklist { |
| 21 | struct wpa_blacklist *next; |
| 22 | u8 bssid[ETH_ALEN]; |
| 23 | int count; |
| 24 | }; |
| 25 | |
| 26 | |
| 27 | struct wpa_scan_result; |
| 28 | struct wpa_sm; |
| 29 | struct wpa_supplicant; |
| 30 | |
| 31 | /* |
| 32 | * Forward declarations of private structures used within the ctrl_iface |
| 33 | * backends. Other parts of wpa_supplicant do not have access to data stored in |
| 34 | * these structures. |
| 35 | */ |
| 36 | struct ctrl_iface_priv; |
| 37 | struct ctrl_iface_global_priv; |
| 38 | struct ctrl_iface_dbus_priv; |
| 39 | |
| 40 | /** |
| 41 | * struct wpa_interface - Parameters for wpa_supplicant_add_iface() |
| 42 | */ |
| 43 | struct wpa_interface { |
| 44 | /** |
| 45 | * confname - Configuration name (file or profile) name |
| 46 | * |
| 47 | * This can also be %NULL when a configuration file is not used. In |
| 48 | * that case, ctrl_interface must be set to allow the interface to be |
| 49 | * configured. |
| 50 | */ |
| 51 | const char *confname; |
| 52 | |
| 53 | /** |
| 54 | * ctrl_interface - Control interface parameter |
| 55 | * |
| 56 | * If a configuration file is not used, this variable can be used to |
| 57 | * set the ctrl_interface parameter that would have otherwise been read |
| 58 | * from the configuration file. If both confname and ctrl_interface are |
| 59 | * set, ctrl_interface is used to override the value from configuration |
| 60 | * file. |
| 61 | */ |
| 62 | const char *ctrl_interface; |
| 63 | |
| 64 | /** |
| 65 | * driver - Driver interface name, or %NULL to use the default driver |
| 66 | */ |
| 67 | const char *driver; |
| 68 | |
| 69 | /** |
| 70 | * driver_param - Driver interface parameters |
| 71 | * |
| 72 | * If a configuration file is not used, this variable can be used to |
| 73 | * set the driver_param parameters that would have otherwise been read |
| 74 | * from the configuration file. If both confname and driver_param are |
| 75 | * set, driver_param is used to override the value from configuration |
| 76 | * file. |
| 77 | */ |
| 78 | const char *driver_param; |
| 79 | |
| 80 | /** |
| 81 | * ifname - Interface name |
| 82 | */ |
| 83 | const char *ifname; |
| 84 | |
| 85 | /** |
| 86 | * bridge_ifname - Optional bridge interface name |
| 87 | * |
| 88 | * If the driver interface (ifname) is included in a Linux bridge |
| 89 | * device, the bridge interface may need to be used for receiving EAPOL |
| 90 | * frames. This can be enabled by setting this variable to enable |
| 91 | * receiving of EAPOL frames from an additional interface. |
| 92 | */ |
| 93 | const char *bridge_ifname; |
| 94 | }; |
| 95 | |
| 96 | /** |
| 97 | * struct wpa_params - Parameters for wpa_supplicant_init() |
| 98 | */ |
| 99 | struct wpa_params { |
| 100 | /** |
| 101 | * daemonize - Run %wpa_supplicant in the background |
| 102 | */ |
| 103 | int daemonize; |
| 104 | |
| 105 | /** |
| 106 | * wait_for_interface - Wait for the network interface to appear |
| 107 | * |
| 108 | * If set, %wpa_supplicant will wait until all the configured network |
| 109 | * interfaces are available before starting processing. Please note |
| 110 | * that in many cases, a better alternative would be to start |
| 111 | * %wpa_supplicant without network interfaces and add the interfaces |
| 112 | * dynamically whenever they become available. |
| 113 | */ |
| 114 | int wait_for_interface; |
| 115 | |
| 116 | /** |
| 117 | * wait_for_monitor - Wait for a monitor program before starting |
| 118 | */ |
| 119 | int wait_for_monitor; |
| 120 | |
| 121 | /** |
| 122 | * pid_file - Path to a PID (process ID) file |
| 123 | * |
| 124 | * If this and daemonize are set, process ID of the background process |
| 125 | * will be written to the specified file. |
| 126 | */ |
| 127 | char *pid_file; |
| 128 | |
| 129 | /** |
| 130 | * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO) |
| 131 | */ |
| 132 | int wpa_debug_level; |
| 133 | |
| 134 | /** |
| 135 | * wpa_debug_show_keys - Whether keying material is included in debug |
| 136 | * |
| 137 | * This parameter can be used to allow keying material to be included |
| 138 | * in debug messages. This is a security risk and this option should |
| 139 | * not be enabled in normal configuration. If needed during |
| 140 | * development or while troubleshooting, this option can provide more |
| 141 | * details for figuring out what is happening. |
| 142 | */ |
| 143 | int wpa_debug_show_keys; |
| 144 | |
| 145 | /** |
| 146 | * wpa_debug_timestamp - Whether to include timestamp in debug messages |
| 147 | */ |
| 148 | int wpa_debug_timestamp; |
| 149 | |
| 150 | /** |
| 151 | * ctrl_interface - Global ctrl_iface path/parameter |
| 152 | */ |
| 153 | char *ctrl_interface; |
| 154 | |
| 155 | /** |
| 156 | * dbus_ctrl_interface - Enable the DBus control interface |
| 157 | */ |
| 158 | int dbus_ctrl_interface; |
| 159 | |
| 160 | /** |
| 161 | * wpa_debug_file_path - Path of debug file or %NULL to use stdout |
| 162 | */ |
| 163 | const char *wpa_debug_file_path; |
| 164 | }; |
| 165 | |
| 166 | /** |
| 167 | * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces |
| 168 | * |
| 169 | * This structure is initialized by calling wpa_supplicant_init() when starting |
| 170 | * %wpa_supplicant. |
| 171 | */ |
| 172 | struct wpa_global { |
| 173 | struct wpa_supplicant *ifaces; |
| 174 | struct wpa_params params; |
| 175 | struct ctrl_iface_global_priv *ctrl_iface; |
| 176 | struct ctrl_iface_dbus_priv *dbus_ctrl_iface; |
| 177 | }; |
| 178 | |
| 179 | |
| 180 | struct wpa_client_mlme { |
| 181 | #ifdef CONFIG_CLIENT_MLME |
| 182 | enum { |
| 183 | IEEE80211_DISABLED, IEEE80211_AUTHENTICATE, |
| 184 | IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED, |
| 185 | IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED |
| 186 | } state; |
| 187 | u8 prev_bssid[ETH_ALEN]; |
| 188 | u8 ssid[32]; |
| 189 | size_t ssid_len; |
| 190 | u16 aid; |
| 191 | u16 ap_capab, capab; |
| 192 | u8 *extra_ie; /* to be added to the end of AssocReq */ |
| 193 | size_t extra_ie_len; |
| 194 | wpa_key_mgmt key_mgmt; |
| 195 | |
| 196 | /* The last AssocReq/Resp IEs */ |
| 197 | u8 *assocreq_ies, *assocresp_ies; |
| 198 | size_t assocreq_ies_len, assocresp_ies_len; |
| 199 | |
| 200 | int auth_tries, assoc_tries; |
| 201 | |
| 202 | unsigned int ssid_set:1; |
| 203 | unsigned int bssid_set:1; |
| 204 | unsigned int prev_bssid_set:1; |
| 205 | unsigned int authenticated:1; |
| 206 | unsigned int associated:1; |
| 207 | unsigned int probereq_poll:1; |
| 208 | unsigned int use_protection:1; |
| 209 | unsigned int create_ibss:1; |
| 210 | unsigned int mixed_cell:1; |
| 211 | unsigned int wmm_enabled:1; |
| 212 | |
| 213 | struct os_time last_probe; |
| 214 | |
| 215 | #define IEEE80211_AUTH_ALG_OPEN BIT(0) |
| 216 | #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1) |
| 217 | #define IEEE80211_AUTH_ALG_LEAP BIT(2) |
| 218 | unsigned int auth_algs; /* bitfield of allowed auth algs */ |
| 219 | int auth_alg; /* currently used IEEE 802.11 authentication algorithm */ |
| 220 | int auth_transaction; |
| 221 | |
| 222 | struct os_time ibss_join_req; |
| 223 | u8 *probe_resp; /* ProbeResp template for IBSS */ |
| 224 | size_t probe_resp_len; |
| 225 | u32 supp_rates_bits; |
| 226 | |
| 227 | int wmm_last_param_set; |
| 228 | |
| 229 | int sta_scanning; |
| 230 | int scan_hw_mode_idx; |
| 231 | int scan_channel_idx; |
| 232 | enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; |
| 233 | struct os_time last_scan_completed; |
| 234 | int scan_oper_channel; |
| 235 | int scan_oper_freq; |
| 236 | int scan_oper_phymode; |
| 237 | u8 scan_ssid[32]; |
| 238 | size_t scan_ssid_len; |
| 239 | int scan_skip_11b; |
| 240 | |
| 241 | struct ieee80211_sta_bss *sta_bss_list; |
| 242 | #define STA_HASH_SIZE 256 |
| 243 | #define STA_HASH(sta) (sta[5]) |
| 244 | struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE]; |
| 245 | |
| 246 | int cts_protect_erp_frames; |
| 247 | |
| 248 | int phymode; /* current mode; WPA_MODE_IEEE80211A, .. */ |
| 249 | struct wpa_hw_modes *modes; |
| 250 | size_t num_modes; |
| 251 | unsigned int hw_modes; /* bitfield of allowed hardware modes; |
| 252 | * (1 << MODE_*) */ |
| 253 | int num_curr_rates; |
| 254 | struct wpa_rate_data *curr_rates; |
| 255 | int freq; /* The current frequency in MHz */ |
| 256 | int channel; /* The current IEEE 802.11 channel number */ |
| 257 | #else /* CONFIG_CLIENT_MLME */ |
| 258 | int dummy; /* to keep MSVC happy */ |
| 259 | #endif /* CONFIG_CLIENT_MLME */ |
| 260 | }; |
| 261 | |
| 262 | /** |
| 263 | * struct wpa_supplicant - Internal data for wpa_supplicant interface |
| 264 | * |
| 265 | * This structure contains the internal data for core wpa_supplicant code. This |
| 266 | * should be only used directly from the core code. However, a pointer to this |
| 267 | * data is used from other files as an arbitrary context pointer in calls to |
| 268 | * core functions. |
| 269 | */ |
| 270 | struct wpa_supplicant { |
| 271 | struct wpa_global *global; |
| 272 | struct wpa_supplicant *next; |
| 273 | struct l2_packet_data *l2; |
| 274 | struct l2_packet_data *l2_br; |
| 275 | unsigned char own_addr[ETH_ALEN]; |
| 276 | char ifname[100]; |
| 277 | #ifdef CONFIG_CTRL_IFACE_DBUS |
| 278 | char *dbus_path; |
| 279 | #endif /* CONFIG_CTRL_IFACE_DBUS */ |
| 280 | char bridge_ifname[16]; |
| 281 | |
| 282 | char *confname; |
| 283 | struct wpa_config *conf; |
| 284 | int countermeasures; |
| 285 | os_time_t last_michael_mic_error; |
| 286 | u8 bssid[ETH_ALEN]; |
| 287 | u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this |
| 288 | * field contains the targer BSSID. */ |
| 289 | int reassociate; /* reassociation requested */ |
| 290 | int disconnected; /* all connections disabled; i.e., do no reassociate |
| 291 | * before this has been cleared */ |
| 292 | struct wpa_ssid *current_ssid; |
| 293 | |
| 294 | /* Selected configuration (based on Beacon/ProbeResp WPA IE) */ |
| 295 | int pairwise_cipher; |
| 296 | int group_cipher; |
| 297 | int key_mgmt; |
| 298 | int mgmt_group_cipher; |
| 299 | |
| 300 | void *drv_priv; /* private data used by driver_ops */ |
| 301 | |
| 302 | struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID; |
| 303 | * NULL = not yet initialized (start |
| 304 | * with broadcast SSID) |
| 305 | * BROADCAST_SSID_SCAN = broadcast |
| 306 | * SSID was used in the previous scan |
| 307 | */ |
| 308 | #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1) |
| 309 | |
| 310 | struct wpa_scan_result *scan_results; |
| 311 | int num_scan_results; |
| 312 | |
| 313 | struct wpa_driver_ops *driver; |
| 314 | int interface_removed; /* whether the network interface has been |
| 315 | * removed */ |
| 316 | struct wpa_sm *wpa; |
| 317 | struct eapol_sm *eapol; |
| 318 | |
| 319 | struct ctrl_iface_priv *ctrl_iface; |
| 320 | |
| 321 | wpa_states wpa_state; |
| 322 | int new_connection; |
| 323 | int reassociated_connection; |
| 324 | |
| 325 | int eapol_received; /* number of EAPOL packets received after the |
| 326 | * previous association event */ |
| 327 | |
| 328 | struct scard_data *scard; |
| 329 | |
| 330 | unsigned char last_eapol_src[ETH_ALEN]; |
| 331 | |
| 332 | int keys_cleared; |
| 333 | |
| 334 | struct wpa_blacklist *blacklist; |
| 335 | |
| 336 | int scan_req; /* manual scan request; this forces a scan even if there |
| 337 | * are no enabled networks in the configuration */ |
| 338 | int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan |
| 339 | * results without a new scan request; this is used |
| 340 | * to speed up the first association if the driver |
| 341 | * has already available scan results. */ |
| 342 | |
| 343 | struct wpa_client_mlme mlme; |
| 344 | int use_client_mlme; |
| 345 | #ifdef ANDROID |
| 346 | int scan_interval; /* time between scans when no APs available */ |
| 347 | #endif |
| 348 | }; |
| 349 | |
| 350 | |
| 351 | /* wpa_supplicant.c */ |
| 352 | void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s); |
| 353 | |
| 354 | int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s); |
| 355 | |
| 356 | const char * wpa_supplicant_state_txt(int state); |
| 357 | int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s, |
| 358 | int wait_for_interface); |
| 359 | struct wpa_blacklist * wpa_blacklist_get(struct wpa_supplicant *wpa_s, |
| 360 | const u8 *bssid); |
| 361 | int wpa_blacklist_add(struct wpa_supplicant *wpa_s, const u8 *bssid); |
| 362 | void wpa_blacklist_clear(struct wpa_supplicant *wpa_s); |
| 363 | int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s, |
| 364 | struct wpa_scan_result *bss, |
| 365 | struct wpa_ssid *ssid, |
| 366 | u8 *wpa_ie, size_t *wpa_ie_len); |
| 367 | void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, |
| 368 | struct wpa_scan_result *bss, |
| 369 | struct wpa_ssid *ssid); |
| 370 | void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s, |
| 371 | struct wpa_ssid *ssid); |
| 372 | void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s); |
| 373 | int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s); |
| 374 | void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr); |
| 375 | void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s, |
| 376 | int sec, int usec); |
| 377 | void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state); |
| 378 | struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s); |
| 379 | void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s); |
| 380 | void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s, |
| 381 | int reason_code); |
| 382 | void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s, |
| 383 | int reason_code); |
| 384 | void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec); |
| 385 | |
| 386 | void wpa_show_license(void); |
| 387 | |
| 388 | struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, |
| 389 | struct wpa_interface *iface); |
| 390 | int wpa_supplicant_remove_iface(struct wpa_global *global, |
| 391 | struct wpa_supplicant *wpa_s); |
| 392 | struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global, |
| 393 | const char *ifname); |
| 394 | struct wpa_global * wpa_supplicant_init(struct wpa_params *params); |
| 395 | int wpa_supplicant_run(struct wpa_global *global); |
| 396 | void wpa_supplicant_deinit(struct wpa_global *global); |
| 397 | |
| 398 | int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s, |
| 399 | struct wpa_ssid *ssid); |
| 400 | |
| 401 | /* events.c */ |
| 402 | void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s); |
| 403 | |
| 404 | /* driver_ops */ |
| 405 | static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s, |
| 406 | const char *ifname) |
| 407 | { |
| 408 | if (wpa_s->driver->init) { |
| 409 | return wpa_s->driver->init(wpa_s, ifname); |
| 410 | } |
| 411 | return NULL; |
| 412 | } |
| 413 | |
| 414 | static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s) |
| 415 | { |
| 416 | if (wpa_s->driver->deinit) |
| 417 | wpa_s->driver->deinit(wpa_s->drv_priv); |
| 418 | } |
| 419 | |
| 420 | static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s, |
| 421 | const char *param) |
| 422 | { |
| 423 | if (wpa_s->driver->set_param) |
| 424 | return wpa_s->driver->set_param(wpa_s->drv_priv, param); |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s, |
| 429 | int enabled) |
| 430 | { |
| 431 | if (wpa_s->driver->set_drop_unencrypted) { |
| 432 | return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv, |
| 433 | enabled); |
| 434 | } |
| 435 | return -1; |
| 436 | } |
| 437 | |
| 438 | static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s, |
| 439 | int enabled) |
| 440 | { |
| 441 | if (wpa_s->driver->set_countermeasures) { |
| 442 | return wpa_s->driver->set_countermeasures(wpa_s->drv_priv, |
| 443 | enabled); |
| 444 | } |
| 445 | return -1; |
| 446 | } |
| 447 | |
| 448 | static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s, |
| 449 | int auth_alg) |
| 450 | { |
| 451 | if (wpa_s->driver->set_auth_alg) { |
| 452 | return wpa_s->driver->set_auth_alg(wpa_s->drv_priv, |
| 453 | auth_alg); |
| 454 | } |
| 455 | return -1; |
| 456 | } |
| 457 | |
| 458 | static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled) |
| 459 | { |
| 460 | if (wpa_s->driver->set_wpa) { |
| 461 | return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled); |
| 462 | } |
| 463 | return 0; |
| 464 | } |
| 465 | |
| 466 | static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s, |
| 467 | struct wpa_driver_associate_params *params) |
| 468 | { |
| 469 | if (wpa_s->driver->associate) { |
| 470 | return wpa_s->driver->associate(wpa_s->drv_priv, params); |
| 471 | } |
| 472 | return -1; |
| 473 | } |
| 474 | |
| 475 | static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid, |
| 476 | size_t ssid_len) |
| 477 | { |
| 478 | if (wpa_s->driver->scan) { |
| 479 | return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len); |
| 480 | } |
| 481 | return -1; |
| 482 | } |
| 483 | |
| 484 | static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s, |
| 485 | struct wpa_scan_result *results, |
| 486 | size_t max_size) |
| 487 | { |
| 488 | if (wpa_s->driver->get_scan_results) { |
| 489 | return wpa_s->driver->get_scan_results(wpa_s->drv_priv, |
| 490 | results, max_size); |
| 491 | } |
| 492 | return -1; |
| 493 | } |
| 494 | |
| 495 | static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid) |
| 496 | { |
| 497 | if (wpa_s->driver->get_bssid) { |
| 498 | return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid); |
| 499 | } |
| 500 | return -1; |
| 501 | } |
| 502 | |
| 503 | static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid) |
| 504 | { |
| 505 | if (wpa_s->driver->get_ssid) { |
| 506 | return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid); |
| 507 | } |
| 508 | return -1; |
| 509 | } |
| 510 | |
| 511 | static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg, |
| 512 | const u8 *addr, int key_idx, int set_tx, |
| 513 | const u8 *seq, size_t seq_len, |
| 514 | const u8 *key, size_t key_len) |
| 515 | { |
| 516 | if (wpa_s->driver->set_key) { |
| 517 | wpa_s->keys_cleared = 0; |
| 518 | return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr, |
| 519 | key_idx, set_tx, seq, seq_len, |
| 520 | key, key_len); |
| 521 | } |
| 522 | return -1; |
| 523 | } |
| 524 | |
| 525 | static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s, |
| 526 | const u8 *addr, int reason_code) |
| 527 | { |
| 528 | if (wpa_s->driver->deauthenticate) { |
| 529 | return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr, |
| 530 | reason_code); |
| 531 | } |
| 532 | return -1; |
| 533 | } |
| 534 | |
| 535 | static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s, |
| 536 | const u8 *addr, int reason_code) |
| 537 | { |
| 538 | if (wpa_s->driver->disassociate) { |
| 539 | return wpa_s->driver->disassociate(wpa_s->drv_priv, addr, |
| 540 | reason_code); |
| 541 | } |
| 542 | return -1; |
| 543 | } |
| 544 | |
| 545 | static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s, |
| 546 | const u8 *bssid, const u8 *pmkid) |
| 547 | { |
| 548 | if (wpa_s->driver->add_pmkid) { |
| 549 | return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid); |
| 550 | } |
| 551 | return -1; |
| 552 | } |
| 553 | |
| 554 | static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s, |
| 555 | const u8 *bssid, const u8 *pmkid) |
| 556 | { |
| 557 | if (wpa_s->driver->remove_pmkid) { |
| 558 | return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid, |
| 559 | pmkid); |
| 560 | } |
| 561 | return -1; |
| 562 | } |
| 563 | |
| 564 | static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s) |
| 565 | { |
| 566 | if (wpa_s->driver->flush_pmkid) { |
| 567 | return wpa_s->driver->flush_pmkid(wpa_s->drv_priv); |
| 568 | } |
| 569 | return -1; |
| 570 | } |
| 571 | |
| 572 | static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s, |
| 573 | struct wpa_driver_capa *capa) |
| 574 | { |
| 575 | if (wpa_s->driver->get_capa) { |
| 576 | return wpa_s->driver->get_capa(wpa_s->drv_priv, capa); |
| 577 | } |
| 578 | return -1; |
| 579 | } |
| 580 | |
| 581 | static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s) |
| 582 | { |
| 583 | if (wpa_s->driver->poll) { |
| 584 | wpa_s->driver->poll(wpa_s->drv_priv); |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s) |
| 589 | { |
| 590 | if (wpa_s->driver->get_ifname) { |
| 591 | return wpa_s->driver->get_ifname(wpa_s->drv_priv); |
| 592 | } |
| 593 | return NULL; |
| 594 | } |
| 595 | |
| 596 | static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s) |
| 597 | { |
| 598 | if (wpa_s->driver->get_mac_addr) { |
| 599 | return wpa_s->driver->get_mac_addr(wpa_s->drv_priv); |
| 600 | } |
| 601 | return NULL; |
| 602 | } |
| 603 | |
| 604 | static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s, |
| 605 | const u8 *dst, u16 proto, |
| 606 | const u8 *data, size_t data_len) |
| 607 | { |
| 608 | if (wpa_s->driver->send_eapol) |
| 609 | return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto, |
| 610 | data, data_len); |
| 611 | return -1; |
| 612 | } |
| 613 | |
| 614 | static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s, |
| 615 | int state) |
| 616 | { |
| 617 | if (wpa_s->driver->set_operstate) |
| 618 | return wpa_s->driver->set_operstate(wpa_s->drv_priv, state); |
| 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s, |
| 623 | const u8 *addr, int protect_type, |
| 624 | int key_type) |
| 625 | { |
| 626 | if (wpa_s->driver->mlme_setprotection) |
| 627 | return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr, |
| 628 | protect_type, |
| 629 | key_type); |
| 630 | return 0; |
| 631 | } |
| 632 | |
| 633 | static inline struct wpa_hw_modes * |
| 634 | wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes, |
| 635 | u16 *flags) |
| 636 | { |
| 637 | if (wpa_s->driver->get_hw_feature_data) |
| 638 | return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv, |
| 639 | num_modes, flags); |
| 640 | return NULL; |
| 641 | } |
| 642 | |
| 643 | static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s, |
| 644 | wpa_hw_mode phymode, int chan, |
| 645 | int freq) |
| 646 | { |
| 647 | if (wpa_s->driver->set_channel) |
| 648 | return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode, |
| 649 | chan, freq); |
| 650 | return -1; |
| 651 | } |
| 652 | |
| 653 | static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s, |
| 654 | const u8 *ssid, size_t ssid_len) |
| 655 | { |
| 656 | if (wpa_s->driver->set_ssid) { |
| 657 | return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid, |
| 658 | ssid_len); |
| 659 | } |
| 660 | return -1; |
| 661 | } |
| 662 | |
| 663 | static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s, |
| 664 | const u8 *bssid) |
| 665 | { |
| 666 | if (wpa_s->driver->set_bssid) { |
| 667 | return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid); |
| 668 | } |
| 669 | return -1; |
| 670 | } |
| 671 | |
| 672 | static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s, |
| 673 | const u8 *data, size_t data_len) |
| 674 | { |
| 675 | if (wpa_s->driver->send_mlme) |
| 676 | return wpa_s->driver->send_mlme(wpa_s->drv_priv, |
| 677 | data, data_len); |
| 678 | return -1; |
| 679 | } |
| 680 | |
| 681 | static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s, |
| 682 | const u8 *addr, const u8 *supp_rates, |
| 683 | size_t supp_rates_len) |
| 684 | { |
| 685 | if (wpa_s->driver->mlme_add_sta) |
| 686 | return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr, |
| 687 | supp_rates, supp_rates_len); |
| 688 | return -1; |
| 689 | } |
| 690 | |
| 691 | static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s, |
| 692 | const u8 *addr) |
| 693 | { |
| 694 | if (wpa_s->driver->mlme_remove_sta) |
| 695 | return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr); |
| 696 | return -1; |
| 697 | } |
| 698 | |
| 699 | static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s, |
| 700 | char *cmd, char *buf, size_t buf_len) |
| 701 | { |
| 702 | if (wpa_s->driver->driver_cmd) |
| 703 | return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len); |
| 704 | return -1; |
| 705 | } |
| 706 | |
| 707 | #endif /* WPA_SUPPLICANT_I_H */ |