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 #define DEFAULT_AP_SCAN 1 20 #define DEFAULT_FAST_REAUTH 1 21 22 #include "config_ssid.h" 23 24 /** 25 * struct wpa_config_blob - Named configuration blob 26 * 27 * This data structure is used to provide storage for binary objects to store 28 * abstract information like certificates and private keys inlined with the 29 * configuration data. 30 */ 31 struct wpa_config_blob { 32 /** 33 * name - Blob name 34 */ 35 char *name; 36 37 /** 38 * data - Pointer to binary data 39 */ 40 u8 *data; 41 42 /** 43 * len - Length of binary data 44 */ 45 size_t len; 46 47 /** 48 * next - Pointer to next blob in the configuration 49 */ 50 struct wpa_config_blob *next; 51 }; 52 53 54 /** 55 * struct wpa_config - wpa_supplicant configuration data 56 * 57 * This data structure is presents the per-interface (radio) configuration 58 * data. In many cases, there is only one struct wpa_config instance, but if 59 * more than one network interface is being controlled, one instance is used 60 * for each. 61 */ 62 struct wpa_config { 63 /** 64 * ssid - Head of the global network list 65 * 66 * This is the head for the list of all the configured networks. 67 */ 68 struct wpa_ssid *ssid; 69 70 /** 71 * pssid - Per-priority network lists (in priority order) 72 */ 73 struct wpa_ssid **pssid; 74 75 /** 76 * num_prio - Number of different priorities used in the pssid lists 77 * 78 * This indicates how many per-priority network lists are included in 79 * pssid. 80 */ 81 int num_prio; 82 83 /** 84 * eapol_version - IEEE 802.1X/EAPOL version number 85 * 86 * wpa_supplicant is implemented based on IEEE Std 802.1X-2004 which 87 * defines EAPOL version 2. However, there are many APs that do not 88 * handle the new version number correctly (they seem to drop the 89 * frames completely). In order to make wpa_supplicant interoperate 90 * with these APs, the version number is set to 1 by default. This 91 * configuration value can be used to set it to the new version (2). 92 */ 93 int eapol_version; 94 95 /** 96 * ap_scan - AP scanning/selection 97 * 98 * By default, wpa_supplicant requests driver to perform AP 99 * scanning and then uses the scan results to select a 100 * suitable AP. Another alternative is to allow the driver to 101 * take care of AP scanning and selection and use 102 * wpa_supplicant just to process EAPOL frames based on IEEE 103 * 802.11 association information from the driver. 104 * 105 * 1: wpa_supplicant initiates scanning and AP selection (default). 106 * 107 * 0: Driver takes care of scanning, AP selection, and IEEE 802.11 108 * association parameters (e.g., WPA IE generation); this mode can 109 * also be used with non-WPA drivers when using IEEE 802.1X mode; 110 * do not try to associate with APs (i.e., external program needs 111 * to control association). This mode must also be used when using 112 * wired Ethernet drivers. 113 * 114 * 2: like 0, but associate with APs using security policy and SSID 115 * (but not BSSID); this can be used, e.g., with ndiswrapper and NDIS 116 * drivers to enable operation with hidden SSIDs and optimized roaming; 117 * in this mode, the network blocks in the configuration are tried 118 * one by one until the driver reports successful association; each 119 * network block should have explicit security policy (i.e., only one 120 * option in the lists) for key_mgmt, pairwise, group, proto variables. 121 */ 122 int ap_scan; 123 124 /** 125 * ctrl_interface - Parameters for the control interface 126 * 127 * If this is specified, %wpa_supplicant will open a control interface 128 * that is available for external programs to manage %wpa_supplicant. 129 * The meaning of this string depends on which control interface 130 * mechanism is used. For all cases, the existance of this parameter 131 * in configuration is used to determine whether the control interface 132 * is enabled. 133 * 134 * For UNIX domain sockets (default on Linux and BSD): This is a 135 * directory that will be created for UNIX domain sockets for listening 136 * to requests from external programs (CLI/GUI, etc.) for status 137 * information and configuration. The socket file will be named based 138 * on the interface name, so multiple %wpa_supplicant processes can be 139 * run at the same time if more than one interface is used. 140 * /var/run/wpa_supplicant is the recommended directory for sockets and 141 * by default, wpa_cli will use it when trying to connect with 142 * %wpa_supplicant. 143 * 144 * Access control for the control interface can be configured 145 * by setting the directory to allow only members of a group 146 * to use sockets. This way, it is possible to run 147 * %wpa_supplicant as root (since it needs to change network 148 * configuration and open raw sockets) and still allow GUI/CLI 149 * components to be run as non-root users. However, since the 150 * control interface can be used to change the network 151 * configuration, this access needs to be protected in many 152 * cases. By default, %wpa_supplicant is configured to use gid 153 * 0 (root). If you want to allow non-root users to use the 154 * control interface, add a new group and change this value to 155 * match with that group. Add users that should have control 156 * interface access to this group. 157 * 158 * When configuring both the directory and group, use following format: 159 * DIR=/var/run/wpa_supplicant GROUP=wheel 160 * DIR=/var/run/wpa_supplicant GROUP=0 161 * (group can be either group name or gid) 162 * 163 * For UDP connections (default on Windows): The value will be ignored. 164 * This variable is just used to select that the control interface is 165 * to be created. The value can be set to, e.g., udp 166 * (ctrl_interface=udp). 167 * 168 * For Windows Named Pipe: This value can be used to set the security 169 * descriptor for controlling access to the control interface. Security 170 * descriptor can be set using Security Descriptor String Format (see 171 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/security/security_descriptor_string_format.asp). 172 * The descriptor string needs to be prefixed with SDDL=. For example, 173 * ctrl_interface=SDDL=D: would set an empty DACL (which will reject 174 * all connections). 175 */ 176 char *ctrl_interface; 177 178 /** 179 * ctrl_interface_group - Control interface group (DEPRECATED) 180 * 181 * This variable is only used for backwards compatibility. Group for 182 * UNIX domain sockets should now be specified using GROUP=<group> in 183 * ctrl_interface variable. 184 */ 185 char *ctrl_interface_group; 186 187 /** 188 * fast_reauth - EAP fast re-authentication (session resumption) 189 * 190 * By default, fast re-authentication is enabled for all EAP methods 191 * that support it. This variable can be used to disable fast 192 * re-authentication (by setting fast_reauth=0). Normally, there is no 193 * need to disable fast re-authentication. 194 */ 195 int fast_reauth; 196 197 /** 198 * opensc_engine_path - Path to the OpenSSL engine for opensc 199 * 200 * This is an OpenSSL specific configuration option for loading OpenSC 201 * engine (engine_opensc.so); if %NULL, this engine is not loaded. 202 */ 203 char *opensc_engine_path; 204 205 /** 206 * pkcs11_engine_path - Path to the OpenSSL engine for PKCS#11 207 * 208 * This is an OpenSSL specific configuration option for loading PKCS#11 209 * engine (engine_pkcs11.so); if %NULL, this engine is not loaded. 210 */ 211 char *pkcs11_engine_path; 212 213 /** 214 * pkcs11_module_path - Path to the OpenSSL OpenSC/PKCS#11 module 215 * 216 * This is an OpenSSL specific configuration option for configuring 217 * path to OpenSC/PKCS#11 engine (opensc-pkcs11.so); if %NULL, this 218 * module is not loaded. 219 */ 220 char *pkcs11_module_path; 221 222 /** 223 * driver_param - Driver interface parameters 224 * 225 * This text string is passed to the selected driver interface with the 226 * optional struct wpa_driver_ops::set_param() handler. This can be 227 * used to configure driver specific options without having to add new 228 * driver interface functionality. 229 */ 230 char *driver_param; 231 232 /** 233 * dot11RSNAConfigPMKLifetime - Maximum lifetime of a PMK 234 * 235 * dot11 MIB variable for the maximum lifetime of a PMK in the PMK 236 * cache (unit: seconds). 237 */ 238 unsigned int dot11RSNAConfigPMKLifetime; 239 240 /** 241 * dot11RSNAConfigPMKReauthThreshold - PMK re-authentication threshold 242 * 243 * dot11 MIB variable for the percentage of the PMK lifetime 244 * that should expire before an IEEE 802.1X reauthentication occurs. 245 */ 246 unsigned int dot11RSNAConfigPMKReauthThreshold; 247 248 /** 249 * dot11RSNAConfigSATimeout - Security association timeout 250 * 251 * dot11 MIB variable for the maximum time a security association 252 * shall take to set up (unit: seconds). 253 */ 254 unsigned int dot11RSNAConfigSATimeout; 255 256 /** 257 * update_config - Is wpa_supplicant allowed to update configuration 258 * 259 * This variable control whether wpa_supplicant is allow to re-write 260 * its configuration with wpa_config_write(). If this is zero, 261 * configuration data is only changed in memory and the external data 262 * is not overriden. If this is non-zero, wpa_supplicant will update 263 * the configuration data (e.g., a file) whenever configuration is 264 * changed. This update may replace the old configuration which can 265 * remove comments from it in case of a text file configuration. 266 */ 267 int update_config; 268 269 /** 270 * blobs - Configuration blobs 271 */ 272 struct wpa_config_blob *blobs; 273 }; 274 275 276 /* Prototypes for common functions from config.c */ 277 278 void wpa_config_free(struct wpa_config *ssid); 279 void wpa_config_free_ssid(struct wpa_ssid *ssid); 280 struct wpa_ssid * wpa_config_get_network(struct wpa_config *config, int id); 281 struct wpa_ssid * wpa_config_add_network(struct wpa_config *config); 282 int wpa_config_remove_network(struct wpa_config *config, int id); 283 void wpa_config_set_network_defaults(struct wpa_ssid *ssid); 284 int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value, 285 int line); 286 char * wpa_config_get(struct wpa_ssid *ssid, const char *var); 287 char * wpa_config_get_no_key(struct wpa_ssid *ssid, const char *var); 288 void wpa_config_update_psk(struct wpa_ssid *ssid); 289 int wpa_config_add_prio_network(struct wpa_config *config, 290 struct wpa_ssid *ssid); 291 292 const struct wpa_config_blob * wpa_config_get_blob(struct wpa_config *config, 293 const char *name); 294 void wpa_config_set_blob(struct wpa_config *config, 295 struct wpa_config_blob *blob); 296 void wpa_config_free_blob(struct wpa_config_blob *blob); 297 int wpa_config_remove_blob(struct wpa_config *config, const char *name); 298 struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, 299 const char *driver_param); 300 #ifndef CONFIG_NO_STDOUT_DEBUG 301 void wpa_config_debug_dump_networks(struct wpa_config *config); 302 #else /* CONFIG_NO_STDOUT_DEBUG */ 303 #define wpa_config_debug_dump_networks(c) do { } while (0) 304 #endif /* CONFIG_NO_STDOUT_DEBUG */ 305 306 307 /* Prototypes for backend specific functions from the selected config_*.c */ 308 309 /** 310 * wpa_config_read - Read and parse configuration database 311 * @name: Name of the configuration (e.g., path and file name for the 312 * configuration file) 313 * Returns: Pointer to allocated configuration data or %NULL on failure 314 * 315 * This function reads configuration data, parses its contents, and allocates 316 * data structures needed for storing configuration information. The allocated 317 * data can be freed with wpa_config_free(). 318 * 319 * Each configuration backend needs to implement this function. 320 */ 321 struct wpa_config * wpa_config_read(const char *name); 322 323 /** 324 * wpa_config_write - Write or update configuration data 325 * @name: Name of the configuration (e.g., path and file name for the 326 * configuration file) 327 * @config: Configuration data from wpa_config_read() 328 * Returns: 0 on success, -1 on failure 329 * 330 * This function write all configuration data into an external database (e.g., 331 * a text file) in a format that can be read with wpa_config_read(). This can 332 * be used to allow wpa_supplicant to update its configuration, e.g., when a 333 * new network is added or a password is changed. 334 * 335 * Each configuration backend needs to implement this function. 336 */ 337 int wpa_config_write(const char *name, struct wpa_config *config); 338 339 #endif /* CONFIG_H */ 340