wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Functions
config.h File Reference

WPA Supplicant / Configuration file structures. More...

#include "config_ssid.h"
#include "wps/wps.h"
#include "common/ieee802_11_defs.h"
#include "common/ieee802_11_common.h"

Go to the source code of this file.

Data Structures

struct  wpa_cred
 
struct  wpa_cred::excluded_ssid
 
struct  wpa_cred::roaming_partner
 
struct  wpa_config
 wpa_supplicant configuration data More...
 

Macros

#define DEFAULT_EAPOL_VERSION   1
 
#define DEFAULT_AP_SCAN   1
 
#define DEFAULT_USER_MPM   1
 
#define DEFAULT_MAX_PEER_LINKS   99
 
#define DEFAULT_MESH_MAX_INACTIVITY   300
 
#define DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD   1000
 
#define DEFAULT_FAST_REAUTH   1
 
#define DEFAULT_P2P_GO_INTENT   7
 
#define DEFAULT_P2P_INTRA_BSS   1
 
#define DEFAULT_P2P_GO_MAX_INACTIVITY   (5 * 60)
 
#define DEFAULT_P2P_OPTIMIZE_LISTEN_CHAN   0
 
#define DEFAULT_BSS_MAX_COUNT   200
 
#define DEFAULT_BSS_EXPIRATION_AGE   180
 
#define DEFAULT_BSS_EXPIRATION_SCAN_COUNT   2
 
#define DEFAULT_MAX_NUM_STA   128
 
#define DEFAULT_ACCESS_NETWORK_TYPE   15
 
#define DEFAULT_SCAN_CUR_FREQ   0
 
#define DEFAULT_P2P_SEARCH_DELAY   500
 
#define DEFAULT_RAND_ADDR_LIFETIME   60
 
#define DEFAULT_KEY_MGMT_OFFLOAD   1
 
#define DEFAULT_CERT_IN_CB   1
 
#define DEFAULT_P2P_GO_CTWINDOW   0
 
#define CFG_CHANGED_DEVICE_NAME   BIT(0)
 
#define CFG_CHANGED_CONFIG_METHODS   BIT(1)
 
#define CFG_CHANGED_DEVICE_TYPE   BIT(2)
 
#define CFG_CHANGED_OS_VERSION   BIT(3)
 
#define CFG_CHANGED_UUID   BIT(4)
 
#define CFG_CHANGED_COUNTRY   BIT(5)
 
#define CFG_CHANGED_SEC_DEVICE_TYPE   BIT(6)
 
#define CFG_CHANGED_P2P_SSID_POSTFIX   BIT(7)
 
#define CFG_CHANGED_WPS_STRING   BIT(8)
 
#define CFG_CHANGED_P2P_INTRA_BSS   BIT(9)
 
#define CFG_CHANGED_VENDOR_EXTENSION   BIT(10)
 
#define CFG_CHANGED_P2P_LISTEN_CHANNEL   BIT(11)
 
#define CFG_CHANGED_P2P_OPER_CHANNEL   BIT(12)
 
#define CFG_CHANGED_P2P_PREF_CHAN   BIT(13)
 
#define CFG_CHANGED_EXT_PW_BACKEND   BIT(14)
 
#define CFG_CHANGED_NFC_PASSWORD_TOKEN   BIT(15)
 
#define CFG_CHANGED_P2P_PASSPHRASE_LEN   BIT(16)
 
#define MAX_SEC_DEVICE_TYPES   5
 
#define MAX_WPS_VENDOR_EXT   10
 
#define DEFAULT_P2P_GO_FREQ_MOVE   P2P_GO_FREQ_MOVE_STAY
 

Functions

void wpa_config_free (struct wpa_config *ssid)
 Free configuration data. More...
 
void wpa_config_free_ssid (struct wpa_ssid *ssid)
 Free network/ssid configuration data. More...
 
void wpa_config_foreach_network (struct wpa_config *config, void(*func)(void *, struct wpa_ssid *), void *arg)
 Iterate over each configured network. More...
 
struct wpa_ssidwpa_config_get_network (struct wpa_config *config, int id)
 Get configured network based on id. More...
 
struct wpa_ssidwpa_config_add_network (struct wpa_config *config)
 Add a new network with empty configuration. More...
 
int wpa_config_remove_network (struct wpa_config *config, int id)
 Remove a configured network based on id. More...
 
void wpa_config_set_network_defaults (struct wpa_ssid *ssid)
 Set network default values. More...
 
int wpa_config_set (struct wpa_ssid *ssid, const char *var, const char *value, int line)
 Set a variable in network configuration. More...
 
int wpa_config_set_quoted (struct wpa_ssid *ssid, const char *var, const char *value)
 
int wpa_config_dump_values (struct wpa_config *config, char *buf, size_t buflen)
 
