2 * WPA Supplicant / Configuration file structures
3 * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #define DEFAULT_EAPOL_VERSION 1
19 #ifdef CONFIG_NO_SCAN_PROCESSING
20 #define DEFAULT_AP_SCAN 2
21 #else /* CONFIG_NO_SCAN_PROCESSING */
22 #define DEFAULT_AP_SCAN 1
23 #endif /* CONFIG_NO_SCAN_PROCESSING */
24 #define DEFAULT_FAST_REAUTH 1
25 #define DEFAULT_P2P_GO_INTENT 7
26 #define DEFAULT_P2P_INTRA_BSS 1
27 #define DEFAULT_BSS_MAX_COUNT 200
28 #define DEFAULT_BSS_EXPIRATION_AGE 180
29 #define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2
30 #define DEFAULT_MAX_NUM_STA 128
31 #define DEFAULT_ACCESS_NETWORK_TYPE 15
33 #include "config_ssid.h"
37 #define CFG_CHANGED_DEVICE_NAME BIT(0)
38 #define CFG_CHANGED_CONFIG_METHODS BIT(1)
39 #define CFG_CHANGED_DEVICE_TYPE BIT(2)
40 #define CFG_CHANGED_OS_VERSION BIT(3)
41 #define CFG_CHANGED_UUID BIT(4)
42 #define CFG_CHANGED_COUNTRY BIT(5)
43 #define CFG_CHANGED_SEC_DEVICE_TYPE BIT(6)
44 #define CFG_CHANGED_P2P_SSID_POSTFIX BIT(7)
45 #define CFG_CHANGED_WPS_STRING BIT(8)
46 #define CFG_CHANGED_P2P_INTRA_BSS BIT(9)
47 #define CFG_CHANGED_VENDOR_EXTENSION BIT(10)
48 #define CFG_CHANGED_P2P_LISTEN_CHANNEL BIT(11)
49 #define CFG_CHANGED_P2P_OPER_CHANNEL BIT(12)
52 * struct wpa_config - wpa_supplicant configuration data
54 * This data structure is presents the per-interface (radio) configuration
55 * data. In many cases, there is only one struct wpa_config instance, but if
56 * more than one network interface is being controlled, one instance is used
61 * ssid - Head of the global network list
63 * This is the head for the list of all the configured networks.
65 struct wpa_ssid
*ssid
;
68 * pssid - Per-priority network lists (in priority order)
70 struct wpa_ssid
**pssid
;
73 * num_prio - Number of different priorities used in the pssid lists
75 * This indicates how many per-priority network lists are included in
81 * eapol_version - IEEE 802.1X/EAPOL version number
83 * wpa_supplicant is implemented based on IEEE Std 802.1X-2004 which
84 * defines EAPOL version 2. However, there are many APs that do not
85 * handle the new version number correctly (they seem to drop the
86 * frames completely). In order to make wpa_supplicant interoperate
87 * with these APs, the version number is set to 1 by default. This
88 * configuration value can be used to set it to the new version (2).
93 * ap_scan - AP scanning/selection
95 * By default, wpa_supplicant requests driver to perform AP
96 * scanning and then uses the scan results to select a
97 * suitable AP. Another alternative is to allow the driver to
98 * take care of AP scanning and selection and use
99 * wpa_supplicant just to process EAPOL frames based on IEEE
100 * 802.11 association information from the driver.
102 * 1: wpa_supplicant initiates scanning and AP selection (default).
104 * 0: Driver takes care of scanning, AP selection, and IEEE 802.11
105 * association parameters (e.g., WPA IE generation); this mode can
106 * also be used with non-WPA drivers when using IEEE 802.1X mode;
107 * do not try to associate with APs (i.e., external program needs
108 * to control association). This mode must also be used when using
109 * wired Ethernet drivers.
111 * 2: like 0, but associate with APs using security policy and SSID
112 * (but not BSSID); this can be used, e.g., with ndiswrapper and NDIS
113 * drivers to enable operation with hidden SSIDs and optimized roaming;
114 * in this mode, the network blocks in the configuration are tried
115 * one by one until the driver reports successful association; each
116 * network block should have explicit security policy (i.e., only one
117 * option in the lists) for key_mgmt, pairwise, group, proto variables.
122 * ctrl_interface - Parameters for the control interface
124 * If this is specified, %wpa_supplicant will open a control interface
125 * that is available for external programs to manage %wpa_supplicant.
126 * The meaning of this string depends on which control interface
127 * mechanism is used. For all cases, the existence of this parameter
128 * in configuration is used to determine whether the control interface
131 * For UNIX domain sockets (default on Linux and BSD): This is a
132 * directory that will be created for UNIX domain sockets for listening
133 * to requests from external programs (CLI/GUI, etc.) for status
134 * information and configuration. The socket file will be named based
135 * on the interface name, so multiple %wpa_supplicant processes can be
136 * run at the same time if more than one interface is used.
137 * /var/run/wpa_supplicant is the recommended directory for sockets and
138 * by default, wpa_cli will use it when trying to connect with
141 * Access control for the control interface can be configured
142 * by setting the directory to allow only members of a group
143 * to use sockets. This way, it is possible to run
144 * %wpa_supplicant as root (since it needs to change network
145 * configuration and open raw sockets) and still allow GUI/CLI
146 * components to be run as non-root users. However, since the
147 * control interface can be used to change the network
148 * configuration, this access needs to be protected in many
149 * cases. By default, %wpa_supplicant is configured to use gid
150 * 0 (root). If you want to allow non-root users to use the
151 * control interface, add a new group and change this value to
152 * match with that group. Add users that should have control
153 * interface access to this group.
155 * When configuring both the directory and group, use following format:
156 * DIR=/var/run/wpa_supplicant GROUP=wheel
157 * DIR=/var/run/wpa_supplicant GROUP=0
158 * (group can be either group name or gid)
160 * For UDP connections (default on Windows): The value will be ignored.
161 * This variable is just used to select that the control interface is
162 * to be created. The value can be set to, e.g., udp
163 * (ctrl_interface=udp).
165 * For Windows Named Pipe: This value can be used to set the security
166 * descriptor for controlling access to the control interface. Security
167 * descriptor can be set using Security Descriptor String Format (see
168 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/security/security_descriptor_string_format.asp).
169 * The descriptor string needs to be prefixed with SDDL=. For example,
170 * ctrl_interface=SDDL=D: would set an empty DACL (which will reject
173 char *ctrl_interface
;
176 * ctrl_interface_group - Control interface group (DEPRECATED)
178 * This variable is only used for backwards compatibility. Group for
179 * UNIX domain sockets should now be specified using GROUP=group in
180 * ctrl_interface variable.
182 char *ctrl_interface_group
;
185 * fast_reauth - EAP fast re-authentication (session resumption)
187 * By default, fast re-authentication is enabled for all EAP methods
188 * that support it. This variable can be used to disable fast
189 * re-authentication (by setting fast_reauth=0). Normally, there is no
190 * need to disable fast re-authentication.
195 * opensc_engine_path - Path to the OpenSSL engine for opensc
197 * This is an OpenSSL specific configuration option for loading OpenSC
198 * engine (engine_opensc.so); if %NULL, this engine is not loaded.
200 char *opensc_engine_path
;
203 * pkcs11_engine_path - Path to the OpenSSL engine for PKCS#11
205 * This is an OpenSSL specific configuration option for loading PKCS#11
206 * engine (engine_pkcs11.so); if %NULL, this engine is not loaded.
208 char *pkcs11_engine_path
;
211 * pkcs11_module_path - Path to the OpenSSL OpenSC/PKCS#11 module
213 * This is an OpenSSL specific configuration option for configuring
214 * path to OpenSC/PKCS#11 engine (opensc-pkcs11.so); if %NULL, this
215 * module is not loaded.
217 char *pkcs11_module_path
;
220 * driver_param - Driver interface parameters
222 * This text string is passed to the selected driver interface with the
223 * optional struct wpa_driver_ops::set_param() handler. This can be
224 * used to configure driver specific options without having to add new
225 * driver interface functionality.
230 * dot11RSNAConfigPMKLifetime - Maximum lifetime of a PMK
232 * dot11 MIB variable for the maximum lifetime of a PMK in the PMK
233 * cache (unit: seconds).
235 unsigned int dot11RSNAConfigPMKLifetime
;
238 * dot11RSNAConfigPMKReauthThreshold - PMK re-authentication threshold
240 * dot11 MIB variable for the percentage of the PMK lifetime
241 * that should expire before an IEEE 802.1X reauthentication occurs.
243 unsigned int dot11RSNAConfigPMKReauthThreshold
;
246 * dot11RSNAConfigSATimeout - Security association timeout
248 * dot11 MIB variable for the maximum time a security association
249 * shall take to set up (unit: seconds).
251 unsigned int dot11RSNAConfigSATimeout
;
254 * update_config - Is wpa_supplicant allowed to update configuration
256 * This variable control whether wpa_supplicant is allow to re-write
257 * its configuration with wpa_config_write(). If this is zero,
258 * configuration data is only changed in memory and the external data
259 * is not overriden. If this is non-zero, wpa_supplicant will update
260 * the configuration data (e.g., a file) whenever configuration is
261 * changed. This update may replace the old configuration which can
262 * remove comments from it in case of a text file configuration.
267 * blobs - Configuration blobs
269 struct wpa_config_blob
*blobs
;
272 * uuid - Universally Unique IDentifier (UUID; see RFC 4122) for WPS
277 * device_name - Device Name (WPS)
278 * User-friendly description of device; up to 32 octets encoded in
284 * manufacturer - Manufacturer (WPS)
285 * The manufacturer of the device (up to 64 ASCII characters)
290 * model_name - Model Name (WPS)
291 * Model of the device (up to 32 ASCII characters)
296 * model_number - Model Number (WPS)
297 * Additional device description (up to 32 ASCII characters)
302 * serial_number - Serial Number (WPS)
303 * Serial number of the device (up to 32 characters)
308 * device_type - Primary Device Type (WPS)
310 u8 device_type
[WPS_DEV_TYPE_LEN
];
313 * config_methods - Config Methods
315 * This is a space-separated list of supported WPS configuration
316 * methods. For example, "label virtual_display virtual_push_button
318 * Available methods: usba ethernet label display ext_nfc_token
319 * int_nfc_token nfc_interface push_button keypad
320 * virtual_display physical_display
321 * virtual_push_button physical_push_button.
323 char *config_methods
;
326 * os_version - OS Version (WPS)
327 * 4-octet operating system version number
332 * country - Country code
334 * This is the ISO/IEC alpha2 country code for which we are operating
340 * wps_cred_processing - Credential processing
342 * 0 = process received credentials internally
343 * 1 = do not process received credentials; just pass them over
344 * ctrl_iface to external program(s)
345 * 2 = process received credentials internally and pass them over
346 * ctrl_iface to external program(s)
348 int wps_cred_processing
;
350 #define MAX_SEC_DEVICE_TYPES 5
352 * sec_device_types - Secondary Device Types (P2P)
354 u8 sec_device_type
[MAX_SEC_DEVICE_TYPES
][WPS_DEV_TYPE_LEN
];
355 int num_sec_device_types
;
357 int p2p_listen_reg_class
;
358 int p2p_listen_channel
;
359 int p2p_oper_reg_class
;
360 int p2p_oper_channel
;
362 char *p2p_ssid_postfix
;
363 int persistent_reconnect
;
366 #define MAX_WPS_VENDOR_EXT 10
368 * wps_vendor_ext - Vendor extension attributes in WPS
370 struct wpabuf
*wps_vendor_ext
[MAX_WPS_VENDOR_EXT
];
373 * p2p_group_idle - Maximum idle time in seconds for P2P group
375 * This value controls how long a P2P group is maintained after there
376 * is no other members in the group. As a GO, this means no associated
377 * stations in the group. As a P2P client, this means no GO seen in
378 * scan results. The maximum idle time is specified in seconds with 0
379 * indicating no time limit, i.e., the P2P group remains in active
380 * state indefinitely until explicitly removed.
382 unsigned int p2p_group_idle
;
385 * bss_max_count - Maximum number of BSS entries to keep in memory
387 unsigned int bss_max_count
;
390 * bss_expiration_age - BSS entry age after which it can be expired
392 * This value controls the time in seconds after which a BSS entry
393 * gets removed if it has not been updated or is not in use.
395 unsigned int bss_expiration_age
;
398 * bss_expiration_scan_count - Expire BSS after number of scans
400 * If the BSS entry has not been seen in this many scans, it will be
401 * removed. A value of 1 means that entry is removed after the first
402 * scan in which the BSSID is not seen. Larger values can be used
403 * to avoid BSS entries disappearing if they are not visible in
404 * every scan (e.g., low signal quality or interference).
406 unsigned int bss_expiration_scan_count
;
409 * filter_ssids - SSID-based scan result filtering
411 * 0 = do not filter scan results
412 * 1 = only include configured SSIDs in scan results/BSS table
417 * max_num_sta - Maximum number of STAs in an AP/P2P GO
419 unsigned int max_num_sta
;
422 * changed_parameters - Bitmap of changed parameters since last update
424 unsigned int changed_parameters
;
427 * disassoc_low_ack - Disassocicate stations with massive packet loss
429 int disassoc_low_ack
;
432 * interworking - Whether Interworking (IEEE 802.11u) is enabled
437 * access_network_type - Access Network Type
439 * When Interworking is enabled, scans will be limited to APs that
440 * advertise the specified Access Network Type (0..15; with 15
441 * indicating wildcard match).
443 int access_network_type
;
446 * hessid - Homogenous ESS identifier
448 * If this is set (any octet is non-zero), scans will be used to
449 * request response only from BSSes belonging to the specified
450 * Homogeneous ESS. This is used only if interworking is enabled.
455 * home_realm - Home Realm for Interworking
460 * home_username - Username for Interworking network selection
465 * home_password - Password for Interworking network selection
470 * home_ca_cert - CA certificate for Interworking network selection
475 * home_imsi - IMSI in <MCC> | <MNC> | '-' | <MSIN> format
480 * home_milenage - Milenage parameters for SIM/USIM simulator in
481 * <Ki>:<OPc>:<SQN> format
487 /* Prototypes for common functions from config.c */
489 void wpa_config_free(struct wpa_config
*ssid
);
490 void wpa_config_free_ssid(struct wpa_ssid
*ssid
);
491 void wpa_config_foreach_network(struct wpa_config
*config
,
492 void (*func
)(void *, struct wpa_ssid
*),
494 struct wpa_ssid
* wpa_config_get_network(struct wpa_config
*config
, int id
);
495 struct wpa_ssid
* wpa_config_add_network(struct wpa_config
*config
);
496 int wpa_config_remove_network(struct wpa_config
*config
, int id
);
497 void wpa_config_set_network_defaults(struct wpa_ssid
*ssid
);
498 int wpa_config_set(struct wpa_ssid
*ssid
, const char *var
, const char *value
,
500 int wpa_config_set_quoted(struct wpa_ssid
*ssid
, const char *var
,
502 char ** wpa_config_get_all(struct wpa_ssid
*ssid
, int get_keys
);
503 char * wpa_config_get(struct wpa_ssid
*ssid
, const char *var
);
504 char * wpa_config_get_no_key(struct wpa_ssid
*ssid
, const char *var
);
505 void wpa_config_update_psk(struct wpa_ssid
*ssid
);
506 int wpa_config_add_prio_network(struct wpa_config
*config
,
507 struct wpa_ssid
*ssid
);
508 int wpa_config_update_prio_list(struct wpa_config
*config
);
509 const struct wpa_config_blob
* wpa_config_get_blob(struct wpa_config
*config
,
511 void wpa_config_set_blob(struct wpa_config
*config
,
512 struct wpa_config_blob
*blob
);
513 void wpa_config_free_blob(struct wpa_config_blob
*blob
);
514 int wpa_config_remove_blob(struct wpa_config
*config
, const char *name
);
516 struct wpa_config
* wpa_config_alloc_empty(const char *ctrl_interface
,
517 const char *driver_param
);
518 #ifndef CONFIG_NO_STDOUT_DEBUG
519 void wpa_config_debug_dump_networks(struct wpa_config
*config
);
520 #else /* CONFIG_NO_STDOUT_DEBUG */
521 #define wpa_config_debug_dump_networks(c) do { } while (0)
522 #endif /* CONFIG_NO_STDOUT_DEBUG */
525 /* Prototypes for common functions from config.c */
526 int wpa_config_process_global(struct wpa_config
*config
, char *pos
, int line
);
529 /* Prototypes for backend specific functions from the selected config_*.c */
532 * wpa_config_read - Read and parse configuration database
533 * @name: Name of the configuration (e.g., path and file name for the
534 * configuration file)
535 * Returns: Pointer to allocated configuration data or %NULL on failure
537 * This function reads configuration data, parses its contents, and allocates
538 * data structures needed for storing configuration information. The allocated
539 * data can be freed with wpa_config_free().
541 * Each configuration backend needs to implement this function.
543 struct wpa_config
* wpa_config_read(const char *name
);
546 * wpa_config_write - Write or update configuration data
547 * @name: Name of the configuration (e.g., path and file name for the
548 * configuration file)
549 * @config: Configuration data from wpa_config_read()
550 * Returns: 0 on success, -1 on failure
552 * This function write all configuration data into an external database (e.g.,
553 * a text file) in a format that can be read with wpa_config_read(). This can
554 * be used to allow wpa_supplicant to update its configuration, e.g., when a
555 * new network is added or a password is changed.
557 * Each configuration backend needs to implement this function.
559 int wpa_config_write(const char *name
, struct wpa_config
*config
);
561 #endif /* CONFIG_H */