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