1189251Ssam/*
2189251Ssam * WPA Supplicant / Configuration file structures
3252726Srpaulo * Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
4189251Ssam *
5252726Srpaulo * This software may be distributed under the terms of the BSD license.
6252726Srpaulo * See README for more details.
7189251Ssam */
8189251Ssam
9189251Ssam#ifndef CONFIG_H
10189251Ssam#define CONFIG_H
11189251Ssam
12189251Ssam#define DEFAULT_EAPOL_VERSION 1
13189251Ssam#ifdef CONFIG_NO_SCAN_PROCESSING
14189251Ssam#define DEFAULT_AP_SCAN 2
15189251Ssam#else /* CONFIG_NO_SCAN_PROCESSING */
16189251Ssam#define DEFAULT_AP_SCAN 1
17189251Ssam#endif /* CONFIG_NO_SCAN_PROCESSING */
18189251Ssam#define DEFAULT_FAST_REAUTH 1
19252726Srpaulo#define DEFAULT_P2P_GO_INTENT 7
20252726Srpaulo#define DEFAULT_P2P_INTRA_BSS 1
21252726Srpaulo#define DEFAULT_P2P_GO_MAX_INACTIVITY (5 * 60)
22214734Srpaulo#define DEFAULT_BSS_MAX_COUNT 200
23252726Srpaulo#define DEFAULT_BSS_EXPIRATION_AGE 180
24252726Srpaulo#define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2
25252726Srpaulo#define DEFAULT_MAX_NUM_STA 128
26252726Srpaulo#define DEFAULT_ACCESS_NETWORK_TYPE 15
27189251Ssam
28189251Ssam#include "config_ssid.h"
29252726Srpaulo#include "wps/wps.h"
30252726Srpaulo#include "common/ieee802_11_common.h"
31189251Ssam
32189251Ssam
33252726Srpaulostruct wpa_cred {
34252726Srpaulo	/**
35252726Srpaulo	 * next - Next credential in the list
36252726Srpaulo	 *
37252726Srpaulo	 * This pointer can be used to iterate over all credentials. The head
38252726Srpaulo	 * of this list is stored in the cred field of struct wpa_config.
39252726Srpaulo	 */
40252726Srpaulo	struct wpa_cred *next;
41252726Srpaulo
42252726Srpaulo	/**
43252726Srpaulo	 * id - Unique id for the credential
44252726Srpaulo	 *
45252726Srpaulo	 * This identifier is used as a unique identifier for each credential
46252726Srpaulo	 * block when using the control interface. Each credential is allocated
47252726Srpaulo	 * an id when it is being created, either when reading the
48252726Srpaulo	 * configuration file or when a new credential is added through the
49252726Srpaulo	 * control interface.
50252726Srpaulo	 */
51252726Srpaulo	int id;
52252726Srpaulo
53252726Srpaulo	/**
54252726Srpaulo	 * priority - Priority group
55252726Srpaulo	 *
56252726Srpaulo	 * By default, all networks and credentials get the same priority group
57252726Srpaulo	 * (0). This field can be used to give higher priority for credentials
58252726Srpaulo	 * (and similarly in struct wpa_ssid for network blocks) to change the
59252726Srpaulo	 * Interworking automatic networking selection behavior. The matching
60252726Srpaulo	 * network (based on either an enabled network block or a credential)
61252726Srpaulo	 * with the highest priority value will be selected.
62252726Srpaulo	 */
63252726Srpaulo	int priority;
64252726Srpaulo
65252726Srpaulo	/**
66252726Srpaulo	 * pcsc - Use PC/SC and SIM/USIM card
67252726Srpaulo	 */
68252726Srpaulo	int pcsc;
69252726Srpaulo
70252726Srpaulo	/**
71252726Srpaulo	 * realm - Home Realm for Interworking
72252726Srpaulo	 */
73252726Srpaulo	char *realm;
74252726Srpaulo
75252726Srpaulo	/**
76252726Srpaulo	 * username - Username for Interworking network selection
77252726Srpaulo	 */
78252726Srpaulo	char *username;
79252726Srpaulo
80252726Srpaulo	/**
81252726Srpaulo	 * password - Password for Interworking network selection
82252726Srpaulo	 */
83252726Srpaulo	char *password;
84252726Srpaulo
85252726Srpaulo	/**
86252726Srpaulo	 * ext_password - Whether password is a name for external storage
87252726Srpaulo	 */
88252726Srpaulo	int ext_password;
89252726Srpaulo
90252726Srpaulo	/**
91252726Srpaulo	 * ca_cert - CA certificate for Interworking network selection
92252726Srpaulo	 */
93252726Srpaulo	char *ca_cert;
94252726Srpaulo
95252726Srpaulo	/**
96252726Srpaulo	 * client_cert - File path to client certificate file (PEM/DER)
97252726Srpaulo	 *
98252726Srpaulo	 * This field is used with Interworking networking selection for a case
99252726Srpaulo	 * where client certificate/private key is used for authentication
100252726Srpaulo	 * (EAP-TLS). Full path to the file should be used since working
101252726Srpaulo	 * directory may change when wpa_supplicant is run in the background.
102252726Srpaulo	 *
103252726Srpaulo	 * Alternatively, a named configuration blob can be used by setting
104252726Srpaulo	 * this to blob://blob_name.
105252726Srpaulo	 */
106252726Srpaulo	char *client_cert;
107252726Srpaulo
108252726Srpaulo	/**
109252726Srpaulo	 * private_key - File path to client private key file (PEM/DER/PFX)
110252726Srpaulo	 *
111252726Srpaulo	 * When PKCS#12/PFX file (.p12/.pfx) is used, client_cert should be
112252726Srpaulo	 * commented out. Both the private key and certificate will be read
113252726Srpaulo	 * from the PKCS#12 file in this case. Full path to the file should be
114252726Srpaulo	 * used since working directory may change when wpa_supplicant is run
115252726Srpaulo	 * in the background.
116252726Srpaulo	 *
117252726Srpaulo	 * Windows certificate store can be used by leaving client_cert out and
118252726Srpaulo	 * configuring private_key in one of the following formats:
119252726Srpaulo	 *
120252726Srpaulo	 * cert://substring_to_match
121252726Srpaulo	 *
122252726Srpaulo	 * hash://certificate_thumbprint_in_hex
123252726Srpaulo	 *
124252726Srpaulo	 * For example: private_key="hash://63093aa9c47f56ae88334c7b65a4"
125252726Srpaulo	 *
126252726Srpaulo	 * Note that when running wpa_supplicant as an application, the user
127252726Srpaulo	 * certificate store (My user account) is used, whereas computer store
128252726Srpaulo	 * (Computer account) is used when running wpasvc as a service.
129252726Srpaulo	 *
130252726Srpaulo	 * Alternatively, a named configuration blob can be used by setting
131252726Srpaulo	 * this to blob://blob_name.
132252726Srpaulo	 */
133252726Srpaulo	char *private_key;
134252726Srpaulo
135252726Srpaulo	/**
136252726Srpaulo	 * private_key_passwd - Password for private key file
137252726Srpaulo	 */
138252726Srpaulo	char *private_key_passwd;
139252726Srpaulo
140252726Srpaulo	/**
141252726Srpaulo	 * imsi - IMSI in <MCC> | <MNC> | '-' | <MSIN> format
142252726Srpaulo	 */
143252726Srpaulo	char *imsi;
144252726Srpaulo
145252726Srpaulo	/**
146252726Srpaulo	 * milenage - Milenage parameters for SIM/USIM simulator in
147252726Srpaulo	 *	<Ki>:<OPc>:<SQN> format
148252726Srpaulo	 */
149252726Srpaulo	char *milenage;
150252726Srpaulo
151252726Srpaulo	/**
152252726Srpaulo	 * domain - Home service provider FQDN
153252726Srpaulo	 *
154252726Srpaulo	 * This is used to compare against the Domain Name List to figure out
155252726Srpaulo	 * whether the AP is operated by the Home SP.
156252726Srpaulo	 */
157252726Srpaulo	char *domain;
158252726Srpaulo
159252726Srpaulo	/**
160252726Srpaulo	 * roaming_consortium - Roaming Consortium OI
161252726Srpaulo	 *
162252726Srpaulo	 * If roaming_consortium_len is non-zero, this field contains the
163252726Srpaulo	 * Roaming Consortium OI that can be used to determine which access
164252726Srpaulo	 * points support authentication with this credential. This is an
165252726Srpaulo	 * alternative to the use of the realm parameter. When using Roaming
166252726Srpaulo	 * Consortium to match the network, the EAP parameters need to be
167252726Srpaulo	 * pre-configured with the credential since the NAI Realm information
168252726Srpaulo	 * may not be available or fetched.
169252726Srpaulo	 */
170252726Srpaulo	u8 roaming_consortium[15];
171252726Srpaulo
172252726Srpaulo	/**
173252726Srpaulo	 * roaming_consortium_len - Length of roaming_consortium
174252726Srpaulo	 */
175252726Srpaulo	size_t roaming_consortium_len;
176252726Srpaulo
177252726Srpaulo	/**
178252726Srpaulo	 * eap_method - EAP method to use
179252726Srpaulo	 *
180252726Srpaulo	 * Pre-configured EAP method to use with this credential or %NULL to
181252726Srpaulo	 * indicate no EAP method is selected, i.e., the method will be
182252726Srpaulo	 * selected automatically based on ANQP information.
183252726Srpaulo	 */
184252726Srpaulo	struct eap_method_type *eap_method;
185252726Srpaulo
186252726Srpaulo	/**
187252726Srpaulo	 * phase1 - Phase 1 (outer authentication) parameters
188252726Srpaulo	 *
189252726Srpaulo	 * Pre-configured EAP parameters or %NULL.
190252726Srpaulo	 */
191252726Srpaulo	char *phase1;
192252726Srpaulo
193252726Srpaulo	/**
194252726Srpaulo	 * phase2 - Phase 2 (inner authentication) parameters
195252726Srpaulo	 *
196252726Srpaulo	 * Pre-configured EAP parameters or %NULL.
197252726Srpaulo	 */
198252726Srpaulo	char *phase2;
199252726Srpaulo
200252726Srpaulo	struct excluded_ssid {
201252726Srpaulo		u8 ssid[MAX_SSID_LEN];
202252726Srpaulo		size_t ssid_len;
203252726Srpaulo	} *excluded_ssid;
204252726Srpaulo	size_t num_excluded_ssid;
205252726Srpaulo};
206252726Srpaulo
207252726Srpaulo
208252726Srpaulo#define CFG_CHANGED_DEVICE_NAME BIT(0)
209252726Srpaulo#define CFG_CHANGED_CONFIG_METHODS BIT(1)
210252726Srpaulo#define CFG_CHANGED_DEVICE_TYPE BIT(2)
211252726Srpaulo#define CFG_CHANGED_OS_VERSION BIT(3)
212252726Srpaulo#define CFG_CHANGED_UUID BIT(4)
213252726Srpaulo#define CFG_CHANGED_COUNTRY BIT(5)
214252726Srpaulo#define CFG_CHANGED_SEC_DEVICE_TYPE BIT(6)
215252726Srpaulo#define CFG_CHANGED_P2P_SSID_POSTFIX BIT(7)
216252726Srpaulo#define CFG_CHANGED_WPS_STRING BIT(8)
217252726Srpaulo#define CFG_CHANGED_P2P_INTRA_BSS BIT(9)
218252726Srpaulo#define CFG_CHANGED_VENDOR_EXTENSION BIT(10)
219252726Srpaulo#define CFG_CHANGED_P2P_LISTEN_CHANNEL BIT(11)
220252726Srpaulo#define CFG_CHANGED_P2P_OPER_CHANNEL BIT(12)
221252726Srpaulo#define CFG_CHANGED_P2P_PREF_CHAN BIT(13)
222252726Srpaulo#define CFG_CHANGED_EXT_PW_BACKEND BIT(14)
223252726Srpaulo
224189251Ssam/**
225189251Ssam * struct wpa_config - wpa_supplicant configuration data
226189251Ssam *
227189251Ssam * This data structure is presents the per-interface (radio) configuration
228189251Ssam * data. In many cases, there is only one struct wpa_config instance, but if
229189251Ssam * more than one network interface is being controlled, one instance is used
230189251Ssam * for each.
231189251Ssam */
232189251Ssamstruct wpa_config {
233189251Ssam	/**
234189251Ssam	 * ssid - Head of the global network list
235189251Ssam	 *
236189251Ssam	 * This is the head for the list of all the configured networks.
237189251Ssam	 */
238189251Ssam	struct wpa_ssid *ssid;
239189251Ssam
240189251Ssam	/**
241189251Ssam	 * pssid - Per-priority network lists (in priority order)
242189251Ssam	 */
243189251Ssam	struct wpa_ssid **pssid;
244189251Ssam
245189251Ssam	/**
246189251Ssam	 * num_prio - Number of different priorities used in the pssid lists
247189251Ssam	 *
248189251Ssam	 * This indicates how many per-priority network lists are included in
249189251Ssam	 * pssid.
250189251Ssam	 */
251189251Ssam	int num_prio;
252189251Ssam
253189251Ssam	/**
254252726Srpaulo	 * cred - Head of the credential list
255252726Srpaulo	 *
256252726Srpaulo	 * This is the head for the list of all the configured credentials.
257252726Srpaulo	 */
258252726Srpaulo	struct wpa_cred *cred;
259252726Srpaulo
260252726Srpaulo	/**
261189251Ssam	 * eapol_version - IEEE 802.1X/EAPOL version number
262189251Ssam	 *
263189251Ssam	 * wpa_supplicant is implemented based on IEEE Std 802.1X-2004 which
264189251Ssam	 * defines EAPOL version 2. However, there are many APs that do not
265189251Ssam	 * handle the new version number correctly (they seem to drop the
266189251Ssam	 * frames completely). In order to make wpa_supplicant interoperate
267189251Ssam	 * with these APs, the version number is set to 1 by default. This
268189251Ssam	 * configuration value can be used to set it to the new version (2).
269189251Ssam	 */
270189251Ssam	int eapol_version;
271189251Ssam
272189251Ssam	/**
273189251Ssam	 * ap_scan - AP scanning/selection
274189251Ssam	 *
275189251Ssam	 * By default, wpa_supplicant requests driver to perform AP
276189251Ssam	 * scanning and then uses the scan results to select a
277189251Ssam	 * suitable AP. Another alternative is to allow the driver to
278189251Ssam	 * take care of AP scanning and selection and use
279189251Ssam	 * wpa_supplicant just to process EAPOL frames based on IEEE
280189251Ssam	 * 802.11 association information from the driver.
281189251Ssam	 *
282189251Ssam	 * 1: wpa_supplicant initiates scanning and AP selection (default).
283189251Ssam	 *
284189251Ssam	 * 0: Driver takes care of scanning, AP selection, and IEEE 802.11
285189251Ssam	 * association parameters (e.g., WPA IE generation); this mode can
286189251Ssam	 * also be used with non-WPA drivers when using IEEE 802.1X mode;
287189251Ssam	 * do not try to associate with APs (i.e., external program needs
288189251Ssam	 * to control association). This mode must also be used when using
289189251Ssam	 * wired Ethernet drivers.
290189251Ssam	 *
291189251Ssam	 * 2: like 0, but associate with APs using security policy and SSID
292189251Ssam	 * (but not BSSID); this can be used, e.g., with ndiswrapper and NDIS
293189251Ssam	 * drivers to enable operation with hidden SSIDs and optimized roaming;
294189251Ssam	 * in this mode, the network blocks in the configuration are tried
295189251Ssam	 * one by one until the driver reports successful association; each
296189251Ssam	 * network block should have explicit security policy (i.e., only one
297189251Ssam	 * option in the lists) for key_mgmt, pairwise, group, proto variables.
298189251Ssam	 */
299189251Ssam	int ap_scan;
300189251Ssam
301189251Ssam	/**
302252726Srpaulo	 * disable_scan_offload - Disable automatic offloading of scan requests
303252726Srpaulo	 *
304252726Srpaulo	 * By default, %wpa_supplicant tries to offload scanning if the driver
305252726Srpaulo	 * indicates support for this (sched_scan). This configuration
306252726Srpaulo	 * parameter can be used to disable this offloading mechanism.
307252726Srpaulo	 */
308252726Srpaulo	int disable_scan_offload;
309252726Srpaulo
310252726Srpaulo	/**
311189251Ssam	 * ctrl_interface - Parameters for the control interface
312189251Ssam	 *
313189251Ssam	 * If this is specified, %wpa_supplicant will open a control interface
314189251Ssam	 * that is available for external programs to manage %wpa_supplicant.
315189251Ssam	 * The meaning of this string depends on which control interface
316252726Srpaulo	 * mechanism is used. For all cases, the existence of this parameter
317189251Ssam	 * in configuration is used to determine whether the control interface
318189251Ssam	 * is enabled.
319189251Ssam	 *
320189251Ssam	 * For UNIX domain sockets (default on Linux and BSD): This is a
321189251Ssam	 * directory that will be created for UNIX domain sockets for listening
322189251Ssam	 * to requests from external programs (CLI/GUI, etc.) for status
323189251Ssam	 * information and configuration. The socket file will be named based
324189251Ssam	 * on the interface name, so multiple %wpa_supplicant processes can be
325189251Ssam	 * run at the same time if more than one interface is used.
326189251Ssam	 * /var/run/wpa_supplicant is the recommended directory for sockets and
327189251Ssam	 * by default, wpa_cli will use it when trying to connect with
328189251Ssam	 * %wpa_supplicant.
329189251Ssam	 *
330189251Ssam	 * Access control for the control interface can be configured
331189251Ssam	 * by setting the directory to allow only members of a group
332189251Ssam	 * to use sockets. This way, it is possible to run
333189251Ssam	 * %wpa_supplicant as root (since it needs to change network
334189251Ssam	 * configuration and open raw sockets) and still allow GUI/CLI
335189251Ssam	 * components to be run as non-root users. However, since the
336189251Ssam	 * control interface can be used to change the network
337189251Ssam	 * configuration, this access needs to be protected in many
338189251Ssam	 * cases. By default, %wpa_supplicant is configured to use gid
339189251Ssam	 * 0 (root). If you want to allow non-root users to use the
340189251Ssam	 * control interface, add a new group and change this value to
341189251Ssam	 * match with that group. Add users that should have control
342189251Ssam	 * interface access to this group.
343189251Ssam	 *
344189251Ssam	 * When configuring both the directory and group, use following format:
345189251Ssam	 * DIR=/var/run/wpa_supplicant GROUP=wheel
346189251Ssam	 * DIR=/var/run/wpa_supplicant GROUP=0
347189251Ssam	 * (group can be either group name or gid)
348189251Ssam	 *
349189251Ssam	 * For UDP connections (default on Windows): The value will be ignored.
350189251Ssam	 * This variable is just used to select that the control interface is
351189251Ssam	 * to be created. The value can be set to, e.g., udp
352189251Ssam	 * (ctrl_interface=udp).
353189251Ssam	 *
354189251Ssam	 * For Windows Named Pipe: This value can be used to set the security
355189251Ssam	 * descriptor for controlling access to the control interface. Security
356189251Ssam	 * descriptor can be set using Security Descriptor String Format (see
357189251Ssam	 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/security/security_descriptor_string_format.asp).
358189251Ssam	 * The descriptor string needs to be prefixed with SDDL=. For example,
359189251Ssam	 * ctrl_interface=SDDL=D: would set an empty DACL (which will reject
360189251Ssam	 * all connections).
361189251Ssam	 */
362189251Ssam	char *ctrl_interface;
363189251Ssam
364189251Ssam	/**
365189251Ssam	 * ctrl_interface_group - Control interface group (DEPRECATED)
366189251Ssam	 *
367189251Ssam	 * This variable is only used for backwards compatibility. Group for
368189251Ssam	 * UNIX domain sockets should now be specified using GROUP=group in
369189251Ssam	 * ctrl_interface variable.
370189251Ssam	 */
371189251Ssam	char *ctrl_interface_group;
372189251Ssam
373189251Ssam	/**
374189251Ssam	 * fast_reauth - EAP fast re-authentication (session resumption)
375189251Ssam	 *
376189251Ssam	 * By default, fast re-authentication is enabled for all EAP methods
377189251Ssam	 * that support it. This variable can be used to disable fast
378189251Ssam	 * re-authentication (by setting fast_reauth=0). Normally, there is no
379189251Ssam	 * need to disable fast re-authentication.
380189251Ssam	 */
381189251Ssam	int fast_reauth;
382189251Ssam
383189251Ssam	/**
384189251Ssam	 * opensc_engine_path - Path to the OpenSSL engine for opensc
385189251Ssam	 *
386189251Ssam	 * This is an OpenSSL specific configuration option for loading OpenSC
387189251Ssam	 * engine (engine_opensc.so); if %NULL, this engine is not loaded.
388189251Ssam	 */
389189251Ssam	char *opensc_engine_path;
390189251Ssam
391189251Ssam	/**
392189251Ssam	 * pkcs11_engine_path - Path to the OpenSSL engine for PKCS#11
393189251Ssam	 *
394189251Ssam	 * This is an OpenSSL specific configuration option for loading PKCS#11
395189251Ssam	 * engine (engine_pkcs11.so); if %NULL, this engine is not loaded.
396189251Ssam	 */
397189251Ssam	char *pkcs11_engine_path;
398189251Ssam
399189251Ssam	/**
400189251Ssam	 * pkcs11_module_path - Path to the OpenSSL OpenSC/PKCS#11 module
401189251Ssam	 *
402189251Ssam	 * This is an OpenSSL specific configuration option for configuring
403189251Ssam	 * path to OpenSC/PKCS#11 engine (opensc-pkcs11.so); if %NULL, this
404189251Ssam	 * module is not loaded.
405189251Ssam	 */
406189251Ssam	char *pkcs11_module_path;
407189251Ssam
408189251Ssam	/**
409252726Srpaulo	 * pcsc_reader - PC/SC reader name prefix
410252726Srpaulo	 *
411252726Srpaulo	 * If not %NULL, PC/SC reader with a name that matches this prefix is
412252726Srpaulo	 * initialized for SIM/USIM access. Empty string can be used to match
413252726Srpaulo	 * the first available reader.
414252726Srpaulo	 */
415252726Srpaulo	char *pcsc_reader;
416252726Srpaulo
417252726Srpaulo	/**
418252726Srpaulo	 * pcsc_pin - PIN for USIM, GSM SIM, and smartcards
419252726Srpaulo	 *
420252726Srpaulo	 * This field is used to configure PIN for SIM/USIM for EAP-SIM and
421252726Srpaulo	 * EAP-AKA. If left out, this will be asked through control interface.
422252726Srpaulo	 */
423252726Srpaulo	char *pcsc_pin;
424252726Srpaulo
425252726Srpaulo	/**
426189251Ssam	 * driver_param - Driver interface parameters
427189251Ssam	 *
428189251Ssam	 * This text string is passed to the selected driver interface with the
429189251Ssam	 * optional struct wpa_driver_ops::set_param() handler. This can be
430189251Ssam	 * used to configure driver specific options without having to add new
431189251Ssam	 * driver interface functionality.
432189251Ssam	 */
433189251Ssam	char *driver_param;
434189251Ssam
435189251Ssam	/**
436189251Ssam	 * dot11RSNAConfigPMKLifetime - Maximum lifetime of a PMK
437189251Ssam	 *
438189251Ssam	 * dot11 MIB variable for the maximum lifetime of a PMK in the PMK
439189251Ssam	 * cache (unit: seconds).
440189251Ssam	 */
441189251Ssam	unsigned int dot11RSNAConfigPMKLifetime;
442189251Ssam
443189251Ssam	/**
444189251Ssam	 * dot11RSNAConfigPMKReauthThreshold - PMK re-authentication threshold
445189251Ssam	 *
446189251Ssam	 * dot11 MIB variable for the percentage of the PMK lifetime
447189251Ssam	 * that should expire before an IEEE 802.1X reauthentication occurs.
448189251Ssam	 */
449189251Ssam	unsigned int dot11RSNAConfigPMKReauthThreshold;
450189251Ssam
451189251Ssam	/**
452189251Ssam	 * dot11RSNAConfigSATimeout - Security association timeout
453189251Ssam	 *
454189251Ssam	 * dot11 MIB variable for the maximum time a security association
455189251Ssam	 * shall take to set up (unit: seconds).
456189251Ssam	 */
457189251Ssam	unsigned int dot11RSNAConfigSATimeout;
458189251Ssam
459189251Ssam	/**
460189251Ssam	 * update_config - Is wpa_supplicant allowed to update configuration
461189251Ssam	 *
462189251Ssam	 * This variable control whether wpa_supplicant is allow to re-write
463189251Ssam	 * its configuration with wpa_config_write(). If this is zero,
464189251Ssam	 * configuration data is only changed in memory and the external data
465189251Ssam	 * is not overriden. If this is non-zero, wpa_supplicant will update
466189251Ssam	 * the configuration data (e.g., a file) whenever configuration is
467189251Ssam	 * changed. This update may replace the old configuration which can
468189251Ssam	 * remove comments from it in case of a text file configuration.
469189251Ssam	 */
470189251Ssam	int update_config;
471189251Ssam
472189251Ssam	/**
473189251Ssam	 * blobs - Configuration blobs
474189251Ssam	 */
475189251Ssam	struct wpa_config_blob *blobs;
476189251Ssam
477189251Ssam	/**
478189251Ssam	 * uuid - Universally Unique IDentifier (UUID; see RFC 4122) for WPS
479189251Ssam	 */
480189251Ssam	u8 uuid[16];
481189251Ssam
482189251Ssam	/**
483189251Ssam	 * device_name - Device Name (WPS)
484189251Ssam	 * User-friendly description of device; up to 32 octets encoded in
485189251Ssam	 * UTF-8
486189251Ssam	 */
487189251Ssam	char *device_name;
488189251Ssam
489189251Ssam	/**
490189251Ssam	 * manufacturer - Manufacturer (WPS)
491189251Ssam	 * The manufacturer of the device (up to 64 ASCII characters)
492189251Ssam	 */
493189251Ssam	char *manufacturer;
494189251Ssam
495189251Ssam	/**
496189251Ssam	 * model_name - Model Name (WPS)
497189251Ssam	 * Model of the device (up to 32 ASCII characters)
498189251Ssam	 */
499189251Ssam	char *model_name;
500189251Ssam
501189251Ssam	/**
502189251Ssam	 * model_number - Model Number (WPS)
503189251Ssam	 * Additional device description (up to 32 ASCII characters)
504189251Ssam	 */
505189251Ssam	char *model_number;
506189251Ssam
507189251Ssam	/**
508189251Ssam	 * serial_number - Serial Number (WPS)
509189251Ssam	 * Serial number of the device (up to 32 characters)
510189251Ssam	 */
511189251Ssam	char *serial_number;
512189251Ssam
513189251Ssam	/**
514189251Ssam	 * device_type - Primary Device Type (WPS)
515189251Ssam	 */
516252726Srpaulo	u8 device_type[WPS_DEV_TYPE_LEN];
517189251Ssam
518189251Ssam	/**
519214734Srpaulo	 * config_methods - Config Methods
520214734Srpaulo	 *
521214734Srpaulo	 * This is a space-separated list of supported WPS configuration
522252726Srpaulo	 * methods. For example, "label virtual_display virtual_push_button
523252726Srpaulo	 * keypad".
524214734Srpaulo	 * Available methods: usba ethernet label display ext_nfc_token
525252726Srpaulo	 * int_nfc_token nfc_interface push_button keypad
526252726Srpaulo	 * virtual_display physical_display
527252726Srpaulo	 * virtual_push_button physical_push_button.
528214734Srpaulo	 */
529214734Srpaulo	char *config_methods;
530214734Srpaulo
531214734Srpaulo	/**
532189251Ssam	 * os_version - OS Version (WPS)
533189251Ssam	 * 4-octet operating system version number
534189251Ssam	 */
535189251Ssam	u8 os_version[4];
536189251Ssam
537189251Ssam	/**
538189251Ssam	 * country - Country code
539189251Ssam	 *
540189251Ssam	 * This is the ISO/IEC alpha2 country code for which we are operating
541189251Ssam	 * in
542189251Ssam	 */
543189251Ssam	char country[2];
544189251Ssam
545189251Ssam	/**
546189251Ssam	 * wps_cred_processing - Credential processing
547189251Ssam	 *
548189251Ssam	 *   0 = process received credentials internally
549189251Ssam	 *   1 = do not process received credentials; just pass them over
550189251Ssam	 *	ctrl_iface to external program(s)
551189251Ssam	 *   2 = process received credentials internally and pass them over
552189251Ssam	 *	ctrl_iface to external program(s)
553189251Ssam	 */
554189251Ssam	int wps_cred_processing;
555214734Srpaulo
556252726Srpaulo#define MAX_SEC_DEVICE_TYPES 5
557214734Srpaulo	/**
558252726Srpaulo	 * sec_device_types - Secondary Device Types (P2P)
559252726Srpaulo	 */
560252726Srpaulo	u8 sec_device_type[MAX_SEC_DEVICE_TYPES][WPS_DEV_TYPE_LEN];
561252726Srpaulo	int num_sec_device_types;
562252726Srpaulo
563252726Srpaulo	int p2p_listen_reg_class;
564252726Srpaulo	int p2p_listen_channel;
565252726Srpaulo	int p2p_oper_reg_class;
566252726Srpaulo	int p2p_oper_channel;
567252726Srpaulo	int p2p_go_intent;
568252726Srpaulo	char *p2p_ssid_postfix;
569252726Srpaulo	int persistent_reconnect;
570252726Srpaulo	int p2p_intra_bss;
571252726Srpaulo	unsigned int num_p2p_pref_chan;
572252726Srpaulo	struct p2p_channel *p2p_pref_chan;
573252726Srpaulo
574252726Srpaulo	struct wpabuf *wps_vendor_ext_m1;
575252726Srpaulo
576252726Srpaulo#define MAX_WPS_VENDOR_EXT 10
577252726Srpaulo	/**
578252726Srpaulo	 * wps_vendor_ext - Vendor extension attributes in WPS
579252726Srpaulo	 */
580252726Srpaulo	struct wpabuf *wps_vendor_ext[MAX_WPS_VENDOR_EXT];
581252726Srpaulo
582252726Srpaulo	/**
583252726Srpaulo	 * p2p_group_idle - Maximum idle time in seconds for P2P group
584252726Srpaulo	 *
585252726Srpaulo	 * This value controls how long a P2P group is maintained after there
586252726Srpaulo	 * is no other members in the group. As a GO, this means no associated
587252726Srpaulo	 * stations in the group. As a P2P client, this means no GO seen in
588252726Srpaulo	 * scan results. The maximum idle time is specified in seconds with 0
589252726Srpaulo	 * indicating no time limit, i.e., the P2P group remains in active
590252726Srpaulo	 * state indefinitely until explicitly removed. As a P2P client, the
591252726Srpaulo	 * maximum idle time of P2P_MAX_CLIENT_IDLE seconds is enforced, i.e.,
592252726Srpaulo	 * this parameter is mainly meant for GO use and for P2P client, it can
593252726Srpaulo	 * only be used to reduce the default timeout to smaller value. A
594252726Srpaulo	 * special value -1 can be used to configure immediate removal of the
595252726Srpaulo	 * group for P2P client role on any disconnection after the data
596252726Srpaulo	 * connection has been established.
597252726Srpaulo	 */
598252726Srpaulo	int p2p_group_idle;
599252726Srpaulo
600252726Srpaulo	/**
601214734Srpaulo	 * bss_max_count - Maximum number of BSS entries to keep in memory
602214734Srpaulo	 */
603214734Srpaulo	unsigned int bss_max_count;
604214734Srpaulo
605214734Srpaulo	/**
606252726Srpaulo	 * bss_expiration_age - BSS entry age after which it can be expired
607252726Srpaulo	 *
608252726Srpaulo	 * This value controls the time in seconds after which a BSS entry
609252726Srpaulo	 * gets removed if it has not been updated or is not in use.
610252726Srpaulo	 */
611252726Srpaulo	unsigned int bss_expiration_age;
612252726Srpaulo
613252726Srpaulo	/**
614252726Srpaulo	 * bss_expiration_scan_count - Expire BSS after number of scans
615252726Srpaulo	 *
616252726Srpaulo	 * If the BSS entry has not been seen in this many scans, it will be
617252726Srpaulo	 * removed. A value of 1 means that entry is removed after the first
618252726Srpaulo	 * scan in which the BSSID is not seen. Larger values can be used
619252726Srpaulo	 * to avoid BSS entries disappearing if they are not visible in
620252726Srpaulo	 * every scan (e.g., low signal quality or interference).
621252726Srpaulo	 */
622252726Srpaulo	unsigned int bss_expiration_scan_count;
623252726Srpaulo
624252726Srpaulo	/**
625214734Srpaulo	 * filter_ssids - SSID-based scan result filtering
626214734Srpaulo	 *
627214734Srpaulo	 *   0 = do not filter scan results
628214734Srpaulo	 *   1 = only include configured SSIDs in scan results/BSS table
629214734Srpaulo	 */
630214734Srpaulo	int filter_ssids;
631252726Srpaulo
632252726Srpaulo	/**
633252726Srpaulo	 * filter_rssi - RSSI-based scan result filtering
634252726Srpaulo	 *
635252726Srpaulo	 * 0 = do not filter scan results
636252726Srpaulo	 * -n = filter scan results below -n dBm
637252726Srpaulo	 */
638252726Srpaulo	int filter_rssi;
639252726Srpaulo
640252726Srpaulo	/**
641252726Srpaulo	 * max_num_sta - Maximum number of STAs in an AP/P2P GO
642252726Srpaulo	 */
643252726Srpaulo	unsigned int max_num_sta;
644252726Srpaulo
645252726Srpaulo	/**
646252726Srpaulo	 * changed_parameters - Bitmap of changed parameters since last update
647252726Srpaulo	 */
648252726Srpaulo	unsigned int changed_parameters;
649252726Srpaulo
650252726Srpaulo	/**
651252726Srpaulo	 * disassoc_low_ack - Disassocicate stations with massive packet loss
652252726Srpaulo	 */
653252726Srpaulo	int disassoc_low_ack;
654252726Srpaulo
655252726Srpaulo	/**
656252726Srpaulo	 * interworking - Whether Interworking (IEEE 802.11u) is enabled
657252726Srpaulo	 */
658252726Srpaulo	int interworking;
659252726Srpaulo
660252726Srpaulo	/**
661252726Srpaulo	 * access_network_type - Access Network Type
662252726Srpaulo	 *
663252726Srpaulo	 * When Interworking is enabled, scans will be limited to APs that
664252726Srpaulo	 * advertise the specified Access Network Type (0..15; with 15
665252726Srpaulo	 * indicating wildcard match).
666252726Srpaulo	 */
667252726Srpaulo	int access_network_type;
668252726Srpaulo
669252726Srpaulo	/**
670252726Srpaulo	 * hessid - Homogenous ESS identifier
671252726Srpaulo	 *
672252726Srpaulo	 * If this is set (any octet is non-zero), scans will be used to
673252726Srpaulo	 * request response only from BSSes belonging to the specified
674252726Srpaulo	 * Homogeneous ESS. This is used only if interworking is enabled.
675252726Srpaulo	 */
676252726Srpaulo	u8 hessid[ETH_ALEN];
677252726Srpaulo
678252726Srpaulo	/**
679252726Srpaulo	 * hs20 - Hotspot 2.0
680252726Srpaulo	 */
681252726Srpaulo	int hs20;
682252726Srpaulo
683252726Srpaulo	/**
684252726Srpaulo	 * pbc_in_m1 - AP mode WPS probing workaround for PBC with Windows 7
685252726Srpaulo	 *
686252726Srpaulo	 * Windows 7 uses incorrect way of figuring out AP's WPS capabilities
687252726Srpaulo	 * by acting as a Registrar and using M1 from the AP. The config
688252726Srpaulo	 * methods attribute in that message is supposed to indicate only the
689252726Srpaulo	 * configuration method supported by the AP in Enrollee role, i.e., to
690252726Srpaulo	 * add an external Registrar. For that case, PBC shall not be used and
691252726Srpaulo	 * as such, the PushButton config method is removed from M1 by default.
692252726Srpaulo	 * If pbc_in_m1=1 is included in the configuration file, the PushButton
693252726Srpaulo	 * config method is left in M1 (if included in config_methods
694252726Srpaulo	 * parameter) to allow Windows 7 to use PBC instead of PIN (e.g., from
695252726Srpaulo	 * a label in the AP).
696252726Srpaulo	 */
697252726Srpaulo	int pbc_in_m1;
698252726Srpaulo
699252726Srpaulo	/**
700252726Srpaulo	 * autoscan - Automatic scan parameters or %NULL if none
701252726Srpaulo	 *
702252726Srpaulo	 * This is an optional set of parameters for automatic scanning
703252726Srpaulo	 * within an interface in following format:
704252726Srpaulo	 * <autoscan module name>:<module parameters>
705252726Srpaulo	 */
706252726Srpaulo	char *autoscan;
707252726Srpaulo
708252726Srpaulo	/**
709252726Srpaulo	 * wps_nfc_dev_pw_id - NFC Device Password ID for password token
710252726Srpaulo	 */
711252726Srpaulo	int wps_nfc_dev_pw_id;
712252726Srpaulo
713252726Srpaulo	/**
714252726Srpaulo	 * wps_nfc_dh_pubkey - NFC DH Public Key for password token
715252726Srpaulo	 */
716252726Srpaulo	struct wpabuf *wps_nfc_dh_pubkey;
717252726Srpaulo
718252726Srpaulo	/**
719252726Srpaulo	 * wps_nfc_dh_privkey - NFC DH Private Key for password token
720252726Srpaulo	 */
721252726Srpaulo	struct wpabuf *wps_nfc_dh_privkey;
722252726Srpaulo
723252726Srpaulo	/**
724252726Srpaulo	 * wps_nfc_dev_pw - NFC Device Password for password token
725252726Srpaulo	 */
726252726Srpaulo	struct wpabuf *wps_nfc_dev_pw;
727252726Srpaulo
728252726Srpaulo	/**
729252726Srpaulo	 * ext_password_backend - External password backend or %NULL if none
730252726Srpaulo	 *
731252726Srpaulo	 * format: <backend name>[:<optional backend parameters>]
732252726Srpaulo	 */
733252726Srpaulo	char *ext_password_backend;
734252726Srpaulo
735252726Srpaulo	/*
736252726Srpaulo	 * p2p_go_max_inactivity - Timeout in seconds to detect STA inactivity
737252726Srpaulo	 *
738252726Srpaulo	 * This timeout value is used in P2P GO mode to clean up
739252726Srpaulo	 * inactive stations.
740252726Srpaulo	 * By default: 300 seconds.
741252726Srpaulo	 */
742252726Srpaulo	int p2p_go_max_inactivity;
743252726Srpaulo
744252726Srpaulo	struct hostapd_wmm_ac_params wmm_ac_params[4];
745252726Srpaulo
746252726Srpaulo	/**
747252726Srpaulo	 * auto_interworking - Whether to use network selection automatically
748252726Srpaulo	 *
749252726Srpaulo	 * 0 = do not automatically go through Interworking network selection
750252726Srpaulo	 *     (i.e., require explicit interworking_select command for this)
751252726Srpaulo	 * 1 = perform Interworking network selection if one or more
752252726Srpaulo	 *     credentials have been configured and scan did not find a
753252726Srpaulo	 *     matching network block
754252726Srpaulo	 */
755252726Srpaulo	int auto_interworking;
756252726Srpaulo
757252726Srpaulo	/**
758252726Srpaulo	 * p2p_go_ht40 - Default mode for HT40 enable when operating as GO.
759252726Srpaulo	 *
760252726Srpaulo	 * This will take effect for p2p_group_add, p2p_connect, and p2p_invite.
761252726Srpaulo	 * Note that regulatory constraints and driver capabilities are
762252726Srpaulo	 * consulted anyway, so setting it to 1 can't do real harm.
763252726Srpaulo	 * By default: 0 (disabled)
764252726Srpaulo	 */
765252726Srpaulo	int p2p_go_ht40;
766252726Srpaulo
767252726Srpaulo	/**
768252726Srpaulo	 * p2p_disabled - Whether P2P operations are disabled for this interface
769252726Srpaulo	 */
770252726Srpaulo	int p2p_disabled;
771252726Srpaulo
772252726Srpaulo	/**
773252726Srpaulo	 * p2p_no_group_iface - Whether group interfaces can be used
774252726Srpaulo	 *
775252726Srpaulo	 * By default, wpa_supplicant will create a separate interface for P2P
776252726Srpaulo	 * group operations if the driver supports this. This functionality can
777252726Srpaulo	 * be disabled by setting this parameter to 1. In that case, the same
778252726Srpaulo	 * interface that was used for the P2P management operations is used
779252726Srpaulo	 * also for the group operation.
780252726Srpaulo	 */
781252726Srpaulo	int p2p_no_group_iface;
782252726Srpaulo
783252726Srpaulo	/**
784252726Srpaulo	 * okc - Whether to enable opportunistic key caching by default
785252726Srpaulo	 *
786252726Srpaulo	 * By default, OKC is disabled unless enabled by the per-network
787252726Srpaulo	 * proactive_key_caching=1 parameter. okc=1 can be used to change this
788252726Srpaulo	 * default behavior.
789252726Srpaulo	 */
790252726Srpaulo	int okc;
791252726Srpaulo
792252726Srpaulo	/**
793252726Srpaulo	 * pmf - Whether to enable/require PMF by default
794252726Srpaulo	 *
795252726Srpaulo	 * By default, PMF is disabled unless enabled by the per-network
796252726Srpaulo	 * ieee80211w=1 or ieee80211w=2 parameter. pmf=1/2 can be used to change
797252726Srpaulo	 * this default behavior.
798252726Srpaulo	 */
799252726Srpaulo	enum mfp_options pmf;
800189251Ssam};
801189251Ssam
802189251Ssam
803189251Ssam/* Prototypes for common functions from config.c */
804189251Ssam
805189251Ssamvoid wpa_config_free(struct wpa_config *ssid);
806189251Ssamvoid wpa_config_free_ssid(struct wpa_ssid *ssid);
807252726Srpaulovoid wpa_config_foreach_network(struct wpa_config *config,
808252726Srpaulo				void (*func)(void *, struct wpa_ssid *),
809252726Srpaulo				void *arg);
810189251Ssamstruct wpa_ssid * wpa_config_get_network(struct wpa_config *config, int id);
811189251Ssamstruct wpa_ssid * wpa_config_add_network(struct wpa_config *config);
812189251Ssamint wpa_config_remove_network(struct wpa_config *config, int id);
813189251Ssamvoid wpa_config_set_network_defaults(struct wpa_ssid *ssid);
814189251Ssamint wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value,
815189251Ssam		   int line);
816252726Srpauloint wpa_config_set_quoted(struct wpa_ssid *ssid, const char *var,
817252726Srpaulo			  const char *value);
818214734Srpaulochar ** wpa_config_get_all(struct wpa_ssid *ssid, int get_keys);
819189251Ssamchar * wpa_config_get(struct wpa_ssid *ssid, const char *var);
820189251Ssamchar * wpa_config_get_no_key(struct wpa_ssid *ssid, const char *var);
821189251Ssamvoid wpa_config_update_psk(struct wpa_ssid *ssid);
822189251Ssamint wpa_config_add_prio_network(struct wpa_config *config,
823189251Ssam				struct wpa_ssid *ssid);
824214734Srpauloint wpa_config_update_prio_list(struct wpa_config *config);
825189251Ssamconst struct wpa_config_blob * wpa_config_get_blob(struct wpa_config *config,
826189251Ssam						   const char *name);
827189251Ssamvoid wpa_config_set_blob(struct wpa_config *config,
828189251Ssam			 struct wpa_config_blob *blob);
829189251Ssamvoid wpa_config_free_blob(struct wpa_config_blob *blob);
830189251Ssamint wpa_config_remove_blob(struct wpa_config *config, const char *name);
831189251Ssam
832252726Srpaulostruct wpa_cred * wpa_config_get_cred(struct wpa_config *config, int id);
833252726Srpaulostruct wpa_cred * wpa_config_add_cred(struct wpa_config *config);
834252726Srpauloint wpa_config_remove_cred(struct wpa_config *config, int id);
835252726Srpaulovoid wpa_config_free_cred(struct wpa_cred *cred);
836252726Srpauloint wpa_config_set_cred(struct wpa_cred *cred, const char *var,
837252726Srpaulo			const char *value, int line);
838252726Srpaulo
839189251Ssamstruct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
840189251Ssam					   const char *driver_param);
841189251Ssam#ifndef CONFIG_NO_STDOUT_DEBUG
842189251Ssamvoid wpa_config_debug_dump_networks(struct wpa_config *config);
843189251Ssam#else /* CONFIG_NO_STDOUT_DEBUG */
844189251Ssam#define wpa_config_debug_dump_networks(c) do { } while (0)
845189251Ssam#endif /* CONFIG_NO_STDOUT_DEBUG */
846189251Ssam
847189251Ssam
848252726Srpaulo/* Prototypes for common functions from config.c */
849252726Srpauloint wpa_config_process_global(struct wpa_config *config, char *pos, int line);
850252726Srpaulo
851252726Srpaulo
852189251Ssam/* Prototypes for backend specific functions from the selected config_*.c */
853189251Ssam
854189251Ssam/**
855189251Ssam * wpa_config_read - Read and parse configuration database
856189251Ssam * @name: Name of the configuration (e.g., path and file name for the
857189251Ssam * configuration file)
858189251Ssam * Returns: Pointer to allocated configuration data or %NULL on failure
859189251Ssam *
860189251Ssam * This function reads configuration data, parses its contents, and allocates
861189251Ssam * data structures needed for storing configuration information. The allocated
862189251Ssam * data can be freed with wpa_config_free().
863189251Ssam *
864189251Ssam * Each configuration backend needs to implement this function.
865189251Ssam */
866189251Ssamstruct wpa_config * wpa_config_read(const char *name);
867189251Ssam
868189251Ssam/**
869189251Ssam * wpa_config_write - Write or update configuration data
870189251Ssam * @name: Name of the configuration (e.g., path and file name for the
871189251Ssam * configuration file)
872189251Ssam * @config: Configuration data from wpa_config_read()
873189251Ssam * Returns: 0 on success, -1 on failure
874189251Ssam *
875189251Ssam * This function write all configuration data into an external database (e.g.,
876189251Ssam * a text file) in a format that can be read with wpa_config_read(). This can
877189251Ssam * be used to allow wpa_supplicant to update its configuration, e.g., when a
878189251Ssam * new network is added or a password is changed.
879189251Ssam *
880189251Ssam * Each configuration backend needs to implement this function.
881189251Ssam */
882189251Ssamint wpa_config_write(const char *name, struct wpa_config *config);
883189251Ssam
884189251Ssam#endif /* CONFIG_H */
885