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