int wpa_config_get_value (const char *name, struct wpa_config *config, char *buf, size_t buflen)
 
char ** wpa_config_get_all (struct wpa_ssid *ssid, int get_keys)
 Get all options from network configuration. More...
 
char * wpa_config_get (struct wpa_ssid *ssid, const char *var)
 Get a variable in network configuration. More...
 
char * wpa_config_get_no_key (struct wpa_ssid *ssid, const char *var)
 Get a variable in network configuration (no keys) More...
 
void wpa_config_update_psk (struct wpa_ssid *ssid)
 Update WPA PSK based on passphrase and SSID. More...
 
int wpa_config_add_prio_network (struct wpa_config *config, struct wpa_ssid *ssid)
 Add a network to priority lists. More...
 
int wpa_config_update_prio_list (struct wpa_config *config)
 Update network priority list. More...
 
const struct wpa_config_blobwpa_config_get_blob (struct wpa_config *config, const char *name)
 Get a named configuration blob. More...
 
void wpa_config_set_blob (struct wpa_config *config, struct wpa_config_blob *blob)
 Set or add a named configuration blob. More...
 
void wpa_config_free_blob (struct wpa_config_blob *blob)
 Free blob data. More...
 
int wpa_config_remove_blob (struct wpa_config *config, const char *name)
 Remove a named configuration blob. More...
 
void wpa_config_flush_blobs (struct wpa_config *config)
 
struct wpa_credwpa_config_get_cred (struct wpa_config *config, int id)
 
struct wpa_credwpa_config_add_cred (struct wpa_config *config)
 
int wpa_config_remove_cred (struct wpa_config *config, int id)
 
void wpa_config_free_cred (struct wpa_cred *cred)
 
int wpa_config_set_cred (struct wpa_cred *cred, const char *var, const char *value, int line)
 
char * wpa_config_get_cred_no_key (struct wpa_cred *cred, const char *var)
 
struct wpa_configwpa_config_alloc_empty (const char *ctrl_interface, const char *driver_param)
 Allocate an empty configuration. More...
 
void wpa_config_debug_dump_networks (struct wpa_config *config)
 Debug dump of configured networks. More...
 
int wpa_config_process_global (struct wpa_config *config, char *pos, int line)
 
struct wpa_configwpa_config_read (const char *name, struct wpa_config *cfgp)
 Read and parse configuration database. More...
 
int wpa_config_write (const char *name, struct wpa_config *config)
 Write or update configuration data. More...
 

Detailed Description

WPA Supplicant / Configuration file structures.

Function Documentation

struct wpa_ssid* wpa_config_add_network ( struct wpa_config config)

Add a new network with empty configuration.

Parameters
configConfiguration data from wpa_config_read()
Returns
The new network configuration or NULL if operation failed
int wpa_config_add_prio_network ( struct wpa_config config,
struct wpa_ssid ssid 
)

Add a network to priority lists.

Parameters
configConfiguration data from wpa_config_read()
ssidPointer to the network configuration to be added to the list
Returns
0 on success, -1 on failure

This function is used to add a network block to the priority list of networks. This must be called for each network when reading in the full configuration. In addition, this can be used indirectly when updating priorities by calling wpa_config_update_prio_list().

struct wpa_config* wpa_config_alloc_empty ( const char *  ctrl_interface,
const char *  driver_param 
)

Allocate an empty configuration.

Parameters
ctrl_interfaceControl interface parameters, e.g., path to UNIX domain socket
driver_paramDriver parameters
Returns
Pointer to allocated configuration data or NULL on failure
void wpa_config_debug_dump_networks ( struct wpa_config config)

Debug dump of configured networks.

Parameters
configConfiguration data from wpa_config_read()
void wpa_config_foreach_network ( struct wpa_config config,
void(*)(void *, struct wpa_ssid *)  func,
void *  arg 
)

Iterate over each configured network.

Parameters
configConfiguration data from wpa_config_read()
funcCallback function to process each network
argOpaque argument to pass to callback function

Iterate over the set of configured networks calling the specified function for each item. We guard against callbacks removing the supplied network.

void wpa_config_free ( struct wpa_config config)

Free configuration data.

Parameters
configConfiguration data from wpa_config_read()

This function frees all resources allocated for the configuration data by wpa_config_read().

void wpa_config_free_blob ( struct wpa_config_blob blob)

Free blob data.

Parameters
blobPointer to blob to be freed
void wpa_config_free_ssid ( struct wpa_ssid ssid)

Free network/ssid configuration data.

Parameters
ssidConfiguration data for the network

This function frees all resources allocated for the network configuration data.

char* wpa_config_get ( struct wpa_ssid ssid,
const char *  var 
)

Get a variable in network configuration.

Parameters
ssidPointer to network configuration data
varVariable name, e.g., "ssid"
Returns
Value of the variable or NULL on failure

