config.h 15 KB

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