wpa_supplicant.c File Reference

WPA Supplicant. More...

#include "includes.h"
#include "common.h"
#include "eapol_sm.h"
#include "eap.h"
#include "wpa.h"
#include "eloop.h"
#include "wpa_supplicant.h"
#include "config.h"
#include "l2_packet.h"
#include "wpa_supplicant_i.h"
#include "ctrl_iface.h"
#include "ctrl_iface_dbus.h"
#include "pcsc_funcs.h"
#include "version.h"
#include "preauth.h"
#include "pmksa_cache.h"
#include "wpa_ctrl.h"
#include "mlme.h"

Include dependency graph for wpa_supplicant.c:

Go to the source code of this file.

Defines

#define SCAN_AP_LIMIT   128

Functions

wpa_blacklist * wpa_blacklist_get (struct wpa_supplicant *wpa_s, const u8 *bssid)
 Get the blacklist entry for a BSSID.
int wpa_blacklist_add (struct wpa_supplicant *wpa_s, const u8 *bssid)
 Add an BSSID to the blacklist.
void wpa_blacklist_clear (struct wpa_supplicant *wpa_s)
 Clear the blacklist of all entries.
void wpa_supplicant_req_scan (struct wpa_supplicant *wpa_s, int sec, int usec)
 Schedule a scan for neighboring access points.
void wpa_supplicant_cancel_scan (struct wpa_supplicant *wpa_s)
 Cancel a scheduled scan request.
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.
wpa_states wpa_supplicant_get_state (struct wpa_supplicant *wpa_s)
 Get the 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_result *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_result *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.
int wpa_supplicant_get_scan_results (struct wpa_supplicant *wpa_s)
 Get scan results.
wpa_ssidwpa_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.
int wpa_supplicant_driver_init (struct wpa_supplicant *wpa_s, int wait_for_interface)
 Initialize driver interface parameters.
wpa_supplicantwpa_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.
wpa_supplicantwpa_supplicant_get_iface (struct wpa_global *global, const char *ifname)
 Get a new network interface.
wpa_globalwpa_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
wpa_driver_opswpa_supplicant_drivers []
int wpa_debug_use_file
int wpa_debug_level
int wpa_debug_show_keys
int wpa_debug_timestamp


Detailed Description

WPA Supplicant.

Copyright
Copyright (c) 2003-2006, Jouni Malinen <[email protected]>
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.

Definition in file wpa_supplicant.c.


Function Documentation

int wpa_blacklist_add struct wpa_supplicant wpa_s,
const u8 *  bssid
 

Add an BSSID to the blacklist.

Parameters:
wpa_s Pointer to wpa_supplicant data
bssid BSSID to be added to the blacklist
Returns:
0 on success, -1 on failure
This function adds the specified BSSID to the blacklist or increases the blacklist count if the BSSID was already listed. It should be called when an association attempt fails either due to the selected BSS rejecting association or due to timeout.

This blacklist is used to force wpa_supplicant to go through all available BSSes before retrying to associate with an BSS that rejected or timed out association. It does not prevent the listed BSS from being used; it only changes the order in which they are tried.

Definition at line 418 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_blacklist_clear struct wpa_supplicant wpa_s  ) 
 

Clear the blacklist of all entries.

Parameters:
wpa_s Pointer to wpa_supplicant data

Definition at line 474 of file wpa_supplicant.c.

Here is the call graph for this function:

struct wpa_blacklist* wpa_blacklist_get struct wpa_supplicant wpa_s,
const u8 *  bssid
 

Get the blacklist entry for a BSSID.

Parameters:
wpa_s Pointer to wpa_supplicant data
bssid BSSID
Returns:
Matching blacklist entry for the BSSID or NULL if not found

Definition at line 385 of file wpa_supplicant.c.

void wpa_clear_keys struct wpa_supplicant wpa_s,
const u8 *  addr
 

Clear keys configured for the driver.

Parameters:
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.

Definition at line 739 of file wpa_supplicant.c.

Here is the call graph for this function:

struct wpa_supplicant* wpa_supplicant_add_iface struct wpa_global global,
struct wpa_interface iface
 

