1189251Ssam/*
2189251Ssam * WPA Supplicant - Common definitions
3189251Ssam * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
4189251Ssam *
5252726Srpaulo * This software may be distributed under the terms of the BSD license.
6252726Srpaulo * See README for more details.
7189251Ssam */
8189251Ssam
9189251Ssam#ifndef DEFS_H
10189251Ssam#define DEFS_H
11189251Ssam
12189251Ssam#ifdef FALSE
13189251Ssam#undef FALSE
14189251Ssam#endif
15189251Ssam#ifdef TRUE
16189251Ssam#undef TRUE
17189251Ssam#endif
18189251Ssamtypedef enum { FALSE = 0, TRUE = 1 } Boolean;
19189251Ssam
20189251Ssam
21189251Ssam#define WPA_CIPHER_NONE BIT(0)
22189251Ssam#define WPA_CIPHER_WEP40 BIT(1)
23189251Ssam#define WPA_CIPHER_WEP104 BIT(2)
24189251Ssam#define WPA_CIPHER_TKIP BIT(3)
25189251Ssam#define WPA_CIPHER_CCMP BIT(4)
26189251Ssam#ifdef CONFIG_IEEE80211W
27189251Ssam#define WPA_CIPHER_AES_128_CMAC BIT(5)
28189251Ssam#endif /* CONFIG_IEEE80211W */
29252726Srpaulo#define WPA_CIPHER_GCMP BIT(6)
30252726Srpaulo#define WPA_CIPHER_SMS4 BIT(7)
31189251Ssam
32189251Ssam#define WPA_KEY_MGMT_IEEE8021X BIT(0)
33189251Ssam#define WPA_KEY_MGMT_PSK BIT(1)
34189251Ssam#define WPA_KEY_MGMT_NONE BIT(2)
35189251Ssam#define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
36189251Ssam#define WPA_KEY_MGMT_WPA_NONE BIT(4)
37189251Ssam#define WPA_KEY_MGMT_FT_IEEE8021X BIT(5)
38189251Ssam#define WPA_KEY_MGMT_FT_PSK BIT(6)
39189251Ssam#define WPA_KEY_MGMT_IEEE8021X_SHA256 BIT(7)
40189251Ssam#define WPA_KEY_MGMT_PSK_SHA256 BIT(8)
41189251Ssam#define WPA_KEY_MGMT_WPS BIT(9)
42252726Srpaulo#define WPA_KEY_MGMT_SAE BIT(10)
43252726Srpaulo#define WPA_KEY_MGMT_FT_SAE BIT(11)
44252726Srpaulo#define WPA_KEY_MGMT_WAPI_PSK BIT(12)
45252726Srpaulo#define WPA_KEY_MGMT_WAPI_CERT BIT(13)
46252726Srpaulo#define WPA_KEY_MGMT_CCKM BIT(14)
47189251Ssam
48189251Ssamstatic inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
49189251Ssam{
50252726Srpaulo	return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
51252726Srpaulo			 WPA_KEY_MGMT_FT_IEEE8021X |
52252726Srpaulo			 WPA_KEY_MGMT_CCKM |
53252726Srpaulo			 WPA_KEY_MGMT_IEEE8021X_SHA256));
54189251Ssam}
55189251Ssam
56189251Ssamstatic inline int wpa_key_mgmt_wpa_psk(int akm)
57189251Ssam{
58252726Srpaulo	return !!(akm & (WPA_KEY_MGMT_PSK |
59252726Srpaulo			 WPA_KEY_MGMT_FT_PSK |
60252726Srpaulo			 WPA_KEY_MGMT_PSK_SHA256 |
61252726Srpaulo			 WPA_KEY_MGMT_SAE));
62189251Ssam}
63189251Ssam
64189251Ssamstatic inline int wpa_key_mgmt_ft(int akm)
65189251Ssam{
66252726Srpaulo	return !!(akm & (WPA_KEY_MGMT_FT_PSK |
67252726Srpaulo			 WPA_KEY_MGMT_FT_IEEE8021X |
68252726Srpaulo			 WPA_KEY_MGMT_FT_SAE));
69189251Ssam}
70189251Ssam
71252726Srpaulostatic inline int wpa_key_mgmt_sae(int akm)
72252726Srpaulo{
73252726Srpaulo	return !!(akm & (WPA_KEY_MGMT_SAE |
74252726Srpaulo			 WPA_KEY_MGMT_FT_SAE));
75252726Srpaulo}
76252726Srpaulo
77189251Ssamstatic inline int wpa_key_mgmt_sha256(int akm)
78189251Ssam{
79252726Srpaulo	return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
80252726Srpaulo			 WPA_KEY_MGMT_IEEE8021X_SHA256));
81189251Ssam}
82189251Ssam
83252726Srpaulostatic inline int wpa_key_mgmt_wpa(int akm)
84252726Srpaulo{
85252726Srpaulo	return wpa_key_mgmt_wpa_ieee8021x(akm) ||
86252726Srpaulo		wpa_key_mgmt_wpa_psk(akm);
87252726Srpaulo}
88189251Ssam
89252726Srpaulostatic inline int wpa_key_mgmt_wpa_any(int akm)
90252726Srpaulo{
91252726Srpaulo	return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
92252726Srpaulo}
93252726Srpaulo
94252726Srpaulostatic inline int wpa_key_mgmt_cckm(int akm)
95252726Srpaulo{
96252726Srpaulo	return akm == WPA_KEY_MGMT_CCKM;
97252726Srpaulo}
98252726Srpaulo
99252726Srpaulo
100189251Ssam#define WPA_PROTO_WPA BIT(0)
101189251Ssam#define WPA_PROTO_RSN BIT(1)
102252726Srpaulo#define WPA_PROTO_WAPI BIT(2)
103189251Ssam
104189251Ssam#define WPA_AUTH_ALG_OPEN BIT(0)
105189251Ssam#define WPA_AUTH_ALG_SHARED BIT(1)
106189251Ssam#define WPA_AUTH_ALG_LEAP BIT(2)
107214734Srpaulo#define WPA_AUTH_ALG_FT BIT(3)
108252726Srpaulo#define WPA_AUTH_ALG_SAE BIT(4)
109189251Ssam
110189251Ssam
111214734Srpauloenum wpa_alg {
112214734Srpaulo	WPA_ALG_NONE,
113214734Srpaulo	WPA_ALG_WEP,
114214734Srpaulo	WPA_ALG_TKIP,
115214734Srpaulo	WPA_ALG_CCMP,
116214734Srpaulo	WPA_ALG_IGTK,
117252726Srpaulo	WPA_ALG_PMK,
118252726Srpaulo	WPA_ALG_GCMP,
119252726Srpaulo	WPA_ALG_SMS4,
120252726Srpaulo	WPA_ALG_KRK
121214734Srpaulo};
122189251Ssam
123189251Ssam/**
124214734Srpaulo * enum wpa_cipher - Cipher suites
125214734Srpaulo */
126214734Srpauloenum wpa_cipher {
127214734Srpaulo	CIPHER_NONE,
128214734Srpaulo	CIPHER_WEP40,
129214734Srpaulo	CIPHER_TKIP,
130214734Srpaulo	CIPHER_CCMP,
131252726Srpaulo	CIPHER_WEP104,
132252726Srpaulo	CIPHER_GCMP,
133252726Srpaulo	CIPHER_SMS4
134214734Srpaulo};
135214734Srpaulo
136214734Srpaulo/**
137214734Srpaulo * enum wpa_key_mgmt - Key management suites
138214734Srpaulo */
139214734Srpauloenum wpa_key_mgmt {
140214734Srpaulo	KEY_MGMT_802_1X,
141214734Srpaulo	KEY_MGMT_PSK,
142214734Srpaulo	KEY_MGMT_NONE,
143214734Srpaulo	KEY_MGMT_802_1X_NO_WPA,
144214734Srpaulo	KEY_MGMT_WPA_NONE,
145214734Srpaulo	KEY_MGMT_FT_802_1X,
146214734Srpaulo	KEY_MGMT_FT_PSK,
147214734Srpaulo	KEY_MGMT_802_1X_SHA256,
148214734Srpaulo	KEY_MGMT_PSK_SHA256,
149252726Srpaulo	KEY_MGMT_WPS,
150252726Srpaulo	KEY_MGMT_SAE,
151252726Srpaulo	KEY_MGMT_FT_SAE,
152252726Srpaulo	KEY_MGMT_WAPI_PSK,
153252726Srpaulo	KEY_MGMT_WAPI_CERT,
154252726Srpaulo	KEY_MGMT_CCKM
155214734Srpaulo};
156214734Srpaulo
157214734Srpaulo/**
158189251Ssam * enum wpa_states - wpa_supplicant state
159189251Ssam *
160189251Ssam * These enumeration values are used to indicate the current wpa_supplicant
161189251Ssam * state (wpa_s->wpa_state). The current state can be retrieved with
162189251Ssam * wpa_supplicant_get_state() function and the state can be changed by calling
163189251Ssam * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
164189251Ssam * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
165189251Ssam * to access the state variable.
166189251Ssam */
167214734Srpauloenum wpa_states {
168189251Ssam	/**
169189251Ssam	 * WPA_DISCONNECTED - Disconnected state
170189251Ssam	 *
171189251Ssam	 * This state indicates that client is not associated, but is likely to
172189251Ssam	 * start looking for an access point. This state is entered when a
173189251Ssam	 * connection is lost.
174189251Ssam	 */
175189251Ssam	WPA_DISCONNECTED,
176189251Ssam
177189251Ssam	/**
178252726Srpaulo	 * WPA_INTERFACE_DISABLED - Interface disabled
179252726Srpaulo	 *
180252726Srpaulo	 * This stat eis entered if the network interface is disabled, e.g.,
181252726Srpaulo	 * due to rfkill. wpa_supplicant refuses any new operations that would
182252726Srpaulo	 * use the radio until the interface has been enabled.
183252726Srpaulo	 */
184252726Srpaulo	WPA_INTERFACE_DISABLED,
185252726Srpaulo
186252726Srpaulo	/**
187189251Ssam	 * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
188189251Ssam	 *
189189251Ssam	 * This state is entered if there are no enabled networks in the
190189251Ssam	 * configuration. wpa_supplicant is not trying to associate with a new
191189251Ssam	 * network and external interaction (e.g., ctrl_iface call to add or
192189251Ssam	 * enable a network) is needed to start association.
193189251Ssam	 */
194189251Ssam	WPA_INACTIVE,
195189251Ssam
196189251Ssam	/**
197189251Ssam	 * WPA_SCANNING - Scanning for a network
198189251Ssam	 *
199189251Ssam	 * This state is entered when wpa_supplicant starts scanning for a
200189251Ssam	 * network.
201189251Ssam	 */
202189251Ssam	WPA_SCANNING,
203189251Ssam
204189251Ssam	/**
205214734Srpaulo	 * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
206214734Srpaulo	 *
207214734Srpaulo	 * This state is entered when wpa_supplicant has found a suitable BSS
208214734Srpaulo	 * to authenticate with and the driver is configured to try to
209214734Srpaulo	 * authenticate with this BSS. This state is used only with drivers
210214734Srpaulo	 * that use wpa_supplicant as the SME.
211214734Srpaulo	 */
212214734Srpaulo	WPA_AUTHENTICATING,
213214734Srpaulo
214214734Srpaulo	/**
215189251Ssam	 * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
216189251Ssam	 *
217189251Ssam	 * This state is entered when wpa_supplicant has found a suitable BSS
218189251Ssam	 * to associate with and the driver is configured to try to associate
219189251Ssam	 * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
220189251Ssam	 * state is entered when the driver is configured to try to associate
221189251Ssam	 * with a network using the configured SSID and security policy.
222189251Ssam	 */
223189251Ssam	WPA_ASSOCIATING,
224189251Ssam
225189251Ssam	/**
226189251Ssam	 * WPA_ASSOCIATED - Association completed
227189251Ssam	 *
228189251Ssam	 * This state is entered when the driver reports that association has
229189251Ssam	 * been successfully completed with an AP. If IEEE 802.1X is used
230189251Ssam	 * (with or without WPA/WPA2), wpa_supplicant remains in this state
231189251Ssam	 * until the IEEE 802.1X/EAPOL authentication has been completed.
232189251Ssam	 */
233189251Ssam	WPA_ASSOCIATED,
234189251Ssam
235189251Ssam	/**
236189251Ssam	 * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
237189251Ssam	 *
238189251Ssam	 * This state is entered when WPA/WPA2 4-Way Handshake is started. In
239189251Ssam	 * case of WPA-PSK, this happens when receiving the first EAPOL-Key
240189251Ssam	 * frame after association. In case of WPA-EAP, this state is entered
241189251Ssam	 * when the IEEE 802.1X/EAPOL authentication has been completed.
242189251Ssam	 */
243189251Ssam	WPA_4WAY_HANDSHAKE,
244189251Ssam
245189251Ssam	/**
246189251Ssam	 * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
247189251Ssam	 *
248189251Ssam	 * This state is entered when 4-Way Key Handshake has been completed
249189251Ssam	 * (i.e., when the supplicant sends out message 4/4) and when Group
250189251Ssam	 * Key rekeying is started by the AP (i.e., when supplicant receives
251189251Ssam	 * message 1/2).
252189251Ssam	 */
253189251Ssam	WPA_GROUP_HANDSHAKE,
254189251Ssam
255189251Ssam	/**
256189251Ssam	 * WPA_COMPLETED - All authentication completed
257189251Ssam	 *
258189251Ssam	 * This state is entered when the full authentication process is
259189251Ssam	 * completed. In case of WPA2, this happens when the 4-Way Handshake is
260189251Ssam	 * successfully completed. With WPA, this state is entered after the
261189251Ssam	 * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
262189251Ssam	 * completed after dynamic keys are received (or if not used, after
263189251Ssam	 * the EAP authentication has been completed). With static WEP keys and
264189251Ssam	 * plaintext connections, this state is entered when an association
265189251Ssam	 * has been completed.
266189251Ssam	 *
267189251Ssam	 * This state indicates that the supplicant has completed its
268189251Ssam	 * processing for the association phase and that data connection is
269189251Ssam	 * fully configured.
270189251Ssam	 */
271189251Ssam	WPA_COMPLETED
272214734Srpaulo};
273189251Ssam
274189251Ssam#define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
275189251Ssam#define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
276189251Ssam#define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
277189251Ssam#define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
278189251Ssam
279189251Ssam#define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
280189251Ssam#define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
281189251Ssam
282214734Srpaulo
283214734Srpaulo/**
284214734Srpaulo * enum mfp_options - Management frame protection (IEEE 802.11w) options
285214734Srpaulo */
286214734Srpauloenum mfp_options {
287214734Srpaulo	NO_MGMT_FRAME_PROTECTION = 0,
288214734Srpaulo	MGMT_FRAME_PROTECTION_OPTIONAL = 1,
289252726Srpaulo	MGMT_FRAME_PROTECTION_REQUIRED = 2,
290214734Srpaulo};
291252726Srpaulo#define MGMT_FRAME_PROTECTION_DEFAULT 3
292214734Srpaulo
293214734Srpaulo/**
294214734Srpaulo * enum hostapd_hw_mode - Hardware mode
295214734Srpaulo */
296214734Srpauloenum hostapd_hw_mode {
297214734Srpaulo	HOSTAPD_MODE_IEEE80211B,
298214734Srpaulo	HOSTAPD_MODE_IEEE80211G,
299214734Srpaulo	HOSTAPD_MODE_IEEE80211A,
300252726Srpaulo	HOSTAPD_MODE_IEEE80211AD,
301214734Srpaulo	NUM_HOSTAPD_MODES
302214734Srpaulo};
303214734Srpaulo
304252726Srpaulo/**
305252726Srpaulo * enum wpa_ctrl_req_type - Control interface request types
306252726Srpaulo */
307252726Srpauloenum wpa_ctrl_req_type {
308252726Srpaulo	WPA_CTRL_REQ_UNKNOWN,
309252726Srpaulo	WPA_CTRL_REQ_EAP_IDENTITY,
310252726Srpaulo	WPA_CTRL_REQ_EAP_PASSWORD,
311252726Srpaulo	WPA_CTRL_REQ_EAP_NEW_PASSWORD,
312252726Srpaulo	WPA_CTRL_REQ_EAP_PIN,
313252726Srpaulo	WPA_CTRL_REQ_EAP_OTP,
314252726Srpaulo	WPA_CTRL_REQ_EAP_PASSPHRASE,
315252726Srpaulo	NUM_WPA_CTRL_REQS
316252726Srpaulo};
317252726Srpaulo
318252726Srpaulo/* Maximum number of EAP methods to store for EAP server user information */
319252726Srpaulo#define EAP_MAX_METHODS 8
320252726Srpaulo
321189251Ssam#endif /* DEFS_H */
322