config.h 14 KB

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