Add a new network interface.

Parameters:
global Pointer to global data from wpa_supplicant_init()
iface Interface configuration options
Returns:
Pointer to the created interface or NULL on failure
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.

Definition at line 2386 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_associate struct wpa_supplicant wpa_s,
struct wpa_scan_result bss,
struct wpa_ssid ssid
 

Request association.

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
This function is used to request wpa_supplicant to associate with a BSS.

Definition at line 1336 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_cancel_auth_timeout struct wpa_supplicant wpa_s  ) 
 

Cancel authentication timeout.

Parameters:
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.

Definition at line 573 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_cancel_scan struct wpa_supplicant wpa_s  ) 
 

Cancel a scheduled scan request.

Parameters:
wpa_s Pointer to wpa_supplicant data
This function is used to cancel a scan request scheduled with wpa_supplicant_req_scan().

Definition at line 517 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_deauthenticate struct wpa_supplicant wpa_s,
int  reason_code
 

Deauthenticate the current connection.

Parameters:
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 disassociate with the current AP.

Definition at line 1604 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_deinit struct wpa_global global  ) 
 

Deinitialize wpa_supplicant.

Parameters:
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.

Definition at line 2608 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_disassociate struct wpa_supplicant wpa_s,
int  reason_code
 

Disassociate the current connection.

Parameters:
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.

Definition at line 1573 of file wpa_supplicant.c.

Here is the call graph for this function:

int wpa_supplicant_driver_init struct wpa_supplicant wpa_s,
int  wait_for_interface
 

Initialize driver interface parameters.

Parameters:
wpa_s Pointer to wpa_supplicant data
wait_for_interface 0 = do not wait for the interface (reports a failure if the interface is not present), 1 = wait until the interface is available
Returns:
0 on success, -1 on failure
This function is called to initialize driver interface parameters. wpa_drv_init() must have been called before this function to initialize the driver interface.

Definition at line 1981 of file wpa_supplicant.c.

Here is the call graph for this function:

struct wpa_supplicant* wpa_supplicant_get_iface struct wpa_global global,
const char *  ifname
 

Get a new network interface.

Parameters:
global Pointer to global data from wpa_supplicant_init()
ifname Interface name
Returns:
Pointer to the interface or NULL if not found

Definition at line 2471 of file wpa_supplicant.c.

int wpa_supplicant_get_scan_results struct wpa_supplicant wpa_s  ) 
 

Get scan results.

Parameters:
wpa_s Pointer to wpa_supplicant data
Returns:
0 on success, -1 on failure
This function is request the current scan results from the driver and stores a local copy of the results in wpa_s->scan_results.

Definition at line 1636 of file wpa_supplicant.c.

Here is the call graph for this function:

struct wpa_ssid* wpa_supplicant_get_ssid struct wpa_supplicant wpa_s  ) 
 

Get a pointer to the current network structure.

Parameters:
wpa_s Pointer to wpa_supplicant data
Returns:
A pointer to the current network structure or NULL on failure

Definition at line 1743 of file wpa_supplicant.c.

Here is the call graph for this function:

wpa_states wpa_supplicant_get_state struct wpa_supplicant wpa_s  ) 
 

Get the connection state.

Parameters:
wpa_s Pointer to wpa_supplicant data
Returns:
The current connection state (WPA_*)

Definition at line 851 of file wpa_supplicant.c.

struct wpa_global* wpa_supplicant_init struct wpa_params params  ) 
 

Initialize wpa_supplicant.

Parameters:
params Parameters for wpa_supplicant
Returns:
Pointer to global wpa_supplicant data, or NULL on failure
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.

Definition at line 2494 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_initiate_eapol struct wpa_supplicant wpa_s  ) 
 

Configure EAPOL state machine.

Parameters:
wpa_s Pointer to wpa_supplicant data
This function is used to configure EAPOL state machine based on the selected authentication mode.

Definition at line 589 of file wpa_supplicant.c.

Here is the call graph for this function:

int wpa_supplicant_reload_configuration struct wpa_supplicant wpa_s  ) 
 

