1/*
2 * WPA Supplicant / Network configuration structures
3 * Copyright (c) 2003-2013, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9#ifndef CONFIG_SSID_H
10#define CONFIG_SSID_H
11
12#include "common/defs.h"
13#include "utils/list.h"
14#include "eap_peer/eap_config.h"
15
16
17#define DEFAULT_EAP_WORKAROUND ((unsigned int) -1)
18#define DEFAULT_EAPOL_FLAGS (EAPOL_FLAG_REQUIRE_KEY_UNICAST | \
19			     EAPOL_FLAG_REQUIRE_KEY_BROADCAST)
20#define DEFAULT_PROTO (WPA_PROTO_WPA | WPA_PROTO_RSN)
21#define DEFAULT_KEY_MGMT (WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_IEEE8021X)
22#define DEFAULT_PAIRWISE (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP)
23#define DEFAULT_GROUP (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP)
24#define DEFAULT_FRAGMENT_SIZE 1398
25
26#define DEFAULT_BG_SCAN_PERIOD -1
27#define DEFAULT_MESH_MAX_RETRIES 2
28#define DEFAULT_MESH_RETRY_TIMEOUT 40
29#define DEFAULT_MESH_CONFIRM_TIMEOUT 40
30#define DEFAULT_MESH_HOLDING_TIMEOUT 40
31#define DEFAULT_DISABLE_HT 0
32#define DEFAULT_DISABLE_HT40 0
33#define DEFAULT_DISABLE_SGI 0
34#define DEFAULT_DISABLE_LDPC 0
35#define DEFAULT_DISABLE_MAX_AMSDU -1 /* no change */
36#define DEFAULT_AMPDU_FACTOR -1 /* no change */
37#define DEFAULT_AMPDU_DENSITY -1 /* no change */
38#define DEFAULT_USER_SELECTED_SIM 1
39
40struct psk_list_entry {
41	struct dl_list list;
42	u8 addr[ETH_ALEN];
43	u8 psk[32];
44	u8 p2p;
45};
46
47/**
48 * struct wpa_ssid - Network configuration data
49 *
50 * This structure includes all the configuration variables for a network. This
51 * data is included in the per-interface configuration data as an element of
52 * the network list, struct wpa_config::ssid. Each network block in the
53 * configuration is mapped to a struct wpa_ssid instance.
54 */
55struct wpa_ssid {
56	/**
57	 * next - Next network in global list
58	 *
59	 * This pointer can be used to iterate over all networks. The head of
60	 * this list is stored in the ssid field of struct wpa_config.
61	 */
62	struct wpa_ssid *next;
63
64	/**
65	 * pnext - Next network in per-priority list
66	 *
67	 * This pointer can be used to iterate over all networks in the same
68	 * priority class. The heads of these list are stored in the pssid
69	 * fields of struct wpa_config.
70	 */
71	struct wpa_ssid *pnext;
72
73	/**
74	 * id - Unique id for the network
75	 *
76	 * This identifier is used as a unique identifier for each network
77	 * block when using the control interface. Each network is allocated an
78	 * id when it is being created, either when reading the configuration
79	 * file or when a new network is added through the control interface.
80	 */
81	int id;
82
83	/**
84	 * priority - Priority group
85	 *
86	 * By default, all networks will get same priority group (0). If some
87	 * of the networks are more desirable, this field can be used to change
88	 * the order in which wpa_supplicant goes through the networks when
89	 * selecting a BSS. The priority groups will be iterated in decreasing
90	 * priority (i.e., the larger the priority value, the sooner the
91	 * network is matched against the scan results). Within each priority
92	 * group, networks will be selected based on security policy, signal
93	 * strength, etc.
94	 *
95	 * Please note that AP scanning with scan_ssid=1 and ap_scan=2 mode are
96	 * not using this priority to select the order for scanning. Instead,
97	 * they try the networks in the order that used in the configuration
98	 * file.
99	 */
100	int priority;
101
102	/**
103	 * ssid - Service set identifier (network name)
104	 *
105	 * This is the SSID for the network. For wireless interfaces, this is
106	 * used to select which network will be used. If set to %NULL (or
107	 * ssid_len=0), any SSID can be used. For wired interfaces, this must
108	 * be set to %NULL. Note: SSID may contain any characters, even nul
109	 * (ASCII 0) and as such, this should not be assumed to be a nul
110	 * terminated string. ssid_len defines how many characters are valid
111	 * and the ssid field is not guaranteed to be nul terminated.
112	 */
113	u8 *ssid;
114
115	/**
116	 * ssid_len - Length of the SSID
117	 */
118	size_t ssid_len;
119
120	/**
121	 * bssid - BSSID
122	 *
123	 * If set, this network block is used only when associating with the AP
124	 * using the configured BSSID
125	 *
126	 * If this is a persistent P2P group (disabled == 2), this is the GO
127	 * Device Address.
128	 */
129	u8 bssid[ETH_ALEN];
130
131	/**
132	 * bssid_blacklist - List of inacceptable BSSIDs
133	 */
134	u8 *bssid_blacklist;
135	size_t num_bssid_blacklist;
136
137	/**
138	 * bssid_blacklist - List of acceptable BSSIDs
139	 */
140	u8 *bssid_whitelist;
141	size_t num_bssid_whitelist;
142
143	/**
144	 * bssid_set - Whether BSSID is configured for this network
145	 */
146	int bssid_set;
147
148	/**
149	 * go_p2p_dev_addr - GO's P2P Device Address or all zeros if not set
150	 */
151	u8 go_p2p_dev_addr[ETH_ALEN];
152
153	/**
154	 * psk - WPA pre-shared key (256 bits)
155	 */
156	u8 psk[32];
157
158	/**
159	 * psk_set - Whether PSK field is configured
160	 */
161	int psk_set;
162
163	/**
164	 * passphrase - WPA ASCII passphrase
165	 *
166	 * If this is set, psk will be generated using the SSID and passphrase
167	 * configured for the network. ASCII passphrase must be between 8 and
168	 * 63 characters (inclusive).
169	 */
170	char *passphrase;
171
172	/**
173	 * ext_psk - PSK/passphrase name in external storage
174	 *
175	 * If this is set, PSK/passphrase will be fetched from external storage
176	 * when requesting association with the network.
177	 */
178	char *ext_psk;
179
180	/**
181	 * mem_only_psk - Whether to keep PSK/passphrase only in memory
182	 *
183	 * 0 = allow psk/passphrase to be stored to the configuration file
184	 * 1 = do not store psk/passphrase to the configuration file
185	 */
186	int mem_only_psk;
187
188	/**
189	 * pairwise_cipher - Bitfield of allowed pairwise ciphers, WPA_CIPHER_*
190	 */
191	int pairwise_cipher;
192
193	/**
194	 * group_cipher - Bitfield of allowed group ciphers, WPA_CIPHER_*
195	 */
196	int group_cipher;
197
198	/**
199	 * key_mgmt - Bitfield of allowed key management protocols
200	 *
201	 * WPA_KEY_MGMT_*
202	 */
203	int key_mgmt;
204
205	/**
206	 * bg_scan_period - Background scan period in seconds, 0 to disable, or
207	 * -1 to indicate no change to default driver configuration
208	 */
209	int bg_scan_period;
210
211	/**
212	 * proto - Bitfield of allowed protocols, WPA_PROTO_*
213	 */
214	int proto;
215
216	/**
217	 * auth_alg -  Bitfield of allowed authentication algorithms
218	 *
219	 * WPA_AUTH_ALG_*
220	 */
221	int auth_alg;
222
223	/**
224	 * scan_ssid - Scan this SSID with Probe Requests
225	 *
226	 * scan_ssid can be used to scan for APs using hidden SSIDs.
227	 * Note: Many drivers do not support this. ap_mode=2 can be used with
228	 * such drivers to use hidden SSIDs.
229	 */
230	int scan_ssid;
231
232#ifdef IEEE8021X_EAPOL
233#define EAPOL_FLAG_REQUIRE_KEY_UNICAST BIT(0)
234#define EAPOL_FLAG_REQUIRE_KEY_BROADCAST BIT(1)
235	/**
236	 * eapol_flags - Bit field of IEEE 802.1X/EAPOL options (EAPOL_FLAG_*)
237	 */
238	int eapol_flags;
239
240	/**
241	 * eap - EAP peer configuration for this network
242	 */
243	struct eap_peer_config eap;
244#endif /* IEEE8021X_EAPOL */
245
246#define NUM_WEP_KEYS 4
247#define MAX_WEP_KEY_LEN 16
248	/**
249	 * wep_key - WEP keys
250	 */
251	u8 wep_key[NUM_WEP_KEYS][MAX_WEP_KEY_LEN];
252
253	/**
254	 * wep_key_len - WEP key lengths
255	 */
256	size_t wep_key_len[NUM_WEP_KEYS];
257
258	/**
259	 * wep_tx_keyidx - Default key index for TX frames using WEP
260	 */
261	int wep_tx_keyidx;
262
263	/**
264	 * proactive_key_caching - Enable proactive key caching
265	 *
266	 * This field can be used to enable proactive key caching which is also
267	 * known as opportunistic PMKSA caching for WPA2. This is disabled (0)
268	 * by default unless default value is changed with the global okc=1
269	 * parameter. Enable by setting this to 1.
270	 *
271	 * Proactive key caching is used to make supplicant assume that the APs
272	 * are using the same PMK and generate PMKSA cache entries without
273	 * doing RSN pre-authentication. This requires support from the AP side
274	 * and is normally used with wireless switches that co-locate the
275	 * authenticator.
276	 *
277	 * Internally, special value -1 is used to indicate that the parameter
278	 * was not specified in the configuration (i.e., default behavior is
279	 * followed).
280	 */
281	int proactive_key_caching;
282
283	/**
284	 * mixed_cell - Whether mixed cells are allowed
285	 *
286	 * This option can be used to configure whether so called mixed cells,
287	 * i.e., networks that use both plaintext and encryption in the same
288	 * SSID, are allowed. This is disabled (0) by default. Enable by
289	 * setting this to 1.
290	 */
291	int mixed_cell;
292
293#ifdef IEEE8021X_EAPOL
294
295	/**
296	 * leap - Number of EAP methods using LEAP
297	 *
298	 * This field should be set to 1 if LEAP is enabled. This is used to
299	 * select IEEE 802.11 authentication algorithm.
300	 */
301	int leap;
302
303	/**
304	 * non_leap - Number of EAP methods not using LEAP
305	 *
306	 * This field should be set to >0 if any EAP method other than LEAP is
307	 * enabled. This is used to select IEEE 802.11 authentication
308	 * algorithm.
309	 */
310	int non_leap;
311
312	/**
313	 * eap_workaround - EAP workarounds enabled
314	 *
315	 * wpa_supplicant supports number of "EAP workarounds" to work around
316	 * interoperability issues with incorrectly behaving authentication
317	 * servers. This is recommended to be enabled by default because some
318	 * of the issues are present in large number of authentication servers.
319	 *
320	 * Strict EAP conformance mode can be configured by disabling
321	 * workarounds with eap_workaround = 0.
322	 */
323	unsigned int eap_workaround;
324
325#endif /* IEEE8021X_EAPOL */
326
327	/**
328	 * mode - IEEE 802.11 operation mode (Infrastucture/IBSS)
329	 *
330	 * 0 = infrastructure (Managed) mode, i.e., associate with an AP.
331	 *
332	 * 1 = IBSS (ad-hoc, peer-to-peer)
333	 *
334	 * 2 = AP (access point)
335	 *
336	 * 3 = P2P Group Owner (can be set in the configuration file)
337	 *
338	 * 4 = P2P Group Formation (used internally; not in configuration
339	 * files)
340	 *
341	 * 5 = Mesh
342	 *
343	 * Note: IBSS can only be used with key_mgmt NONE (plaintext and static
344	 * WEP) and WPA-PSK (with proto=RSN). In addition, key_mgmt=WPA-NONE
345	 * (fixed group key TKIP/CCMP) is available for backwards compatibility,
346	 * but its use is deprecated. WPA-None requires following network block
347	 * options: proto=WPA, key_mgmt=WPA-NONE, pairwise=NONE, group=TKIP (or
348	 * CCMP, but not both), and psk must also be set (either directly or
349	 * using ASCII passphrase).
350	 */
351	enum wpas_mode {
352		WPAS_MODE_INFRA = 0,
353		WPAS_MODE_IBSS = 1,
354		WPAS_MODE_AP = 2,
355		WPAS_MODE_P2P_GO = 3,
356		WPAS_MODE_P2P_GROUP_FORMATION = 4,
357		WPAS_MODE_MESH = 5,
358	} mode;
359
360	/**
361	 * disabled - Whether this network is currently disabled
362	 *
363	 * 0 = this network can be used (default).
364	 * 1 = this network block is disabled (can be enabled through
365	 * ctrl_iface, e.g., with wpa_cli or wpa_gui).
366	 * 2 = this network block includes parameters for a persistent P2P
367	 * group (can be used with P2P ctrl_iface commands)
368	 */
369	int disabled;
370
371	/**
372	 * disabled_for_connect - Whether this network was temporarily disabled
373	 *
374	 * This flag is used to reenable all the temporarily disabled networks
375	 * after either the success or failure of a WPS connection.
376	 */
377	int disabled_for_connect;
378
379	/**
380	 * peerkey -  Whether PeerKey handshake for direct links is allowed
381	 *
382	 * This is only used when both RSN/WPA2 and IEEE 802.11e (QoS) are
383	 * enabled.
384	 *
385	 * 0 = disabled (default)
386	 * 1 = enabled
387	 */
388	int peerkey;
389
390	/**
391	 * id_str - Network identifier string for external scripts
392	 *
393	 * This value is passed to external ctrl_iface monitors in
394	 * WPA_EVENT_CONNECTED event and wpa_cli sets this as WPA_ID_STR
395	 * environment variable for action scripts.
396	 */
397	char *id_str;
398
399#ifdef CONFIG_IEEE80211W
400	/**
401	 * ieee80211w - Whether management frame protection is enabled
402	 *
403	 * This value is used to configure policy for management frame
404	 * protection (IEEE 802.11w). 0 = disabled, 1 = optional, 2 = required.
405	 * This is disabled by default unless the default value has been changed
406	 * with the global pmf=1/2 parameter.
407	 *
408	 * Internally, special value 3 is used to indicate that the parameter
409	 * was not specified in the configuration (i.e., default behavior is
410	 * followed).
411	 */
412	enum mfp_options ieee80211w;
413#endif /* CONFIG_IEEE80211W */
414
415	/**
416	 * frequency - Channel frequency in megahertz (MHz) for IBSS
417	 *
418	 * This value is used to configure the initial channel for IBSS (adhoc)
419	 * networks, e.g., 2412 = IEEE 802.11b/g channel 1. It is ignored in
420	 * the infrastructure mode. In addition, this value is only used by the
421	 * station that creates the IBSS. If an IBSS network with the
422	 * configured SSID is already present, the frequency of the network
423	 * will be used instead of this configured value.
424	 */
425	int frequency;
426
427	/**
428	 * fixed_freq - Use fixed frequency for IBSS
429	 */
430	int fixed_freq;
431
432	/**
433	 * mesh_basic_rates - BSS Basic rate set for mesh network
434	 *
435	 */
436	int *mesh_basic_rates;
437
438	/**
439	 * Mesh network plink parameters
440	 */
441	int dot11MeshMaxRetries;
442	int dot11MeshRetryTimeout; /* msec */
443	int dot11MeshConfirmTimeout; /* msec */
444	int dot11MeshHoldingTimeout; /* msec */
445
446	int ht40;
447
448	int vht;
449
450	/**
451	 * wpa_ptk_rekey - Maximum lifetime for PTK in seconds
452	 *
453	 * This value can be used to enforce rekeying of PTK to mitigate some
454	 * attacks against TKIP deficiencies.
455	 */
456	int wpa_ptk_rekey;
457
458	/**
459	 * scan_freq - Array of frequencies to scan or %NULL for all
460	 *
461	 * This is an optional zero-terminated array of frequencies in
462	 * megahertz (MHz) to include in scan requests when searching for this
463	 * network. This can be used to speed up scanning when the network is
464	 * known to not use all possible channels.
465	 */
466	int *scan_freq;
467
468	/**
469	 * bgscan - Background scan and roaming parameters or %NULL if none
470	 *
471	 * This is an optional set of parameters for background scanning and
472	 * roaming within a network (ESS) in following format:
473	 * <bgscan module name>:<module parameters>
474	 */
475	char *bgscan;
476
477	/**
478	 * ignore_broadcast_ssid - Hide SSID in AP mode
479	 *
480	 * Send empty SSID in beacons and ignore probe request frames that do
481	 * not specify full SSID, i.e., require stations to know SSID.
482	 * default: disabled (0)
483	 * 1 = send empty (length=0) SSID in beacon and ignore probe request
484	 * for broadcast SSID
485	 * 2 = clear SSID (ASCII 0), but keep the original length (this may be
486	 * required with some clients that do not support empty SSID) and
487	 * ignore probe requests for broadcast SSID
488	 */
489	int ignore_broadcast_ssid;
490
491	/**
492	 * freq_list - Array of allowed frequencies or %NULL for all
493	 *
494	 * This is an optional zero-terminated array of frequencies in
495	 * megahertz (MHz) to allow for selecting the BSS. If set, scan results
496	 * that do not match any of the specified frequencies are not
497	 * considered when selecting a BSS.
498	 */
499	int *freq_list;
500
501	/**
502	 * p2p_client_list - List of P2P Clients in a persistent group (GO)
503	 *
504	 * This is a list of P2P Clients (P2P Device Address) that have joined
505	 * the persistent group. This is maintained on the GO for persistent
506	 * group entries (disabled == 2).
507	 */
508	u8 *p2p_client_list;
509
510	/**
511	 * num_p2p_clients - Number of entries in p2p_client_list
512	 */
513	size_t num_p2p_clients;
514
515#ifndef P2P_MAX_STORED_CLIENTS
516#define P2P_MAX_STORED_CLIENTS 100
517#endif /* P2P_MAX_STORED_CLIENTS */
518
519	/**
520	 * psk_list - Per-client PSKs (struct psk_list_entry)
521	 */
522	struct dl_list psk_list;
523
524	/**
525	 * p2p_group - Network generated as a P2P group (used internally)
526	 */
527	int p2p_group;
528
529	/**
530	 * p2p_persistent_group - Whether this is a persistent group
531	 */
532	int p2p_persistent_group;
533
534	/**
535	 * temporary - Whether this network is temporary and not to be saved
536	 */
537	int temporary;
538
539	/**
540	 * export_keys - Whether keys may be exported
541	 *
542	 * This attribute will be set when keys are determined through
543	 * WPS or similar so that they may be exported.
544	 */
545	int export_keys;
546
547#ifdef CONFIG_HT_OVERRIDES
548	/**
549	 * disable_ht - Disable HT (IEEE 802.11n) for this network
550	 *
551	 * By default, use it if it is available, but this can be configured
552	 * to 1 to have it disabled.
553	 */
554	int disable_ht;
555
556	/**
557	 * disable_ht40 - Disable HT40 for this network
558	 *
559	 * By default, use it if it is available, but this can be configured
560	 * to 1 to have it disabled.
561	 */
562	int disable_ht40;
563
564	/**
565	 * disable_sgi - Disable SGI (Short Guard Interval) for this network
566	 *
567	 * By default, use it if it is available, but this can be configured
568	 * to 1 to have it disabled.
569	 */
570	int disable_sgi;
571
572	/**
573	 * disable_ldpc - Disable LDPC for this network
574	 *
575	 * By default, use it if it is available, but this can be configured
576	 * to 1 to have it disabled.
577	 */
578	int disable_ldpc;
579
580	/**
581	 * ht40_intolerant - Indicate 40 MHz intolerant for this network
582	 */
583	int ht40_intolerant;
584
585	/**
586	 * disable_max_amsdu - Disable MAX A-MSDU
587	 *
588	 * A-MDSU will be 3839 bytes when disabled, or 7935
589	 * when enabled (assuming it is otherwise supported)
590	 * -1 (default) means do not apply any settings to the kernel.
591	 */
592	int disable_max_amsdu;
593
594	/**
595	 * ampdu_factor - Maximum A-MPDU Length Exponent
596	 *
597	 * Value: 0-3, see 7.3.2.56.3 in IEEE Std 802.11n-2009.
598	 */
599	int ampdu_factor;
600
601	/**
602	 * ampdu_density - Minimum A-MPDU Start Spacing
603	 *
604	 * Value: 0-7, see 7.3.2.56.3 in IEEE Std 802.11n-2009.
605	 */
606	int ampdu_density;
607
608	/**
609	 * ht_mcs - Allowed HT-MCS rates, in ASCII hex: ffff0000...
610	 *
611	 * By default (empty string): Use whatever the OS has configured.
612	 */
613	char *ht_mcs;
614#endif /* CONFIG_HT_OVERRIDES */
615
616#ifdef CONFIG_VHT_OVERRIDES
617	/**
618	 * disable_vht - Disable VHT (IEEE 802.11ac) for this network
619	 *
620	 * By default, use it if it is available, but this can be configured
621	 * to 1 to have it disabled.
622	 */
623	int disable_vht;
624
625	/**
626	 * vht_capa - VHT capabilities to use
627	 */
628	unsigned int vht_capa;
629
630	/**
631	 * vht_capa_mask - mask for VHT capabilities
632	 */
633	unsigned int vht_capa_mask;
634
635	int vht_rx_mcs_nss_1, vht_rx_mcs_nss_2,
636	    vht_rx_mcs_nss_3, vht_rx_mcs_nss_4,
637	    vht_rx_mcs_nss_5, vht_rx_mcs_nss_6,
638	    vht_rx_mcs_nss_7, vht_rx_mcs_nss_8;
639	int vht_tx_mcs_nss_1, vht_tx_mcs_nss_2,
640	    vht_tx_mcs_nss_3, vht_tx_mcs_nss_4,
641	    vht_tx_mcs_nss_5, vht_tx_mcs_nss_6,
642	    vht_tx_mcs_nss_7, vht_tx_mcs_nss_8;
643#endif /* CONFIG_VHT_OVERRIDES */
644
645	/**
646	 * ap_max_inactivity - Timeout in seconds to detect STA's inactivity
647	 *
648	 * This timeout value is used in AP mode to clean up inactive stations.
649	 * By default: 300 seconds.
650	 */
651	int ap_max_inactivity;
652
653	/**
654	 * dtim_period - DTIM period in Beacon intervals
655	 * By default: 2
656	 */
657	int dtim_period;
658
659	/**
660	 * beacon_int - Beacon interval (default: 100 TU)
661	 */
662	int beacon_int;
663
664	/**
665	 * auth_failures - Number of consecutive authentication failures
666	 */
667	unsigned int auth_failures;
668
669	/**
670	 * disabled_until - Network block disabled until this time if non-zero
671	 */
672	struct os_reltime disabled_until;
673
674	/**
675	 * parent_cred - Pointer to parent wpa_cred entry
676	 *
677	 * This pointer can be used to delete temporary networks when a wpa_cred
678	 * that was used to create them is removed. This pointer should not be
679	 * dereferences since it may not be updated in all cases.
680	 */
681	void *parent_cred;
682
683#ifdef CONFIG_MACSEC
684	/**
685	 * macsec_policy - Determines the policy for MACsec secure session
686	 *
687	 * 0: MACsec not in use (default)
688	 * 1: MACsec enabled - Should secure, accept key server's advice to
689	 *    determine whether to use a secure session or not.
690	 */
691	int macsec_policy;
692#endif /* CONFIG_MACSEC */
693
694#ifdef CONFIG_HS20
695	int update_identifier;
696#endif /* CONFIG_HS20 */
697
698	unsigned int wps_run;
699
700	/**
701	 * mac_addr - MAC address policy
702	 *
703	 * 0 = use permanent MAC address
704	 * 1 = use random MAC address for each ESS connection
705	 * 2 = like 1, but maintain OUI (with local admin bit set)
706	 *
707	 * Internally, special value -1 is used to indicate that the parameter
708	 * was not specified in the configuration (i.e., default behavior is
709	 * followed).
710	 */
711	int mac_addr;
712
713	/**
714	 * no_auto_peer - Do not automatically peer with compatible mesh peers
715	 *
716	 * When unset, the reception of a beacon from a another mesh peer in
717	 * this MBSS will trigger a peering attempt.
718	 */
719	int no_auto_peer;
720};
721
722#endif /* CONFIG_SSID_H */
723