1 /* 2 * WPA Supplicant / Network configuration structures 3 * Copyright (c) 2003-2008, Jouni Malinen <j (at) 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_SSID_H 16 #define CONFIG_SSID_H 17 18 #include "common/defs.h" 19 #include "eap_peer/eap_config.h" 20 21 #define MAX_SSID_LEN 32 22 23 24 #define DEFAULT_EAP_WORKAROUND ((unsigned int) -1) 25 #define DEFAULT_EAPOL_FLAGS (EAPOL_FLAG_REQUIRE_KEY_UNICAST | \ 26 EAPOL_FLAG_REQUIRE_KEY_BROADCAST) 27 #define DEFAULT_PROTO (WPA_PROTO_WPA | WPA_PROTO_RSN) 28 #define DEFAULT_KEY_MGMT (WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_IEEE8021X) 29 #define DEFAULT_PAIRWISE (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP) 30 #define DEFAULT_GROUP (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP | \ 31 WPA_CIPHER_WEP104 | WPA_CIPHER_WEP40) 32 #define DEFAULT_FRAGMENT_SIZE 1398 33 34 /** 35 * struct wpa_ssid - Network configuration data 36 * 37 * This structure includes all the configuration variables for a network. This 38 * data is included in the per-interface configuration data as an element of 39 * the network list, struct wpa_config::ssid. Each network block in the 40 * configuration is mapped to a struct wpa_ssid instance. 41 */ 42 struct wpa_ssid { 43 /** 44 * next - Next network in global list 45 * 46 * This pointer can be used to iterate over all networks. The head of 47 * this list is stored in the ssid field of struct wpa_config. 48 */ 49 struct wpa_ssid *next; 50 51 /** 52 * pnext - Next network in per-priority list 53 * 54 * This pointer can be used to iterate over all networks in the same 55 * priority class. The heads of these list are stored in the pssid 56 * fields of struct wpa_config. 57 */ 58 struct wpa_ssid *pnext; 59 60 /** 61 * id - Unique id for the network 62 * 63 * This identifier is used as a unique identifier for each network 64 * block when using the control interface. Each network is allocated an 65 * id when it is being created, either when reading the configuration 66 * file or when a new network is added through the control interface. 67 */ 68 int id; 69 70 /** 71 * priority - Priority group 72 * 73 * By default, all networks will get same priority group (0). If some 74 * of the networks are more desirable, this field can be used to change 75 * the order in which wpa_supplicant goes through the networks when 76 * selecting a BSS. The priority groups will be iterated in decreasing 77 * priority (i.e., the larger the priority value, the sooner the 78 * network is matched against the scan results). Within each priority 79 * group, networks will be selected based on security policy, signal 80 * strength, etc. 81 * 82 * Please note that AP scanning with scan_ssid=1 and ap_scan=2 mode are 83 * not using this priority to select the order for scanning. Instead, 84 * they try the networks in the order that used in the configuration 85 * file. 86 */ 87 int priority; 88 89 /** 90 * ssid - Service set identifier (network name) 91 * 92 * This is the SSID for the network. For wireless interfaces, this is 93 * used to select which network will be used. If set to %NULL (or 94 * ssid_len=0), any SSID can be used. For wired interfaces, this must 95 * be set to %NULL. Note: SSID may contain any characters, even nul 96 * (ASCII 0) and as such, this should not be assumed to be a nul 97 * terminated string. ssid_len defines how many characters are valid 98 * and the ssid field is not guaranteed to be nul terminated. 99 */ 100 u8 *ssid; 101 102 /** 103 * ssid_len - Length of the SSID 104 */ 105 size_t ssid_len; 106 107 /** 108 * bssid - BSSID 109 * 110 * If set, this network block is used only when associating with the AP 111 * using the configured BSSID 112 * 113 * If this is a persistent P2P group (disabled == 2), this is the GO 114 * Device Address. 115 */ 116 u8 bssid[ETH_ALEN]; 117 118 /** 119 * bssid_set - Whether BSSID is configured for this network 120 */ 121 int bssid_set; 122 123 /** 124 * psk - WPA pre-shared key (256 bits) 125 */ 126 u8 psk[32]; 127 128 /** 129 * psk_set - Whether PSK field is configured 130 */ 131 int psk_set; 132 133 /** 134 * passphrase - WPA ASCII passphrase 135 * 136 * If this is set, psk will be generated using the SSID and passphrase 137 * configured for the network. ASCII passphrase must be between 8 and 138 * 63 characters (inclusive). 139 */ 140 char *passphrase; 141 142 /** 143 * pairwise_cipher - Bitfield of allowed pairwise ciphers, WPA_CIPHER_* 144 */ 145 int pairwise_cipher; 146 147 /** 148 * group_cipher - Bitfield of allowed group ciphers, WPA_CIPHER_* 149 */ 150 int group_cipher; 151 152 /** 153 * key_mgmt - Bitfield of allowed key management protocols 154 * 155 * WPA_KEY_MGMT_* 156 */ 157 int key_mgmt; 158 159 /** 160 * proto - Bitfield of allowed protocols, WPA_PROTO_* 161 */ 162 int proto; 163 164 /** 165 * auth_alg - Bitfield of allowed authentication algorithms 166 * 167 * WPA_AUTH_ALG_* 168 */ 169 int auth_alg; 170 171 /** 172 * scan_ssid - Scan this SSID with Probe Requests 173 * 174 * scan_ssid can be used to scan for APs using hidden SSIDs. 175 * Note: Many drivers do not support this. ap_mode=2 can be used with 176 * such drivers to use hidden SSIDs. 177 */ 178 int scan_ssid; 179 180 #ifdef IEEE8021X_EAPOL 181 #define EAPOL_FLAG_REQUIRE_KEY_UNICAST BIT(0) 182 #define EAPOL_FLAG_REQUIRE_KEY_BROADCAST BIT(1) 183 /** 184 * eapol_flags - Bit field of IEEE 802.1X/EAPOL options (EAPOL_FLAG_*) 185 */ 186 int eapol_flags; 187 188 /** 189 * eap - EAP peer configuration for this network 190 */ 191 struct eap_peer_config eap; 192 #endif /* IEEE8021X_EAPOL */ 193 194 #define NUM_WEP_KEYS 4 195 #define MAX_WEP_KEY_LEN 16 196 /** 197 * wep_key - WEP keys 198 */ 199 u8 wep_key[NUM_WEP_KEYS][MAX_WEP_KEY_LEN]; 200 201 /** 202 * wep_key_len - WEP key lengths 203 */ 204 size_t wep_key_len[NUM_WEP_KEYS]; 205 206 /** 207 * wep_tx_keyidx - Default key index for TX frames using WEP 208 */ 209 int wep_tx_keyidx; 210 211 /** 212 * proactive_key_caching - Enable proactive key caching 213 * 214 * This field can be used to enable proactive key caching which is also 215 * known as opportunistic PMKSA caching for WPA2. This is disabled (0) 216 * by default. Enable by setting this to 1. 217 * 218 * Proactive key caching is used to make supplicant assume that the APs 219 * are using the same PMK and generate PMKSA cache entries without 220 * doing RSN pre-authentication. This requires support from the AP side 221 * and is normally used with wireless switches that co-locate the 222 * authenticator. 223 */ 224 int proactive_key_caching; 225 226 /** 227 * mixed_cell - Whether mixed cells are allowed 228 * 229 * This option can be used to configure whether so called mixed cells, 230 * i.e., networks that use both plaintext and encryption in the same 231 * SSID, are allowed. This is disabled (0) by default. Enable by 232 * setting this to 1. 233 */ 234 int mixed_cell; 235 236 #ifdef IEEE8021X_EAPOL 237 238 /** 239 * leap - Number of EAP methods using LEAP 240 * 241 * This field should be set to 1 if LEAP is enabled. This is used to 242 * select IEEE 802.11 authentication algorithm. 243 */ 244 int leap; 245 246 /** 247 * non_leap - Number of EAP methods not using LEAP 248 * 249 * This field should be set to >0 if any EAP method other than LEAP is 250 * enabled. This is used to select IEEE 802.11 authentication 251 * algorithm. 252 */ 253 int non_leap; 254 255 /** 256 * eap_workaround - EAP workarounds enabled 257 * 258 * wpa_supplicant supports number of "EAP workarounds" to work around 259 * interoperability issues with incorrectly behaving authentication 260 * servers. This is recommended to be enabled by default because some 261 * of the issues are present in large number of authentication servers. 262 * 263 * Strict EAP conformance mode can be configured by disabling 264 * workarounds with eap_workaround = 0. 265 */ 266 unsigned int eap_workaround; 267 268 #endif /* IEEE8021X_EAPOL */ 269 270 /** 271 * mode - IEEE 802.11 operation mode (Infrastucture/IBSS) 272 * 273 * 0 = infrastructure (Managed) mode, i.e., associate with an AP. 274 * 275 * 1 = IBSS (ad-hoc, peer-to-peer) 276 * 277 * 2 = AP (access point) 278 * 279 * 3 = P2P Group Owner (can be set in the configuration file) 280 * 281 * 4 = P2P Group Formation (used internally; not in configuration 282 * files) 283 * 284 * Note: IBSS can only be used with key_mgmt NONE (plaintext and 285 * static WEP) and key_mgmt=WPA-NONE (fixed group key TKIP/CCMP). In 286 * addition, ap_scan has to be set to 2 for IBSS. WPA-None requires 287 * following network block options: proto=WPA, key_mgmt=WPA-NONE, 288 * pairwise=NONE, group=TKIP (or CCMP, but not both), and psk must also 289 * be set (either directly or using ASCII passphrase). 290 */ 291 enum wpas_mode { 292 WPAS_MODE_INFRA = 0, 293 WPAS_MODE_IBSS = 1, 294 WPAS_MODE_AP = 2, 295 WPAS_MODE_P2P_GO = 3, 296 WPAS_MODE_P2P_GROUP_FORMATION = 4, 297 } mode; 298 299 /** 300 * disabled - Whether this network is currently disabled 301 * 302 * 0 = this network can be used (default). 303 * 1 = this network block is disabled (can be enabled through 304 * ctrl_iface, e.g., with wpa_cli or wpa_gui). 305 * 2 = this network block includes parameters for a persistent P2P 306 * group (can be used with P2P ctrl_iface commands) 307 */ 308 int disabled; 309 310 /** 311 * peerkey - Whether PeerKey handshake for direct links is allowed 312 * 313 * This is only used when both RSN/WPA2 and IEEE 802.11e (QoS) are 314 * enabled. 315 * 316 * 0 = disabled (default) 317 * 1 = enabled 318 */ 319 int peerkey; 320 321 /** 322 * id_str - Network identifier string for external scripts 323 * 324 * This value is passed to external ctrl_iface monitors in 325 * WPA_EVENT_CONNECTED event and wpa_cli sets this as WPA_ID_STR 326 * environment variable for action scripts. 327 */ 328 char *id_str; 329 330 #ifdef CONFIG_IEEE80211W 331 /** 332 * ieee80211w - Whether management frame protection is enabled 333 * 334 * This value is used to configure policy for management frame 335 * protection (IEEE 802.11w). 0 = disabled, 1 = optional, 2 = required. 336 */ 337 enum mfp_options ieee80211w; 338 #endif /* CONFIG_IEEE80211W */ 339 340 /** 341 * frequency - Channel frequency in megahertz (MHz) for IBSS 342 * 343 * This value is used to configure the initial channel for IBSS (adhoc) 344 * networks, e.g., 2412 = IEEE 802.11b/g channel 1. It is ignored in 345 * the infrastructure mode. In addition, this value is only used by the 346 * station that creates the IBSS. If an IBSS network with the 347 * configured SSID is already present, the frequency of the network 348 * will be used instead of this configured value. 349 */ 350 int frequency; 351 352 /** 353 * wpa_ptk_rekey - Maximum lifetime for PTK in seconds 354 * 355 * This value can be used to enforce rekeying of PTK to mitigate some 356 * attacks against TKIP deficiencies. 357 */ 358 int wpa_ptk_rekey; 359 360 /** 361 * scan_freq - Array of frequencies to scan or %NULL for all 362 * 363 * This is an optional zero-terminated array of frequencies in 364 * megahertz (MHz) to include in scan requests when searching for this 365 * network. This can be used to speed up scanning when the network is 366 * known to not use all possible channels. 367 */ 368 int *scan_freq; 369 370 /** 371 * bgscan - Background scan and roaming parameters or %NULL if none 372 * 373 * This is an optional set of parameters for background scanning and 374 * roaming within a network (ESS) in following format: 375 * <bgscan module name>:<module parameters> 376 */ 377 char *bgscan; 378 379 /** 380 * freq_list - Array of allowed frequencies or %NULL for all 381 * 382 * This is an optional zero-terminated array of frequencies in 383 * megahertz (MHz) to allow for selecting the BSS. If set, scan results 384 * that do not match any of the specified frequencies are not 385 * considered when selecting a BSS. 386 */ 387 int *freq_list; 388 389 /** 390 * p2p_group - Network generated as a P2P group (used internally) 391 */ 392 int p2p_group; 393 394 /** 395 * p2p_persistent_group - Whether this is a persistent group 396 */ 397 int p2p_persistent_group; 398 399 /** 400 * temporary - Whether this network is temporary and not to be saved 401 */ 402 int temporary; 403 404 /** 405 * export_keys - Whether keys may be exported 406 * 407 * This attribute will be set when keys are determined through 408 * WPS or similar so that they may be exported. 409 */ 410 int export_keys; 411 }; 412 413 #endif /* CONFIG_SSID_H */ 414