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