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