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