Add option for disabling automatic reconnection on disconnection
[libeap.git] / wpa_supplicant / config.h
1 /*
2  * WPA Supplicant / Configuration file structures
3  * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
4  *
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.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #ifndef CONFIG_H
16 #define CONFIG_H
17
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_BSS_MAX_COUNT 200
27
28 #include "config_ssid.h"
29
30
31 #define CFG_CHANGED_DEVICE_NAME BIT(0)
32 #define CFG_CHANGED_CONFIG_METHODS BIT(1)
33 #define CFG_CHANGED_DEVICE_TYPE BIT(2)
34 #define CFG_CHANGED_OS_VERSION BIT(3)
35 #define CFG_CHANGED_UUID BIT(4)
36 #define CFG_CHANGED_COUNTRY BIT(5)
37 #define CFG_CHANGED_SEC_DEVICE_TYPE BIT(6)
38 #define CFG_CHANGED_P2P_SSID_POSTFIX BIT(7)
39 #define CFG_CHANGED_WPS_STRING BIT(8)
40
41 /**
42  * struct wpa_config - wpa_supplicant configuration data
43  *
44  * This data structure is presents the per-interface (radio) configuration
45  * data. In many cases, there is only one struct wpa_config instance, but if
46  * more than one network interface is being controlled, one instance is used
47  * for each.
48  */
49 struct wpa_config {
50         /**
51          * ssid - Head of the global network list
52          *
53          * This is the head for the list of all the configured networks.
54          */
55         struct wpa_ssid *ssid;
56
57         /**
58          * pssid - Per-priority network lists (in priority order)
59          */
60         struct wpa_ssid **pssid;
61
62         /**
63          * num_prio - Number of different priorities used in the pssid lists
64          *
65          * This indicates how many per-priority network lists are included in
66          * pssid.
67          */
68         int num_prio;
69
70         /**
71          * eapol_version - IEEE 802.1X/EAPOL version number
72          *
73          * wpa_supplicant is implemented based on IEEE Std 802.1X-2004 which
74          * defines EAPOL version 2. However, there are many APs that do not
75          * handle the new version number correctly (they seem to drop the
76          * frames completely). In order to make wpa_supplicant interoperate
77          * with these APs, the version number is set to 1 by default. This
78          * configuration value can be used to set it to the new version (2).
79          */
80         int eapol_version;
81
82         /**
83          * ap_scan - AP scanning/selection
84          *
85          * By default, wpa_supplicant requests driver to perform AP
86          * scanning and then uses the scan results to select a
87          * suitable AP. Another alternative is to allow the driver to
88          * take care of AP scanning and selection and use
89          * wpa_supplicant just to process EAPOL frames based on IEEE
90          * 802.11 association information from the driver.
91          *
92          * 1: wpa_supplicant initiates scanning and AP selection (default).
93          *
94          * 0: Driver takes care of scanning, AP selection, and IEEE 802.11
95          * association parameters (e.g., WPA IE generation); this mode can
96          * also be used with non-WPA drivers when using IEEE 802.1X mode;
97          * do not try to associate with APs (i.e., external program needs
98          * to control association). This mode must also be used when using
99          * wired Ethernet drivers.
100          *
101          * 2: like 0, but associate with APs using security policy and SSID
102          * (but not BSSID); this can be used, e.g., with ndiswrapper and NDIS
103          * drivers to enable operation with hidden SSIDs and optimized roaming;
104          * in this mode, the network blocks in the configuration are tried
105          * one by one until the driver reports successful association; each
106          * network block should have explicit security policy (i.e., only one
107          * option in the lists) for key_mgmt, pairwise, group, proto variables.
108          */
109         int ap_scan;
110
111         /**
112          * ctrl_interface - Parameters for the control interface
113          *
114          * If this is specified, %wpa_supplicant will open a control interface
115          * that is available for external programs to manage %wpa_supplicant.
116          * The meaning of this string depends on which control interface
117          * mechanism is used. For all cases, the existance of this parameter
118          * in configuration is used to determine whether the control interface
119          * is enabled.
120          *
121          * For UNIX domain sockets (default on Linux and BSD): This is a
122          * directory that will be created for UNIX domain sockets for listening
123          * to requests from external programs (CLI/GUI, etc.) for status
124          * information and configuration. The socket file will be named based
125          * on the interface name, so multiple %wpa_supplicant processes can be
126          * run at the same time if more than one interface is used.
127          * /var/run/wpa_supplicant is the recommended directory for sockets and
128          * by default, wpa_cli will use it when trying to connect with
129          * %wpa_supplicant.
130          *
131          * Access control for the control interface can be configured
132          * by setting the directory to allow only members of a group
133          * to use sockets. This way, it is possible to run
134          * %wpa_supplicant as root (since it needs to change network
135          * configuration and open raw sockets) and still allow GUI/CLI
136          * components to be run as non-root users. However, since the
137          * control interface can be used to change the network
138          * configuration, this access needs to be protected in many
139          * cases. By default, %wpa_supplicant is configured to use gid
140          * 0 (root). If you want to allow non-root users to use the
141          * control interface, add a new group and change this value to
142          * match with that group. Add users that should have control
143          * interface access to this group.
144          *
145          * When configuring both the directory and group, use following format:
146          * DIR=/var/run/wpa_supplicant GROUP=wheel
147          * DIR=/var/run/wpa_supplicant GROUP=0
148          * (group can be either group name or gid)
149          *
150          * For UDP connections (default on Windows): The value will be ignored.
151          * This variable is just used to select that the control interface is
152          * to be created. The value can be set to, e.g., udp
153          * (ctrl_interface=udp).
154          *
155          * For Windows Named Pipe: This value can be used to set the security
156          * descriptor for controlling access to the control interface. Security
157          * descriptor can be set using Security Descriptor String Format (see
158          * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/security/security_descriptor_string_format.asp).
159          * The descriptor string needs to be prefixed with SDDL=. For example,
160          * ctrl_interface=SDDL=D: would set an empty DACL (which will reject
161          * all connections).
162          */
163         char *ctrl_interface;
164
165         /**
166          * ctrl_interface_group - Control interface group (DEPRECATED)
167          *
168          * This variable is only used for backwards compatibility. Group for
169          * UNIX domain sockets should now be specified using GROUP=group in
170          * ctrl_interface variable.
171          */
172         char *ctrl_interface_group;
173
174         /**
175          * fast_reauth - EAP fast re-authentication (session resumption)
176          *
177          * By default, fast re-authentication is enabled for all EAP methods
178          * that support it. This variable can be used to disable fast
179          * re-authentication (by setting fast_reauth=0). Normally, there is no
180          * need to disable fast re-authentication.
181          */
182         int fast_reauth;
183
184         /**
185          * opensc_engine_path - Path to the OpenSSL engine for opensc
186          *
187          * This is an OpenSSL specific configuration option for loading OpenSC
188          * engine (engine_opensc.so); if %NULL, this engine is not loaded.
189          */
190         char *opensc_engine_path;
191
192         /**
193          * pkcs11_engine_path - Path to the OpenSSL engine for PKCS#11
194          *
195          * This is an OpenSSL specific configuration option for loading PKCS#11
196          * engine (engine_pkcs11.so); if %NULL, this engine is not loaded.
197          */
198         char *pkcs11_engine_path;
199
200         /**
201          * pkcs11_module_path - Path to the OpenSSL OpenSC/PKCS#11 module
202          *
203          * This is an OpenSSL specific configuration option for configuring
204          * path to OpenSC/PKCS#11 engine (opensc-pkcs11.so); if %NULL, this
205          * module is not loaded.
206          */
207         char *pkcs11_module_path;
208
209         /**
210          * driver_param - Driver interface parameters
211          *
212          * This text string is passed to the selected driver interface with the
213          * optional struct wpa_driver_ops::set_param() handler. This can be
214          * used to configure driver specific options without having to add new
215          * driver interface functionality.
216          */
217         char *driver_param;
218
219         /**
220          * dot11RSNAConfigPMKLifetime - Maximum lifetime of a PMK
221          *
222          * dot11 MIB variable for the maximum lifetime of a PMK in the PMK
223          * cache (unit: seconds).
224          */
225         unsigned int dot11RSNAConfigPMKLifetime;
226
227         /**
228          * dot11RSNAConfigPMKReauthThreshold - PMK re-authentication threshold
229          *
230          * dot11 MIB variable for the percentage of the PMK lifetime
231          * that should expire before an IEEE 802.1X reauthentication occurs.
232          */
233         unsigned int dot11RSNAConfigPMKReauthThreshold;
234
235         /**
236          * dot11RSNAConfigSATimeout - Security association timeout
237          *
238          * dot11 MIB variable for the maximum time a security association
239          * shall take to set up (unit: seconds).
240          */
241         unsigned int dot11RSNAConfigSATimeout;
242
243         /**
244          * update_config - Is wpa_supplicant allowed to update configuration
245          *
246          * This variable control whether wpa_supplicant is allow to re-write
247          * its configuration with wpa_config_write(). If this is zero,
248          * configuration data is only changed in memory and the external data
249          * is not overriden. If this is non-zero, wpa_supplicant will update
250          * the configuration data (e.g., a file) whenever configuration is
251          * changed. This update may replace the old configuration which can
252          * remove comments from it in case of a text file configuration.
253          */
254         int update_config;
255
256         /**
257          * blobs - Configuration blobs
258          */
259         struct wpa_config_blob *blobs;
260
261         /**
262          * uuid - Universally Unique IDentifier (UUID; see RFC 4122) for WPS
263          */
264         u8 uuid[16];
265
266         /**
267          * device_name - Device Name (WPS)
268          * User-friendly description of device; up to 32 octets encoded in
269          * UTF-8
270          */
271         char *device_name;
272
273         /**
274          * manufacturer - Manufacturer (WPS)
275          * The manufacturer of the device (up to 64 ASCII characters)
276          */
277         char *manufacturer;
278
279         /**
280          * model_name - Model Name (WPS)
281          * Model of the device (up to 32 ASCII characters)
282          */
283         char *model_name;
284
285         /**
286          * model_number - Model Number (WPS)
287          * Additional device description (up to 32 ASCII characters)
288          */
289         char *model_number;
290
291         /**
292          * serial_number - Serial Number (WPS)
293          * Serial number of the device (up to 32 characters)
294          */
295         char *serial_number;
296
297         /**
298          * device_type - Primary Device Type (WPS)
299          * Used format: categ-OUI-subcateg
300          * categ = Category as an integer value
301          * OUI = OUI and type octet as a 4-octet hex-encoded value;
302          *      0050F204 for default WPS OUI
303          * subcateg = OUI-specific Sub Category as an integer value
304          * Examples:
305          *   1-0050F204-1 (Computer / PC)
306          *   1-0050F204-2 (Computer / Server)
307          *   5-0050F204-1 (Storage / NAS)
308          *   6-0050F204-1 (Network Infrastructure / AP)
309          */
310         char *device_type;
311
312         /**
313          * config_methods - Config Methods
314          *
315          * This is a space-separated list of supported WPS configuration
316          * methods. For example, "label virtual_display virtual_push_button
317          * keypad".
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.
322          */
323         char *config_methods;
324
325         /**
326          * os_version - OS Version (WPS)
327          * 4-octet operating system version number
328          */
329         u8 os_version[4];
330
331         /**
332          * country - Country code
333          *
334          * This is the ISO/IEC alpha2 country code for which we are operating
335          * in
336          */
337         char country[2];
338
339         /**
340          * wps_cred_processing - Credential processing
341          *
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)
347          */
348         int wps_cred_processing;
349
350 #define MAX_SEC_DEVICE_TYPES 5
351         /**
352          * sec_device_type - Secondary Device Types (P2P)
353          * See device_type for the format used with these.
354          */
355         char *sec_device_type[MAX_SEC_DEVICE_TYPES];
356
357         int p2p_listen_reg_class;
358         int p2p_listen_channel;
359         int p2p_oper_reg_class;
360         int p2p_oper_channel;
361         int p2p_go_intent;
362         char *p2p_ssid_postfix;
363         int persistent_reconnect;
364
365         /**
366          * bss_max_count - Maximum number of BSS entries to keep in memory
367          */
368         unsigned int bss_max_count;
369
370         /**
371          * filter_ssids - SSID-based scan result filtering
372          *
373          *   0 = do not filter scan results
374          *   1 = only include configured SSIDs in scan results/BSS table
375          */
376         int filter_ssids;
377
378         /**
379          * changed_parameters - Bitmap of changed parameters since last update
380          */
381         unsigned int changed_parameters;
382 };
383
384
385 /* Prototypes for common functions from config.c */
386
387 void wpa_config_free(struct wpa_config *ssid);
388 void wpa_config_free_ssid(struct wpa_ssid *ssid);
389 struct wpa_ssid * wpa_config_get_network(struct wpa_config *config, int id);
390 struct wpa_ssid * wpa_config_add_network(struct wpa_config *config);
391 int wpa_config_remove_network(struct wpa_config *config, int id);
392 void wpa_config_set_network_defaults(struct wpa_ssid *ssid);
393 int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value,
394                    int line);
395 char ** wpa_config_get_all(struct wpa_ssid *ssid, int get_keys);
396 char * wpa_config_get(struct wpa_ssid *ssid, const char *var);
397 char * wpa_config_get_no_key(struct wpa_ssid *ssid, const char *var);
398 void wpa_config_update_psk(struct wpa_ssid *ssid);
399 int wpa_config_add_prio_network(struct wpa_config *config,
400                                 struct wpa_ssid *ssid);
401 int wpa_config_update_prio_list(struct wpa_config *config);
402 const struct wpa_config_blob * wpa_config_get_blob(struct wpa_config *config,
403                                                    const char *name);
404 void wpa_config_set_blob(struct wpa_config *config,
405                          struct wpa_config_blob *blob);
406 void wpa_config_free_blob(struct wpa_config_blob *blob);
407 int wpa_config_remove_blob(struct wpa_config *config, const char *name);
408
409 struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
410                                            const char *driver_param);
411 #ifndef CONFIG_NO_STDOUT_DEBUG
412 void wpa_config_debug_dump_networks(struct wpa_config *config);
413 #else /* CONFIG_NO_STDOUT_DEBUG */
414 #define wpa_config_debug_dump_networks(c) do { } while (0)
415 #endif /* CONFIG_NO_STDOUT_DEBUG */
416
417
418 /* Prototypes for common functions from config.c */
419 int wpa_config_process_global(struct wpa_config *config, char *pos, int line);
420
421
422 /* Prototypes for backend specific functions from the selected config_*.c */
423
424 /**
425  * wpa_config_read - Read and parse configuration database
426  * @name: Name of the configuration (e.g., path and file name for the
427  * configuration file)
428  * Returns: Pointer to allocated configuration data or %NULL on failure
429  *
430  * This function reads configuration data, parses its contents, and allocates
431  * data structures needed for storing configuration information. The allocated
432  * data can be freed with wpa_config_free().
433  *
434  * Each configuration backend needs to implement this function.
435  */
436 struct wpa_config * wpa_config_read(const char *name);
437
438 /**
439  * wpa_config_write - Write or update configuration data
440  * @name: Name of the configuration (e.g., path and file name for the
441  * configuration file)
442  * @config: Configuration data from wpa_config_read()
443  * Returns: 0 on success, -1 on failure
444  *
445  * This function write all configuration data into an external database (e.g.,
446  * a text file) in a format that can be read with wpa_config_read(). This can
447  * be used to allow wpa_supplicant to update its configuration, e.g., when a
448  * new network is added or a password is changed.
449  *
450  * Each configuration backend needs to implement this function.
451  */
452 int wpa_config_write(const char *name, struct wpa_config *config);
453
454 #endif /* CONFIG_H */