Reload configuration data.

Parameters:
wpa_s Pointer to wpa_supplicant data
Returns:
0 on success or -1 if configuration parsing failed
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.

Definition at line 892 of file wpa_supplicant.c.

Here is the call graph for this function:

int wpa_supplicant_remove_iface struct wpa_global global,
struct wpa_supplicant wpa_s
 

Remove a network interface.

Parameters:
global Pointer to global data from wpa_supplicant_init()
wpa_s Pointer to the network interface to be removed
Returns:
0 if interface was removed, -1 if interface was not found
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 interdaces when wpa_supplicant is terminated.

Definition at line 2438 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_req_auth_timeout struct wpa_supplicant wpa_s,
int  sec,
int  usec
 

Schedule a timeout for authentication.

Parameters:
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.

Definition at line 550 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_req_scan struct wpa_supplicant wpa_s,
int  sec,
int  usec
 

Schedule a scan for neighboring access points.

Parameters:
wpa_s Pointer to wpa_supplicant data
sec Number of seconds after which to scan
usec Number of microseconds after which to scan
This function is used to schedule a scan for neighboring access points after the specified time.

Definition at line 500 of file wpa_supplicant.c.

Here is the call graph for this function:

int wpa_supplicant_run struct wpa_global global  ) 
 

Run the wpa_supplicant main event loop.

Parameters:
global Pointer to global data from wpa_supplicant_init()
Returns:
0 after successful event loop run, -1 on failure
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.

Definition at line 2576 of file wpa_supplicant.c.

Here is the call graph for this function:

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.

Parameters:
ctx Context pointer (wpa_s)
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.

Definition at line 1924 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_set_non_wpa_policy struct wpa_supplicant wpa_s,
struct wpa_ssid ssid
 

Set WPA parameters to non-WPA mode.

Parameters:
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.

Definition at line 642 of file wpa_supplicant.c.

Here is the call graph for this function:

void wpa_supplicant_set_state struct wpa_supplicant wpa_s,
wpa_states  state
 

Set current connection state.

Parameters:
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.

Definition at line 814 of file wpa_supplicant.c.

Here is the call graph for this function:

int wpa_supplicant_set_suites struct wpa_supplicant wpa_s,
struct wpa_scan_result bss,
struct wpa_ssid ssid,
u8 *  wpa_ie,
size_t *  wpa_ie_len
 

Set authentication and encryption parameters.

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.
Returns:
0 on success or -1 on failure
This function is used to configure authentication and encryption parameters based on the network configuration and scan result for the selected BSS (if available).

Definition at line 1177 of file wpa_supplicant.c.

Here is the call graph for this function:

const char* wpa_supplicant_state_txt int  state  ) 
 

Get the connection state name as a text string.

Parameters:
state State (wpa_state; WPA_*)
Returns:
The state name as a printable text string

Definition at line 780 of file wpa_supplicant.c.


Variable Documentation

const char* wpa_supplicant_full_license1
 

Initial value:

"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"

Definition at line 58 of file wpa_supplicant.c.

const char* wpa_supplicant_full_license2
 

Initial value:

"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"

Definition at line 68 of file wpa_supplicant.c.

const char* wpa_supplicant_full_license3
 

Initial value:

"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"

Definition at line 80 of file wpa_supplicant.c.

const char* wpa_supplicant_full_license4
 

Initial value:

"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"

Definition at line 88 of file wpa_supplicant.c.

const char* wpa_supplicant_full_license5
 

Initial value:

"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"

Definition at line 97 of file wpa_supplicant.c.

const char* wpa_supplicant_license
 

Initial value:

"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"

Definition at line 44 of file wpa_supplicant.c.

const char* wpa_supplicant_version
 

Initial value:

"wpa_supplicant v" VERSION_STR "\n"
"Copyright (c) 2003-2006, Jouni Malinen <[email protected]> and contributors"

Definition at line 40 of file wpa_supplicant.c.


Generated on Sun Dec 31 13:55:32 2006 for wpa_supplicant by  doxygen 1.4.2