This function can be used to get network configuration variables. The returned value is a copy of the configuration variable in text format, i.e,. the same format that the text-based configuration file and wpa_config_set() are using for the value. The caller is responsible for freeing the returned value.

char** wpa_config_get_all ( struct wpa_ssid ssid,
int  get_keys 
)

Get all options from network configuration.

Parameters
ssidPointer to network configuration data
get_keysDetermines if keys/passwords will be included in returned list (if they may be exported)
Returns
NULL terminated list of all set keys and their values in the form of [key1, val1, key2, val2, ... , NULL]

This function can be used to get list of all configured network properties. The caller is responsible for freeing the returned list and all its elements.

const struct wpa_config_blob* wpa_config_get_blob ( struct wpa_config config,
const char *  name 
)

Get a named configuration blob.

Parameters
configConfiguration data from wpa_config_read()
nameName of the blob
Returns
Pointer to blob data or NULL if not found
struct wpa_ssid* wpa_config_get_network ( struct wpa_config config,
int  id 
)

Get configured network based on id.

Parameters
configConfiguration data from wpa_config_read()
idUnique network id to search for
Returns
Network configuration or NULL if not found
char* wpa_config_get_no_key ( struct wpa_ssid ssid,
const char *  var 
)

Get a variable in network configuration (no keys)

Parameters
ssidPointer to network configuration data
varVariable name, e.g., "ssid"
Returns
Value of the variable or NULL on failure

This function can be used to get network configuration variable like wpa_config_get(). The only difference is that this functions does not expose key/password material from the configuration. In case a key/password field is requested, the returned value is an empty string or NULL if the variable is not set or "*" if the variable is set (regardless of its value). The returned value is a copy of the configuration variable in text format, i.e,. the same format that the text-based configuration file and wpa_config_set() are using for the value. The caller is responsible for freeing the returned value.

struct wpa_config* wpa_config_read ( const char *  name,
struct wpa_config cfgp 
)

Read and parse configuration database.

Parameters
nameName of the configuration (e.g., path and file name for the configuration file)
cfgpPointer to previously allocated configuration data or NULL if none
Returns
Pointer to allocated configuration data or NULL on failure

This function reads configuration data, parses its contents, and allocates data structures needed for storing configuration information. The allocated data can be freed with wpa_config_free().

Each configuration backend needs to implement this function.

int wpa_config_remove_blob ( struct wpa_config config,
const char *  name 
)

Remove a named configuration blob.

Parameters
configConfiguration data from wpa_config_read()
nameName of the blob to remove
Returns
0 if blob was removed or -1 if blob was not found
int wpa_config_remove_network ( struct wpa_config config,
int  id 
)

Remove a configured network based on id.

Parameters
configConfiguration data from wpa_config_read()
idUnique network id to search for
Returns
0 on success, or -1 if the network was not found
int wpa_config_set ( struct wpa_ssid ssid,
const char *  var,
const char *  value,
int  line 
)

Set a variable in network configuration.

Parameters
ssidPointer to network configuration data
varVariable name, e.g., "ssid"
valueVariable value
lineLine number in configuration file or 0 if not used
Returns
0 on success, -1 on failure

This function can be used to set network configuration variables based on both the configuration file and management interface input. The value parameter must be in the same format as the text-based configuration file is using. For example, strings are using double quotation marks.

void wpa_config_set_blob ( struct wpa_config config,
struct wpa_config_blob blob 
)

Set or add a named configuration blob.

Parameters
configConfiguration data from wpa_config_read()
blobNew value for the blob

Adds a new configuration blob or replaces the current value of an existing blob.

void wpa_config_set_network_defaults ( struct wpa_ssid ssid)

Set network default values.

Parameters
ssidPointer to network configuration data
int wpa_config_update_prio_list ( struct wpa_config config)

Update network priority list.

Parameters
configConfiguration data from wpa_config_read()
Returns
0 on success, -1 on failure

This function is called to update the priority list of networks in the configuration when a network is being added or removed. This is also called if a priority for a network is changed.

void wpa_config_update_psk ( struct wpa_ssid ssid)

Update WPA PSK based on passphrase and SSID.

Parameters
ssidPointer to network configuration data

This function must be called to update WPA PSK when either SSID or the passphrase has changed for the network configuration.

int wpa_config_write ( const char *  name,
struct wpa_config config 
)

Write or update configuration data.

Parameters
nameName of the configuration (e.g., path and file name for the configuration file)
configConfiguration data from wpa_config_read()
Returns
0 on success, -1 on failure

This function write all configuration data into an external database (e.g., a text file) in a format that can be read with wpa_config_read(). This can be used to allow wpa_supplicant to update its configuration, e.g., when a new network is added or a password is changed.

Each configuration backend needs to implement this function.