PageRenderTime 26ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/wpa_supplicant/wpa_supplicant/config.h

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