defs.h revision f21452aea786ac056eb01f1cbba4f553bd502747
1/*
2 * WPA Supplicant - Common definitions
3 * Copyright (c) 2004-2008, 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 DEFS_H
10#define DEFS_H
11
12#ifdef FALSE
13#undef FALSE
14#endif
15#ifdef TRUE
16#undef TRUE
17#endif
18typedef enum { FALSE = 0, TRUE = 1 } Boolean;
19
20
21#define WPA_CIPHER_NONE BIT(0)
22#define WPA_CIPHER_WEP40 BIT(1)
23#define WPA_CIPHER_WEP104 BIT(2)
24#define WPA_CIPHER_TKIP BIT(3)
25#define WPA_CIPHER_CCMP BIT(4)
26#define WPA_CIPHER_AES_128_CMAC BIT(5)
27#define WPA_CIPHER_GCMP BIT(6)
28#define WPA_CIPHER_SMS4 BIT(7)
29#define WPA_CIPHER_GCMP_256 BIT(8)
30#define WPA_CIPHER_CCMP_256 BIT(9)
31#define WPA_CIPHER_BIP_GMAC_128 BIT(11)
32#define WPA_CIPHER_BIP_GMAC_256 BIT(12)
33#define WPA_CIPHER_BIP_CMAC_256 BIT(13)
34#define WPA_CIPHER_GTK_NOT_USED BIT(14)
35
36#define WPA_KEY_MGMT_IEEE8021X BIT(0)
37#define WPA_KEY_MGMT_PSK BIT(1)
38#define WPA_KEY_MGMT_NONE BIT(2)
39#define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3)
40#define WPA_KEY_MGMT_WPA_NONE BIT(4)
41#define WPA_KEY_MGMT_FT_IEEE8021X BIT(5)
42#define WPA_KEY_MGMT_FT_PSK BIT(6)
43#define WPA_KEY_MGMT_IEEE8021X_SHA256 BIT(7)
44#define WPA_KEY_MGMT_PSK_SHA256 BIT(8)
45#define WPA_KEY_MGMT_WPS BIT(9)
46#define WPA_KEY_MGMT_SAE BIT(10)
47#define WPA_KEY_MGMT_FT_SAE BIT(11)
48#define WPA_KEY_MGMT_WAPI_PSK BIT(12)
49#define WPA_KEY_MGMT_WAPI_CERT BIT(13)
50#define WPA_KEY_MGMT_CCKM BIT(14)
51#define WPA_KEY_MGMT_OSEN BIT(15)
52
53static inline int wpa_key_mgmt_wpa_ieee8021x(int akm)
54{
55	return !!(akm & (WPA_KEY_MGMT_IEEE8021X |
56			 WPA_KEY_MGMT_FT_IEEE8021X |
57			 WPA_KEY_MGMT_CCKM |
58			 WPA_KEY_MGMT_OSEN |
59			 WPA_KEY_MGMT_IEEE8021X_SHA256));
60}
61
62static inline int wpa_key_mgmt_wpa_psk(int akm)
63{
64	return !!(akm & (WPA_KEY_MGMT_PSK |
65			 WPA_KEY_MGMT_FT_PSK |
66			 WPA_KEY_MGMT_PSK_SHA256 |
67			 WPA_KEY_MGMT_SAE |
68			 WPA_KEY_MGMT_FT_SAE));
69}
70
71static inline int wpa_key_mgmt_ft(int akm)
72{
73	return !!(akm & (WPA_KEY_MGMT_FT_PSK |
74			 WPA_KEY_MGMT_FT_IEEE8021X |
75			 WPA_KEY_MGMT_FT_SAE));
76}
77
78static inline int wpa_key_mgmt_sae(int akm)
79{
80	return !!(akm & (WPA_KEY_MGMT_SAE |
81			 WPA_KEY_MGMT_FT_SAE));
82}
83
84static inline int wpa_key_mgmt_sha256(int akm)
85{
86	return !!(akm & (WPA_KEY_MGMT_PSK_SHA256 |
87			 WPA_KEY_MGMT_IEEE8021X_SHA256 |
88			 WPA_KEY_MGMT_OSEN));
89}
90
91static inline int wpa_key_mgmt_wpa(int akm)
92{
93	return wpa_key_mgmt_wpa_ieee8021x(akm) ||
94		wpa_key_mgmt_wpa_psk(akm) ||
95		wpa_key_mgmt_sae(akm);
96}
97
98static inline int wpa_key_mgmt_wpa_any(int akm)
99{
100	return wpa_key_mgmt_wpa(akm) || (akm & WPA_KEY_MGMT_WPA_NONE);
101}
102
103static inline int wpa_key_mgmt_cckm(int akm)
104{
105	return akm == WPA_KEY_MGMT_CCKM;
106}
107
108
109#define WPA_PROTO_WPA BIT(0)
110#define WPA_PROTO_RSN BIT(1)
111#define WPA_PROTO_WAPI BIT(2)
112#define WPA_PROTO_OSEN BIT(3)
113
114#define WPA_AUTH_ALG_OPEN BIT(0)
115#define WPA_AUTH_ALG_SHARED BIT(1)
116#define WPA_AUTH_ALG_LEAP BIT(2)
117#define WPA_AUTH_ALG_FT BIT(3)
118#define WPA_AUTH_ALG_SAE BIT(4)
119
120
121enum wpa_alg {
122	WPA_ALG_NONE,
123	WPA_ALG_WEP,
124	WPA_ALG_TKIP,
125	WPA_ALG_CCMP,
126	WPA_ALG_IGTK,
127	WPA_ALG_PMK,
128	WPA_ALG_GCMP,
129	WPA_ALG_SMS4,
130	WPA_ALG_KRK,
131	WPA_ALG_GCMP_256,
132	WPA_ALG_CCMP_256,
133	WPA_ALG_BIP_GMAC_128,
134	WPA_ALG_BIP_GMAC_256,
135	WPA_ALG_BIP_CMAC_256
136};
137
138/**
139 * enum wpa_states - wpa_supplicant state
140 *
141 * These enumeration values are used to indicate the current wpa_supplicant
142 * state (wpa_s->wpa_state). The current state can be retrieved with
143 * wpa_supplicant_get_state() function and the state can be changed by calling
144 * wpa_supplicant_set_state(). In WPA state machine (wpa.c and preauth.c), the
145 * wrapper functions wpa_sm_get_state() and wpa_sm_set_state() should be used
146 * to access the state variable.
147 */
148enum wpa_states {
149	/**
150	 * WPA_DISCONNECTED - Disconnected state
151	 *
152	 * This state indicates that client is not associated, but is likely to
153	 * start looking for an access point. This state is entered when a
154	 * connection is lost.
155	 */
156	WPA_DISCONNECTED,
157
158	/**
159	 * WPA_INTERFACE_DISABLED - Interface disabled
160	 *
161	 * This stat eis entered if the network interface is disabled, e.g.,
162	 * due to rfkill. wpa_supplicant refuses any new operations that would
163	 * use the radio until the interface has been enabled.
164	 */
165	WPA_INTERFACE_DISABLED,
166
167	/**
168	 * WPA_INACTIVE - Inactive state (wpa_supplicant disabled)
169	 *
170	 * This state is entered if there are no enabled networks in the
171	 * configuration. wpa_supplicant is not trying to associate with a new
172	 * network and external interaction (e.g., ctrl_iface call to add or
173	 * enable a network) is needed to start association.
174	 */
175	WPA_INACTIVE,
176
177	/**
178	 * WPA_SCANNING - Scanning for a network
179	 *
180	 * This state is entered when wpa_supplicant starts scanning for a
181	 * network.
182	 */
183	WPA_SCANNING,
184
185	/**
186	 * WPA_AUTHENTICATING - Trying to authenticate with a BSS/SSID
187	 *
188	 * This state is entered when wpa_supplicant has found a suitable BSS
189	 * to authenticate with and the driver is configured to try to
190	 * authenticate with this BSS. This state is used only with drivers
191	 * that use wpa_supplicant as the SME.
192	 */
193	WPA_AUTHENTICATING,
194
195	/**
196	 * WPA_ASSOCIATING - Trying to associate with a BSS/SSID
197	 *
198	 * This state is entered when wpa_supplicant has found a suitable BSS
199	 * to associate with and the driver is configured to try to associate
200	 * with this BSS in ap_scan=1 mode. When using ap_scan=2 mode, this
201	 * state is entered when the driver is configured to try to associate
202	 * with a network using the configured SSID and security policy.
203	 */
204	WPA_ASSOCIATING,
205
206	/**
207	 * WPA_ASSOCIATED - Association completed
208	 *
209	 * This state is entered when the driver reports that association has
210	 * been successfully completed with an AP. If IEEE 802.1X is used
211	 * (with or without WPA/WPA2), wpa_supplicant remains in this state
212	 * until the IEEE 802.1X/EAPOL authentication has been completed.
213	 */
214	WPA_ASSOCIATED,
215
216	/**
217	 * WPA_4WAY_HANDSHAKE - WPA 4-Way Key Handshake in progress
218	 *
219	 * This state is entered when WPA/WPA2 4-Way Handshake is started. In
220	 * case of WPA-PSK, this happens when receiving the first EAPOL-Key
221	 * frame after association. In case of WPA-EAP, this state is entered
222	 * when the IEEE 802.1X/EAPOL authentication has been completed.
223	 */
224	WPA_4WAY_HANDSHAKE,
225
226	/**
227	 * WPA_GROUP_HANDSHAKE - WPA Group Key Handshake in progress
228	 *
229	 * This state is entered when 4-Way Key Handshake has been completed
230	 * (i.e., when the supplicant sends out message 4/4) and when Group
231	 * Key rekeying is started by the AP (i.e., when supplicant receives
232	 * message 1/2).
233	 */
234	WPA_GROUP_HANDSHAKE,
235
236	/**
237	 * WPA_COMPLETED - All authentication completed
238	 *
239	 * This state is entered when the full authentication process is
240	 * completed. In case of WPA2, this happens when the 4-Way Handshake is
241	 * successfully completed. With WPA, this state is entered after the
242	 * Group Key Handshake; with IEEE 802.1X (non-WPA) connection is
243	 * completed after dynamic keys are received (or if not used, after
244	 * the EAP authentication has been completed). With static WEP keys and
245	 * plaintext connections, this state is entered when an association
246	 * has been completed.
247	 *
248	 * This state indicates that the supplicant has completed its
249	 * processing for the association phase and that data connection is
250	 * fully configured.
251	 */
252	WPA_COMPLETED
253};
254
255#define MLME_SETPROTECTION_PROTECT_TYPE_NONE 0
256#define MLME_SETPROTECTION_PROTECT_TYPE_RX 1
257#define MLME_SETPROTECTION_PROTECT_TYPE_TX 2
258#define MLME_SETPROTECTION_PROTECT_TYPE_RX_TX 3
259
260#define MLME_SETPROTECTION_KEY_TYPE_GROUP 0
261#define MLME_SETPROTECTION_KEY_TYPE_PAIRWISE 1
262
263
264/**
265 * enum mfp_options - Management frame protection (IEEE 802.11w) options
266 */
267enum mfp_options {
268	NO_MGMT_FRAME_PROTECTION = 0,
269	MGMT_FRAME_PROTECTION_OPTIONAL = 1,
270	MGMT_FRAME_PROTECTION_REQUIRED = 2,
271};
272#define MGMT_FRAME_PROTECTION_DEFAULT 3
273
274/**
275 * enum hostapd_hw_mode - Hardware mode
276 */
277enum hostapd_hw_mode {
278	HOSTAPD_MODE_IEEE80211B,
279	HOSTAPD_MODE_IEEE80211G,
280	HOSTAPD_MODE_IEEE80211A,
281	HOSTAPD_MODE_IEEE80211AD,
282	NUM_HOSTAPD_MODES
283};
284
285/**
286 * enum wpa_ctrl_req_type - Control interface request types
287 */
288enum wpa_ctrl_req_type {
289	WPA_CTRL_REQ_UNKNOWN,
290	WPA_CTRL_REQ_EAP_IDENTITY,
291	WPA_CTRL_REQ_EAP_PASSWORD,
292	WPA_CTRL_REQ_EAP_NEW_PASSWORD,
293	WPA_CTRL_REQ_EAP_PIN,
294	WPA_CTRL_REQ_EAP_OTP,
295	WPA_CTRL_REQ_EAP_PASSPHRASE,
296	WPA_CTRL_REQ_SIM,
297	NUM_WPA_CTRL_REQS
298};
299
300/* Maximum number of EAP methods to store for EAP server user information */
301#define EAP_MAX_METHODS 8
302
303#endif /* DEFS_H */
304