WPA Supplicant. More...
#include "includes.h"#include "common.h"#include "eapol_supp/eapol_supp_sm.h"#include "eap_peer/eap.h"#include "eap_server/eap_methods.h"#include "wpa.h"#include "eloop.h"#include "config.h"#include "l2_packet/l2_packet.h"#include "wpa_supplicant_i.h"#include "driver_i.h"#include "ctrl_iface.h"#include "pcsc_funcs.h"#include "version.h"#include "preauth.h"#include "pmksa_cache.h"#include "wpa_ctrl.h"#include "mlme.h"#include "ieee802_11_defs.h"#include "blacklist.h"#include "wpas_glue.h"#include "wps_supplicant.h"#include "ibss_rsn.h"#include "sme.h"#include "ap.h"#include "notify.h"#include "bgscan.h"Functions | |
| int | wpa_set_wep_keys (struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) |
| void | wpa_supplicant_req_auth_timeout (struct wpa_supplicant *wpa_s, int sec, int usec) |
| Schedule a timeout for authentication. | |
| void | wpa_supplicant_cancel_auth_timeout (struct wpa_supplicant *wpa_s) |
| Cancel authentication timeout. | |
| void | wpa_supplicant_initiate_eapol (struct wpa_supplicant *wpa_s) |
| Configure EAPOL state machine. | |
| void | wpa_supplicant_set_non_wpa_policy (struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) |
| Set WPA parameters to non-WPA mode. | |
| void | wpa_clear_keys (struct wpa_supplicant *wpa_s, const u8 *addr) |
| Clear keys configured for the driver. | |
| const char * | wpa_supplicant_state_txt (int state) |
| Get the connection state name as a text string. | |
| void | wpa_supplicant_set_state (struct wpa_supplicant *wpa_s, wpa_states state) |
| Set current connection state. | |
| int | wpa_supplicant_reload_configuration (struct wpa_supplicant *wpa_s) |
| Reload configuration data. | |
| int | wpa_supplicant_set_suites (struct wpa_supplicant *wpa_s, struct wpa_scan_res *bss, struct wpa_ssid *ssid, u8 *wpa_ie, size_t *wpa_ie_len) |
| Set authentication and encryption parameters. | |
| void | wpa_supplicant_associate (struct wpa_supplicant *wpa_s, struct wpa_scan_res *bss, struct wpa_ssid *ssid) |
| Request association. | |
| void | wpa_supplicant_disassociate (struct wpa_supplicant *wpa_s, int reason_code) |
| Disassociate the current connection. | |
| void | wpa_supplicant_deauthenticate (struct wpa_supplicant *wpa_s, int reason_code) |
| Deauthenticate the current connection. | |
| void | wpa_supplicant_enable_network (struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) |
| Mark a configured network as enabled. | |
| void | wpa_supplicant_disable_network (struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) |
| Mark a configured network as disabled. | |
| void | wpa_supplicant_select_network (struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) |
| Attempt association with a network. | |
| int | wpa_supplicant_set_ap_scan (struct wpa_supplicant *wpa_s, int ap_scan) |
| Set AP scan mode for interface. | |
| int | wpa_supplicant_set_debug_params (struct wpa_global *global, int debug_level, int debug_timestamp, int debug_show_keys) |
| Set global debug params. | |
| int | wpa_supplicant_get_scan_results (struct wpa_supplicant *wpa_s) |
| Get scan results. | |
| struct wpa_ssid * | wpa_supplicant_get_ssid (struct wpa_supplicant *wpa_s) |
| Get a pointer to the current network structure. | |
| void | wpa_supplicant_rx_eapol (void *ctx, const u8 *src_addr, const u8 *buf, size_t len) |
| Deliver a received EAPOL frame to wpa_supplicant. | |
| void | wpa_supplicant_sta_rx (void *ctx, const u8 *buf, size_t len, struct ieee80211_rx_status *rx_status) |
| int | wpa_supplicant_driver_init (struct wpa_supplicant *wpa_s) |
| Initialize driver interface parameters. | |
| struct wpa_supplicant * | wpa_supplicant_add_iface (struct wpa_global *global, struct wpa_interface *iface) |
| Add a new network interface. | |
| int | wpa_supplicant_remove_iface (struct wpa_global *global, struct wpa_supplicant *wpa_s) |
| Remove a network interface. | |
| struct wpa_supplicant * | wpa_supplicant_get_iface (struct wpa_global *global, const char *ifname) |
| Get a new network interface. | |
| struct wpa_global * | wpa_supplicant_init (struct wpa_params *params) |
| Initialize wpa_supplicant. | |
| int | wpa_supplicant_run (struct wpa_global *global) |
| Run the wpa_supplicant main event loop. | |
| void | wpa_supplicant_deinit (struct wpa_global *global) |
| Deinitialize wpa_supplicant. | |
Variables | |
| const char * | wpa_supplicant_version |
| const char * | wpa_supplicant_license |
| const char * | wpa_supplicant_full_license1 |
| const char * | wpa_supplicant_full_license2 |
| const char * | wpa_supplicant_full_license3 |
| const char * | wpa_supplicant_full_license4 |
| const char * | wpa_supplicant_full_license5 |
| int | wpa_debug_level |
| int | wpa_debug_show_keys |
| int | wpa_debug_timestamp |
| struct wpa_driver_ops * | wpa_drivers [] |
WPA Supplicant.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
Alternatively, this software may be distributed under the terms of BSD license.
See README and COPYING for more details.
This file implements functions for registering and unregistering wpa_supplicant interfaces. In addition, this file contains number of functions for managing network connections.
| void wpa_clear_keys | ( | struct wpa_supplicant * | wpa_s, | |
| const u8 * | addr | |||
| ) |
Clear keys configured for the driver.
| wpa_s | Pointer to wpa_supplicant data | |
| addr | Previously used BSSID or NULL if not available |
This function clears the encryption keys that has been previously configured for the driver.
| struct wpa_supplicant* wpa_supplicant_add_iface | ( | struct wpa_global * | global, | |
| struct wpa_interface * | iface | |||
| ) | [read] |
Add a new network interface.
| global | Pointer to global data from wpa_supplicant_init() | |
| iface | Interface configuration options |
This function is used to add new network interfaces for wpa_supplicant. This can be called before wpa_supplicant_run() to add interfaces before the main event loop has been started. In addition, new interfaces can be added dynamically while wpa_supplicant is already running. This could happen, e.g., when a hotplug network adapter is inserted.
| void wpa_supplicant_associate | ( | struct wpa_supplicant * | wpa_s, | |
| struct wpa_scan_res * | bss, | |||
| struct wpa_ssid * | ssid | |||
| ) |
Request association.
| wpa_s | Pointer to wpa_supplicant data | |
| bss | Scan results for the selected BSS, or NULL if not available | |
| ssid | Configuration data for the selected network |
This function is used to request wpa_supplicant to associate with a BSS.
| void wpa_supplicant_cancel_auth_timeout | ( | struct wpa_supplicant * | wpa_s | ) |
Cancel authentication timeout.
| wpa_s | Pointer to wpa_supplicant data |
This function is used to cancel authentication timeout scheduled with wpa_supplicant_req_auth_timeout() and it is called when authentication has been completed.
| void wpa_supplicant_deauthenticate | ( | struct wpa_supplicant * | wpa_s, | |
| int | reason_code | |||
| ) |
Deauthenticate the current connection.
| wpa_s | Pointer to wpa_supplicant data | |
| reason_code | IEEE 802.11 reason code for the deauthenticate frame |
This function is used to request wpa_supplicant to deauthenticate from the current AP.
| void wpa_supplicant_deinit | ( | struct wpa_global * | global | ) |
Deinitialize wpa_supplicant.
| global | Pointer to global data from wpa_supplicant_init() |
This function is called to deinitialize wpa_supplicant and to free all allocated resources. Remaining network interfaces will also be removed.
| void wpa_supplicant_disable_network | ( | struct wpa_supplicant * | wpa_s, | |
| struct wpa_ssid * | ssid | |||
| ) |
Mark a configured network as disabled.
| wpa_s | wpa_supplicant structure for a network interface | |
| ssid | wpa_ssid structure for a configured network or NULL |
Disables the specified network or all networks if no network specified.
| void wpa_supplicant_disassociate | ( | struct wpa_supplicant * | wpa_s, | |
| int | reason_code | |||
| ) |
Disassociate the current connection.
| wpa_s | Pointer to wpa_supplicant data | |
| reason_code | IEEE 802.11 reason code for the disassociate frame |
This function is used to request wpa_supplicant to disassociate with the current AP.
| int wpa_supplicant_driver_init | ( | struct wpa_supplicant * | wpa_s | ) |
Initialize driver interface parameters.
| wpa_s | Pointer to wpa_supplicant data |
This function is called to initialize driver interface parameters. wpa_drv_init() must have been called before this function to initialize the driver interface.
| void wpa_supplicant_enable_network | ( | struct wpa_supplicant * | wpa_s, | |
| struct wpa_ssid * | ssid | |||
| ) |
Mark a configured network as enabled.
| wpa_s | wpa_supplicant structure for a network interface | |
| ssid | wpa_ssid structure for a configured network or NULL |
Enables the specified network or all networks if no network specified.
| struct wpa_supplicant* wpa_supplicant_get_iface | ( | struct wpa_global * | global, | |
| const char * | ifname | |||
| ) | [read] |
Get a new network interface.
| global | Pointer to global data from wpa_supplicant_init() | |
| ifname | Interface name |
| int wpa_supplicant_get_scan_results | ( | struct wpa_supplicant * | wpa_s | ) |
Get scan results.
| wpa_s | Pointer to wpa_supplicant data |
This function is request the current scan results from the driver and stores a local copy of the results in wpa_s->scan_res.
| struct wpa_ssid* wpa_supplicant_get_ssid | ( | struct wpa_supplicant * | wpa_s | ) | [read] |
Get a pointer to the current network structure.
| wpa_s | Pointer to wpa_supplicant data |
| struct wpa_global* wpa_supplicant_init | ( | struct wpa_params * | params | ) | [read] |
Initialize wpa_supplicant.
| params | Parameters for wpa_supplicant |
This function is used to initialize wpa_supplicant. After successful initialization, the returned data pointer can be used to add and remove network interfaces, and eventually, to deinitialize wpa_supplicant.
| void wpa_supplicant_initiate_eapol | ( | struct wpa_supplicant * | wpa_s | ) |
Configure EAPOL state machine.
| wpa_s | Pointer to wpa_supplicant data |
This function is used to configure EAPOL state machine based on the selected authentication mode.
| int wpa_supplicant_reload_configuration | ( | struct wpa_supplicant * | wpa_s | ) |
Reload configuration data.
| wpa_s | Pointer to wpa_supplicant data |
This function can be used to request that the configuration data is reloaded (e.g., after configuration file change). This function is reloading configuration only for one interface, so this may need to be called multiple times if wpa_supplicant is controlling multiple interfaces and all interfaces need reconfiguration.
| int wpa_supplicant_remove_iface | ( | struct wpa_global * | global, | |
| struct wpa_supplicant * | wpa_s | |||
| ) |
Remove a network interface.
| global | Pointer to global data from wpa_supplicant_init() | |
| wpa_s | Pointer to the network interface to be removed |
This function can be used to dynamically remove network interfaces from wpa_supplicant, e.g., when a hotplug network adapter is ejected. In addition, this function is used to remove all remaining interfaces when wpa_supplicant is terminated.
| void wpa_supplicant_req_auth_timeout | ( | struct wpa_supplicant * | wpa_s, | |
| int | sec, | |||
| int | usec | |||
| ) |
Schedule a timeout for authentication.
| wpa_s | Pointer to wpa_supplicant data | |
| sec | Number of seconds after which to time out authentication | |
| usec | Number of microseconds after which to time out authentication |
This function is used to schedule a timeout for the current authentication attempt.
| int wpa_supplicant_run | ( | struct wpa_global * | global | ) |
Run the wpa_supplicant main event loop.
| global | Pointer to global data from wpa_supplicant_init() |
This function starts the main event loop and continues running as long as there are any remaining events. In most cases, this function is running as long as the wpa_supplicant process in still in use.
| void wpa_supplicant_rx_eapol | ( | void * | ctx, | |
| const u8 * | src_addr, | |||
| const u8 * | buf, | |||
| size_t | len | |||
| ) |
Deliver a received EAPOL frame to wpa_supplicant.
| ctx | Context pointer (wpa_s); this is the ctx variable registered with struct wpa_driver_ops::init() | |
| src_addr | Source address of the EAPOL frame | |
| buf | EAPOL data starting from the EAPOL header (i.e., no Ethernet header) | |
| len | Length of the EAPOL data |
This function is called for each received EAPOL frame. Most driver interfaces rely on more generic OS mechanism for receiving frames through l2_packet, but if such a mechanism is not available, the driver wrapper may take care of received EAPOL frames and deliver them to the core supplicant code by calling this function.
| void wpa_supplicant_select_network | ( | struct wpa_supplicant * | wpa_s, | |
| struct wpa_ssid * | ssid | |||
| ) |
Attempt association with a network.
| wpa_s | wpa_supplicant structure for a network interface | |
| ssid | wpa_ssid structure for a configured network or NULL for any network |
| int wpa_supplicant_set_ap_scan | ( | struct wpa_supplicant * | wpa_s, | |
| int | ap_scan | |||
| ) |
Set AP scan mode for interface.
| wpa_s | wpa_supplicant structure for a network interface | |
| ap_scan | AP scan mode |
| int wpa_supplicant_set_debug_params | ( | struct wpa_global * | global, | |
| int | debug_level, | |||
| int | debug_timestamp, | |||
| int | debug_show_keys | |||
| ) |
Set global debug params.
| global | wpa_global structure | |
| debug_level | debug level | |
| debug_timestamp | determines if show timestamp in debug data | |
| debug_show_keys | determines if show keys in debug data |
| void wpa_supplicant_set_non_wpa_policy | ( | struct wpa_supplicant * | wpa_s, | |
| struct wpa_ssid * | ssid | |||
| ) |
Set WPA parameters to non-WPA mode.
| wpa_s | Pointer to wpa_supplicant data | |
| ssid | Configuration data for the network |
This function is used to configure WPA state machine and related parameters to a mode where WPA is not enabled. This is called as part of the authentication configuration when the selected network does not use WPA.
| void wpa_supplicant_set_state | ( | struct wpa_supplicant * | wpa_s, | |
| wpa_states | state | |||
| ) |
Set current connection state.
| wpa_s | Pointer to wpa_supplicant data | |
| state | The new connection state |
This function is called whenever the connection state changes, e.g., association is completed for WPA/WPA2 4-Way Handshake is started.
| int wpa_supplicant_set_suites | ( | struct wpa_supplicant * | wpa_s, | |
| struct wpa_scan_res * | bss, | |||
| struct wpa_ssid * | ssid, | |||
| u8 * | wpa_ie, | |||
| size_t * | wpa_ie_len | |||
| ) |
Set authentication and encryption parameters.
| wpa_s | Pointer to wpa_supplicant data | |
| bss | Scan results for the selected BSS, or NULL if not available | |
| ssid | Configuration data for the selected network | |
| wpa_ie | Buffer for the WPA/RSN IE | |
| wpa_ie_len | Maximum wpa_ie buffer size on input. This is changed to be the used buffer length in case the functions returns success. |
This function is used to configure authentication and encryption parameters based on the network configuration and scan result for the selected BSS (if available).
| const char* wpa_supplicant_state_txt | ( | int | state | ) |
Get the connection state name as a text string.
| state | State (wpa_state; WPA_*) |
| const char* wpa_supplicant_full_license1 |
"This program is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License version 2 as\n" "published by the Free Software Foundation.\n" "\n" "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n" "\n"
| const char* wpa_supplicant_full_license2 |
"You should have received a copy of the GNU General Public License\n" "along with this program; if not, write to the Free Software\n" "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n" "\n" "Alternatively, this software may be distributed under the terms of the\n" "BSD license.\n" "\n" "Redistribution and use in source and binary forms, with or without\n" "modification, are permitted provided that the following conditions are\n" "met:\n" "\n"
| const char* wpa_supplicant_full_license3 |
"1. Redistributions of source code must retain the above copyright\n" " notice, this list of conditions and the following disclaimer.\n" "\n" "2. Redistributions in binary form must reproduce the above copyright\n" " notice, this list of conditions and the following disclaimer in the\n" " documentation and/or other materials provided with the distribution.\n" "\n"
| const char* wpa_supplicant_full_license4 |
"3. Neither the name(s) of the above-listed copyright holder(s) nor the\n" " names of its contributors may be used to endorse or promote products\n" " derived from this software without specific prior written permission.\n" "\n" "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" "\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n" "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
| const char* wpa_supplicant_full_license5 |
"OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" "LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" "\n"
| const char* wpa_supplicant_license |
"This program is free software. You can distribute it and/or modify it\n" "under the terms of the GNU General Public License version 2.\n" "\n" "Alternatively, this software may be distributed under the terms of the\n" "BSD license. See README and COPYING for more details.\n"
| const char* wpa_supplicant_version |
"wpa_supplicant v" VERSION_STR "\n" "Copyright (c) 2003-2009, Jouni Malinen <j@w1.fi> and contributors"
1.6.1