wpa_supplicant / hostapd
2.5
|
WPA Supplicant / Configuration parser and common functions. More...
#include "includes.h"
#include "common.h"
#include "utils/uuid.h"
#include "utils/ip_addr.h"
#include "crypto/sha1.h"
#include "rsn_supp/wpa.h"
#include "eap_peer/eap.h"
#include "p2p/p2p.h"
#include "fst/fst.h"
#include "config.h"
Data Structures | |
struct | parse_data |
struct | global_parse_data |
Macros | |
#define | OFFSET(v) ((void *) &((struct wpa_ssid *) 0)->v) |
#define | _STR(f) #f, wpa_config_parse_str, wpa_config_write_str, OFFSET(f) |
#define | _STRe(f) #f, wpa_config_parse_str, wpa_config_write_str, OFFSET(eap.f) |
#define | STR(f) _STR(f), NULL, NULL, NULL, 0 |
#define | STRe(f) _STRe(f), NULL, NULL, NULL, 0 |
#define | STR_KEY(f) _STR(f), NULL, NULL, NULL, 1 |
#define | STR_KEYe(f) _STRe(f), NULL, NULL, NULL, 1 |
#define | _STR_LEN(f) _STR(f), OFFSET(f ## _len) |
#define | _STR_LENe(f) _STRe(f), OFFSET(eap.f ## _len) |
#define | STR_LEN(f) _STR_LEN(f), NULL, NULL, 0 |
#define | STR_LENe(f) _STR_LENe(f), NULL, NULL, 0 |
#define | STR_LEN_KEY(f) _STR_LEN(f), NULL, NULL, 1 |
#define | _STR_RANGE(f, min, max) _STR_LEN(f), (void *) (min), (void *) (max) |
#define | STR_RANGE(f, min, max) _STR_RANGE(f, min, max), 0 |
#define | STR_RANGE_KEY(f, min, max) _STR_RANGE(f, min, max), 1 |
#define | _INT(f) |
#define | _INTe(f) |
#define | INT(f) _INT(f), NULL, NULL, 0 |
#define | INTe(f) _INTe(f), NULL, NULL, 0 |
#define | INT_RANGE(f, min, max) _INT(f), (void *) (min), (void *) (max), 0 |
#define | _FUNC(f) |
#define | FUNC(f) _FUNC(f), 0 |
#define | FUNC_KEY(f) _FUNC(f), 1 |
#define | NUM_SSID_FIELDS ARRAY_SIZE(ssid_fields) |
#define | OFFSET(v) ((void *) &((struct wpa_config *) 0)->v) |
#define | FUNC(f) #f, wpa_config_process_ ## f, NULL, OFFSET(f), NULL, NULL |
#define | FUNC_NO_VAR(f) #f, wpa_config_process_ ## f, NULL, NULL, NULL, NULL |
#define | _INT(f) #f, wpa_global_config_parse_int, wpa_config_get_int, OFFSET(f) |
#define | INT(f) _INT(f), NULL, NULL |
#define | INT_RANGE(f, min, max) _INT(f), (void *) min, (void *) max |
#define | _STR(f) #f, wpa_global_config_parse_str, wpa_config_get_str, OFFSET(f) |
#define | STR(f) _STR(f), NULL, NULL |
#define | STR_RANGE(f, min, max) _STR(f), (void *) min, (void *) max |
#define | BIN(f) #f, wpa_global_config_parse_bin, NULL, OFFSET(f), NULL, NULL |
#define | IPV4(f) |
#define | NUM_GLOBAL_FIELDS ARRAY_SIZE(global_fields) |
Functions | |
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... | |
void | wpa_config_free_ssid (struct wpa_ssid *ssid) |
Free network/ssid configuration data. More... | |
void | wpa_config_free_cred (struct wpa_cred *cred) |
void | wpa_config_flush_blobs (struct wpa_config *config) |
void | wpa_config_free (struct wpa_config *config) |
Free 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_ssid * | wpa_config_get_network (struct wpa_config *config, int id) |
Get configured network based on id. More... | |
struct wpa_ssid * | wpa_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) |
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_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_cred * | wpa_config_get_cred (struct wpa_config *config, int id) |
struct wpa_cred * | wpa_config_add_cred (struct wpa_config *config) |
int | wpa_config_remove_cred (struct wpa_config *config, int id) |
const struct wpa_config_blob * | wpa_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... | |
struct wpa_config * | wpa_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_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) |
int | wpa_config_process_global (struct wpa_config *config, char *pos, int line) |
WPA Supplicant / Configuration parser and common functions.
#define _FUNC | ( | f | ) |
#define _INT | ( | f | ) |
#define _INTe | ( | f | ) |
#define IPV4 | ( | f | ) |
struct wpa_ssid* wpa_config_add_network | ( | struct wpa_config * | config | ) |
Add a new network with empty configuration.
config | Configuration data from wpa_config_read() |
int wpa_config_add_prio_network | ( | struct wpa_config * | config, |
struct wpa_ssid * | ssid | ||
) |
Add a network to priority lists.
config | Configuration data from wpa_config_read() |
ssid | Pointer to the network configuration to be added to the list |
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.
ctrl_interface | Control interface parameters, e.g., path to UNIX domain socket |
driver_param | Driver parameters |
void wpa_config_debug_dump_networks | ( | struct wpa_config * | config | ) |
Debug dump of configured networks.
config | Configuration 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.
config | Configuration data from wpa_config_read() |
func | Callback function to process each network |
arg | Opaque 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.
config | Configuration 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.
blob | Pointer to blob to be freed |
void wpa_config_free_ssid | ( | struct wpa_ssid * | ssid | ) |
Free network/ssid configuration data.
ssid | Configuration 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.
ssid | Pointer to network configuration data |
var | Variable name, e.g., "ssid" |
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.
ssid | Pointer to network configuration data |
get_keys | Determines if keys/passwords will be included in returned list (if they may be exported) |
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.
config | Configuration data from wpa_config_read() |
name | Name of the blob |
struct wpa_ssid* wpa_config_get_network | ( | struct wpa_config * | config, |
int | id | ||
) |
Get configured network based on id.
config | Configuration data from wpa_config_read() |
id | Unique network id to search for |
char* wpa_config_get_no_key | ( | struct wpa_ssid * | ssid, |
const char * | var | ||
) |
Get a variable in network configuration (no keys)
ssid | Pointer to network configuration data |
var | Variable name, e.g., "ssid" |
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.
int wpa_config_remove_blob | ( | struct wpa_config * | config, |
const char * | name | ||
) |
Remove a named configuration blob.
config | Configuration data from wpa_config_read() |
name | Name of the blob to remove |
int wpa_config_remove_network | ( | struct wpa_config * | config, |
int | id | ||
) |
Remove a configured network based on id.
config | Configuration data from wpa_config_read() |
id | Unique network id to search for |
int wpa_config_set | ( | struct wpa_ssid * | ssid, |
const char * | var, | ||
const char * | value, | ||
int | line | ||
) |
Set a variable in network configuration.
ssid | Pointer to network configuration data |
var | Variable name, e.g., "ssid" |
value | Variable value |
line | Line number in configuration file or 0 if not used |
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.
config | Configuration data from wpa_config_read() |
blob | New 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.
ssid | Pointer to network configuration data |
int wpa_config_update_prio_list | ( | struct wpa_config * | config | ) |
Update network priority list.
config | Configuration data from wpa_config_read() |
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.
ssid | Pointer 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.